@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&family=Sora:wght@400;600;700;800&display=swap');

/* =========================================================
   CHMS — Design System v5
   by Vira Apps
   Palette  : Deep Navy / Cool Slate / Electric Indigo
   Type     : Sora (display) + Inter (body)
   Feel     : Modern SaaS — dark sidebar, crisp whites,
              vibrant indigo accent
   ========================================================= */

:root {
    /* ── Surfaces ── */
    --c-bg:        #F0F2F5;
    --c-surface:   #FFFFFF;
    --c-surface-2: #F7F8FA;
    --c-surface-3: #EFF1F5;

    /* ── Sidebar ── */
    --c-sidebar:       #0F1629;
    --c-sidebar-deep:  #080D1A;
    --c-sidebar-hover: rgba(255,255,255,.05);
    --c-sidebar-fg:    rgba(218,224,240,.78);
    --c-sidebar-fg2:   rgba(218,224,240,.38);

    /* ── Brand / Accent ── */
    --c-indigo-600:  #4F46E5;
    --c-indigo-500:  #6366F1;
    --c-indigo-400:  #818CF8;
    --c-indigo-100:  #EEF2FF;
    --c-indigo-50:   #F5F3FF;

    /* ── Neutral ── */
    --c-text:     #0F172A;
    --c-text-2:   #334155;
    --c-muted:    #64748B;
    --c-border:   #E2E8F0;
    --c-border-2: #CBD5E1;

    /* ── Semantic ── */
    --c-danger:      #DC2626;
    --c-danger-bg:   #FEF2F2;
    --c-danger-bd:   #FECACA;
    --c-success:     #16A34A;
    --c-success-bg:  #F0FDF4;
    --c-success-bd:  #BBF7D0;
    --c-warning:     #D97706;
    --c-warning-bg:  #FFFBEB;
    --c-warning-bd:  #FDE68A;

    /* ── Typography ── */
    --f-display: 'Sora', -apple-system, sans-serif;
    --f-body:    'Inter', -apple-system, sans-serif;

    /* ── Tokens ── */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius:    8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-xs: 0 1px 2px rgba(15,23,42,.06);
    --shadow-sm: 0 1px 3px rgba(15,23,42,.08), 0 1px 8px rgba(15,23,42,.04);
    --shadow-md: 0 4px 16px rgba(15,23,42,.10), 0 1px 4px rgba(15,23,42,.06);
    --shadow-lg: 0 10px 32px rgba(15,23,42,.14);
    --sidebar-w: 256px;
    --t:         0.16s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--f-body);
    background: var(--c-bg);
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--c-indigo-600); text-decoration: none; transition: color var(--t); }
a:hover { color: var(--c-indigo-500); }

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

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
    background: var(--c-sidebar);
    color: var(--c-sidebar-fg);
    width: var(--sidebar-w);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    z-index: 100;
    border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-mark {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--f-display);
    font-size: 17px;
    font-weight: 800;
    color: var(--c-indigo-600);
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,.35);
    overflow: hidden;
}

/* Logo custom (upload) sedikit lebih besar & padding lebih longgar supaya
   logo tidak mepet ke tepi; tetap sama-sama berlatar putih seperti fallback */
.brand-mark.brand-mark-logo {
    width: 44px; height: 44px;
    padding: 4px;
}

.brand-text .title {
    display: block;
    font-family: var(--f-display);
    font-size: 14.5px;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
    letter-spacing: -.01em;
}

.brand-text .by-vira {
    display: block;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: var(--c-indigo-400);
    margin-top: 2px;
}

/* Nav section labels */
.nav-section-label {
    padding: 18px 20px 5px;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .13em;
    color: var(--c-sidebar-fg2);
}

/* Nav links */
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 20px;
    color: var(--c-sidebar-fg);
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 0;
    transition: background var(--t), color var(--t);
    position: relative;
}

.sidebar nav a .ic {
    width: 18px;
    text-align: center;
    font-size: 13px;
    flex-shrink: 0;
    opacity: .75;
}

.sidebar nav a:hover {
    background: var(--c-sidebar-hover);
    color: #fff;
}
.sidebar nav a:hover .ic { opacity: 1; }

.sidebar nav a.active {
    background: rgba(99,102,241,.18);
    color: var(--c-indigo-400);
    font-weight: 600;
}
.sidebar nav a.active .ic { opacity: 1; }

/* Active indicator pill */
.sidebar nav a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--c-indigo-500);
    border-radius: 0 3px 3px 0;
}

/* Sidebar footer */
.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px 20px;
    border-top: 1px solid rgba(255,255,255,.05);
    font-size: 10.5px;
    color: var(--c-sidebar-fg2);
    flex-shrink: 0;
}

/* =====================================================
   MAIN
   ===================================================== */
.main {
    margin-left: var(--sidebar-w);
    padding: 28px 36px 80px;
    min-width: 0;
    width: calc(100% - var(--sidebar-w));
    min-height: 100vh;
    box-sizing: border-box;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--c-border);
    gap: 16px;
    flex-wrap: wrap;
}

.topbar .eyebrow {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--c-indigo-600);
    font-weight: 700;
    margin-bottom: 4px;
}

.topbar h1 {
    font-family: var(--f-display);
    font-size: 24px;
    font-weight: 700;
    color: var(--c-text);
    line-height: 1.2;
    letter-spacing: -.02em;
    margin-bottom: 4px;
}

.topbar p.desc {
    font-size: 13.5px;
    color: var(--c-muted);
    line-height: 1.5;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8.5px 16px;
    border-radius: var(--radius);
    border: 1.5px solid transparent;
    font-family: var(--f-body);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.25;
    transition: background var(--t), border-color var(--t), color var(--t),
                box-shadow var(--t), transform var(--t);
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--c-indigo-600);
    color: #fff;
    border-color: var(--c-indigo-600);
    box-shadow: 0 1px 3px rgba(79,70,229,.30), 0 1px 1px rgba(0,0,0,.05);
}
.btn-primary:hover {
    background: var(--c-indigo-500);
    border-color: var(--c-indigo-500);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79,70,229,.35);
}

.btn-outline {
    background: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text-2);
    box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
    border-color: var(--c-border-2);
    color: var(--c-text);
    background: var(--c-surface);
    box-shadow: var(--shadow-sm);
}

.btn-danger {
    background: var(--c-surface);
    border-color: var(--c-border-2);
    color: var(--c-danger);
    box-shadow: var(--shadow-xs);
}
.btn-danger:hover {
    background: var(--c-danger-bg);
    border-color: var(--c-danger);
    color: var(--c-danger);
    box-shadow: var(--shadow-sm);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* =====================================================
   STAT CARDS
   ===================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 20px 20px 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--t), transform var(--t);
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Accent stripe */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--c-indigo-600), var(--c-indigo-400));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Subtle bg glow */
.stat-card::after {
    content: '';
    position: absolute;
    right: -16px; bottom: -16px;
    width: 72px; height: 72px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,.07) 0%, transparent 70%);
    pointer-events: none;
}

.stat-card .num {
    font-family: var(--f-display);
    font-size: 32px;
    font-weight: 700;
    color: var(--c-text);
    line-height: 1;
    letter-spacing: -.02em;
}

.stat-card .label {
    margin-top: 7px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--c-muted);
    font-weight: 600;
}

/* =====================================================
   PANEL
   ===================================================== */
.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 20px;
}

.panel-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--c-surface-2);
}

.panel-head h2 {
    font-family: var(--f-display);
    font-size: 14.5px;
    font-weight: 700;
    color: var(--c-text);
    letter-spacing: -.01em;
}

.panel-body { padding: 4px 0; }
.panel-body.pad { padding: 20px; }

/* =====================================================
   SEARCH / FILTER BAR
   ===================================================== */
.search-box {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.search-box input[type=text],
.search-box select {
    padding: 7px 12px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--f-body);
    background: var(--c-surface);
    color: var(--c-text);
    transition: border-color var(--t), box-shadow var(--t);
    height: 34px;
}
.search-box input[type=text] { min-width: 200px; }
.search-box input:focus,
.search-box select:focus {
    outline: none;
    border-color: var(--c-indigo-500);
    box-shadow: 0 0 0 3px rgba(99,102,241,.14);
}

/* =====================================================
   LEDGER TABLE
   ===================================================== */
table.ledger {
    width: 100%;
    border-collapse: collapse;
}

table.ledger thead th {
    text-align: left;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--c-muted);
    font-weight: 700;
    padding: 10px 20px;
    border-bottom: 1.5px solid var(--c-border);
    background: var(--c-surface-2);
    white-space: nowrap;
}

table.ledger tbody td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--c-border);
    font-size: 13.5px;
    vertical-align: middle;
}

table.ledger tbody tr:last-child td { border-bottom: none; }
table.ledger tbody tr { transition: background var(--t); }
table.ledger tbody tr:hover { background: var(--c-indigo-50); }

table.ledger .nama-utama,
.nama-utama {
    font-weight: 600;
    color: var(--c-text);
    font-size: 13.8px;
    text-decoration: none;
}
a.nama-utama:hover { color: var(--c-indigo-600); }
/* .sub sebagai child element (div/span) di dalam td → block, abu */
.sub {
    font-size: 12px;
    color: var(--c-muted);
    margin-top: 1px;
    display: block;
}
/* Jika .sub adalah td itu sendiri → jangan override display */
td.sub { display: table-cell; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--c-muted);
}
.empty-state .ic {
    font-size: 30px;
    opacity: .3;
    display: block;
    margin-bottom: 10px;
}
.empty-state p { font-size: 14px; }

/* =====================================================
   BADGES / SEALS
   ===================================================== */
.seal {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2.5px 9px 2.5px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border: 1px solid transparent;
    white-space: nowrap;
}
.seal::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.seal-success { color: var(--c-success);    background: var(--c-success-bg); border-color: var(--c-success-bd); }
.seal-warning  { color: var(--c-warning);    background: var(--c-warning-bg); border-color: var(--c-warning-bd); }
.seal-muted    { color: var(--c-muted);      background: var(--c-surface-3);  border-color: var(--c-border); }
.seal-dark     { color: var(--c-text-2);     background: var(--c-surface-2);  border-color: var(--c-border-2); }
.seal-indigo   { color: var(--c-indigo-600); background: var(--c-indigo-100); border-color: #C7D2FE; }

.tag-sektor {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--c-indigo-600);
    font-weight: 500;
}
.tag-sektor .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--c-indigo-500);
}

/* =====================================================
   FORMS
   ===================================================== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 24px;
}
.form-grid .full { grid-column: 1 / -1; }

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--c-text);
    margin-bottom: 6px;
    letter-spacing: .01em;
}
.field .hint {
    font-size: 11.5px;
    color: var(--c-muted);
    font-weight: 400;
    margin-left: 4px;
}

.field input[type=text],
.field input[type=password],
.field input[type=date],
.field input[type=email],
.field input[type=tel],
.field input[type=number],
.field input[type=file],
.field select,
.field textarea {
    width: 100%;
    padding: 8.5px 12px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius);
    font-family: var(--f-body);
    font-size: 13.5px;
    background: var(--c-surface);
    color: var(--c-text);
    transition: border-color var(--t), box-shadow var(--t);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--c-indigo-500);
    box-shadow: 0 0 0 3px rgba(99,102,241,.14);
}

.field input[readonly] {
    background: var(--c-surface-2);
    color: var(--c-muted);
    cursor: not-allowed;
}

.field textarea { resize: vertical; min-height: 72px; }

fieldset.group {
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius);
    padding: 16px 18px 18px;
}
fieldset.group legend {
    font-family: var(--f-display);
    font-size: 12.5px;
    font-weight: 700;
    padding: 0 8px;
    color: var(--c-indigo-600);
}

/* =====================================================
   FLASH MESSAGES
   ===================================================== */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 20px;
    border: 1.5px solid;
    display: flex;
    align-items: center;
    gap: 10px;
}
.flash-success {
    background: var(--c-success-bg);
    color: #15803D;
    border-color: var(--c-success-bd);
}
.flash-success::before { content: '✓'; font-weight: 700; }
.flash-error {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    border-color: var(--c-danger-bd);
}
.flash-error::before { content: '⚠'; }

/* =====================================================
   PROFILE / DETAIL
   ===================================================== */
.profile-head {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 22px 24px;
}

.profile-photo {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c-indigo-600), var(--c-indigo-400));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--f-display);
    font-size: 26px;
    font-weight: 700;
    border: 3px solid #C7D2FE;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(79,70,229,.20);
}

.profile-head h2 {
    font-family: var(--f-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--c-text);
    letter-spacing: -.02em;
    margin-bottom: 5px;
}
.profile-meta {
    color: var(--c-muted);
    font-size: 13px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 32px;
    padding: 4px 24px 24px;
}
.detail-grid .dt {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--c-muted);
    margin-bottom: 2px;
    font-weight: 700;
}
.detail-grid .dd { font-size: 14px; color: var(--c-text); }

/* =====================================================
   TIMELINE
   ===================================================== */
.timeline { padding: 6px 24px 24px; }
.timeline-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px dashed var(--c-border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-marker {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--c-indigo-100);
    color: var(--c-indigo-600);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    border: 1.5px solid #C7D2FE;
}
.timeline-content .jenis { font-weight: 600; font-size: 13.8px; color: var(--c-text); }
.timeline-content .meta { font-size: 12px; color: var(--c-muted); margin-top: 2px; }

/* =====================================================
   BREADCRUMB
   ===================================================== */
.breadcrumb {
    font-size: 12.5px;
    color: var(--c-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.breadcrumb::before { content: '←'; opacity: .5; }
.breadcrumb a { color: var(--c-muted); transition: color var(--t); }
.breadcrumb a:hover { color: var(--c-indigo-600); }

/* =====================================================
   MOBILE TOPBAR + HAMBURGER + OVERLAY
   (disembunyikan secara default, ditampilkan lewat
   media query RESPONSIVE di bawah saat lebar <960px)
   ===================================================== */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: var(--c-sidebar);
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    z-index: 150;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.mobile-menu-btn {
    width: 38px; height: 38px;
    border-radius: var(--radius);
    background: rgba(255,255,255,.08);
    border: none;
    color: var(--c-sidebar-fg);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.mobile-menu-btn:active { background: rgba(255,255,255,.16); }
.mobile-topbar-title {
    font-family: var(--f-display);
    font-weight: 700;
    font-size: 15px;
    color: var(--c-sidebar-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 18px; right: 14px;
    width: 32px; height: 32px;
    border-radius: var(--radius);
    background: rgba(255,255,255,.08);
    border: none;
    color: var(--c-sidebar-fg);
    align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 5;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,12,20,.55);
    z-index: 99;
}
.sidebar-overlay.is-open { display: block; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 0 0 40px rgba(0,0,0,.35);
    }
    .sidebar.is-open { transform: translateX(0); z-index: 200; }
    .main { margin-left: 0; width: 100%; padding: 86px 16px 60px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }

    .mobile-topbar { display: flex; }
    .sidebar-close-btn { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
