:root {
    --bg:         #eaf4ec;
    --bg-2:       #dcebdf;
    --surface:    #ffffff;
    --surface-2:  #f4faf5;
    --border:     #cfe1d3;
    --border-2:   #e1eee4;
    --text:       #1f3328;
    --text-muted: #6b8074;
    --text-light: #90a295;
    --primary:    #3f9b6a;
    --primary-h:  #358a5c;
    --primary-soft: #d5ecdc;
    --primary-softer: #e8f5ec;
    --success:    #4ab87a;
    --warning:    #e0a343;
    --danger:     #d87872;
    --info:       #6a9cc9;
  }

  * { box-sizing: border-box; }
  html, body { margin:0; padding:0; }
  body {
    font-family: 'Manrope', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.005em;
  }
  .mono { font-family: 'JetBrains Mono', monospace; font-feature-settings: 'tnum'; }
  .tnum { font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums; }

  /* ==== Layout ==== */
  .app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
  .sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
  .main { padding: 0; }

  /* ==== Logo ==== */
  .logo {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px 20px;
    border-bottom: 1px solid var(--border-2);
    margin-bottom: 14px;
  }
  .logo-mark {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 10px;
    display: grid; place-items: center;
    color: white; font-weight: 700;
    font-size: 14px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.04);
  }
  .logo-text { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
  .logo-sub { font-size: 11px; color: var(--text-muted); font-weight: 500; }

  /* ==== Nav ==== */
  .nav-group { margin-bottom: 14px; }
  .nav-label {
    font-size: 10.5px; font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase; letter-spacing: 0.08em;
    padding: 8px 12px 6px;
  }
  .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500; font-size: 13.5px;
    cursor: pointer; user-select: none;
    transition: all 0.15s;
    margin-bottom: 2px;
  }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-h);
    font-weight: 600;
  }
  .nav-item i[data-lucide] { width: 18px; height: 18px; stroke-width: 1.8; }
  .nav-item .badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
  }

  /* ==== Topbar ==== */
  .topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex; align-items: center; gap: 16px;
    position: sticky; top: 0; z-index: 10;
  }
  .topbar h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
  .topbar-sub { font-size: 12px; color: var(--text-muted); }
  .topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

  /* ==== Controls ==== */
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border-radius: 9px;
    font-weight: 600; font-size: 13px;
    cursor: pointer; border: 1px solid transparent;
    transition: all 0.15s;
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
  }
  .btn:hover { background: var(--surface-2); border-color: var(--primary-soft); }
  .btn-primary {
    background: var(--primary); color: white; border-color: var(--primary);
  }
  .btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
  .btn i[data-lucide] { width: 15px; height: 15px; stroke-width: 2; }

  .select, .input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    font-family: inherit; font-size: 13px;
    color: var(--text);
    outline: none; transition: all 0.15s;
  }
  .select:focus, .input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-softer); }
  .select { appearance: none; padding-right: 32px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b8074' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat; background-position: right 10px center;
  }

  /* ==== Page ==== */
  .page { padding: 24px 28px 40px; }
  .page h2 { font-size: 16px; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.01em; }

  /* ==== Cards ==== */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
  }
  .card-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; }

  /* ==== KPI cards ==== */
  .kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
  .kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    position: relative;
  }
  .kpi-label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
  .kpi-value { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
  .kpi-delta { font-size: 11.5px; font-weight: 600; margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; }
  .kpi-delta.up { color: var(--success); }
  .kpi-delta.down { color: var(--danger); }
  .kpi-icon { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 8px; background: var(--primary-softer); display: grid; place-items: center; }
  .kpi-icon i { width: 16px; height: 16px; stroke-width: 1.8; color: var(--primary); }

  /* ==== Grid layouts ==== */
  .grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
  .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

  /* ==== Tables ==== */
  table { width: 100%; border-collapse: collapse; }
  thead th {
    text-align: left; font-weight: 600; font-size: 11.5px;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-2);
    background: var(--surface-2);
  }
  tbody td {
    padding: 12px; font-size: 13px;
    border-bottom: 1px solid var(--border-2);
  }
  tbody tr:hover { background: var(--surface-2); }
  tbody tr:last-child td { border-bottom: none; }

  /* ==== Status pills ==== */
  .pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
  .pill-dot { width: 6px; height: 6px; border-radius: 50%; }
  .pill.ok { background: #e2f4e8; color: #2a7849; }
  .pill.ok .pill-dot { background: #4ab87a; }
  .pill.warn { background: #fbf1de; color: #87601e; }
  .pill.warn .pill-dot { background: #e0a343; }
  .pill.danger { background: #f9e1df; color: #8c3d37; }
  .pill.danger .pill-dot { background: #d87872; }
  .pill.info { background: #e2edf7; color: #34617e; }
  .pill.info .pill-dot { background: #6a9cc9; }
  .pill.neutral { background: #edf1ee; color: #5a6f62; }
  .pill.neutral .pill-dot { background: #a0b2a8; }

  /* ==== Filter bar ==== */
  .filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
  .filter-bar .input-search { min-width: 260px; position: relative; }
  .filter-bar .input-search input { width: 100%; padding-left: 36px; }
  .filter-bar .input-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }

  /* ==== Progress bar ==== */
  .progress { height: 6px; background: var(--border-2); border-radius: 10px; overflow: hidden; }
  .progress-bar { height: 100%; background: var(--primary); border-radius: 10px; }
  .progress-bar.warn { background: var(--warning); }
  .progress-bar.danger { background: var(--danger); }

  /* ==== Investor card ==== */
  .investor-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    transition: all 0.15s;
    cursor: pointer;
  }
  .investor-card:hover { border-color: var(--primary); }
  .investor-avatar {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--primary-soft); color: var(--primary-h);
    display: grid; place-items: center; font-weight: 700; font-size: 15px;
  }

  /* ==== Modal (inline simulation) ==== */
  .modal-overlay { position: fixed; inset: 0; background: rgba(31,51,40,0.35); backdrop-filter: blur(2px); display: none; z-index: 100; align-items: flex-start; justify-content: center; padding-top: 60px; }
  .modal-overlay.open { display: flex; }
  .modal { background: var(--surface); border-radius: 16px; max-width: 560px; width: 100%; padding: 26px 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.12); border: 1px solid var(--border); }
  .modal h3 { margin: 0 0 4px; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
  .modal-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

  .form-row { margin-bottom: 14px; }
  .form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; display: block; }
  .form-control { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-family: inherit; font-size: 13.5px; outline: none; }
  .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-softer); }
  .form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

  /* ==== Chart ==== */
  .chart-wrap { position: relative; height: 260px; }
  .chart-wrap-sm { position: relative; height: 200px; }

  /* ==== Kassa page special ==== */
  .kassa-hero {
    background: linear-gradient(135deg, var(--primary-softer) 0%, var(--primary-soft) 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px;
    margin-bottom: 16px;
  }
  .kassa-hero h2 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.02em; }
  .kassa-hero p { color: var(--text-muted); margin: 0; font-size: 13.5px; }

  .kassa-preview {
    background: var(--surface);
    border-radius: 14px;
    padding: 22px;
    margin-top: 16px;
    border: 1px solid var(--border);
  }
  .kassa-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--border-2); }
  .kassa-row:last-child { border: none; }
  .kassa-row span:first-child { color: var(--text-muted); font-size: 13px; }
  .kassa-row span:last-child { font-weight: 600; font-size: 13.5px; }

  /* ==== Kassa tabs (cash register selector) ==== */
  .kassa-tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 13px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-family: inherit; font-weight: 600; font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .kassa-tab:hover { background: var(--surface-2); color: var(--text); }
  .kassa-tab.active {
    background: var(--primary-soft);
    color: var(--primary-h);
    border-color: var(--primary);
  }
  .kassa-tab i { width: 14px; height: 14px; stroke-width: 1.8; }
  .kassa-tab-bal {
    background: var(--surface);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11.5px; font-weight: 700;
    color: var(--primary-h);
    border: 1px solid var(--border-2);
    font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums;
  }

  /* ==== Kassa action cards (Kirim/Chiqim big buttons) ==== */
  .kassa-action {
    display: flex; align-items: center; gap: 14px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .kassa-action:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(63,155,106,0.06); }
  .kassa-action-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: grid; place-items: center;
    flex-shrink: 0;
  }
  .kassa-action-icon i { width: 22px; height: 22px; stroke-width: 1.8; }
  .kassa-action-title { font-weight: 700; font-size: 15px; color: var(--text); letter-spacing: -0.01em; }
  .kassa-action-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
  .kassa-action-arrow { color: var(--text-light); margin-left: auto; width: 18px; height: 18px; }

  /* ==== Misc ==== */
  .muted { color: var(--text-muted); }
  .text-sm { font-size: 12.5px; }
  .text-xs { font-size: 11.5px; }
  .divider { height: 1px; background: var(--border-2); margin: 14px 0; }
  .empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
  .empty-state i { width: 40px; height: 40px; margin: 0 auto 10px; color: var(--text-light); stroke-width: 1.4; }

  /* Scroll styling */
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--primary-soft); }

  /* Responsive guard */
  @media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
  }

/* ===================== App additions (live frontend) ===================== */
/* Keep the prototype's grid layout (.app { display:grid }); the ID+class rule
   below must restore grid, not block, or the 100vh sidebar pushes content off-screen. */
#app { display: none; }
#app.ready { display: grid; }

/* Login screen */
.auth-screen {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg-2) 0%, var(--bg) 60%);
  z-index: 200;
}
.auth-card {
  width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.10);
}
.auth-card .logo-mark { width: 44px; height: 44px; font-size: 17px; border-radius: 12px; margin-bottom: 14px; }
.auth-card h2 { margin: 0 0 2px; font-size: 20px; }
.auth-err { color: var(--danger); font-size: 12.5px; margin-top: 10px; min-height: 16px; }
.auth-hint { font-size: 11.5px; color: var(--text-light); margin-top: 14px; text-align: center; }

/* Buttons */
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(0.95); }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Avatar in topbar */
.user-chip { display: flex; align-items: center; gap: 9px; }
.user-chip .investor-avatar { width: 34px; height: 34px; font-size: 13px; border-radius: 10px; }
.user-chip-name { font-size: 13px; font-weight: 600; line-height: 1.1; }
.user-chip-role { font-size: 11px; color: var(--text-muted); }

/* Toast */
#toast-wrap { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast {
  background: var(--text); color: #fff; padding: 11px 15px; border-radius: 10px;
  font-size: 13px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  display: flex; align-items: center; gap: 8px; animation: toast-in 0.16s ease;
  max-width: 360px;
}
.toast.ok { background: #2a7849; }
.toast.err { background: #8c3d37; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Modal actions row */
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.modal-lg { max-width: 720px; }

/* Loading / inline states */
.skeleton { color: var(--text-light); padding: 28px; text-align: center; font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.clickable { cursor: pointer; }
.row-actions { display: flex; gap: 6px; }
.otp-box {
  font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 600;
  letter-spacing: 2px; background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: 10px; padding: 14px; text-align: center; color: var(--primary-h);
}
.stat-inline { display: flex; gap: 24px; flex-wrap: wrap; }
.stat-inline .kpi-label { margin-bottom: 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { margin: 0; }

/* ===================== Dark theme + i18n controls ===================== */
:root[data-theme="dark"] {
  --bg:         #0f1613;
  --bg-2:       #15201b;
  --surface:    #16211c;
  --surface-2:  #1c2922;
  --border:     #27362d;
  --border-2:   #202d26;
  --text:       #e7efe9;
  --text-muted: #9db2a6;
  --text-light: #6f8579;
  --primary:    #4ab87a;
  --primary-h:  #56c486;
  --primary-soft:   #20382a;
  --primary-softer: #1a2a20;
  --success:    #4ab87a;
  --warning:    #e0a343;
  --danger:     #d87872;
  --info:       #6a9cc9;
}
:root[data-theme="dark"] .pill.ok      { background:#173026; color:#7fe0a6; }
:root[data-theme="dark"] .pill.warn    { background:#33290f; color:#f0c878; }
:root[data-theme="dark"] .pill.danger  { background:#3a201e; color:#f0a59f; }
:root[data-theme="dark"] .pill.info    { background:#19293a; color:#9cc3e6; }
:root[data-theme="dark"] .pill.neutral { background:#222e27; color:#9db2a6; }
:root[data-theme="dark"] .auth-screen  { background: radial-gradient(120% 120% at 50% 0%, #16211c 0%, #0f1613 60%); }
:root[data-theme="dark"] .kassa-hero   { background: linear-gradient(135deg, #1a2a20 0%, #20382a 100%); }
:root[data-theme="dark"] .otp-box,
:root[data-theme="dark"] .skeleton     { color: var(--primary-h); }

/* Smooth theme switching */
body, .card, .kpi, .sidebar, .topbar, .modal, .investor-card, .btn, .select,
.input, .form-control, .nav-item, .kassa-tab { transition: background-color .18s ease, border-color .18s ease, color .18s ease; }

/* Topbar language + theme controls */
.topbar-actions .lang-select {
  padding: 6px 26px 6px 10px; font-size: 12px; font-weight: 600; border-radius: 8px;
}
.icon-btn {
  width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; transition: all .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--primary-soft); }
.icon-btn i { width: 17px; height: 17px; }

/* Native form controls (select options, date pickers, scrollbars) follow the theme */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="dark"] select option,
:root[data-theme="dark"] .select option,
:root[data-theme="dark"] .form-control option {
  background: var(--surface-2);
  color: var(--text);
}
