/* CRM interface styles. Brand colour comes from Settings via --brand (set at runtime). */
:root {
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: color-mix(in srgb, var(--brand) 12%, transparent);
  --bg: #f1f4f2;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --ink: #17211c;
  --muted: #5c6a63;
  --faint: #8a968f;
  --line: #dbe2de;
  --line-strong: #c4cec8;
  --side-bg: #15201b;
  --side-ink: #c9d3ce;
  --side-muted: #7d8c84;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #a15c07;
  --warn-soft: #fdf3e1;
  --ok: #08754a;
  --ok-soft: #e3f4ec;
  --info: #355a8a;
  --info-soft: #e8eef7;
  --grey-soft: #eceeed;
  --radius: 8px;
  --radius-lg: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Bengali", "Helvetica Neue", Arial, sans-serif;
  --shadow-pop: 0 12px 32px rgba(15, 25, 20, 0.18), 0 2px 6px rgba(15, 25, 20, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1613;
    --surface: #161f1b;
    --surface-2: #1b2521;
    --ink: #e4ebe7;
    --muted: #9aa8a1;
    --faint: #6f7d76;
    --line: #2a3631;
    --line-strong: #3a4842;
    --side-bg: #0b110e;
    --danger-soft: #3a1b17;
    --warn-soft: #36290f;
    --ok-soft: #12301f;
    --info-soft: #1a2638;
    --grey-soft: #242e2a;
    --brand-soft: color-mix(in srgb, var(--brand) 22%, transparent);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1613; --surface: #161f1b; --surface-2: #1b2521; --ink: #e4ebe7; --muted: #9aa8a1; --faint: #6f7d76;
  --line: #2a3631; --line-strong: #3a4842; --side-bg: #0b110e; --danger-soft: #3a1b17; --warn-soft: #36290f;
  --ok-soft: #12301f; --info-soft: #1a2638; --grey-soft: #242e2a;
  --brand-soft: color-mix(in srgb, var(--brand) 22%, transparent);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--side-bg);
  color: var(--side-ink);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brandmark { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brandmark .logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none;
}
.brandmark .name { color: #fff; font-weight: 650; font-size: 15px; line-height: 1.2; }
.brandmark .sub { color: var(--side-muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--side-ink); font-weight: 500; position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255, 255, 255, 0.09); color: #fff; }
.nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav .count { margin-left: auto; font-size: 11.5px; background: var(--brand); color: var(--brand-ink); border-radius: 10px; padding: 0 7px; font-weight: 600; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 12px 8px 0; }
.me { display: flex; align-items: center; gap: 10px; }
.me .who { min-width: 0; }
.me .who b { display: block; color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who span { color: var(--side-muted); font-size: 12px; text-transform: capitalize; }
.me button { margin-left: auto; }
.side .btn-ghost { color: var(--side-muted); }
.side .btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar .menu-btn { display: none; }
.content { padding: 24px 28px 48px; width: 100%; max-width: 1440px; }

/* global search */
.gsearch { position: relative; flex: 1; max-width: 460px; }
.gsearch input { padding-left: 34px; background: var(--surface-2); }
.gsearch svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.gresults {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 6px; max-height: 420px; overflow: auto; z-index: 50;
}
.gresults h4 { margin: 8px 8px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.gresults a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 8px; border-radius: 6px; color: var(--ink); }
.gresults a:hover, .gresults a.focus { background: var(--surface-2); text-decoration: none; }
.gresults .none { padding: 10px 8px; color: var(--muted); }

/* ------------------------------------------------------------ page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; display: inline-block; }

/* ------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 13px;
  border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, black); }
.btn-danger { color: var(--danger); }
.btn-danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 7px;
  padding: 7px 10px; width: 100%; min-height: 34px;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--brand); padding: 0; }
input[type="color"] { padding: 2px; width: 52px; height: 34px; }
select { padding-right: 28px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.field-error { color: var(--danger); font-size: 12px; font-weight: 500; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 9px 12px; border-radius: 7px; margin-bottom: 14px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type="search"] { width: 260px; }
.filters select { width: auto; min-width: 140px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; }
.seg a, .seg button {
  padding: 6px 12px; color: var(--muted); font-weight: 550; border: 0; background: var(--surface); font: inherit; cursor: pointer;
}
.seg > * + * { border-left: 1px solid var(--line-strong) !important; }
.seg .on { background: var(--brand-soft); color: var(--ink); }
.seg a:hover { text-decoration: none; color: var(--ink); }

/* ------------------------------------------------------------ panels & tables */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 16px; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
table.data th button { all: unset; cursor: pointer; }
table.data th button:hover { color: var(--ink); }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.link { cursor: pointer; }
table.data tbody tr.link:hover { background: var(--surface-2); }
table.data td.right, table.data th.right { text-align: right; }
table.data .check { width: 36px; padding-right: 0; }
.cell-main { font-weight: 550; color: var(--ink); }
.cell-sub { color: var(--muted); font-size: 12.5px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; color: var(--muted); }
.bulkbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 10px; border-radius: var(--radius);
  background: var(--brand-soft); flex-wrap: wrap;
}
.bulkbar select { width: auto; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 15px; }
.empty .btn { margin-top: 14px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 20px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.st-lead { background: var(--info-soft); color: var(--info); }
.st-prospect { background: var(--warn-soft); color: var(--warn); }
.st-customer { background: var(--ok-soft); color: var(--ok); }
.st-inactive { background: var(--grey-soft); color: var(--muted); }
.k-open { background: var(--brand-soft); color: var(--brand); }
.k-won { background: var(--ok-soft); color: var(--ok); }
.k-lost { background: var(--danger-soft); color: var(--danger); }
.p-high { color: var(--danger); background: var(--danger-soft); }
.p-normal { color: var(--muted); background: var(--grey-soft); }
.p-low { color: var(--faint); background: transparent; border: 1px solid var(--line); }
.tag { display: inline-block; font-size: 12px; padding: 0 7px; border-radius: 5px; background: var(--grey-soft); color: var(--muted); margin: 1px 3px 1px 0; }
.role { text-transform: capitalize; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 650; color: #fff; background: #5b6f66;
}
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }

/* ------------------------------------------------------------ dashboard */
.dash { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.dash .wide { grid-column: 1 / -1; }
.today-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.today-head h1 { font-size: 24px; }
.statline {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); margin: 18px 0;
}
.statline > * { padding: 14px 18px; color: inherit; }
.statline > * + * { border-left: 1px solid var(--line); }
.statline > a:hover { background: var(--surface-2); text-decoration: none; }
.statline .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.statline .l { color: var(--muted); font-size: 13px; }
.statline .d { color: var(--faint); font-size: 12px; margin-top: 2px; }

.tasklist { list-style: none; margin: 0; padding: 0; }
.tasklist li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.tasklist li:last-child { border-bottom: 0; }
.tasklist .t-main { flex: 1; min-width: 0; }
.tasklist .t-title { font-weight: 550; }
.tasklist .done .t-title { text-decoration: line-through; color: var(--faint); }
.tasklist .t-meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.tasklist input[type="checkbox"] { margin-top: 3px; }
.due-over { color: var(--danger); font-weight: 600; }
.due-today { color: var(--warn); font-weight: 600; }

.funnel { display: flex; flex-direction: column; gap: 12px; }
.funnel .row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; }
.funnel .bar { height: 10px; background: var(--grey-soft); border-radius: 6px; overflow: hidden; }
.funnel .bar span { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.funnel .val { text-align: right; font-variant-numeric: tabular-nums; min-width: 96px; }

.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; height: 170px; padding-top: 10px; }
.months .m { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.months .col { width: 100%; max-width: 46px; background: var(--brand); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.months .col.zero { background: var(--line); }
.months .lbl { font-size: 12px; color: var(--muted); }
.months .amt { font-size: 11.5px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .ic { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; flex: none; color: var(--muted); }
.feed .ic svg { width: 14px; height: 14px; }
.feed .body { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.feed .meta { color: var(--faint); font-size: 12px; margin-top: 2px; }
.feed .sys .body { color: var(--muted); }

/* ------------------------------------------------------------ record page */
.record { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.record-card .who { display: flex; gap: 14px; align-items: center; padding: 18px 16px; border-bottom: 1px solid var(--line); }
.record-card .who h1 { font-size: 19px; }
dl.props { margin: 0; padding: 8px 16px 14px; display: grid; grid-template-columns: 110px 1fr; gap: 9px 12px; }
dl.props dt { color: var(--muted); font-size: 13px; }
dl.props dd { margin: 0; overflow-wrap: anywhere; }
.record-card .notes { padding: 12px 16px 16px; border-top: 1px solid var(--line); white-space: pre-wrap; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.composer { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.composer .types { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.composer .types button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 20px; padding: 3px 11px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted); }
.composer .types button.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.composer textarea { min-height: 64px; }
.composer .row { display: flex; justify-content: flex-end; margin-top: 8px; }

.minilist { list-style: none; margin: 0; padding: 0; }
.minilist li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.minilist li:last-child { border-bottom: 0; }

/* stage stepper on deal page */
.stepper { display: flex; gap: 4px; flex-wrap: wrap; }
.stepper button {
  flex: 1; min-width: 90px; border: 0; padding: 8px 10px; font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
  background: var(--grey-soft); color: var(--muted); border-radius: 6px;
}
.stepper button.past { background: var(--brand-soft); color: var(--ink); }
.stepper button.cur { background: var(--brand); color: var(--brand-ink); }
.stepper button.won.cur { background: var(--ok); color: #fff; }
.stepper button.lost.cur { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------ pipeline board */
.board-summary { display: flex; gap: 24px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
.board-summary b { color: var(--ink); font-variant-numeric: tabular-nums; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 60vh; }
.lane { flex: 1 0 252px; max-width: 320px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 200px); }
.lane-head { padding: 12px 12px 10px; border-bottom: 1px solid var(--line); }
.lane-head .t { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lane-head .t b { font-weight: 650; }
.lane-head .t span { color: var(--muted); font-size: 12.5px; }
.lane-head .amt { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: -0.01em; }
/* the share bar: this column's value relative to the biggest column */
.lane-head .share { height: 4px; background: var(--line); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.lane-head .share span { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width 0.3s ease; }
.lane.won .share span { background: var(--ok); }
.lane.lost .share span { background: var(--danger); }
.lane-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 80px; flex: 1; }
.lane.over .lane-body { background: var(--brand-soft); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.dcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 11px; cursor: grab;
  display: block; color: var(--ink);
}
.dcard:hover { border-color: var(--line-strong); text-decoration: none; }
.dcard.dragging { opacity: 0.45; }
.dcard .dt { font-weight: 600; line-height: 1.3; }
.dcard .dv { font-variant-numeric: tabular-nums; margin-top: 4px; font-weight: 550; }
.dcard .dm { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; }
.dcard .late { color: var(--danger); }
.lane-add { margin: 0 8px 8px; }

/* ------------------------------------------------------------ settings */
.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 76px; }
.subnav a { padding: 7px 10px; border-radius: 7px; color: var(--muted); font-weight: 550; }
.subnav a.on { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.subnav a:hover { text-decoration: none; color: var(--ink); }
.settings .panel + .panel { margin-top: 18px; }
.stage-row { display: grid; grid-template-columns: 24px 1fr 110px 110px auto; gap: 10px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.stage-row:last-child { border-bottom: 0; }
.stage-row .grip { color: var(--faint); cursor: grab; }
.stage-row.dragging { opacity: 0.4; }

/* ------------------------------------------------------------ modal, toast */
.overlay { position: fixed; inset: 0; background: rgba(10, 18, 14, 0.45); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); width: min(640px, 100%);
  max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
.modal.narrow { width: min(440px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-pop); font-weight: 500; max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------ auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--side-bg); color: var(--side-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .big { font-size: 34px; font-weight: 650; color: #fff; line-height: 1.15; letter-spacing: -0.02em; max-width: 14ch; }
.auth-side .lines { display: flex; flex-direction: column; gap: 10px; margin-top: 28px; max-width: 34ch; }
.auth-side .lines div { display: flex; gap: 10px; }
.auth-side .lines span { color: var(--brand); filter: brightness(1.5); }
.auth-main { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth-form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.auth-form h1 { font-size: 24px; margin-bottom: 4px; }
.auth-form .btn { height: 40px; }

.loading { padding: 60px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .dash { grid-template-columns: 1fr; }
  .record { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; z-index: 90; transform: translateX(-100%); transition: transform 0.2s ease; }
  .side.open { transform: none; box-shadow: var(--shadow-pop); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 40px; }
  .statline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statline > *:nth-child(odd) { border-left: 0; }
  .statline > *:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .settings { grid-template-columns: 1fr; }
  .subnav { position: static; flex-direction: row; flex-wrap: wrap; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .filters input[type="search"] { width: 100%; }
  .stage-row { grid-template-columns: 20px 1fr 80px auto; }
  .stage-row .kind { display: none; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .side, .topbar, .actions, .filters { display: none !important; }
  .shell { display: block; }
}

/* ============================================================ clothing shop additions */
/* order / payment states */
.os-pending { background: var(--warn-soft); color: var(--warn); }
.os-confirmed { background: var(--info-soft); color: var(--info); }
.os-packed { background: color-mix(in srgb, #7c4dbd 14%, transparent); color: #6b3fb0; }
.os-shipped { background: var(--brand-soft); color: var(--brand); }
.os-delivered { background: var(--ok-soft); color: var(--ok); }
.os-cancelled, .os-returned { background: var(--grey-soft); color: var(--muted); }
.ps-unpaid { color: var(--danger); background: var(--danger-soft); }
.ps-partial { color: var(--warn); background: var(--warn-soft); }
.ps-paid { color: var(--ok); background: var(--ok-soft); }
.ps-refunded { color: var(--muted); background: var(--grey-soft); }
.chan { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.chan::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--faint); vertical-align: 1px; }
.ch-whatsapp::before { background: #1fa855; }
.ch-messenger::before { background: #2f6fed; }
.ch-instagram::before { background: #c4378f; }
.ch-website::before { background: var(--brand); }

/* status tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); }
.tabs .n { font-size: 12px; color: var(--faint); margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ inbox */
.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; height: calc(100vh - 61px); margin: -24px -28px -48px; background: var(--surface); }
.inbox > * { min-height: 0; }
.ib-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.ib-list .ib-filters { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.ib-list .ib-filters .row { display: flex; gap: 6px; }
.ib-list .ib-filters select { flex: 1; min-width: 0; font-size: 13px; padding: 5px 22px 5px 8px; min-height: 30px; }
.ib-back { display: none !important; }
.ib-items { overflow-y: auto; flex: 1; }
.ib-item { display: flex; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); color: var(--ink); cursor: pointer; position: relative; }
.ib-item:hover { background: var(--surface-2); text-decoration: none; }
.ib-item.on { background: var(--brand-soft); }
.ib-item .mid { flex: 1; min-width: 0; }
.ib-item .top { display: flex; justify-content: space-between; gap: 8px; }
.ib-item .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-item .tm { color: var(--faint); font-size: 12px; white-space: nowrap; }
.ib-item .pv { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-item.unread .nm, .ib-item.unread .pv { color: var(--ink); font-weight: 650; }
.ib-item .meta { display: flex; gap: 8px; align-items: center; margin-top: 3px; font-size: 12px; color: var(--faint); }
.ib-item .dot { min-width: 20px; height: 20px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; }
.ib-item .avatar { position: relative; }
.ib-item .avatar i { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); }
.ib-item .avatar i.whatsapp { background: #1fa855; }
.ib-item .avatar i.messenger { background: #2f6fed; }

.ib-thread { display: flex; flex-direction: column; min-width: 0; }
.ib-head { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.ib-head .who { flex: 1; min-width: 0; }
.ib-head .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-head .who span { color: var(--muted); font-size: 12.5px; }
.ib-head select { width: auto; }
.ib-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.ib-day { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 1px 10px; border-radius: 10px; margin: 8px 0; }
.bubble { max-width: min(560px, 78%); padding: 8px 11px 6px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; position: relative; }
.bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: color-mix(in srgb, var(--brand) 14%, var(--surface)); border-bottom-right-radius: 4px; }
.bubble.failed { border: 1px solid var(--danger); }
.bubble .bt { font-size: 11px; color: var(--faint); text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; }
.bubble .bt .err { color: var(--danger); }
.bubble img { display: block; max-width: 260px; max-height: 320px; border-radius: 8px; margin-bottom: 4px; cursor: zoom-in; }
.bubble .tpl { font-size: 12px; color: var(--muted); }
.ib-compose { border-top: 1px solid var(--line); padding: 10px 12px; background: var(--surface); }
.ib-compose .tools { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.ib-compose .row { display: flex; gap: 8px; align-items: flex-end; }
.ib-compose textarea { min-height: 42px; max-height: 160px; resize: none; }
.ib-window { font-size: 12.5px; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin-bottom: 8px; }
.ib-empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 24px; }

.ib-side { border-left: 1px solid var(--line); overflow-y: auto; }
.ib-side section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ib-side h3 { margin-bottom: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.ib-side dl.props { padding: 0; grid-template-columns: 80px 1fr; }
.popover { position: absolute; bottom: calc(100% + 6px); left: 0; width: min(380px, 90vw); max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); z-index: 30; padding: 6px; }
.popover button { all: unset; display: block; width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.popover button:hover, .popover button:focus-visible { background: var(--surface-2); }
.popover b { display: block; font-size: 13px; }
.popover span { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rel { position: relative; }

/* ------------------------------------------------------------ products */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; color: var(--ink); display: flex; flex-direction: column; }
.pcard:hover { border-color: var(--line-strong); text-decoration: none; }
.pcard .ph { aspect-ratio: 4 / 5; background: var(--surface-2); display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.pcard .ph img { width: 100%; height: 100%; object-fit: cover; }
.pcard .ph svg { width: 40px; height: 40px; }
.pcard .pb { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.pcard .pn { font-weight: 600; line-height: 1.3; }
.pcard .pp { font-variant-numeric: tabular-nums; }
.pcard .pp s { color: var(--faint); font-size: 12.5px; margin-left: 6px; }
.pcard .ps { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.stock-low { color: var(--warn); font-weight: 600; }
.stock-out { color: var(--danger); font-weight: 600; }
.badge-inactive { position: absolute; }

.vtable { width: 100%; border-collapse: collapse; }
.vtable th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 6px 6px; }
.vtable td { padding: 4px 6px; }
.vtable input { min-height: 32px; padding: 5px 8px; }
.vtable td.num input { text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 16px; padding: 3px 11px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.photo-box { width: 160px; aspect-ratio: 4 / 5; border: 1px dashed var(--line-strong); border-radius: var(--radius); display: grid; place-items: center; overflow: hidden; background: var(--surface-2); color: var(--muted); text-align: center; font-size: 12.5px; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.stockgrid { border-collapse: collapse; }
.stockgrid th, .stockgrid td { border: 1px solid var(--line); padding: 6px 10px; text-align: center; font-variant-numeric: tabular-nums; }
.stockgrid th { background: var(--surface-2); font-weight: 600; font-size: 12.5px; color: var(--muted); }
.stockgrid td button { all: unset; cursor: pointer; padding: 2px 8px; border-radius: 5px; font-weight: 600; }
.stockgrid td button:hover { background: var(--brand-soft); }

/* ------------------------------------------------------------ orders */
.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
.lines td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lines td.right, .lines th.right { text-align: right; }
.lines input { min-height: 30px; padding: 4px 8px; }
.lines .qty { width: 64px; text-align: right; }
.lines .price { width: 100px; text-align: right; }
.sums { margin-left: auto; width: min(320px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding-top: 10px; font-variant-numeric: tabular-nums; }
.sums .grand { font-weight: 700; font-size: 16px; border-top: 1px solid var(--line); padding-top: 8px; }
.sums input { width: 110px; text-align: right; min-height: 30px; padding: 4px 8px; }
.flow { display: flex; gap: 4px; flex-wrap: wrap; }
.flow button { flex: 1; min-width: 92px; border: 0; border-radius: 6px; padding: 8px 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--grey-soft); color: var(--muted); }
.flow button.done { background: var(--brand-soft); color: var(--ink); }
.flow button.cur { background: var(--brand); color: var(--brand-ink); }
.flow button:disabled { cursor: default; }
.big-total { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.addr { white-space: pre-wrap; }
.picker-results { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 6px; }
.picker-results button { all: unset; box-sizing: border-box; width: 100%; display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.picker-results button:last-child { border-bottom: 0; }
.picker-results button:hover, .picker-results button:focus-visible { background: var(--surface-2); }
.picker-results button[disabled] { opacity: 0.5; cursor: not-allowed; }
.modal.wide { width: min(880px, 100%); }

/* ------------------------------------------------------------ dashboard additions */
.statline.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.todo-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.todo-strip a { padding: 14px 16px; color: var(--ink); border-right: 1px solid var(--line); }
.todo-strip a:last-child { border-right: 0; }
.todo-strip a:hover { background: var(--surface-2); text-decoration: none; }
.todo-strip .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.todo-strip .l { color: var(--muted); font-size: 13px; }
.days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 5px; align-items: end; height: 130px; }
.days .d { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.days .col { width: 100%; background: var(--brand); border-radius: 3px 3px 1px 1px; min-height: 2px; }
.days .col.zero { background: var(--line); }
.days .lbl { font-size: 10.5px; color: var(--faint); }

/* ------------------------------------------------------------ invoice (print) */
.invoice { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 40px 44px; border: 1px solid var(--line); border-radius: 6px; }
.invoice h1 { font-size: 22px; }
.invoice .ihead { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid #111; padding-bottom: 16px; margin-bottom: 18px; }
.invoice .ihead .right { text-align: right; }
.invoice .muted { color: #555; }
.invoice table { width: 100%; border-collapse: collapse; margin: 18px 0 8px; }
.invoice th { text-align: left; border-bottom: 1px solid #111; padding: 6px 4px; font-size: 12.5px; }
.invoice td { border-bottom: 1px solid #ddd; padding: 7px 4px; }
.invoice .r { text-align: right; }
.invoice .sums { color: #111; }
.invoice .foot { margin-top: 28px; border-top: 1px solid #ddd; padding-top: 12px; font-size: 13px; color: #444; }
.invoice .stamp { display: inline-block; border: 2px solid currentColor; padding: 2px 10px; font-weight: 700; border-radius: 4px; transform: rotate(-4deg); }
.invoice .stamp.paid { color: #08754a; }
.invoice .stamp.unpaid { color: #b42318; }
@media print {
  body { background: #fff; }
  .main { display: block; }
  .content { padding: 0; max-width: none; }
  .no-print, .page-head, .toasts { display: none !important; }
  .invoice { border: 0; padding: 0; max-width: none; }
  @page { margin: 14mm; }
}

@media (max-width: 1200px) {
  .inbox { grid-template-columns: 280px minmax(0, 1fr); }
  .ib-side { display: none; }
  .ib-side.show { display: block; position: fixed; right: 0; top: 61px; bottom: 0; width: 320px; background: var(--surface); z-index: 40; box-shadow: var(--shadow-pop); }
}
@media (max-width: 860px) {
  .inbox { grid-template-columns: 1fr; margin: -18px -16px -40px; height: calc(100vh - 57px); }
  .inbox.has-thread .ib-list { display: none; }
  .ib-back { display: inline-flex !important; }
  .inbox:not(.has-thread) .ib-thread { display: none; }
  .statline.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .todo-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .todo-strip a:nth-child(2) { border-right: 0; }
  .todo-strip a:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .invoice { padding: 20px; }
  .lines .hide-sm { display: none; }
}

/* ============================================================ AI assistant */
.bubble.out.ai { background: color-mix(in srgb, #6d4bd8 11%, var(--surface)); border: 1px solid color-mix(in srgb, #6d4bd8 22%, transparent); }
.ai-label { color: #5b3cc4; font-weight: 600; }
.needs-tag { white-space: nowrap; background: var(--warn-soft); color: var(--warn); font-weight: 700; border-radius: 10px; padding: 0 7px; }
.ai-bar { background: var(--surface); }
.ai-bar:empty { display: none; }
.ai-note { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 13.5px; flex-wrap: wrap; }
.ai-note.warn { background: var(--warn-soft); color: var(--ink); }
.ai-note.draft { background: color-mix(in srgb, #6d4bd8 8%, var(--surface)); align-items: flex-start; }
.ai-note.draft b { color: #5b3cc4; }
.ai-note .draft-text { white-space: pre-wrap; margin-top: 4px; max-height: 140px; overflow-y: auto; }
.ai-note .actions { flex-wrap: nowrap; }
.as-cust { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 550; color: var(--muted); margin-left: 4px; cursor: pointer; }
.ib-side section.ai-draft { background: color-mix(in srgb, #6d4bd8 6%, var(--surface)); }
.ib-side section.ai-draft h3 { color: #5b3cc4; }
.ai-tag { font-size: 11px; font-weight: 700; color: #5b3cc4; background: color-mix(in srgb, #6d4bd8 12%, transparent); border-radius: 8px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.prov-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.prov { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; background: var(--surface); text-align: left; font: inherit; color: inherit; }
.prov.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.prov b { display: block; }
.prov span { color: var(--muted); font-size: 12.5px; }
.prov .k { margin-top: 6px; font-size: 12px; }
.prov .k.ok { color: var(--ok); }
.usage-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.usage-strip > div { padding: 12px 16px; border-right: 1px solid var(--line); }
.usage-strip > div:last-child { border-right: 0; }
.usage-strip .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.usage-strip .l { color: var(--muted); font-size: 12.5px; }
@media (max-width: 860px) {
  .prov-grid { grid-template-columns: 1fr; }
  .usage-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-strip > div:nth-child(2) { border-right: 0; }
}
.ib-head { flex-wrap: wrap; row-gap: 6px; }
.ib-head .who { flex: 1 1 150px; min-width: 150px; }
.ib-head select { max-width: 190px; min-height: 30px; padding: 4px 24px 4px 8px; font-size: 13px; }
