/* Gold Journal — tema gelap default (warisan "One Percent"), tema terang opsional.
   Tata letak: sidebar (PC) → rail ikon (tablet) → bottom nav (HP). */
:root {
  --bg0: #0D1117; --bg1: #161B22; --bg2: #1C2230; --bg3: #262D3A;
  --line: #2A3140; --line2: #3A4254;
  --txt: #E6EDF3; --txt2: #9AA5B4; --txt3: #6B7585;
  --gold: #E6C84A; --gold2: #C9A832; --gold-bg: rgba(230, 200, 74, .12);
  --green: #3FB950; --green-bg: rgba(63, 185, 80, .13);
  --red: #F85149; --red-bg: rgba(248, 81, 73, .13);
  --blue: #58A6FF; --blue-bg: rgba(88, 166, 255, .13);
  --purple: #BC8CFF; --orange: #F0883E; --orange-bg: rgba(240, 136, 62, .14);
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  --sidebar: 232px; --topbar: 60px; --bottomnav: 64px;
  --header-h: calc(var(--topbar) + var(--safe-t)); /* tinggi topbar sticky, termasuk area status bar */
  /* Area aman iOS (notch/Dynamic Island & home indicator). Di browser biasa semuanya 0. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg0: #F4F6F9; --bg1: #FFFFFF; --bg2: #F0F2F6; --bg3: #E4E8EF;
  --line: #E1E5EC; --line2: #CBD2DC;
  --txt: #141A23; --txt2: #56606E; --txt3: #8A93A1;
  --gold: #B98F0B; --gold2: #9C7806; --gold-bg: rgba(185, 143, 11, .12);
  --green: #1A7F37; --green-bg: rgba(26, 127, 55, .1);
  --red: #CF222E; --red-bg: rgba(207, 34, 46, .09);
  --blue: #0969DA; --blue-bg: rgba(9, 105, 218, .1);
  --orange: #BC4C00; --orange-bg: rgba(188, 76, 0, .1);
  --shadow: 0 8px 24px rgba(20, 30, 50, .12);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
/* Atribut hidden harus selalu menang atas display dari class (.field, .icon-btn, dll.). */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg0); color: var(--txt); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.no-scroll { overflow: hidden; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0 0 8px; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { flex: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::selection { background: var(--gold-bg); }

/* ------------------------------ Boot & login ------------------------------ */
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-content: center; gap: 14px; justify-items: center; color: var(--txt2); }
.boot-logo, .brand-logo {
  width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #F5DC6E, var(--gold) 55%, #B8911F); color: #1A1405;
  font-weight: 800; font-size: 20px; letter-spacing: -.02em; box-shadow: 0 6px 22px rgba(230, 200, 74, .25);
}
.boot-logo { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.94); opacity: .8; } }

.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: calc(24px + var(--safe-t)) calc(16px + var(--safe-r)) calc(24px + var(--safe-b)) calc(16px + var(--safe-l)); }
.auth-card { width: 100%; max-width: 400px; background: var(--bg1); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-card .brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.auth-card h1 { font-size: 20px; }
.auth-card .sub { color: var(--txt2); font-size: 13px; }
.auth-card .btn { width: 100%; margin-top: 14px; }

/* --------------------------------- Shell --------------------------------- */
.shell { display: grid; grid-template-columns: calc(var(--sidebar) + var(--safe-l)) 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; background: var(--bg1);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-t)) 12px calc(16px + var(--safe-b)) calc(12px + var(--safe-l));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-logo { width: 38px; height: 38px; font-size: 15px; border-radius: 10px; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.brand-name span { color: var(--gold); }
.brand-sub { font-size: 11px; color: var(--txt3); font-family: var(--mono); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-sep { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--txt3); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--txt2); font-weight: 500; text-decoration: none; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--bg2); color: var(--txt); }
.nav a.active { background: var(--gold-bg); color: var(--gold); }
.nav a .count { margin-left: auto; font-size: 11px; background: var(--bg3); padding: 1px 7px; border-radius: 10px; color: var(--txt2); }
.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.sidebar-foot .who { font-size: 12px; color: var(--txt2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: calc(var(--topbar) + var(--safe-t));
  display: flex; align-items: center; gap: 10px;
  /* padding-top = area status bar iOS saat aplikasi dipasang di layar utama (viewport-fit=cover). */
  padding: var(--safe-t) calc(20px + var(--safe-r)) 0 calc(20px + var(--safe-l));
  background: color-mix(in srgb, var(--bg0) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
/* Strip di belakang status bar iOS dibuat pekat supaya jam & baterai tetap terbaca
   ketika isi halaman bergulir di bawahnya. */
/* Selalu gelap — pada mode black-translucent iOS menggambar jam & baterai dengan
   warna putih, termasuk saat aplikasi memakai tema terang. */
.topbar::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: var(--safe-t); background: #0D1117; }
.topbar h2 { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .filters { display: flex; gap: 8px; }
.topbar select { min-width: 0; }
.page { padding: 20px calc(20px + var(--safe-r)) 20px calc(20px + var(--safe-l)); max-width: 1480px; width: 100%; margin: 0 auto; flex: 1; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.page-head h3 { font-size: 16px; }
.page-head .spacer { flex: 1; }
/* Kontrol filter di header halaman tetap ringkas (global input/select = width 100%). */
.page-head select { width: auto; min-width: 130px; max-width: 220px; }
.page-head input[type=search] { width: auto; min-width: 200px; max-width: 320px; }

.bottomnav, .fab { display: none; }
/* Baris filter di bawah topbar — hanya terpakai di HP (ikut tergulung saat scroll). */
.subbar { display: flex; gap: 8px; padding: 10px calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l)); }
.subbar:empty { display: none; }
.subbar select { flex: 1; min-width: 0; min-height: 40px; background-color: var(--bg1); }

/* ------------------------------- Komponen ------------------------------- */
.card { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 26px; }
.card-head h3 { font-size: 14px; font-weight: 700; }
.card-head .sub { color: var(--txt3); font-size: 12px; }
.card-head .spacer { flex: 1; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 14px 16px 0; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cols-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
/* Anak flex default min-width:auto — input tidak bisa menyusut dan meluber keluar kolom. */
.row.nowrap > * { min-width: 0; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 14px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 14px; }

.kpi { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; min-width: 0; }
.kpi-label { font-size: 11px; color: var(--txt2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font: 700 21px/1.2 var(--mono); margin-top: 5px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 11.5px; color: var(--txt3); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pos { color: var(--green) !important; } .neg { color: var(--red) !important; } .mut { color: var(--txt3); }
.gold { color: var(--gold); } .blue { color: var(--blue); } .warn { color: var(--orange); }
.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; }
.small { font-size: 12px; } .tiny { font-size: 11px; } .lead { font-size: 15px; color: var(--txt2); }
.muted { color: var(--txt2); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 20px; background: var(--bg3); color: var(--txt2); white-space: nowrap;
}
.badge.pos { background: var(--green-bg); color: var(--green); }
.badge.neg { background: var(--red-bg); color: var(--red); }
.badge.gold { background: var(--gold-bg); color: var(--gold); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.warn { background: var(--orange-bg); color: var(--orange); }
.badge.mut { background: var(--bg3); color: var(--txt3); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 20px; border: 1px solid var(--line2); background: var(--bg2); font-size: 12px; cursor: pointer; user-select: none; }
.chip.on { border-color: var(--gold); background: var(--gold-bg); color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line2); background: var(--bg2); color: var(--txt);
  font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--bg3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #17130A; }
.btn.primary:hover { background: var(--gold2); }
.btn.danger { background: var(--red-bg); border-color: transparent; color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--txt2); }
.btn.ghost:hover { background: var(--bg2); color: var(--txt); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--txt2); cursor: pointer; }
.icon-btn:hover { background: var(--bg2); color: var(--txt); }

/* Form */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 600; color: var(--txt2); }
.field-hint { font-size: 11.5px; color: var(--txt3); }
input[type=text], input[type=number], input[type=email], input[type=password], input[type=url], input[type=search],
input[type=datetime-local], input[type=date], input[type=time], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px; background: var(--bg0); border: 1px solid var(--line2);
  border-radius: var(--radius-sm); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-bg); }
input.num-in { font-family: var(--mono); }
/* iOS merender input tanggal/jam dengan lebar intrinsik besar dan teks di tengah —
   tanpa ini kolomnya meluber ke kolom sebelah. */
input[type=datetime-local], input[type=date], input[type=time] {
  display: block; min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; text-align: left;
}
input::-webkit-date-and-time-value { text-align: left; }

/* Form bertahap (tambah trade) */
.fsec { display: flex; flex-direction: column; gap: 12px; }
.fsec + .fsec { border-top: 1px solid var(--line); padding-top: 16px; }
.fsec-title { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); display: flex; align-items: center; gap: 8px; }
.fsec-title .num { width: 20px; height: 20px; border-radius: 50%; background: var(--gold-bg); display: inline-grid; place-items: center; font-size: 11px; }
.calc-box { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; line-height: 1.7; }
.seg.block { display: flex; width: 100%; }
.seg.block button { flex: 1; padding: 9px 10px; }

/* Menu HP (sheet) */
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.menu-tile { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); color: var(--txt); text-decoration: none; min-height: 118px; }
.menu-tile:hover { border-color: var(--gold); text-decoration: none; }
.menu-tile .ico-wrap { width: 38px; height: 38px; border-radius: 10px; background: var(--gold-bg); color: var(--gold); display: grid; place-items: center; }
.menu-tile b { font-size: 14px; }
.menu-tile span.d { font-size: 12px; color: var(--txt2); line-height: 1.4; }
.menu-list { display: flex; flex-direction: column; gap: 2px; }
.menu-list a { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; color: var(--txt); text-decoration: none; font-weight: 500; }
.menu-list a:hover { background: var(--bg2); text-decoration: none; }
.menu-list a small { color: var(--txt3); font-weight: 400; display: block; }

/* Daftar kas di HP: baris 1 = tanggal/jenis, nominal, hapus; baris 2 = catatan. */
.cash-list { display: flex; flex-direction: column; }
.cash-row { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cash-row:last-child { border-bottom: 0; }
.cash-row .num { font-weight: 600; }
.cash-row .c { grid-column: 1 / -1; font-size: 12px; color: var(--txt3); line-height: 1.45; overflow-wrap: anywhere; }

.danger-zone { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.danger-zone h3 { color: var(--red); }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--txt2) 50%), linear-gradient(135deg, var(--txt2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.topbar select { min-height: 36px; background-color: var(--bg1); font-size: 13px; max-width: 220px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; }
.fields { display: grid; gap: 12px; }
.f2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.f3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.f4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.check:hover { background: var(--bg2); }
.check input { margin-top: 1px; }
.check.done span { color: var(--txt2); text-decoration: line-through; }

.seg { display: inline-flex; background: var(--bg0); border: 1px solid var(--line2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--txt2); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.seg button.on { background: var(--bg3); color: var(--txt); }
.seg.dir button.on[data-v=buy] { background: var(--green-bg); color: var(--green); }
.seg.dir button.on[data-v=sell] { background: var(--red-bg); color: var(--red); }
.seg.cash button.on[data-v=deposit] { background: var(--green-bg); color: var(--green); }
.seg.cash button.on[data-v=withdrawal] { background: var(--red-bg); color: var(--red); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; color: var(--txt2); font-weight: 600; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--gold); border-bottom-color: var(--gold); }

/* Tabel */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--txt3); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--bg1); z-index: 1; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr:hover { background: var(--bg2); }
.tbl tr.click { cursor: pointer; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--txt); }
.tbl th .arrow { color: var(--gold); }
.tbl .r { text-align: right; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line2); border-bottom: 0; }

/* Kartu trade (daftar di HP) */
.tcards { display: none; }
.tcard { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tcard:active { background: var(--bg2); }
.tcard .l1 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tcard .pl { font: 700 15px var(--mono); text-align: right; }
.tcard .l2 { font-size: 12px; color: var(--txt2); }
.tcard .r2 { font-size: 12px; text-align: right; font-family: var(--mono); color: var(--txt2); }

/* Status harian */
.status { display: flex; gap: 14px; align-items: center; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg1); }
.status .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 5px var(--bg2); }
.status h3 { font: 800 16px var(--font); letter-spacing: .04em; }
.status.ready { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); } .status.ready .dot { background: var(--green); } .status.ready h3 { color: var(--green); }
.status.caution { border-color: color-mix(in srgb, var(--orange) 45%, var(--line)); } .status.caution .dot { background: var(--orange); } .status.caution h3 { color: var(--orange); }
.status.stop { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); } .status.stop .dot { background: var(--red); } .status.stop h3 { color: var(--red); }
.status .reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.bar { height: 7px; background: var(--bg3); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--gold); border-radius: 6px; transition: width .4s; }
.bar.pos > span { background: var(--green); } .bar.neg > span { background: var(--red); } .bar.warn > span { background: var(--orange); } .bar.blue > span { background: var(--blue); }
.rule { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.rule:last-child { border-bottom: 0; }
.rule .bar { grid-column: 1 / -1; }

.insight { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg2); border-left: 3px solid var(--txt3); font-size: 13px; line-height: 1.55; }
.insight + .insight { margin-top: 8px; }
.insight.danger { border-left-color: var(--red); } .insight.warning { border-left-color: var(--orange); }
.insight.success { border-left-color: var(--green); } .insight.info { border-left-color: var(--blue); }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 190px; } .chart-box.lg { height: 330px; }
.exec-chart { height: 420px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }

.stat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 18px; }
.stat-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.stat-row span:first-child { color: var(--txt2); }
.stat-row span:last-child { font-family: var(--mono); font-weight: 600; text-align: right; }

/* Kalender P/L */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal .dow { font-size: 11px; color: var(--txt3); text-align: center; font-weight: 600; padding-bottom: 2px; }
.cal .d { min-height: 64px; border-radius: 8px; background: var(--bg2); padding: 6px; font-size: 11px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid transparent; }
.cal .d.out { opacity: .35; }
.cal .d.today { border-color: var(--gold); }
.cal .d .dn { color: var(--txt3); font-weight: 600; }
.cal .d .dv { font: 700 11.5px var(--mono); }
.cal .d .dc { color: var(--txt3); font-size: 10px; }
.cal .d.win { background: var(--green-bg); } .cal .d.loss { background: var(--red-bg); }
.cal .wk { font-size: 11px; text-align: right; padding: 4px 2px; }

/* Heatmap jam × hari */
.heat { display: grid; grid-template-columns: 38px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 10px; }
.heat .hc { aspect-ratio: 1; border-radius: 3px; background: var(--bg2); }
.heat .hl { color: var(--txt3); display: flex; align-items: center; }
.heat .ht { color: var(--txt3); text-align: center; }

/* Link TradingView / pratinjau */
.link-card { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg2); align-items: center; }
.link-card img { width: 120px; height: 72px; object-fit: cover; border-radius: 6px; background: var(--bg3); }
.link-card .noimg { width: 120px; height: 72px; border-radius: 6px; background: var(--bg3); display: grid; place-items: center; color: var(--txt3); }
.link-card .t { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.shot { border-radius: var(--radius-sm); border: 1px solid var(--line); overflow: hidden; background: var(--bg2); }
.shot img { width: 100%; max-height: 420px; object-fit: contain; background: #000; }
.tv-widget { height: 520px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
.tv-widget.sm { height: 420px; }

.plan-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.plan-item:hover { background: var(--bg2); }
.plan-date { text-align: center; min-width: 46px; }
.plan-date b { display: block; font: 800 20px var(--mono); line-height: 1; }
.plan-date span { font-size: 10.5px; color: var(--txt3); text-transform: uppercase; }

.code { font: 12px/1.55 var(--mono); background: var(--bg0); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; overflow: auto; max-height: 360px; white-space: pre; }
.keybox { display: flex; gap: 8px; align-items: center; background: var(--bg0); border: 1px dashed var(--gold); border-radius: var(--radius-sm); padding: 10px 12px; font: 13px var(--mono); word-break: break-all; }
.steps { margin: 0; padding-left: 20px; line-height: 1.8; }
.steps li + li { margin-top: 2px; }
kbd, code.inline { font: 12px var(--mono); background: var(--bg3); padding: 1px 6px; border-radius: 5px; }

.empty { text-align: center; padding: 34px 16px; color: var(--txt2); }
.empty-ico { color: var(--txt3); display: grid; place-items: center; margin-bottom: 8px; }
.empty h4 { color: var(--txt); margin-bottom: 4px; font-size: 15px; }
.empty .btn { margin-top: 12px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 36px; color: var(--txt2); }
.spin { width: 18px; height: 18px; border: 2px solid var(--line2); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stars { color: var(--line2); letter-spacing: 1px; }
.stars .on { color: var(--gold); }
.star-input { display: inline-flex; gap: 2px; }
.star-input button { border: 0; background: none; font-size: 22px; color: var(--line2); cursor: pointer; padding: 0 2px; line-height: 1; }
.star-input button.on { color: var(--gold); }

.score-ring { position: relative; width: 108px; height: 108px; flex: none; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .v { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.score-ring .v b { font: 800 26px var(--mono); line-height: 1; }
.score-ring .v span { font-size: 10.5px; color: var(--txt3); }

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.note { font-size: 12.5px; color: var(--txt2); background: var(--bg2); border-radius: var(--radius-sm); padding: 10px 12px; line-height: 1.55; }
.note b { color: var(--txt); }
.pill-live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--green); }
.pill-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.pill-off { font-size: 11px; color: var(--txt3); }

/* ------------------------------ Modal & toast ------------------------------ */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(1, 4, 9, .62); display: grid; place-items: center;
  padding: calc(18px + var(--safe-t)) calc(18px + var(--safe-r)) calc(18px + var(--safe-b)) calc(18px + var(--safe-l)); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg1); border: 1px solid var(--line2); border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100dvh - 36px - var(--safe-t) - var(--safe-b)); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pop .18s ease-out; }
.modal.wide { max-width: 860px; } .modal.xwide { max-width: 1100px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
/* .modal adalah grid item di .modal-wrap. Grid & flex item bawaannya min-width:auto,
   artinya tidak boleh menyusut di bawah lebar min-content isinya — satu tabel nowrap
   (mis. daftar kas) membuat seluruh sheet lebih lebar dari layar HP dan isinya terpotong.
   min-width:0 memaksa sheet mengikuti lebar layar, lalu .tbl-wrap yang menggulir. */
.modal, .modal-head, .modal-body, .modal-foot { min-width: 0; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px 18px; border-bottom: 1px solid var(--line); }
/* Nama akun panjang dibiarkan turun baris, bukan memaksa sheet melebar. */
.modal-head h3 { flex: 1; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
/* Tanpa baris tombol, isi terakhir harus tetap di atas home indicator iOS. */
.modal-body:last-child { padding-bottom: calc(16px + var(--safe-b)); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); flex-wrap: wrap; }

#toasts { position: fixed; top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r)); z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 28px)); pointer-events: none; }
.toast { background: var(--bg3); color: var(--txt); padding: 11px 14px; border-radius: 10px; border-left: 3px solid var(--blue); box-shadow: var(--shadow); font-size: 13px; animation: pop .2s; transition: opacity .3s, transform .3s; }
.toast.success { border-left-color: var(--green); } .toast.error { border-left-color: var(--red); } .toast.warning { border-left-color: var(--orange); }
.toast.out { opacity: 0; transform: translateX(20px); }

/* ------------------------------- Responsif ------------------------------- */
@media (max-width: 1200px) {
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .f4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Tablet: sidebar menjadi rail ikon */
@media (max-width: 1024px) {
  .shell { grid-template-columns: calc(72px + var(--safe-l)) 1fr; }
  .sidebar { padding: calc(14px + var(--safe-t)) 8px calc(14px + var(--safe-b)) calc(8px + var(--safe-l)); align-items: center; }
  /* Hanya sidebar yang menjadi rail ikon — menu HP (.nav di modal) tetap berlabel. */
  .sidebar .brand { padding: 4px 0 16px; justify-content: center; }
  .sidebar .brand-text, .sidebar .nav-sep, .sidebar .nav a span, .sidebar .nav a .count, .sidebar .sidebar-foot .who { display: none; }
  .sidebar .nav a { justify-content: center; padding: 11px; }
  .sidebar .sidebar-foot { flex-direction: column; padding: 10px 0 0; }
  .cols-21, .cols-12 { grid-template-columns: minmax(0, 1fr); }
}
/* HP: bottom navigation */
@media (max-width: 720px) {
  :root { --header-h: calc(54px + var(--safe-t)); }
  body { font-size: 14.5px; }
  /* < 16px membuat Safari iOS otomatis zoom saat input disentuh. */
  input, select, textarea { font-size: 16px !important; }
  .full-sm { grid-column: 1 / -1; }
  .tabs { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
  /* Header analitik: tab satu baris penuh, tombol laporan berlabel di bawahnya. */
  .an-head { flex-wrap: wrap; gap: 10px; }
  .an-head .tabs { flex: 1 0 100%; }
  .an-head .btn { flex: 1 0 100%; }
  .page-head { gap: 8px; }
  .page-head input[type=search] { flex: 1 0 100%; min-width: 0; max-width: none; }
  .page-head select { flex: 1 1 calc(50% - 4px); min-width: 0; max-width: none; }
  .page-head .spacer { display: none; }
  .page-head .btn { flex: 1 1 auto; }
  /* Detail trade: baris badge dan baris tombol masing-masing satu baris penuh. */
  .page-head > .row { flex: 1 0 100%; }
  .head-actions .btn { flex: 0 0 auto; }
  .head-actions .btn[data-act="edit"] { flex: 1 1 auto; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  /* Topbar HP: judul + tombol di baris 1, filter akun/rentang di baris 2 (lebar penuh).
     padding-top menambah area status bar supaya judul tidak tertimpa jam/baterai
     saat aplikasi dibuka dari layar utama (mode standalone iOS). */
  .topbar {
    padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) 8px calc(12px + var(--safe-l));
    gap: 6px; height: auto; min-height: var(--header-h); flex-wrap: wrap;
  }
  .topbar h2 { font-size: 16px; flex: 1; min-width: 0; }
  .topbar .spacer { display: none; }
  .topbar .filters { order: 3; width: 100%; }
  .topbar .filters:empty { display: none; }
  .topbar .filters select { flex: 1; max-width: none; }
  .topbar .hide-sm { display: none; }
  .page { padding: 12px calc(12px + var(--safe-r)) calc(var(--bottomnav) + 76px + var(--safe-b)) calc(12px + var(--safe-l)); }
  /* minmax(0,1fr), bukan 1fr: 1fr = minmax(auto,1fr) ikut melebar mengikuti isi
     (mis. .stat-list) dan membuat seluruh halaman lebih lebar dari layar HP. */
  .cols-2, .cols-3, .f3, .f4 { grid-template-columns: minmax(0, 1fr); }
  .f2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .f2 .span-2 { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 11px 12px; }
  .kpi-value { font-size: 18px; }
  .card { padding: 13px; }
  .grid { gap: 10px; }
  .hide-sm { display: none !important; }
  .tbl-trades { display: none; }
  .tcards { display: block; }
  .exec-chart { height: 320px; }
  .chart-box { height: 220px; }
  .tv-widget { height: 420px; }
  .link-card { grid-template-columns: 88px 1fr; }
  .link-card img, .link-card .noimg { width: 88px; height: 56px; }
  .cal .d { min-height: 48px; padding: 4px; }
  .cal .d .dc { display: none; }
  .cal .d .dv { font-size: 10px; }
  .heat { grid-template-columns: 30px repeat(24, minmax(0, 1fr)); gap: 1px; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--bottomnav) + var(--safe-b));
    padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
    background: color-mix(in srgb, var(--bg1) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  }
  .bottomnav a, .bottomnav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none;
    color: var(--txt3); font-size: 10.5px; font-weight: 600; text-decoration: none; cursor: pointer;
  }
  .bottomnav .active { color: var(--gold); }
  .bottomnav .add { color: #17130A; }
  .bottomnav .add .add-in { width: 46px; height: 46px; border-radius: 50%; background: var(--gold); display: grid; place-items: center; margin-top: -18px; box-shadow: 0 6px 18px rgba(230, 200, 74, .35); }
  .modal-wrap { place-items: end stretch; padding: 0; }
  .modal, .modal.wide, .modal.xwide {
    max-width: none; border-radius: 18px 18px 0 0; border-bottom: 0; animation: sheet .22s ease-out;
    max-height: calc(100dvh - var(--safe-t) - 24px);
  }
  .modal-head { padding-left: calc(18px + var(--safe-l)); padding-right: calc(16px + var(--safe-r)); }
  .modal-body { padding-left: calc(18px + var(--safe-l)); padding-right: calc(18px + var(--safe-r)); }
  .modal-foot { padding-left: calc(18px + var(--safe-l)); padding-right: calc(18px + var(--safe-r)); }
  @keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
  .modal-foot .btn { flex: 1; }
  #toasts { top: auto; bottom: calc(var(--bottomnav) + 12px + var(--safe-b)); left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); max-width: none; }
  .status { padding: 13px 14px; }
  .report-bar { flex-wrap: wrap; }
  .report-bar .grow { flex: 1 0 100%; }
  .report-bar .btn { flex: 1 1 0; }
  .plan-item { grid-template-columns: auto 1fr; }
  .plan-item > :last-child { grid-column: 2; }
}
@media (min-width: 721px) { .hide-lg { display: none !important; } }

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

/* ------------------------------ Laporan lengkap ------------------------------ */
.report { max-width: 820px; margin: 0 auto; }
.report-bar { position: sticky; top: calc(var(--header-h) + 8px); z-index: 5; display: flex; gap: 8px; align-items: center; padding: 10px 12px; margin-bottom: 16px; background: var(--bg1); border: 1px solid var(--gold); border-radius: var(--radius); }
.report-cover { padding: 22px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg1); margin-bottom: 16px; }
.report-cover h1 { font-size: 24px; letter-spacing: -.02em; }
.report-cover h1 span { color: var(--gold); }
.report-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 6px 16px; margin: 12px 0 16px; font-size: 13px; color: var(--txt2); }
.report-meta b { color: var(--txt); display: block; font-size: 14px; }
.report-section { margin-top: 26px; }
.report-section > h2 { font-size: 18px; padding-bottom: 8px; margin-bottom: 14px; border-bottom: 2px solid var(--gold); display: flex; gap: 10px; align-items: baseline; }
.report-section > h2 small { font-size: 12px; font-weight: 500; color: var(--txt3); }
/* Di laporan semua grid menjadi maksimal 2 kolom agar grafik tetap besar & terbaca. */
.report .cols-21, .report .cols-12, .report .cols-3 { grid-template-columns: minmax(0, 1fr); }
.report .chart-box { height: 290px; }
.report .chart-box.lg { height: 330px; }
.report .kpi-value { font-size: 19px; }
.report form#mc input { min-height: 34px; }
/* KPI ringkasan sudah ada di sampul laporan — jangan diulang di bagian 1. */
.report #rs-summary > .kpis:first-child { display: none; }
.report .cal .d { min-height: 54px; }

@media print {
  @page { size: A4; margin: 11mm; }
  html, body { background: #fff !important; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 11.5px; }
  .sidebar, .topbar, .bottomnav, #toasts, .no-print, .tabs, .report-bar { display: none !important; }
  .shell { display: block; }
  .page { padding: 0; max-width: none; }
  .report { max-width: none; }
  .card, .kpi, .report-cover { break-inside: avoid; box-shadow: none; }
  .report-section { break-before: page; margin-top: 0; }
  .report-section.first { break-before: auto; }
  .report-section > h2 { break-after: avoid; }
  .tbl-wrap { overflow: visible !important; }
  .tbl { font-size: 10px; }
  .tbl th, .tbl td { padding: 4px 6px; white-space: normal; }
  .tbl th { position: static; }
  .report .chart-box { height: 250px; }
  .report .chart-box.lg { height: 280px; }
  a { color: inherit; text-decoration: none; }
}
