/* ==========================================================================
   Shopinn — "Ledger" design system
   Editorial, tenang, berfokus pada angka. Kertas hangat + tinta, satu aksen
   vermilion. Garis tipis 1px, radius kecil, tanpa shadow tebal / gradien / emoji.
   Font: Instrument Serif (angka & judul), Geist (UI), Geist Mono (kode).
   ========================================================================== */

:root {
  --paper: #F4F1EA;          /* kanvas */
  --surface: #FCFBF8;        /* kartu */
  --surface-2: #EFEBE2;      /* header tabel, input disabled */
  --ink: #17191C;
  --ink-2: #4A4741;
  --ink-3: #7A766D;
  --rule: #DCD6C9;           /* garis tipis */
  --rule-strong: #B9B2A2;

  --accent: #CF4A22;         /* vermilion, satu-satunya aksen */
  --accent-dark: #AE3A16;
  --accent-soft: #F6E4DC;

  --pos: #2E6B50;  --pos-soft: #E1EDE6;
  --warn: #9B6B12; --warn-soft: #F4EAD2;
  --neg: #B3261E;  --neg-soft: #F6DEDA;
  --info: #2D5B84; --info-soft: #DFE8F0;

  --side: #15171A;           /* sidebar gelap */
  --side-2: #212428;
  --side-ink: #E8E5DD;
  --side-mute: #8F8B82;

  --r: 8px;
  --r-sm: 6px;
  --bw: 1px;
  --bw-thin: 1px;
  --shadow: 0 1px 2px rgba(23,25,28,.05);
  --shadow-sm: none;
  --shadow-lg: 0 12px 32px rgba(23,25,28,.14);

  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Instrument Serif', 'Times New Roman', serif;
  --font-mono: 'Geist Mono', ui-monospace, Consolas, monospace;

  /* alias untuk halaman lama + komponen yang masih memakai nama pastel */
  --cream: var(--paper);
  --brand: var(--accent);
  --brand-dark: var(--accent-dark);
  --pink: var(--neg-soft);
  --mint: var(--pos-soft);
  --butter: var(--surface-2);
  --lilac: var(--surface-2);
  --sky: var(--info-soft);
  --peach: var(--accent-soft);
  --bg-primary: var(--paper);
  --bg-secondary: var(--surface);
  --bg-sidebar: var(--side);
  --bg-card: var(--surface);
  --bg-card-hover: var(--surface-2);
  --bg-glass: var(--paper);
  --border-color: var(--rule);
  --border-hover: var(--rule-strong);
  --text-primary: var(--ink);
  --text-secondary: var(--ink-2);
  --text-muted: var(--ink-3);
  --primary: var(--accent);
  --primary-hover: var(--accent-dark);
  --primary-glow: var(--accent-soft);
  --secondary: var(--accent);
  --tertiary: var(--warn);
  --cyan: var(--info);
  --success: var(--pos);
  --warning: var(--warn);
  --danger: var(--neg);
  --radius-sm: var(--r-sm);
  --radius-md: var(--r);
  --radius-lg: var(--r);
  --radius-full: 999px;
  --font-family: var(--font);
  --shadow-md: var(--shadow);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--font); -webkit-font-smoothing: antialiased; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: "tnum" 1;
}
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.012em; }
h3 { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
a { color: inherit; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 248px; min-width: 248px; height: 100vh; position: sticky; top: 0; z-index: 100;
  background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column;
}
.sidebar-header { padding: 22px 20px 18px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--side-ink); }
.brand-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.brand-icon svg { width: 18px; height: 18px; }
.brand-text h1 { font-family: var(--font-display); font-size: 25px; font-weight: 400; line-height: 1; letter-spacing: -0.01em; }
.brand-text p { font-size: 11px; color: var(--side-mute); margin-top: 3px; letter-spacing: .02em; }
.icon-btn.sidebar-close { display: none; }

.sidebar-content { flex: 1; overflow-y: auto; padding: 6px 12px 14px; }
.nav-group { margin-bottom: 18px; }
.nav-label { font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .14em; color: var(--side-mute); padding: 0 10px 8px; }
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 6px;
  font-size: 13.5px; font-weight: 450; color: #C9C5BB; text-decoration: none; transition: background .12s, color .12s;
}
.nav-link svg { width: 17px; height: 17px; stroke-width: 1.6; flex-shrink: 0; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.nav-link:hover { background: var(--side-2); color: #fff; }
.nav-link.active { background: var(--side-2); color: #fff; font-weight: 550; }
.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-link.active svg { color: var(--accent); opacity: 1; }

.sidebar-footer { padding: 12px 14px; border-top: 1px solid #272A2F; display: flex; align-items: center; gap: 10px; }
.sidebar-shop { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; text-decoration: none; color: inherit; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: #2B2E33; color: var(--side-ink); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.user-info { overflow: hidden; }
.user-name { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--side-ink); }
.user-role { font-size: 11.5px; color: var(--side-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .icon-btn { background: transparent; border-color: #2F3237; color: var(--side-mute); }
.sidebar-footer .icon-btn:hover { background: var(--side-2); color: #fff; }

/* ---------- MAIN / HEADER ---------- */
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-header {
  min-height: 74px; padding: 14px 36px; background: var(--paper);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 90;
}
.header-left { flex: 1; min-width: 0; }
.header-title { font-family: var(--font-display); font-size: 29px; font-weight: 400; line-height: 1.1; letter-spacing: -0.015em; }
.header-subtitle { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.icon-btn.menu-btn { display: none; }

.shop-switch { display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 36px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-sm); color: var(--ink-2); }
.shop-switch select { border: none !important; box-shadow: none !important; padding: 0 2px; background: transparent; font-weight: 550; font-size: 13px; outline: none; max-width: 170px; cursor: pointer; color: var(--ink); }
.live-badge { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--rule); font-size: 12.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--pos-soft); } 50% { box-shadow: 0 0 0 6px transparent; } }

.content-canvas { flex: 1; padding: 30px 36px 56px; max-width: 1480px; width: 100%; margin: 0 auto; }

/* ---------- CARD / BENTO ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; letter-spacing: -0.005em; }
.card-subtitle { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; font-weight: 400; }

.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }

/* "tint" kini berarti penekanan halus, bukan blok warna */
.tint-pink, .tint-mint, .tint-butter, .tint-lilac, .tint-sky, .tint-peach { background: var(--surface) !important; }
.tint-pink { border-top: 2px solid var(--neg) !important; }
.tint-mint { border-top: 2px solid var(--pos) !important; }
.tint-butter { border-top: 2px solid var(--warn) !important; }
.tint-sky { border-top: 2px solid var(--info) !important; }
.tint-peach { border-top: 2px solid var(--accent) !important; }
.tint-lilac { background: var(--surface-2) !important; }
.tint-brand { background: var(--accent) !important; color: #fff; }

.notice { border: 1px solid var(--rule); border-left: 3px solid var(--warn); border-radius: var(--r-sm); padding: 13px 16px; margin-bottom: 22px; background: var(--surface); display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 13.5px; color: var(--ink-2); }
.notice-warn { border-left-color: var(--warn); }
.notice-ok { border-left-color: var(--pos); }
.notice-bad { border-left-color: var(--neg); }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px;
  border-radius: var(--r-sm); font-size: 13.5px; font-weight: 550; cursor: pointer; text-decoration: none;
  border: 1px solid var(--rule-strong); color: var(--ink); background: var(--surface);
  transition: background .12s, border-color .12s, color .12s; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { background: #E6E1D5; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #2D3035; border-color: #2D3035; }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-secondary { background: var(--surface); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.icon-btn { width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--surface); color: var(--ink-2); border: 1px solid var(--rule); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; transition: background .12s; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- FORMS ---------- */
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], input[type=url], input[type=tel],
select, textarea, .form-control {
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong) !important; border-radius: var(--r-sm);
  padding: 9px 12px; font-size: 13.5px; outline: none; font-family: var(--font); transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink) !important; box-shadow: 0 0 0 3px rgba(23,25,28,.08); }
textarea { resize: vertical; line-height: 1.5; }
::placeholder { color: #A29D91; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-sm); padding: 6px 12px; }
.search-box input { border: none !important; box-shadow: none !important; padding: 2px 0; background: transparent; width: 100%; }
.kbd-shortcut { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 4px; padding: 0 5px; font-size: 10px; font-family: var(--font-mono); }

/* ---------- SWITCH ---------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #CFC9BB; border-radius: 999px; transition: background .16s; }
.slider:before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .16s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
input:checked + .slider { background: var(--pos); }
input:checked + .slider:before { transform: translateX(18px); }

/* ---------- TABLE ---------- */
.table-container { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 11px 16px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--rule); white-space: nowrap; }
td { padding: 13px 16px; font-size: 13.5px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F8F6F0; }

/* ---------- BADGE ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 550; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge-success { background: var(--pos-soft); color: var(--pos); }
.badge-warning { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--neg-soft); color: var(--neg); }
.badge-cyan, .badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--accent-soft); color: var(--accent-dark); }
.badge-secondary { background: var(--surface-2); color: var(--ink-2); }

/* ---------- TOAST ---------- */
#toastContainer { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--ink); border-radius: var(--r-sm); padding: 11px 16px; color: #F4F1EA; box-shadow: var(--shadow-lg); font-size: 13px; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px; animation: toastIn .22s ease; }
.toast-icon { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; background: #5E8CB5; color: #fff; flex-shrink: 0; }
.toast-success .toast-icon { background: #3E8A68; } .toast-error .toast-icon { background: #CF4A22; } .toast-warning .toast-icon { background: #C08A1E; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- MODAL (hanya aksi singkat) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(23,25,28,.45); z-index: 999; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); width: 100%; max-width: 520px; padding: 26px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; }

/* ---------- Pengaman untuk inline-style halaman lama ---------- */
[style*="color: #fff"], [style*="color:#fff"], [style*="color: #ffffff"] { color: var(--ink) !important; }
.btn-primary[style*="color"], .tint-brand { color: #fff !important; }
code { font-family: var(--font-mono); background: var(--surface-2); border-radius: 4px; padding: 1px 6px; font-size: .88em; color: var(--ink) !important; }
pre { background: var(--surface-2); border-radius: var(--r-sm); padding: 12px; overflow-x: auto; font-family: var(--font-mono); }
hr { border: none; border-top: 1px solid var(--rule); }
strong { font-weight: 600; }

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CFC9BB; border-radius: 8px; border: 2px solid var(--paper); }
.sidebar-content::-webkit-scrollbar-thumb { background: #33363B; border-color: var(--side); }

/* ---------- RESPONSIVE ---------- */
.sidebar-scrim { display: none; }
@media (max-width: 1080px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(23,25,28,.45); z-index: 95; }
  .icon-btn.sidebar-close { display: inline-flex; background: transparent; border-color: #2F3237; color: var(--side-mute); }
  .icon-btn.menu-btn { display: inline-flex; }
  .content-canvas { padding: 22px 18px 44px; }
  .top-header { padding: 12px 18px; }
}
@media (max-width: 900px) {
  [style*="grid-template-columns"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .span-3, .span-4, .span-6, .span-8 { grid-column: span 12; }
  .bento > .span-3 { grid-column: span 6; }
}
@media (max-width: 640px) {
  [style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  .bento > .span-3 { grid-column: span 12; }
  .header-subtitle, .hide-sm, .live-badge { display: none; }
  .header-title { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
  .shop-switch select { max-width: 110px; }
  .card { padding: 18px; }
  #toastContainer { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
  [style*="display: flex"][style*="justify-content: space-between"] { flex-wrap: wrap; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* tombol boost disembunyikan untuk akun tanpa fitur boost */
.no-boost [onclick^="triggerBoostSingle"] { display: none; }
