/* =========================================================
   Botlink ERP — dark (default) and light themes
   ========================================================= */
:root {
  color-scheme: dark;
  --bg: #0B0F19;
  --surface: #0F1626;
  --surface-2: #131C30;
  --surface-3: #18233A;
  --ink: #E6EDF7;
  --ink-2: #B7C3D5;
  --muted: #8392A8;
  --line: rgba(148, 163, 184, .15);
  --line-2: rgba(148, 163, 184, .08);
  --input: rgba(255, 255, 255, .035);
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --accent-soft: rgba(59, 130, 246, .14);
  --accent-track: rgba(59, 130, 246, .2);
  --cyan: #22D3EE;
  --glow: rgba(34, 211, 238, .35);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --sidebar: #070B14;
  --sidebar-ink: #AEBBD0;
  --row-hover: rgba(56, 189, 248, .05);
  --chart-bar: #3B82F6;
  --chart-grid: rgba(148, 163, 184, .14);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -18px rgba(0, 0, 0, .8);
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, .85);
  --radius: 16px;
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Sora', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --sidebar-w: 252px;
  /* status tones: background / text */
  --t-neutral: rgba(148, 163, 184, .14); --t-neutral-ink: #CBD5E1;
  --t-info: rgba(59, 130, 246, .16); --t-info-ink: #93C5FD;
  --t-accent: rgba(34, 211, 238, .14); --t-accent-ink: #67E8F9;
  --t-good: rgba(34, 197, 94, .14); --t-good-ink: #86EFAC;
  --t-warn: rgba(245, 158, 11, .15); --t-warn-ink: #FCD34D;
  --t-bad: rgba(239, 68, 68, .15); --t-bad-ink: #FCA5A5;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #EEF2F7;
  --ink: #0F1B2D;
  --ink-2: #3D4B61;
  --muted: #66758B;
  --line: #E2E8F0;
  --line-2: #EEF1F5;
  --input: #FFFFFF;
  --accent: #116DFF;
  --accent-hover: #0B5EE0;
  --accent-soft: #E8F0FF;
  --accent-track: #D6E4FF;
  --cyan: #0891B2;
  --glow: rgba(17, 109, 255, .2);
  --danger: #D92D20;
  --danger-soft: #FEF3F2;
  --sidebar: #0B1F3A;
  --sidebar-ink: #C9D4E3;
  --row-hover: #F5F9FF;
  --chart-bar: #116DFF;
  --chart-grid: #E9EDF3;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 4px 16px -8px rgba(15, 27, 45, .12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 27, 45, .35);
  --t-neutral: #EEF1F5; --t-neutral-ink: #44526A;
  --t-info: #E7F0FF; --t-info-ink: #0B4FC2;
  --t-accent: #E0F6F8; --t-accent-ink: #0A6670;
  --t-good: #E5F6ED; --t-good-ink: #0B6B40;
  --t-warn: #FFF2DD; --t-warn-ink: #975400;
  --t-bad: #FDECEA; --t-bad-ink: #B42318;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 400 14px/1.55 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
:root:not([data-theme="light"]) a { color: #60A5FA; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.ic { font-size: 18px; line-height: 1; flex: none; display: inline-flex; }
.num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: 500 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .15s; }
.btn:hover { background: var(--surface-3); border-color: rgba(148, 163, 184, .3); }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn .ic { font-size: 16px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-hover)); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -10px var(--glow), 0 0 0 1px rgba(56, 189, 248, .25) inset; }
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), var(--accent-hover)); border-color: transparent; box-shadow: 0 10px 26px -10px var(--glow), 0 0 0 1px rgba(56, 189, 248, .4) inset; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: rgba(248, 113, 113, .35); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; height: 44px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; font-size: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

input, select, textarea { font: 400 14px/1.4 var(--font); color: var(--ink); background: var(--input); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; width: 100%; min-height: 38px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; background: var(--input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238392A8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 9px center / 16px no-repeat; padding-right: 32px; }
select option { background: var(--surface); color: var(--ink); }
input[type="date"] { color-scheme: inherit; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(700px 500px at 85% 0%, rgba(34, 211, 238, .22), transparent 70%), radial-gradient(700px 500px at 0% 100%, rgba(59, 130, 246, .28), transparent 70%), #0B0F19; }
.login-card { width: 100%; max-width: 410px; display: grid; gap: 14px; padding: 36px 32px; border-radius: 22px; background: rgba(15, 22, 38, .85); border: 1px solid rgba(56, 189, 248, .22); box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .9), 0 0 60px -30px rgba(34, 211, 238, .5); backdrop-filter: blur(16px); color: #E6EDF7; }
.login-card input { background: rgba(255, 255, 255, .04); border-color: rgba(148, 163, 184, .22); color: #E6EDF7; }
.login-logo { height: 34px; width: auto; margin-bottom: 10px; }
.login-card h1 { font: 600 22px/1.3 var(--display); }
.login-card .muted { color: #8392A8; }
.login-card label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; color: #B7C3D5; }
.login-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.login-foot a { color: #8392A8; }
.form-error { color: #FCA5A5; font-size: 13px; min-height: 1.2em; }
.seg-mini { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); }
.seg-mini button { border: 0; background: none; font: 600 11.5px/1 var(--font); color: var(--muted); padding: 6px 10px; border-radius: 999px; cursor: pointer; }
.seg-mini button.on { background: linear-gradient(135deg, var(--cyan), var(--accent)); color: #06101F; }
.login .seg-mini { border-color: rgba(148, 163, 184, .2); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100%; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 12px; overflow-y: auto; background: radial-gradient(300px 260px at 0% 0%, rgba(34, 211, 238, .1), transparent 70%), var(--sidebar); border-right: 1px solid rgba(148, 163, 184, .1); color: var(--sidebar-ink); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.side-brand img { height: 28px; width: auto; }
.side-brand span { font: 600 10.5px/1 var(--display); letter-spacing: .16em; color: #22D3EE; padding: 4px 7px; border-radius: 6px; border: 1px solid rgba(34, 211, 238, .35); background: rgba(34, 211, 238, .08); }
.side-nav { display: grid; gap: 2px; flex: 1; align-content: start; }
.side-group { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: #5E6E88; padding: 16px 12px 6px; }
.side-link { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--sidebar-ink) !important; font-weight: 500; transition: background .15s, color .15s; }
.side-link:hover { background: rgba(255, 255, 255, .05); color: #fff !important; }
.side-link.active { color: #fff !important; background: linear-gradient(90deg, rgba(34, 211, 238, .16), rgba(59, 130, 246, .06)); box-shadow: 0 0 0 1px rgba(34, 211, 238, .18) inset; }
.side-link.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #22D3EE; box-shadow: 0 0 12px #22D3EE; }
.side-link.active .ic { color: #22D3EE; }
.side-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #22D3EE; color: #06101F; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 12px -2px rgba(34, 211, 238, .8); }
.side-site { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(148, 163, 184, .16); color: var(--sidebar-ink) !important; font-size: 13px; }
.side-site:hover { background: rgba(255, 255, 255, .05); color: #fff !important; }
.side-site .ic { margin-left: auto; font-size: 15px; }
.sidebar-backdrop { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 62px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.menu-toggle { display: none; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs b { color: var(--ink); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.proto-tag { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--t-warn); color: var(--t-warn-ink); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #22D3EE, #3B82F6); color: #06101F; font-weight: 700; font-size: 12px; }
.user-chip small { color: var(--muted); }
.view { padding: 26px 28px 56px; max-width: 1520px; width: 100%; animation: viewIn .35s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------- page head / toolbar ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font: 600 24px/1.25 var(--display); letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 260px; max-width: 380px; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px; }
.search input { padding-left: 34px; }
.toolbar select { width: auto; min-width: 160px; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 5px 10px; border-radius: 7px; font: 500 13px/1 var(--font); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface-3); color: var(--ink); box-shadow: var(--shadow); }
.seg .ic { font-size: 15px; }

/* ---------- cards & tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
.table th[data-sort] { cursor: pointer; }
.table th[data-sort]:hover { color: var(--ink); }
.table th .arrow { font-size: 10px; margin-left: 4px; color: var(--cyan); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--row-hover); }
.table tbody tr:hover td.primary { color: var(--cyan); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.primary { font-weight: 600; color: var(--ink); transition: color .12s; }
.cell-thumb { display: flex; align-items: center; gap: 10px; }
.cell-thumb .thumb-box { width: 44px; height: 44px; border-radius: 10px; flex: none; display: grid; place-items: center; overflow: hidden; background: linear-gradient(180deg, #F5F7FB, #E4EAF2); border: 1px solid var(--line); }
.cell-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; mix-blend-mode: multiply; }
.cell-thumb .ph { color: #9aa6b8; font-size: 20px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pager .btns { display: flex; gap: 6px; }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty .ic { font-size: 36px; color: var(--muted); opacity: .6; margin-bottom: 8px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.loading { padding: 48px; text-align: center; color: var(--muted); }

/* pills (the label is always present — color is never the only signal) */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tone-neutral { background: var(--t-neutral); color: var(--t-neutral-ink); }
.tone-info { background: var(--t-info); color: var(--t-info-ink); }
.tone-accent { background: var(--t-accent); color: var(--t-accent-ink); }
.tone-good { background: var(--t-good); color: var(--t-good-ink); }
.tone-warn { background: var(--t-warn); color: var(--t-warn-ink); }
.tone-bad { background: var(--t-bad); color: var(--t-bad-ink); }

/* ---------- lead pipeline board ---------- */
.board-hint { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.board-hint .ic { font-size: 16px; color: var(--cyan); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; scroll-behavior: smooth; }
.col { display: flex; flex-direction: column; gap: 8px; min-height: 420px; padding: 10px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line-2); transition: background .15s, border-color .15s, box-shadow .15s; }
.col.drop { border-color: var(--cyan); background: color-mix(in srgb, var(--cyan) 8%, var(--surface-2)); box-shadow: 0 0 0 1px var(--cyan) inset, 0 0 40px -16px var(--glow); }
.col-won { background: color-mix(in srgb, #22C55E 5%, var(--surface-2)); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 4px; }
.col-head .count { font-size: 12px; color: var(--muted); font-weight: 600; }
.col-sum { font-size: 12px; color: var(--muted); padding: 0 4px 2px; font-variant-numeric: tabular-nums; }
.col-note { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--t-good-ink); padding: 6px 8px; border-radius: 8px; border: 1px dashed color-mix(in srgb, #22C55E 45%, transparent); }
.col-note .ic { font-size: 14px; }
.lead-card { position: relative; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); cursor: grab; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); transition: box-shadow .15s, transform .15s, border-color .15s, opacity .15s; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.lead-card:hover { border-color: rgba(56, 189, 248, .4); box-shadow: 0 10px 24px -14px var(--glow); transform: translateY(-1px); }
.lead-card.placeholder { opacity: .3; }
.lead-card b { display: block; font-size: 13.5px; color: var(--ink); }
.lead-card .co { font-size: 12.5px; color: var(--ink-2); }
.lead-card .meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.lead-card .val { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.lead-card .cust { position: absolute; top: 10px; right: 10px; color: var(--t-good-ink); }
.lead-card .cust .ic { font-size: 15px; }
.drag-ghost { position: fixed; z-index: 90; pointer-events: none; margin: 0; width: 240px; cursor: grabbing; border-color: var(--cyan) !important; box-shadow: 0 24px 50px -16px rgba(0, 0, 0, .7), 0 0 30px -8px var(--glow) !important; transform-origin: 20% 20%; }
body.dragging, body.dragging * { cursor: grabbing !important; }

/* ---------- dashboard ---------- */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.dash-head h1 { font: 600 24px/1.25 var(--display); }
.kpis { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi-label .ic { font-size: 16px; }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi-sub .bad { color: var(--danger); font-weight: 600; }
.kpi-hero { position: relative; overflow: hidden; color: #fff; border-color: rgba(56, 189, 248, .3); background: radial-gradient(360px 220px at 100% 0%, rgba(34, 211, 238, .35), transparent 70%), linear-gradient(140deg, #0B1B36, #0F2A52); box-shadow: 0 20px 50px -30px rgba(34, 211, 238, .6); }
.kpi-hero .kpi-label, .kpi-hero .kpi-sub { color: #A9C0DD; }
.kpi-hero .kpi-label .ic { color: #22D3EE; }
.kpi-hero .kpi-value { font-size: 48px; line-height: 1.1; }
.meter { height: 8px; border-radius: 999px; background: var(--accent-track); overflow: hidden; margin: 8px 0 4px; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.panel { padding: 18px 20px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { font-size: 15px; }
.panel-head .sub { font-size: 12.5px; color: var(--muted); }
.panel-head a { font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--chart-bar); transition: opacity .15s; }
.chart.hovering .bar { opacity: .35; }
.chart.hovering .bar.hot { opacity: 1; }
.chart .bar-label { fill: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart-tip { position: fixed; z-index: 100; pointer-events: none; padding: 8px 11px; border-radius: 9px; font-size: 12.5px; color: #fff; background: #0B1B36; border: 1px solid rgba(56, 189, 248, .35); box-shadow: var(--shadow-lg); opacity: 0; transform: translate(-50%, calc(-100% - 10px)); transition: opacity .12s; white-space: nowrap; }
.chart-tip.show { opacity: 1; }
.chart-tip b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.chart-tip span { color: #A9C0DD; }
details.data-table { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
details.data-table summary { cursor: pointer; width: max-content; }
details.data-table table { margin-top: 8px; border-collapse: collapse; width: 100%; }
details.data-table td, details.data-table th { padding: 5px 8px; border-bottom: 1px solid var(--line-2); text-align: left; }
details.data-table td:last-child, details.data-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.hbars { display: grid; gap: 11px; }
.hbar { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 10px; font-size: 13px; color: inherit !important; }
.hbar-label { color: var(--ink-2); }
.hbar-track { display: flex; align-items: center; gap: 8px; }
.hbar-fill { height: 12px; min-width: 2px; background: var(--chart-bar); border-radius: 0 4px 4px 0; transition: opacity .15s; }
.hbars:hover .hbar-fill { opacity: .4; }
.hbars .hbar:hover .hbar-fill { opacity: 1; }
.hbar-val { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.panel-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.panel-foot b { color: var(--ink); }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { border-bottom: 1px solid var(--line-2); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list a { color: inherit !important; display: flex; align-items: center; gap: 12px; padding: 10px 0; min-width: 0; }
.mini-list a:hover .main-t b { color: var(--cyan); }
.mini-list .main-t { flex: 1; min-width: 0; }
.mini-list .main-t b { display: block; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); transition: color .12s; }
.mini-list .main-t span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list .right { text-align: right; font-size: 12.5px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.mini-list .right b { display: block; color: var(--ink); font-size: 13px; }
.mini-empty { padding: 18px 0; color: var(--muted); font-size: 13px; }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(3, 6, 14, .6); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(700px, 100%); display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); transform: translateX(104%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.drawer.show { transform: none; }
.drawer.wide { width: min(900px, 100%); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 24px 14px; border-bottom: 1px solid var(--line); }
.drawer-head .eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.drawer-head h2 { font: 600 19px/1.3 var(--display); margin-top: 2px; word-break: break-word; }
.drawer-head .pill { margin-top: 6px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 28px; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface); }
.drawer-foot .spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .field > .flabel { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--danger); }
.field .hint { font-size: 12px; color: var(--muted); }
.ro-val { min-height: 38px; display: flex; align-items: center; padding: 0 2px; font-weight: 500; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 38px; }
.switch input { appearance: none; width: 40px; height: 22px; min-height: 0; padding: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px -4px var(--glow); }
.switch input:checked::after { transform: translateX(18px); }
.form-alert { display: none; margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); border: 1px solid rgba(248, 113, 113, .35); color: var(--t-bad-ink); font-size: 13px; }
.form-alert.show { display: block; }
.img-preview { width: 100%; height: 170px; border-radius: 12px; border: 1px solid var(--line); background: radial-gradient(circle at 50% 85%, rgba(34, 211, 238, .2), transparent 60%), var(--surface-2); object-fit: contain; padding: 12px; }

.items-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.items-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.items-table th { font-size: 11.5px; font-weight: 600; color: var(--muted); text-align: left; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.items-table td { padding: 6px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.items-table tr:last-child td { border-bottom: 0; }
.items-table input, .items-table select { min-height: 34px; padding: 6px 8px; font-size: 13px; }
.items-table .c-prod { width: 170px; }
.items-table .c-qty { width: 76px; }
.items-table .c-price { width: 124px; }
.items-table .c-amt { width: 120px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; padding-right: 10px; color: var(--ink); }
.items-table .c-x { width: 36px; }
.items-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.totals { margin: 0; min-width: 270px; display: grid; gap: 4px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.totals div { display: flex; justify-content: space-between; gap: 24px; font-size: 13px; color: var(--ink-2); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals .grand { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 16px; font-weight: 700; color: var(--ink); }
.totals .grand dd { color: var(--cyan); }

.related { margin-top: 26px; display: grid; gap: 16px; }
.related h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; margin-bottom: 6px; }
.related h3 a { font-weight: 500; font-size: 12.5px; }
.rel-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.rel-list a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line-2); color: var(--ink) !important; font-size: 13px; }
.rel-list li:last-child a { border-bottom: 0; }
.rel-list a:hover { background: var(--row-hover); }
.rel-list .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-list .t small { color: var(--muted); margin-left: 6px; }
.rel-list .amt { font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 120; display: grid; justify-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; color: #E6EDF7; background: #0F1B31; border: 1px solid rgba(56, 189, 248, .3); box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .8), 0 0 30px -14px rgba(34, 211, 238, .6); font-size: 13.5px; animation: toastIn .25s ease; max-width: 460px; }
.toast .ic { color: #22D3EE; }
.toast a { color: #67E8F9 !important; font-weight: 600; margin-left: 4px; white-space: nowrap; }
.toast.err { background: #3A1114; border-color: rgba(248, 113, 113, .45); }
.toast.err .ic { color: #FCA5A5; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- media uploader (Products) ---------- */
.uploader { display: grid; grid-template-columns: 180px 1fr; gap: 14px; align-items: stretch; }
.up-preview { position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #0B0F19; display: grid; place-items: center; }
.up-preview.studio { background: radial-gradient(70% 60% at 50% 42%, #fff 0%, rgba(255, 255, 255, 0) 70%), linear-gradient(180deg, #F5F7FB, #E7ECF3); }
.up-preview img, .up-preview video { width: 100%; height: 100%; object-fit: cover; }
.up-preview.studio img { object-fit: contain; padding: 10px; mix-blend-mode: multiply; }
.up-preview .ph { font-size: 34px; color: var(--muted); opacity: .6; }
.up-side { display: grid; gap: 8px; align-content: start; min-width: 0; }
.up-drop { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1.5px dashed rgba(148, 163, 184, .35); background: var(--input); color: var(--ink-2); cursor: pointer; transition: border-color .15s, background .15s; }
.up-drop:hover, .up-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.up-drop .ic { font-size: 26px; color: var(--accent); }
.up-drop b { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.up-drop small { color: var(--muted); font-size: 12px; }
.up-url { display: flex; gap: 6px; }
.up-url input { font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.up-progress { height: 4px; border-radius: 4px; background: var(--line-2); overflow: hidden; opacity: 0; transition: opacity .2s; }
.up-progress.on { opacity: 1; }
.up-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.up-msg { font-size: 12px; color: var(--muted); min-height: 1em; }
.up-msg.err { color: var(--danger); }

/* ---------- LINE notification panel (Settings → Users) ---------- */
.notify-panel { display: flex; align-items: center; gap: 16px; padding: 16px 18px; margin-bottom: 14px; }
.notify-panel .line-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 26px; color: #fff; background: #06C755; flex: none; }
.notify-panel .txt { flex: 1; min-width: 0; }
.notify-panel b { display: block; }
.notify-panel small { color: var(--muted); }
.notify-panel code { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); }

/* ---------- responsive ---------- */
@media (max-width: 1320px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpi-hero { grid-column: 1 / -1; }
}
@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 45; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(3, 6, 14, .55); }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .view { padding: 20px 16px 48px; }
  .user-chip .who { display: none; }
  .user-chip { padding: 4px; }
}
@media (max-width: 640px) {
  .kpi-hero .kpi-value { font-size: 38px; }
  .kpi-value { font-size: 22px; }
  .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .drawer-head, .drawer-body, .drawer-actions, .drawer-foot { padding-left: 16px; padding-right: 16px; }
  .search { max-width: none; }
  .toolbar select { flex: 1 1 140px; min-width: 0; }
  .proto-tag { display: none; }
  .page-head h1 { font-size: 21px; }
  .topbar-right { gap: 6px; }
}
