:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1a1d21;
  --muted: #6b7280;
  --line: #e6e8eb;
  --brand: #7c3aed;       /* purple — primary accent */
  --brand-ink: #5b21b6;
  --gold: #c9a96e;        /* berrynice.my badge/accent (kept for occasional use) */
  --danger: #dc2626;      /* red */
  --danger-bg: #fef2f2;
  --ok: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
}
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* sidebar */
.sidebar { background: #14161a; color: #d7dade; display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; color: #fff; padding: 6px 8px 18px; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; background: var(--brand); border-radius: 8px; font-size: 13px; font-weight: 700; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7c828c; margin: 16px 8px 6px; }
.nav-item { display: block; padding: 8px 10px; border-radius: 8px; color: #c3c7cd; text-decoration: none; font-size: 13.5px; }
.nav-item:hover { background: #21242a; color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; font-size: 12px; color: #7c828c; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--danger); }

/* content */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 28px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.view { padding: 24px 28px; overflow-x: auto; }

/* kpis */
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 12.5px; }
.kpi-value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.01em; }
.kpi-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-title { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.card-body { padding: 16px 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table td { padding: 9px 10px; border-bottom: 1px solid #f0f1f3; }
.table tr:last-child td { border-bottom: none; }

/* bars */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 190px; align-items: center; gap: 12px; }
.bar-label { color: var(--muted); font-size: 13px; }
.bar-track { background: #eef0f2; border-radius: 6px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 6px; min-width: 2px; }
.bar-fill.danger { background: var(--danger); }
.bar-row.click { cursor: pointer; border-radius: 8px; padding: 2px 6px; margin: 0 -6px; transition: background .12s; }
.bar-row.click:hover { background: #f3eefe; }
.bar-row.click:hover .bar-label { color: var(--brand-ink); }
.bar-val { text-align: right; font-size: 12.5px; color: var(--muted); }

/* states */
.loading, .placeholder { text-align: center; color: var(--muted); padding: 60px 20px; }
.placeholder-icon { font-size: 34px; }
.error-box { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; border-radius: var(--radius); padding: 14px 16px; }

/* controls */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.input { height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; background: var(--surface); color: var(--ink); }
input.input { min-width: 260px; }
input.input.date { min-width: 150px; width: 150px; }
.filter-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
select.input { min-width: 150px; }
.grow-spacer { flex: 1; }
.filter-bar .cbx.filter-cb { min-width: 190px; max-width: 240px; }

/* type-to-search combo box */
.cbx { position: relative; }
.cbx-panel { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60; background: var(--surface, #fff); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 34px rgba(0,0,0,.16); max-height: 264px; overflow-y: auto; padding: 4px; }
.cbx-opt { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.cbx-opt:hover, .cbx-opt.active { background: var(--surface-2, #f0f0f5); }
.cbx-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbx-sub { color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.cbx-add { color: var(--brand, #6366f1); font-weight: 600; }
.cbx-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.sr-count { color: var(--muted); font-size: 12.5px; padding: 4px 2px 12px; }
/* virtual-scrolled table (Stock Balance): internal scroll + sticky header, only visible rows in DOM */
.table-scroll.virtual { overflow: auto; min-height: 240px; }
.table-scroll.virtual thead th { position: sticky; top: 0; z-index: 3; background: var(--surface, #fff); }
.table-scroll.virtual thead th.row-actions { z-index: 4; }
.table-scroll.virtual thead { box-shadow: 0 1px 0 var(--line); }
.table-scroll.virtual tbody tr.click { height: 39px; }
.table-scroll.virtual tbody td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vspacer { pointer-events: none; }
/* click-to-edit price cells */
.editable-cell { cursor: pointer; }
.editable-cell .cell-val.empty { color: var(--muted); }
.editable-cell:hover .cell-val { text-decoration: underline dotted; text-underline-offset: 3px; }
.editable-cell.saving .cell-val { opacity: .5; }
.editable-cell.save-ok .cell-val { color: #16a34a; }
.editable-cell.save-err .cell-val { color: #dc2626; }

/* per-row action icons (Stock Balance) — pinned to the right edge so they stay visible while scrolling */
col.actions-col { width: 108px; }
th.row-actions, td.row-actions { position: sticky; right: 0; background: var(--surface); box-shadow: -6px 0 8px -8px rgba(0,0,0,.25); text-align: center; white-space: nowrap; }
tr.click:hover td.row-actions { background: var(--surface-hover, #f7f7fa); }
td.row-actions .icon-btn { padding: 3px 5px; }
/* ---- Change History (audit) timeline ---- */
.modal.ah-modal { width: min(680px, 96vw); max-height: 88vh; display: flex; flex-direction: column; padding: 0; overflow: hidden; background: var(--surface, #fff); border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.32); }
.ah-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.ah-title { font-size: 19px; font-weight: 700; margin-top: 2px; }
.ah-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ah-filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.ah-fchip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 4px 13px; font-size: 12.5px; cursor: pointer; transition: all .12s; }
.ah-fchip:hover { border-color: var(--brand, #6366f1); color: var(--ink); }
.ah-fchip.active { background: var(--brand, #6366f1); border-color: var(--brand, #6366f1); color: #fff; }
.ah-feed { overflow-y: auto; padding: 6px 22px 14px; }
.ah-entry { display: flex; gap: 13px; padding: 15px 0; border-bottom: 1px solid var(--line-soft, #f0f0f3); }
.ah-entry:last-child { border-bottom: none; }
.ah-avatar { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; letter-spacing: .3px; }
.ah-body { flex: 1; min-width: 0; }
.ah-row1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ah-field { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 6px; background: #eef2ff; color: #4338ca; white-space: nowrap; }
.ah-field.k-price { background: #ecfdf5; color: #047857; }
.ah-field.k-note { background: #f3f4f6; color: #374151; }
.ah-field.k-status { background: #fef3c7; color: #92400e; }
.ah-field.k-spec { background: #e0f2fe; color: #075985; }
.ah-field.k-event { background: #f5f3ff; color: #6d28d9; }
.ah-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ah-change { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 6px; }
.ah-chip { font-size: 13px; padding: 3px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ah-chip.ah-old { color: var(--muted); text-decoration: line-through; background: #fafafa; }
.ah-chip.ah-new { font-weight: 600; border-color: #c7d2fe; background: #eef2ff; color: #3730a3; }
.ah-chip.ah-desc { white-space: normal; font-size: 12.5px; color: var(--ink); background: #fafafa; }
.ah-arrow { color: var(--muted); font-size: 13px; }
.ah-verb { font-size: 12px; color: var(--muted); }
.ah-who { font-size: 12.5px; color: var(--muted); }
.ah-foot { padding: 14px 22px; border-top: 1px solid var(--line); text-align: right; }
@media (prefers-color-scheme: dark) {
  .ah-field { background: #312e81; color: #c7d2fe; } .ah-field.k-price { background: #064e3b; color: #6ee7b7; }
  .ah-field.k-note { background: #374151; color: #e5e7eb; } .ah-field.k-status { background: #78350f; color: #fde68a; }
  .ah-field.k-spec { background: #075985; color: #bae6fd; } .ah-field.k-event { background: #4c1d95; color: #ddd6fe; }
  .ah-chip.ah-old { background: #1f2937; } .ah-chip.ah-new { background: #312e81; color: #c7d2fe; border-color: #4338ca; }
  .ah-chip.ah-desc { background: #1f2937; }
}
.icon-btn { background: none; border: none; cursor: pointer; font-size: 15px; padding: 4px 6px; border-radius: 6px; opacity: .7; }
.icon-btn:hover { opacity: 1; background: var(--surface-2, #f0f0f3); }

/* ---- Stock Receive form / detail ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head-actions { display: flex; gap: 8px; }
.breadcrumb { font-size: 13px; color: var(--muted); }
.breadcrumb a { color: var(--brand, #c2185b); text-decoration: none; }
.notice { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.form-card { margin-bottom: 16px; padding: 18px; }
.form-grid { display: grid; gap: 14px 22px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.form-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.form-label .req { color: #dc2626; }
.input.full { width: 100%; min-width: 0; box-sizing: border-box; }
.input-suffix { display: flex; align-items: center; gap: 6px; }
.input-suffix .suffix { color: var(--muted); font-size: 13px; }
.inline-link { display: inline-block; margin-top: 6px; font-size: 12.5px; color: var(--brand, #c2185b); text-decoration: none; }
.hint { font-size: 12px; color: var(--muted); }
.form-section-title { font-weight: 700; font-size: 13px; margin: 18px 0 10px; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.radio-row { display: flex; gap: 22px; align-items: center; height: 40px; }
.radio-opt { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-size: 14px; }
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.totals-row { display: flex; gap: 28px; justify-content: flex-end; padding: 14px 4px 2px; font-size: 14px; }
/* Stock Transfer create — inline item cards */
.xfer-item { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 12px 0; }
.xfer-head { display: flex; align-items: flex-end; gap: 12px; }
.xfer-pc { display: flex; align-items: center; gap: 14px; flex: 1; }
.xfer-pc-label { font-weight: 600; font-size: 14px; white-space: nowrap; }
.xfer-pc .cbx { flex: 1; }
.field-error { color: #dc2626; font-size: 12px; margin: 4px 0; }
.kv-grid.compact { grid-template-columns: 1fr 1fr; gap: 6px 24px; margin: 12px 0; }
.add-item-row { text-align: right; padding-top: 8px; }
.icon-btn.danger { color: #dc2626; }
/* Settings — logo upload */
.logo-upload { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview { display: flex; align-items: center; gap: 12px; }
.logo-preview img { max-width: 120px; max-height: 64px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.logo-placeholder { width: 44px; height: 44px; }
.logo-placeholder svg { width: 44px; height: 44px; display: block; }
.preview-box { display: flex; align-items: center; height: 40px; }
.money-preview { font-size: 16px; font-weight: 700; color: var(--brand, #c81e6e); }
.check-list { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 6px 0; }
.check-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; }
/* Stock Take — scan-to-count two columns */
.take-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.take-cols .form-card { margin: 0; }
.take-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line-soft, #f0f0f3); }
.take-pc { font-weight: 700; font-size: 13.5px; }
.take-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.empty-rows.all-counted { color: #16a34a; font-weight: 600; }
.hint.err { color: #dc2626; }
.hint.ok { color: #16a34a; }
.take-cols.three { grid-template-columns: 1fr 1fr 1fr; }
.take-sub.muted { opacity: .8; }
.hint.warn { color: #b45309; }
@media (max-width: 1100px) { .take-cols.three { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .take-cols { grid-template-columns: 1fr; } }

/* stock take — live session chrome */
.live-dot { color: #16a34a; font-size: 12px; font-weight: 700; margin-right: 10px; animation: bnpulse 1.6s ease-in-out infinite; }
@keyframes bnpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.take-progress { height: 8px; border-radius: 999px; background: #eef0f2; overflow: hidden; margin: 4px 2px 12px; }
.take-progress-fill { height: 100%; background: linear-gradient(90deg,#7c3aed,#a855f7); width: 0; transition: width .3s ease; }
.take-stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.take-stats.report { margin-top: 12px; }
.take-stat { flex: 1; min-width: 96px; background: var(--surface); border: 1px solid var(--line, #e6e6ea); border-radius: 12px; padding: 12px 14px; text-align: center; }
.take-stat-v { font-size: 22px; font-weight: 800; line-height: 1.1; }
.take-stat-l { font-size: 11.5px; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .03em; }
.take-stat.ok .take-stat-v { color: #15803d; } .take-stat.bad .take-stat-v { color: var(--danger); } .take-stat.warn .take-stat-v { color: #b45309; }
.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.btn.lg { padding: 10px 18px; font-size: 14px; }
.input.lg { padding: 11px 14px; font-size: 15px; }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.meta-l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.meta-v { font-size: 13.5px; margin-top: 2px; }
@media (max-width: 700px) { .meta-grid { grid-template-columns: 1fr; } }

/* ===== stock take — live session (scanner-first UI) ===== */
.st-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.st-topbar-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.st-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.st-eyebrow .live-dot { margin: 0; font-size: 10px; }
.st-title { font-size: 24px; font-weight: 800; margin-top: 2px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.st-verdict { font-size: 12px; font-weight: 700; }
.st-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.st-sound { white-space: nowrap; }
.st-presence { display: flex; align-items: center; gap: 4px; }
.st-avatar { width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; margin-left: -6px; border: 2px solid var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.st-avatar:first-child { margin-left: 0; }
.st-presence-lbl { font-size: 12px; color: var(--muted); margin-left: 8px; white-space: nowrap; }
.st-presence-none { font-size: 12px; color: var(--muted); }

/* scan hero */
.st-hero { background: linear-gradient(135deg, #faf7ff, #f3effc); border: 1px solid #e7ddfb; border-radius: 16px; padding: 18px; margin-bottom: 16px; }
.st-scan-wrap { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 2px solid var(--brand); border-radius: 12px; padding: 4px 14px; box-shadow: 0 4px 16px rgba(124,58,237,.12); }
.st-scan-wrap:focus-within { box-shadow: 0 0 0 4px rgba(124,58,237,.18); }
.st-scan-ico { letter-spacing: -2px; color: var(--brand); font-size: 18px; opacity: .7; user-select: none; }
.st-scan { flex: 1; border: 0; outline: 0; background: transparent; font-size: 22px; font-weight: 600; padding: 12px 0; color: var(--ink); }
.st-flash { margin-top: 14px; border-radius: 12px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); text-align: center; }
.st-flash-big { font-size: 22px; font-weight: 800; }
.st-flash-small { font-size: 13px; color: var(--muted); margin-top: 3px; }
.st-flash.idle { opacity: .8; }
.st-flash.ok { background: #e7f6ec; border-color: #b7e4c6; } .st-flash.ok .st-flash-big { color: #15803d; }
.st-flash.warn { background: #fef6e6; border-color: #f6dfa6; } .st-flash.warn .st-flash-big { color: #b45309; }
.st-flash.err { background: var(--danger-bg); border-color: #f4c0c0; } .st-flash.err .st-flash-big { color: var(--danger); }
.st-flash.pulse { animation: stpulse .4s ease; }
@keyframes stpulse { 0% { transform: scale(.98); } 40% { transform: scale(1.015); } 100% { transform: scale(1); } }

/* metrics: ring + tiles */
.st-metrics { display: flex; gap: 16px; align-items: stretch; margin-bottom: 16px; }
.st-ring { flex: 0 0 auto; width: 150px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; display: flex; align-items: center; justify-content: center; padding: 10px; }
.st-ring-svg { width: 128px; height: 128px; }
.st-ring-track { fill: none; stroke: #eef0f2; stroke-width: 12; }
.st-ring-fill { fill: none; stroke: url(#g); stroke: #7c3aed; stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.st-ring-big { font-size: 26px; font-weight: 800; fill: var(--ink); text-anchor: middle; }
.st-ring-small { font-size: 12px; fill: var(--muted); text-anchor: middle; }
.st-tiles { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.st-tiles.report { grid-template-columns: repeat(5, 1fr); flex: 1; }

/* lower: activity feed + tabbed lists */
.st-lower { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.st-feed-card, .st-lists-card { margin: 0; }
.st-feed { display: flex; flex-direction: column; gap: 2px; max-height: 460px; overflow-y: auto; }
.st-feed-item { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line-soft, #f0f0f3); }
.st-feed-dot { width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.st-feed-dot.ok { background: #e7f6ec; color: #15803d; } .st-feed-dot.warn { background: #fef6e6; color: #b45309; }
.st-feed-main { flex: 1; min-width: 0; }
.st-feed-pc { font-weight: 700; font-size: 13px; }
.st-feed-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-feed-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.st-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.st-tab { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.st-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.st-tab-n { font-size: 11px; font-weight: 700; background: #eef0f2; color: #4b5563; border-radius: 999px; padding: 1px 7px; }
.st-tab.active .st-tab-n { background: rgba(255,255,255,.25); color: #fff; }
.st-tab-n.bad { background: var(--danger-bg); color: var(--danger); } .st-tab-n.ok { background: #e7f6ec; color: #15803d; } .st-tab-n.warn { background: #fef3c7; color: #92600a; }
.st-list-tools { margin-bottom: 8px; }
.st-search { width: 100%; }
.st-list { max-height: 520px; overflow-y: auto; }
.take-item-main { min-width: 0; }
.take-badge { margin-left: 8px; font-size: 10px; vertical-align: middle; }

/* report head */
.st-report-head { display: flex; gap: 16px; align-items: stretch; margin-bottom: 16px; }
.st-donut-card { margin: 0; flex: 0 0 auto; width: 190px; display: flex; align-items: center; justify-content: center; }
.st-donut .st-ring-svg { width: 150px; height: 150px; }

@media (max-width: 1000px) {
  .st-metrics { flex-direction: column; } .st-ring { width: 100%; }
  .st-tiles, .st-tiles.report { grid-template-columns: repeat(2, 1fr); }
  .st-lower { grid-template-columns: 1fr; } .st-report-head { flex-direction: column; } .st-donut-card { width: 100%; }
}
.modal-scroll { overflow-y: auto; padding: 4px 2px; }
.empty-rows { color: var(--muted); font-size: 13px; padding: 20px 4px; }
.img-upload { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.img-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.img-chip { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface-2, #f5f5f7); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; }
.img-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 860px) { .form-grid.two, .form-grid.three { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.btn { height: 34px; padding: 0 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--ink); }
.btn:hover { background: #f3f4f6; }
.btn[disabled] { opacity: .4; cursor: default; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-ink); }

/* pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; background: #eef0f2; color: #4b5563; }
.pill.ok { background: #e7f6ec; color: #15803d; } .pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.warn { background: #fef3c7; color: #92600a; } .pill.muted { background: #eef0f2; color: #6b7280; }
.pill.info { background: #e0edff; color: #1d4ed8; }
tr.row-muted td { opacity: .5; }
tr.row-muted .pill { opacity: 1; }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }
.sold-banner { background: #e7f6ec; border: 1px solid #b7e4c6; border-radius: 12px; padding: 14px 16px; margin: 4px 0 14px; }
.sold-banner .kv-grid { gap: 10px 18px; } .sold-banner .kv-v strong { color: #15803d; font-size: 15px; }
.sold-banner.restricted { background: #f4f5f7; border-color: #e3e5ea; }
.flow-arrow { color: #4b5162; font-weight: 500; }
.st-feed-pc .flow-arrow { margin-left: 10px; font-weight: 400; color: #6b7280; }
.check-cell { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.check-cell input, .flag-row input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); }
.flag-row { display: flex; gap: 28px; flex-wrap: wrap; }
.flag-row .check { font-size: 14px; }
.settle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.settle-v { font-size: 20px; font-weight: 800; margin-top: 3px; }
.settle-v.neg { color: var(--danger); } .settle-v.pos { color: #15803d; }
td .neg, .kv-v .neg, strong.neg { color: var(--danger); }
@media (max-width: 700px) { .settle-grid { grid-template-columns: 1fr; } }

/* clickable rows + pager */
tr.click { cursor: pointer; } tr.click:hover td { background: #faf9fe; }
.table.small td, .table.small th { padding: 6px 8px; font-size: 12.5px; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding-top: 14px; }
.pager-info { color: var(--muted); font-size: 12.5px; margin-right: auto; }

/* modal / drawer */
.modal-overlay { position: fixed; inset: 0; background: rgba(16,20,26,.45); display: flex; justify-content: flex-end; z-index: 50; }
.modal-overlay.center { justify-content: center; align-items: center; }
.modal.arrange { width: min(460px, 94vw); max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 14px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.arrange-list { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.arrange-row { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); cursor: grab; font-size: 13.5px; }
.arrange-row:last-child { border-bottom: none; }
.arrange-row:active { cursor: grabbing; }
.arrange-row:hover { background: #faf9fe; }
.arrange-row.dragging { opacity: .4; }
.arrange-row.drop-target { box-shadow: inset 0 3px 0 var(--brand); background: #f3eefe; }
.drag-handle { color: #b4b7bd; font-size: 15px; letter-spacing: -3px; cursor: grab; }
.arrange-label { flex: 1; }
.arrange-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.hidden { display: none; }
.drawer-eyebrow { font-size: 11px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.drawer-foot { position: sticky; bottom: 0; background: var(--surface); display: flex; gap: 10px; padding: 14px 0 6px; margin-top: 20px; border-top: 1px solid var(--line); }
.drawer-foot .btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 40px; }
.edit-modal { width: min(640px, 94vw); }
.edit-body { display: flex; flex-direction: column; }
.edit-lbl { font-size: 12px; color: var(--muted); margin-top: 12px; margin-bottom: 4px; }
.input.full { width: 100%; height: 40px; }
.edit-prices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.edit-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.edit-field input { width: 112px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.edit-err { color: var(--danger); font-size: 12.5px; margin-top: 10px; min-height: 1em; }
.drawer { width: min(560px, 94vw); background: var(--surface); height: 100%; overflow-y: auto; padding: 22px 24px; box-shadow: -4px 0 24px rgba(0,0,0,.12); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.drawer-title { font-size: 18px; font-weight: 650; }
.drawer-sub { color: var(--muted); font-size: 13px; }
.btn-x { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin-bottom: 20px; }
.kv { display: flex; justify-content: space-between; border-bottom: 1px solid #f0f1f3; padding: 6px 0; font-size: 13px; }
.kv-k { color: var(--muted); } .kv-v { font-weight: 500; }
.drawer-section { margin-top: 18px; }
.drawer-section-title { font-weight: 600; font-size: 13.5px; margin-bottom: 10px; }
.price-edit { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.price-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.price-field input { width: 100px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; }
.ta { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13.5px; resize: vertical; }
.readonly-tag { margin-left: auto; font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; background: #f3f4f6; }
.muted-lbl { font-size: 12px; color: var(--muted); }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 720px; }
.feed-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.card-title-inline { font-weight: 600; font-size: 14px; }
.feed-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.feed-more { color: var(--muted); font-size: 12px; margin-top: 10px; }
.date-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-range .input { height: 34px; }
.kpi-row.tight { grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 4px 0 18px; }
.kpi-row.tight .kpi { padding: 14px 16px; }
.kpi-row.tight .kpi-value { font-size: 22px; }
.feed-head.wrap { flex-wrap: wrap; gap: 12px; }
/* salesman summary tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 18px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.tile-label { color: var(--muted); font-size: 12px; }
.tile-value { font-size: 18px; font-weight: 600; margin-top: 4px; }
.tile-value.green, td.num-green { color: #15803d; }
td.num-green { font-weight: 500; }
/* performance detail modal */
/* these need .modal.arrange specificity to override the base .modal.arrange width */
.modal.arrange.detail-modal { width: min(1240px, 97vw); max-height: 92vh; }
.modal.arrange.unit-modal { width: min(820px, 95vw); max-height: 92vh; }
.unit-modal .kv-grid { grid-template-columns: 1fr 1fr; }
.detail-modal .table.small td, .detail-modal .table.small th { padding: 9px 12px; font-size: 13px; white-space: nowrap; }
.detail-modal .drawer-section-title { font-size: 15px; }
.detail-actions { display: flex; gap: 16px; }
.btn-link { border: none; background: none; color: var(--brand-ink); font-size: 13px; font-weight: 500; cursor: pointer; padding: 2px 0; }
.btn-link:hover { text-decoration: underline; }
@media (max-width: 1000px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.seg { display: inline-flex; background: #eef0f2; border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 16px; }
.seg-btn { display: inline-flex; align-items: center; gap: 7px; border: none; background: transparent; padding: 7px 16px; border-radius: 8px; font-size: 13.5px; cursor: pointer; color: var(--muted); }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow); }
.seg-count { font-size: 11.5px; background: rgba(0,0,0,.06); border-radius: 999px; padding: 1px 8px; color: inherit; }
.seg-btn.active .seg-count { background: var(--brand); color: #fff; }
.btn.ghost { border-style: dashed; color: var(--muted); }
.input.grow { flex: 1; min-width: 260px; }
.filter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.filter-grid .input { min-width: 0; width: 100%; }
.table-scroll { overflow-x: auto; }
.cell-remark { display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; color: var(--muted); font-size: 12.5px; }
.cell-price { width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; background: var(--surface); text-align: right; }
.cell-price:hover { border-color: var(--border-strong, #c9ccd1); }
.cell-price:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(124,58,237,.15); outline: none; }
.cell-price.saving { border-color: var(--brand); }
.cell-price.save-ok { border-color: var(--ok); background: #f0fdf4; }
.cell-price.save-err { border-color: var(--danger); background: var(--danger-bg); }
.cell-text { width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 12.5px; background: var(--surface); }
.cell-text:hover { border-color: #c9ccd1; }
.cell-text:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(124,58,237,.15); outline: none; }
.cell-text.saving { border-color: var(--brand); }
.cell-text.save-ok { border-color: var(--ok); background: #f0fdf4; }
.cell-text.save-err { border-color: var(--danger); background: var(--danger-bg); }
/* kill number-input spinner arrows everywhere */
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* sortable headers */
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--ink); }
th.sortable.active { color: var(--brand); }
.th-col { position: relative; user-select: none; white-space: nowrap; cursor: grab; padding-right: 16px; }
.th-col:active { cursor: grabbing; }
.th-col.dragging { opacity: .4; }
.th-col.drop-target { box-shadow: inset 3px 0 0 var(--brand); background: #f3eefe; }
/* column resize */
table.fixed { table-layout: fixed; }
table.fixed th, table.fixed td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-resizer { position: absolute; top: 0; right: 0; width: 10px; height: 100%; cursor: col-resize; z-index: 3; }
.col-resizer::after { content: ""; position: absolute; right: 3px; top: 16%; height: 68%; width: 2px; border-radius: 2px; background: transparent; }
.col-resizer:hover::after { background: var(--brand); }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing .col-resizer::after { background: var(--brand); }

/* multi-select filter */
.ms { position: relative; }
.ms-btn { display: flex; align-items: center; gap: 6px; width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13.5px; cursor: pointer; color: var(--ink); text-align: left; }
.ms-btn:hover { border-color: #c9ccd1; }
.ms-btn.has { border-color: var(--brand); color: var(--brand-ink); }
.ms-btn > span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-badge { min-width: 18px; text-align: center; font-size: 11px; background: var(--brand); color: #fff; border-radius: 999px; padding: 1px 6px; }
.ms-badge:empty { display: none; }
.ms-caret { color: var(--muted); font-size: 10px; }
.ms-panel { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(16,24,40,.14); padding: 8px; }
.ms-panel.hidden { display: none; }
.ms-search { width: 100%; height: 32px; margin-bottom: 6px; }
.ms-list { max-height: 240px; overflow-y: auto; }
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.ms-opt:hover { background: #f5f5f7; }
.ms-clear { width: 100%; margin-top: 6px; border: none; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 6px; border-top: 1px solid var(--line); }
.ms-clear:hover { color: var(--danger); }
.cols-panel { left: auto; right: 0; }
.cols-panel .ms-list { max-height: 320px; }
@media (max-width: 1100px) { .filter-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .filter-grid { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .kpi-row, .grid-2 { grid-template-columns: 1fr; }
  input.input { min-width: 160px; }
}

/* ---- Roles & Access page ---- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: none; padding: 8px 16px; cursor: pointer; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.check-grid { display: grid; gap: 9px 18px; padding: 6px 0; }
.check-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check-grid .check { color: var(--ink); font-size: 13px; cursor: pointer; align-items: flex-start; }
.check-grid .check input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; margin-top: 1px; }
.check.disabled { opacity: .5; cursor: default; }
.muted-note { color: var(--muted); font-size: 12.5px; margin: 6px 0 2px; }
tr.dimmed { opacity: .55; }
.link { color: var(--brand); font-size: 13px; }
.drawer.wide { width: min(720px, 96vw); }
.input.compact, .btn.compact { padding: 4px 10px; font-size: 13px; height: auto; min-width: 0; }
.btn.danger { color: #dc2626; border-color: #f0c8c8; }
.btn.danger:hover { background: var(--danger-bg, #fdecec); }
@media (max-width: 700px) { .check-grid.cols-3, .check-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Deposit outcome chooser (reservation cancel) */
.deposit-choices { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.deposit-choice { text-align: left; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s; }
.deposit-choice:hover { border-color: var(--brand); }
.deposit-choice.active { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.deposit-choice .dc-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.deposit-choice .dc-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---- Login gate ---- */
.login-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a1130, #241a3a 55%, #10131a); padding: 20px; }
.login-logo { max-height: 52px; max-width: 200px; object-fit: contain; display: block; }
.brand-logo { height: 30px; width: 30px; object-fit: contain; border-radius: 8px; background: #fff; }
.login-card { width: min(400px, 94vw); background: var(--surface, #fff); border-radius: 16px; padding: 32px 30px; box-shadow: 0 24px 70px rgba(0,0,0,.4); }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; color: var(--ink); }
.login-brand .brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 22px; }
.login-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
.login-overlay .input.full { width: 100%; box-sizing: border-box; }
.login-err { color: var(--danger, #dc2626); font-size: 13px; min-height: 18px; margin: 10px 0 4px; }
.btn.full { width: 100%; display: flex; align-items: center; justify-content: center; height: 42px; font-size: 15px; margin-top: 6px; }

/* signed-in user chip in the topbar */
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.user-chip .user-name { font-weight: 650; font-size: 13.5px; color: var(--ink); }
.user-chip .user-role { font-size: 11.5px; color: var(--muted); }

/* Setup page — how-to guide */
.setup-guide { display: flex; flex-direction: column; gap: 16px; }
.setup-step { display: flex; gap: 12px; align-items: flex-start; }
.setup-step-n { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.setup-step-t { font-weight: 600; font-size: 14px; color: var(--ink); }
.setup-step-b { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
