/* ============================================================
   Option Trade Log — design system
   Dark, data-dense trading console. Thai + English, tabular numerals.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Sarabun:wght@400;500;600;700&display=swap');

:root {
  /* accent — overridden by tweak */
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --accent-soft: rgba(59,130,246,0.14);
  --accent-line: rgba(59,130,246,0.42);

  /* semantic P/L (fixed regardless of accent) */
  --pos: #26a269;
  --pos-bright: #3fd07f;
  --pos-soft: rgba(38,162,105,0.14);
  --neg: #e5484d;
  --neg-bright: #ff6166;
  --neg-soft: rgba(229,72,77,0.13);
  --warn: #d8a229;
  --warn-soft: rgba(216,162,41,0.14);

  /* dark surfaces */
  --bg: #0a0d13;
  --bg-grad: radial-gradient(1200px 700px at 78% -8%, #131a26 0%, #0a0d13 58%);
  --surface: #11151d;
  --surface-2: #161b25;
  --surface-3: #1d2430;
  --border: #232b39;
  --border-soft: #1a212c;
  --text: #e8ecf3;
  --text-dim: #97a2b3;
  --text-faint: #5e6a7d;

  --font-sans: 'IBM Plex Sans Thai','IBM Plex Sans','Sarabun',system-ui,sans-serif;
  --font-mono: 'IBM Plex Mono','SF Mono',ui-monospace,monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 28px -12px rgba(0,0,0,0.65);
  --sidebar-w: 234px;
}

/* font tweak: Sarabun-led alternative */
[data-font="sarabun"] {
  --font-sans: 'Sarabun','IBM Plex Sans',system-ui,sans-serif;
}

/* light theme */
[data-theme="light"] {
  --bg: #f4f5f3;
  --bg-grad: radial-gradient(1100px 640px at 80% -10%, #ffffff 0%, #eef0ee 60%);
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --surface-3: #edefec;
  --border: #e1e4df;
  --border-soft: #ebede9;
  --text: #1b2129;
  --text-dim: #5a6573;
  --text-faint: #97a0ad;
  --pos: #1a7f4f;
  --pos-bright: #178a52;
  --neg: #d23b40;
  --neg-bright: #c8363b;
  --shadow: 0 1px 2px rgba(16,24,40,0.04), 0 10px 26px -16px rgba(16,24,40,0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.45;
}
#root { min-height: 100%; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }
button, input, select, textarea { font-family: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-3); background-clip: padding-box; }

.pos { color: var(--pos-bright); }
.neg { color: var(--neg-bright); }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--surface) 0%, rgba(17,21,29,0.6) 100%);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 4px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none; overflow: hidden;
  box-shadow: 0 6px 16px -6px var(--accent-line);
}
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand > div { min-width: 0; }
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: .2px; white-space: nowrap; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-faint); letter-spacing: .3px; white-space: nowrap; }

/* ---------- Portfolio switcher ---------- */
.pf-switch { position: relative; margin: 0 0 14px; }
.pf-switch-top { display: none; }
.pf-current {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 11px;
  cursor: pointer; text-align: left; color: var(--text); transition: border-color .14s, background .14s;
}
.pf-current:hover { border-color: var(--accent-line); }
.pf-current.open { border-color: var(--accent-line); background: var(--accent-soft); }
.pf-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px -5px var(--accent-line);
}
.pf-avatar.sm { width: 26px; height: 26px; font-size: 12.5px; border-radius: 7px; }
.pf-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.pf-eyebrow { font-size: 10px; color: var(--text-faint); letter-spacing: .4px; text-transform: uppercase; }
.pf-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-chev { flex: none; color: var(--text-faint); transition: transform .16s; }
.pf-current.open .pf-chev { transform: rotate(180deg); }
.pf-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  padding: 5px; box-shadow: 0 14px 34px -12px rgba(0,0,0,.55); display: flex; flex-direction: column; gap: 2px;
  animation: pfFade .13s ease;
}
@keyframes pfFade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pf-opt {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 8px;
  background: none; border: none; cursor: pointer; color: var(--text-dim); width: 100%; text-align: left;
  font-size: 13px; transition: background .12s, color .12s;
}
.pf-opt:hover { background: var(--surface-2); color: var(--text); }
.pf-opt.on { color: var(--text); }
.pf-opt-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.pf-check { flex: none; color: var(--accent-2); }

.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px;
  color: var(--text-dim); cursor: pointer; font-weight: 500; font-size: 13.5px;
  border: 1px solid transparent; transition: background .14s, color .14s; user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item span { white-space: nowrap; }
.nav-item > div { min-width: 0; flex: 1; }
.nav-item.active { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }
.nav-item.active .nav-ic { color: var(--accent-2); }
.nav-ic { width: 18px; height: 18px; flex: none; color: var(--text-faint); }
.nav-badge { margin-left: auto; font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }
.pro-badge { margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: .5px; color: var(--accent-2); background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 5px; padding: 1px 6px; }
.free-usage { font-size: 12px; font-family: var(--font-mono); color: var(--text-faint); background: var(--surface-2, #161b25); border: 1px solid var(--border, #232b39); border-radius: 7px; padding: 5px 9px; white-space: nowrap; }
.free-usage .num { color: var(--text-dim, #97a2b3); font-weight: 600; }
.nav-spacer { flex: 1; }
.nav-foot { font-size: 11px; color: var(--text-faint); padding: 8px; line-height: 1.5; }
.feedback-btn { display: flex; align-items: center; gap: 8px; width: calc(100% - 8px); margin: 0 4px 6px; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--accent-2); background: var(--accent-soft); border: 1px solid var(--accent-line); transition: background .14s, border-color .14s; }
.feedback-btn:hover { background: var(--accent-line); }
.feedback-beta { margin-left: auto; font-size: 9px; font-weight: 700; letter-spacing: .5px; color: var(--text-faint); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 14px 28px; border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(12px);
}
.page-title { font-size: 18px; font-weight: 600; }
.page-sub { font-size: 12.5px; color: var(--text-dim); }
.topbar-stats { margin-left: auto; display: flex; gap: 26px; align-items: center; }
.tb-stat { text-align: right; }
.tb-stat .l { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .6px; }
.tb-stat .v { font-size: 15px; font-weight: 600; }
.content { padding: 24px 28px 80px; max-width: 1320px; width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 13.5px; font-weight: 600; letter-spacing: .2px; }
.card-title .th { color: var(--text-dim); font-weight: 500; }
.card-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.grid { display: grid; gap: 16px; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-faint); margin: 4px 2px 10px; font-weight: 600; }

/* ---------- KPI stat ---------- */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 7px; position: relative; overflow: hidden; }
.kpi .k-label { font-size: 11.5px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.kpi .k-val { font-size: 25px; font-weight: 600; letter-spacing: -.3px; line-height: 1.05; }
.kpi .k-sub { font-size: 11.5px; color: var(--text-faint); display: flex; gap: 6px; align-items: center; }
.kpi .k-spark { position: absolute; right: 0; bottom: 0; opacity: .9; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; }
.chip.up { color: var(--pos-bright); background: var(--pos-soft); }
.chip.down { color: var(--neg-bright); background: var(--neg-soft); }
.chip.neutral { color: var(--text-dim); background: var(--surface-3); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 6px; border: 1px solid transparent; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-closed { color: var(--text); background: var(--surface-3); border-color: var(--border); }
.badge-opened { color: var(--accent-2); background: var(--accent-soft); border-color: var(--accent-line); }
.badge-rolled { color: var(--warn); background: var(--warn-soft); border-color: rgba(216,162,41,.3); }
.badge-pair { color: var(--text-faint); background: transparent; border-color: var(--border); }
.badge-win { color: var(--pos-bright); background: var(--pos-soft); }
.badge-loss { color: var(--neg-bright); background: var(--neg-soft); }
.tkr { font-weight: 600; font-family: var(--font-mono); letter-spacing: .3px; cursor: pointer; border-bottom: 1px dashed transparent; transition: color .12s, border-color .12s; }
.tkr:hover { color: var(--accent-2); border-bottom-color: var(--accent-line); }

/* asset-type tag (STK / OPT) in the trades table */
.asset-tag { display: inline-flex; align-items: center; font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: .5px; padding: 1px 5px; border-radius: 5px; flex: none; }
.asset-tag.stk { color: var(--accent-2); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.asset-tag.opt { color: var(--text-dim); background: var(--surface-3); border: 1px solid var(--border); }

/* ---------- Ticker live-chart modal ---------- */
.tc-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  z-index: 121; width: min(1040px, 94vw); height: min(680px, 88vh);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 30px 80px -24px rgba(0,0,0,.7); display: flex; flex-direction: column; overflow: hidden;
  animation: fade .16s ease;
}
.tc-head { display: flex; align-items: center; gap: 16px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.tc-quote { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.tc-sym { font-size: 20px; cursor: default; border-bottom: none; }
.tc-sym:hover { color: inherit; border-bottom: none; }
.tc-price { font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.tc-chg { font-size: 14px; font-weight: 600; }
.tc-live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.tc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos-bright); box-shadow: 0 0 0 0 var(--pos-bright); animation: tcPulse 1.8s infinite; }
@keyframes tcPulse { 0% { box-shadow: 0 0 0 0 rgba(23,138,82,.5); } 70% { box-shadow: 0 0 0 6px rgba(23,138,82,0); } 100% { box-shadow: 0 0 0 0 rgba(23,138,82,0); } }
.tc-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tc-chart { flex: 1; min-height: 0; }
@media (max-width: 640px) {
  .tc-modal { width: 100vw; height: 100vh; max-width: 100vw; border-radius: 0; top: 0; left: 0; transform: none; }
}

/* ---------- Copy preview modal ---------- */
.copy-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 131;
  width: min(540px, 94vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 30px 80px -24px rgba(0,0,0,.7);
  display: flex; flex-direction: column; overflow: hidden; animation: fade .16s ease;
}
.copy-modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 18px; border-bottom: 1px solid var(--border-soft); }
.copy-modal-head > div { flex: 1; }
.copy-ta {
  margin: 0; border: none; resize: none; width: 100%; height: 300px; padding: 16px 18px;
  background: var(--surface-2); color: var(--text);
  font-family: var(--font-mono); font-size: 13px; line-height: 1.7; white-space: pre-wrap;
  border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); outline: none;
}
.copy-ta::selection { background: var(--accent-soft); }
.copy-modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 14px; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); white-space: nowrap; cursor: pointer; user-select: none;
}
table.tbl th.no-sort { cursor: default; }
table.tbl th .sort-ar { opacity: .55; margin-left: 3px; }
table.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .1s; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl td.r, table.tbl th.r { text-align: right; }
table.tbl td.c, table.tbl th.c { text-align: center; }
.row-click { cursor: pointer; }
.t-note { color: var(--text-dim); font-size: 12px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 13px; cursor: pointer; transition: all .13s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -8px var(--accent-line); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-danger { color: var(--neg-bright); border-color: rgba(229,72,77,.3); background: var(--neg-soft); }
.icon-btn { width: 32px; height: 32px; padding: 0; justify-content: center; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; color: var(--text-dim); padding: 6px 13px; border-radius: 6px; font-weight: 600; font-size: 12.5px; cursor: pointer; transition: all .12s; }
.seg button.on { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-line); }
.seg button:hover:not(.on) { color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-dim); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.field .hint { color: var(--text-faint); font-size: 11px; font-weight: 400; }
.input, .select, textarea.input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px;
  color: var(--text); font-size: 13.5px; width: 100%; transition: border-color .13s, box-shadow .13s; outline: none;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.num { font-family: var(--font-mono); }
.input::placeholder { color: var(--text-faint); }
.input-mono { font-family: var(--font-mono); }
textarea.input { resize: vertical; min-height: 64px; line-height: 1.5; }
.input.calc { background: var(--surface); border-style: dashed; color: var(--text-dim); }

/* ---------- Modal / drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(4,6,10,0.62); backdrop-filter: blur(3px); z-index: 100; animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 560px; max-width: 94vw; z-index: 101;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -20px 0 50px -20px rgba(0,0,0,.6);
  display: flex; flex-direction: column; animation: slidein .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes slidein { from { transform: translateX(40px); opacity: .4; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 12px; }
.drawer-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 15px 22px; border-top: 1px solid var(--border-soft); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2); }

/* ---------- Charts ---------- */
.chart-svg { width: 100%; display: block; overflow: visible; }
.chart-grid line { stroke: var(--border-soft); stroke-width: 1; }
.chart-axis { fill: var(--text-faint); font-size: 10px; font-family: var(--font-mono); }
.tooltip {
  position: fixed; z-index: 200; pointer-events: none; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 11px; font-size: 12px; box-shadow: var(--shadow); transform: translate(-50%, -116%);
}
.tooltip .tt-d { color: var(--text-faint); font-size: 11px; margin-bottom: 2px; }
.tooltip .tt-v { font-weight: 600; font-family: var(--font-mono); }

/* bar list */
.barrow { display: grid; grid-template-columns: 116px 1fr auto; align-items: center; gap: 12px; padding: 6px 0; }
.barrow .b-label { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bartrack { height: 8px; border-radius: 5px; background: var(--surface-3); overflow: hidden; position: relative; }
.barfill { height: 100%; border-radius: 5px; }
.barrow .b-val { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }

/* progress */
.prog { height: 10px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.prog > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 6px; }

@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 48px 20px; color: var(--text-faint); }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-dim); }
.kv .v { font-weight: 600; font-family: var(--font-mono); }

.pill-row { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-pill { font-size: 12px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim); cursor: pointer; font-weight: 500; }
.filter-pill.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.filter-pill:hover:not(.on) { color: var(--text); }

.editable-cell { cursor: text; border-radius: 6px; padding: 3px 6px; margin: -3px -6px; transition: background .1s; }
.editable-cell:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.cell-input { width: 92px; background: var(--surface); border: 1px solid var(--accent); border-radius: 6px; padding: 3px 6px; font-family: var(--font-mono); font-size: 12.5px; outline: none; }

/* ---------- Mobile ---------- */
.mobile-nav { display: none; }
@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .pf-switch-top { display: block; margin: 0; flex: none; }
  .pf-switch-top .pf-current { padding: 6px 9px 6px 7px; gap: 7px; border-radius: 10px; }
  .pf-switch-top .pf-avatar { width: 26px; height: 26px; font-size: 12.5px; border-radius: 7px; }
  .pf-switch-top .pf-name { font-size: 13px; max-width: 92px; }
  .pf-switch-top .pf-menu { left: auto; right: 0; min-width: 168px; }
  .topbar-stats { gap: 16px; }
  .topbar-stats .tb-hide { display: none; }
  .content { padding: 16px 14px 96px; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-between; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .mobile-nav::-webkit-scrollbar { display: none; }
  .mnav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; color: var(--text-faint); cursor: pointer; border-radius: 8px; font-size: 10px; font-weight: 600; min-width: 52px; }
  .mnav-item.active { color: var(--accent-2); }
  .mnav-item .nav-ic { width: 21px; height: 21px; }
  .drawer { width: 100%; max-width: 100%; }
  .topbar .page-sub { display: none; }
}
@media (max-width: 560px) {
  .kpi .k-val { font-size: 21px; }
  .page-title { font-size: 16px; }
}

/* ---- Watchlist alert toast ---- */
.wl-toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 200; width: 300px; max-width: calc(100vw - 36px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 40px -8px rgba(0,0,0,.6); padding: 12px; display: flex; flex-direction: column; gap: 8px;
  animation: wlpop .32s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes wlpop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.wl-toast-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.wl-toast-x { margin-left: auto; background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 2px; display: grid; place-items: center; border-radius: 6px; }
.wl-toast-x:hover { background: var(--surface-2); color: var(--text); }
.wl-toast-body { display: flex; flex-direction: column; gap: 2px; }
.wl-toast-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 9px; cursor: pointer; }
.wl-toast-row:hover { background: var(--surface-2); }
.wl-toast-grade { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: #0a0e14; font-weight: 800; font-size: 11px; flex: none; }
.wl-row { display: flex; align-items: center; gap: 14px; padding: 11px 16px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.wl-row:last-child { border-bottom: none; }
.wl-row:hover { background: var(--surface-2); }
.wl-row-metrics { display: flex; gap: 14px; flex-wrap: wrap; }
@media (max-width: 700px) {
  .wl-row { flex-wrap: wrap; gap: 8px 14px; }
  .wl-row-metrics { width: 100%; order: 3; gap: 12px; }
  .wl-row-status { order: 2; }
}
@media (max-width: 560px) {
  .wl-toast { left: 12px; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); width: auto; }
}


/* ============================================================
   Stock lot-ledger ("หุ้น" page)
   ============================================================ */
.sumstat .l { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.sumstat .v { font-size: 23px; font-weight: 600; line-height: 1; letter-spacing: -.3px; }
.sumstat .s { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }

.alloc-legend { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 240px; }
.leg-row { display: grid; grid-template-columns: 12px 1fr auto auto; align-items: center; gap: 11px; padding: 6px; border-radius: 8px; transition: background .12s; }
.leg-row:hover { background: var(--surface-2); }
.leg-dot { width: 11px; height: 11px; border-radius: 3px; }
.leg-name { font-weight: 600; font-size: 13px; }
.leg-name small { color: var(--text-faint); font-weight: 400; margin-left: 6px; }
.leg-pct { font-family: var(--font-mono); font-size: 13px; font-weight: 600; min-width: 52px; text-align: right; }
.leg-val { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); min-width: 74px; text-align: right; }

.lot { display: grid; grid-template-columns: 78px 60px 1fr auto; gap: 14px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.lot:last-child { border-bottom: none; }
.lot-date { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); padding-top: 2px; }
.lot-type { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .4px; padding: 3px 0; text-align: center; border-radius: 6px; height: fit-content; }
.lot-type.buy { color: var(--accent-2); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.lot-type.sell { color: var(--warn); background: var(--warn-soft); border: 1px solid rgba(216,162,41,.3); }
.lot-main { min-width: 0; }
.lot-qty { font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; }
.lot-qty .x { color: var(--text-faint); margin: 0 5px; font-weight: 400; }
.lot-fee { color: var(--text-faint); font-size: 11.5px; margin-left: 8px; }
.lot-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.lot-note { color: var(--text-dim); font-size: 12.5px; margin-top: 6px; line-height: 1.5; }
.lot-right { text-align: right; }
.lot-realized { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.lot-chart { display: block; margin-top: 8px; width: 132px; height: 58px; border-radius: 8px; border: 1px solid var(--border); overflow: hidden; position: relative; cursor: zoom-in; }
.lot-chart .lc-tag { position: absolute; left: 6px; top: 5px; font-size: 9px; color: #fff; font-family: var(--font-mono); letter-spacing: .3px; text-shadow: 0 1px 3px rgba(0,0,0,.8); }

.tagc { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.tagc .td { width: 6px; height: 6px; border-radius: 50%; }
.conf { display: inline-flex; align-items: center; gap: 3px; }
.conf b { font-size: 10px; color: var(--text-faint); font-weight: 600; margin-right: 2px; letter-spacing: .3px; }
.conf i { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border); }
.conf i.on { background: var(--accent-2); border-color: var(--accent-2); }

.exp-row { cursor: pointer; }
.exp-chev { display: inline-flex; transition: transform .18s; color: var(--text-faint); }
.exp-row.open .exp-chev { transform: rotate(90deg); color: var(--accent-2); }
.lotbox { background: var(--surface-2); border-top: 1px solid var(--border); }
.lotbox-inner { padding: 6px 22px 16px; }
.lotbox-head { display: flex; align-items: center; gap: 10px; padding: 14px 0 4px; }
.alloc-bar { height: 7px; border-radius: 5px; background: var(--surface-3); overflow: hidden; min-width: 56px; }
.alloc-bar > i { display: block; height: 100%; border-radius: 5px; }

.tag-pick { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-opt { cursor: pointer; opacity: .5; transition: opacity .12s; }
.tag-opt.on { opacity: 1; }
.tag-opt:hover { opacity: .85; }
.conf-pick { display: flex; gap: 7px; }
.conf-pick b { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); font-family: var(--font-mono); font-size: 13px; color: var(--text-dim); transition: all .12s; }
.conf-pick b.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.note-tag { font-size: 11px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim); cursor: pointer; }
.note-tag:hover { color: var(--text); border-color: var(--accent-line); }


/* mobile-only account/logout in topbar (sidebar is hidden on mobile) */
.tb-acct { display: none; }
@media (max-width: 900px) { .tb-acct { display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; white-space: nowrap; } }
