@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-light: #dbeafe;
    --secondary:     #7c3aed;
    --success:       #059669;
    --warning:       #d97706;
    --danger:        #dc2626;
    --info:          #0891b2;
    --dark:          #0f172a;
    --sidebar-bg:    #0f172a;
    --sidebar-width: 260px;
    --topbar-h:      64px;
    --body-bg:       #f1f5f9;
    --card-bg:       #ffffff;
    --text:          #1e293b;
    --text-muted:    #64748b;
    --border:        #e2e8f0;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --shadow-md:     0 4px 24px rgba(0,0,0,.10);
    --transition:    .2s cubic-bezier(.4,0,.2,1);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', sans-serif;
    background: var(--body-bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== LAYOUT ===== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform var(--transition);
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}
.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.sidebar-brand .brand-text { line-height: 1.2; }
.sidebar-brand .brand-name { font-weight: 700; font-size: .95rem; color: #f8fafc; }
.sidebar-brand .brand-sub  { font-size: .7rem; color: #64748b; }

.sidebar-user {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; color: white; flex-shrink: 0;
}
.sidebar-user .user-info { min-width: 0; }
.sidebar-user .user-name  { font-size: .82rem; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role  { font-size: .7rem; color: #64748b; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section-title {
    font-size: .65rem; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: #475569;
    padding: 12px 20px 4px;
}
.nav-item a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: .855rem; font-weight: 500;
    border-radius: 0;
    transition: all var(--transition);
    position: relative;
}
.nav-item a:hover { color: #f8fafc; background: rgba(255,255,255,.05); }
.nav-item a.active {
    color: #fff;
    background: rgba(37,99,235,.15);
    border-right: 3px solid var(--primary);
}
.nav-item a .nav-icon { width: 18px; flex-shrink: 0; text-align: center; }
.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: .65rem; font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px; text-align: center;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.topbar-title {
    font-size: 1rem; font-weight: 700; color: var(--text);
    flex: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-btn {
    width: 36px; height: 36px;
    background: var(--body-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition);
}
.topbar-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ===== PAGE CONTENT ===== */
.page-content { padding: 24px; flex: 1; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
    width: 52px; height: 52px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: var(--primary); }
.stat-icon.purple { background: #ede9fe; color: var(--secondary); }
.stat-icon.green  { background: #d1fae5; color: var(--success); }
.stat-icon.yellow { background: #fef3c7; color: var(--warning); }
.stat-icon.red    { background: #fee2e2; color: var(--danger); }
.stat-icon.cyan   { background: #cffafe; color: var(--info); }
.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1; color: var(--text); }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }

/* ===== CARDS ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}
.card-title { font-size: .9rem; font-weight: 700; color: var(--text); }
.card-body  { padding: 20px; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
table.kd-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.kd-table th {
    padding: 10px 14px;
    background: #f8fafc;
    text-align: left;
    font-size: .75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
table.kd-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}
table.kd-table tr:last-child td { border-bottom: none; }
table.kd-table tr:hover td { background: #f8fafc; }
table.kd-table .actions { display: flex; gap: 6px; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .72rem; font-weight: 600;
    white-space: nowrap;
}
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-info     { background: #cffafe; color: #164e63; }
.badge-primary  { background: #dbeafe; color: #1e40af; }
.badge-secondary{ background: #f3f0ff; color: #5b21b6; }
.badge-gray     { background: #f1f5f9; color: #475569; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: .855rem; font-weight: 600;
    border: none; cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 5px 10px; font-size: .78rem; border-radius: 6px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; }
.btn-danger  { background: var(--danger);  color: white; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }
.btn-info    { background: var(--info);    color: white; }
.btn-secondary { background: #6b7280; color: white; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 3px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: inherit;
    color: var(--text);
    background: white;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control::placeholder { color: #94a3b8; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-text { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ===== AUTOCOMPLETE ===== */
.autocomplete-wrapper { position: relative; }
.autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0;
    background: white;
    border: 1.5px solid var(--primary);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 220px; overflow-y: auto;
    z-index: 200;
    box-shadow: var(--shadow-md);
    display: none;
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
    padding: 9px 12px;
    cursor: pointer;
    font-size: .855rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--primary-light); }
.autocomplete-item .sub { font-size: .75rem; color: var(--text-muted); }

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: 16px;
    display: flex; align-items: flex-start; gap: 10px;
    border-width: 1px; border-style: solid;
}
.alert-success  { background: #d1fae5; border-color: #a7f3d0; color: #065f46; }
.alert-danger   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-warning  { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.alert-info     { background: #cffafe; border-color: #a5f3fc; color: #164e63; }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-link {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .82rem; font-weight: 600;
    color: var(--text-muted); text-decoration: none;
    transition: all var(--transition);
}
.page-link:hover, .page-link.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== FILTER BAR ===== */
.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 1.35rem; font-weight: 800; color: var(--text); }
.page-header .breadcrumb {
    font-size: .78rem; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px;
}
.page-header .breadcrumb a { color: var(--primary); text-decoration: none; }

/* ===== DETAIL SECTION ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-item label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.detail-item .value { font-size: .95rem; font-weight: 600; color: var(--text); margin-top: 3px; }

/* ===== VERIFICATION CARD ===== */
.verif-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.verif-card.tepat        { border-color: var(--success); background: #f0fdf4; }
.verif-card.perlu_koreksi{ border-color: var(--warning); background: #fffbeb; }
.verif-card.tidak_tepat  { border-color: var(--danger);  background: #fff1f2; }

/* ===== SISA HIGHLIGHT ===== */
.sisa-positive { color: var(--danger); font-weight: 700; }
.sisa-zero     { color: var(--success); font-weight: 600; }

/* ===== CHART ===== */
.chart-container { position: relative; height: 240px; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: .9rem; }

/* ===== PRINT ===== */
@media print {
    .sidebar, .topbar, .no-print, .btn { display: none !important; }
    .main-content { margin-left: 0; }
    .page-content { padding: 0; }
    body { background: white; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
    #sidebar-toggle { display: flex !important; }
    .page-content { padding: 16px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-row.cols-2 { grid-template-columns: 1fr; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .3s ease forwards; }

/* ===== TABS ===== */
.kd-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.kd-tab {
    padding: 9px 18px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: .855rem; font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border: 1.5px solid transparent;
    border-bottom: none;
    transition: all var(--transition);
    cursor: pointer;
}
.kd-tab:hover { color: var(--primary); background: var(--primary-light); }
.kd-tab.active {
    color: var(--primary);
    background: white;
    border-color: var(--border);
    border-bottom: 2px solid white;
    margin-bottom: -2px;
}

/* ===== TOOLTIP ===== */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: white;
    font-size: .72rem;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    z-index: 999;
}
[data-tooltip]:hover::after { opacity: 1; }
.btn-copy {
    background: none; border: none; cursor: pointer; padding: 2px 4px;
    font-size: .9rem; opacity: .4; transition: opacity .2s; border-radius: 4px;
}
.btn-copy:hover { opacity: 1; background: var(--primary-light); color: var(--primary); }
.btn-copy.copied { color: var(--success); opacity: 1; }

/* ===== KALKULASI BOX ===== */
.calc-box {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 12px;
}
.calc-box .calc-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 10px; }
.calc-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: .855rem; }
.calc-row.total { border-top: 1.5px solid var(--border); margin-top: 6px; padding-top: 10px; font-weight: 700; }
.calc-row.sisa-positif .val { color: var(--danger); }
.calc-row.sisa-zero .val    { color: var(--success); }
