/* Celonix app — pure white theme with restrained blue accents.
   Pattern: big white rounded shell on light-gray page, white icon sidebar,
   segmented tabs, widget-card grids. (Reference: Cusana-style SaaS layout.) */

:root {
  --page: #eceef1;
  --white: #ffffff;
  --card: #f7f8fa;
  --card2: #fafbfc;
  --border: #e8e8ec;
  --border2: #dcdfe4;
  --ink: #1a1a1a;
  --ink2: #6b6b6b;
  --muted: #9a9a9a;
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, .08);
  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, .1);
  --red: #e5484d;
  --red-soft: rgba(229, 72, 77, .1);
  --amber: #d97706;
  --sans: -apple-system, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .05);
  --chart-grid: #edeff3;
  --chart-base: #e3e6eb;
  --chart-axis: #a2a8b0;
}

* { box-sizing: border-box; margin: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; }

/* ============ app shell ============ */
/* Gray backdrop is the page itself and never scrolls; only the content
   column inside the white card scrolls. Sidebar sits directly on the gray. */
html, body { height: 100%; }
body { overflow: hidden; }
.shell-frame { padding: 14px; height: 100vh; }
.shell {
  display: flex;
  height: calc(100vh - 28px);
}
.shell.collapsed .sidebar { width: 78px; }

/* ============ sidebar (on the gray backdrop) ============ */
.sidebar {
  display: flex; flex-direction: column;
  flex: none; width: 224px;
  padding: 10px 10px 14px 4px;
  background: transparent;
  min-height: 0;
  overflow: hidden;
  transition: width .25s ease;
}
/* collapsed rail centers on the gray span (viewport edge → main card),
   not the sidebar box: frame adds 14px left of the box, so shift content
   left by the same amount to keep equal gaps either side of the icons */
.shell.collapsed .sidebar { padding: 10px 17px 14px 3px; }
.sb-mark { width: 46px; height: 44px; object-fit: contain; flex: none; }
.sb-logo { display: flex; align-items: center; gap: 4px; padding: 0 6px 14px 8px; flex: none; }
/* only the nav scrolls between the pinned brand block and pinned account block */
.sb-nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* very thin scroll indicators on the two scrolling regions (nav rail + main content);
   both-edges gutter keeps the rail icons dead-center when the indicator shows */
.sb-nav, .content { scrollbar-width: thin; scrollbar-color: #d3d8de transparent; }
.sb-nav { scrollbar-gutter: stable both-edges; }
.sb-nav::-webkit-scrollbar, .content::-webkit-scrollbar { width: 3px; height: 3px; }
.sb-nav::-webkit-scrollbar-thumb, .content::-webkit-scrollbar-thumb { background: #d3d8de; border-radius: 999px; }
.sb-nav::-webkit-scrollbar-track, .content::-webkit-scrollbar-track { background: transparent; }
.sb-bottom { flex: none; margin-top: 0; }
.sb-name { font-family: 'Montserrat', var(--sans); font-size: 21px; font-weight: 700; letter-spacing: -.2px; color: #054e8c; transform: translateY(1px); }
/* one card wrapping Settings + profile, separated by a divider line */
.sb-card {
  background: var(--white); border-radius: 12px; padding: 5px;
  box-shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.06);
}
.sb-sep { height: 1px; background: var(--border); margin: 4px 4px; }

/* collapse chevron lives at the right end of the Settings row */
.sb-settings-row {
  display: flex; align-items: center; gap: 2px;
  padding: 2px 4px 2px 0;
}
.sb-settings-row .sb-link { flex: 1; }
.shell.collapsed .sb-settings-row { justify-content: center; padding: 2px 0; }
.shell.collapsed .sb-settings-row .sb-link { flex: none; justify-content: center; }
.sb-collapse {
  flex: none;
  width: 28px; height: 28px;
  border: none; background: none; color: var(--muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; line-height: 0;
}
.shell.collapsed .sb-collapse { display: none; }
.sb-collapse:hover { color: var(--ink); }

/* expand chevron replaces the profile row when collapsed (same card, below the divider) */
.sb-expand {
  display: none;
  width: 28px; height: 28px;
  margin: 2px auto 4px;
  border: none; background: none; color: var(--muted);
  cursor: pointer; align-items: center; justify-content: center;
  padding: 0; line-height: 0;
}
.shell.collapsed .sb-user { display: none; }
.shell.collapsed .sb-expand { display: flex; }
.sb-expand:hover { color: var(--ink); }

.sb-search { position: relative; margin: 2px 6px 14px; }
.sb-search input {
  width: 100%; border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 46px 8px 34px; font: inherit; font-size: 13px; color: var(--ink);
  background: var(--white); outline: none;
}
.sb-search input:focus { border-color: var(--blue); }
.sb-search .mag { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.sb-search .kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; background: var(--card2);
}

.sb-label {
  font-size: 10.5px; letter-spacing: 1.4px; color: var(--muted);
  padding: 12px 12px 6px; text-transform: uppercase; white-space: nowrap;
}
.sb-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 8px 9px 8px; margin: 1px 0; border-radius: 10px;
  color: #444; font-size: 13.5px; font-weight: 500; white-space: nowrap;
}
.sb-link svg { flex: none; opacity: .8; }
.sb-link:hover { background: var(--card); color: var(--ink); text-decoration: none; }
.sb-link.active { background: #eef1f4; color: var(--ink); font-weight: 600; }
.sb-link.active svg { opacity: 1; color: var(--blue); }

.sb-bottom { margin-top: auto; }
.sb-divider { height: 1px; background: var(--border); margin: 10px 6px; }
.sb-bottom { flex: none; padding-top: 10px; }
.sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 9px;
}
.sb-gear { margin-left: auto; color: var(--muted); display: flex; padding: 4px; border-radius: 6px; }
.sb-gear:hover { color: var(--ink); background: rgba(16,24,40,.06); text-decoration: none; }
.sb-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--blue-soft); color: var(--blue);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.sb-user .who { min-width: 0; flex: 1; }
.sb-user .who .n {
  font-weight: 600; font-size: 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.sb-user .who .s {
  font-size: 11px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.sb-user .chev { margin-left: auto; color: var(--muted); font-size: 10px; }

.shell.collapsed .sb-name,
.shell.collapsed .sb-search,
.shell.collapsed .sb-label,
.shell.collapsed .sb-link span,
.shell.collapsed .sb-user .who,
.shell.collapsed .sb-user .chev { display: none; }
.shell.collapsed .sb-link { justify-content: center; padding: 10px 0; }
.shell.collapsed .sb-logo { justify-content: center; padding: 0 0 14px; }
.shell.collapsed .sb-user { justify-content: center; }

/* ============ main column (the white rounded card) ============ */
.main {
  display: flex; flex-direction: column; min-width: 0; flex: 1;
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 26px 14px;
}
.topbar h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.topbar .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.content { padding: 6px 26px 26px; overflow-y: auto; flex: 1; min-height: 0; }

/* ============ buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 18px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4fd7; }
.btn-dark { background: #1f2430; color: #fff; }
.btn-ghost { background: var(--white); color: var(--ink); border-color: var(--border2); }
.btn-ghost:hover { background: var(--card); }
.btn-danger { background: var(--white); color: var(--red); border-color: rgba(229,72,77,.35); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 6px 13px; font-size: 12.5px; border-radius: 8px; }

/* ============ toolbar (tabs + search) ============ */
.toolbar { display: flex; align-items: center; gap: 12px; margin: 6px 0 20px; flex-wrap: wrap; }
.toolbar-form { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.seg {
  display: inline-flex; gap: 2px; background: #eef1f4;
  border-radius: 10px; padding: 3px;
}
.seg button {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink2);
  border: none; background: transparent; border-radius: 8px; padding: 6px 14px; cursor: pointer;
}
.seg button.active { background: var(--white); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.toolbar .spacer { flex: 1; }
.tool-input {
  position: relative;
}
.tool-input input {
  font: inherit; font-size: 13px; border: 1px solid var(--border2); border-radius: 999px;
  padding: 7px 14px 7px 32px; width: 220px; outline: none; background: var(--white);
}
.tool-input input:focus { border-color: var(--blue); }
.tool-input .mag { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* ============ sections & widget cards ============ */
.section-h { font-size: 16.5px; font-weight: 700; margin: 18px 0 12px; letter-spacing: -.2px; }
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.wcard {
  background: var(--card); border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.wcard .preview {
  background: var(--white); border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 2px rgba(16,24,40,.05);
}
.wcard h3 { font-size: 14.5px; font-weight: 600; letter-spacing: -.1px; }
.wcard .desc { font-size: 12.5px; color: var(--ink2); line-height: 1.5; }

.kpi-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 11.5px; font-weight: 600; color: var(--ink2); letter-spacing: .2px; }
.kpi-more { color: var(--muted); font-size: 15px; line-height: 1; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.kpi-value .u { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }

.bars { display: flex; align-items: flex-end; gap: 5px; height: 46px; margin-top: 10px; }
.bars i { flex: 1; border-radius: 3px 3px 0 0; background: #d7dce3; min-height: 4px; }
.bars i.hi { background: var(--blue); }
.bars.soft i { background: #e3e7ec; }
.bars.soft i.hi { background: var(--green); }

/* ============ table cards ============ */
.tcard { background: var(--white); border-radius: 16px; box-shadow: var(--shadow); padding: 18px 20px; }
.tcard > h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; letter-spacing: -.2px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px;
  letter-spacing: .6px; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.table td { padding: 10px; border-bottom: 1px solid #f1f2f4; }
.table tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 10px;
  border-radius: 999px; letter-spacing: .2px;
}
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: rgba(217,119,6,.1); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.dim { background: #eef1f4; color: var(--ink2); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }

/* ============ auth pages — split layout (hero image | form panel) ============ */
/* auth pages scroll (the app shell is the only overflow:hidden surface) */
body.authpage { overflow: auto; }
.auth-split { display: flex; min-height: 100vh; }
.auth-left { display: none; }
@media (min-width: 920px) {
  /* fixed viewport height + sticky: long forms scroll the right side only,
     the image never stretches or adds scroll of its own. The form side keeps
     only its own width — the image takes everything else. */
  .auth-left {
    display: block; flex: 1;
    height: 100vh; position: sticky; top: 0;
    padding: 14px;
  }
  .auth-right { flex: none; }
}
.auth-hero { position: relative; height: 100%; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
/* a bare image dropped straight into .auth-left (panel login) behaves like .auth-hero */
.auth-left > img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 20px; }
.auth-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(195deg, rgba(8,12,26,0) 34%, rgba(8,12,26,.82) 100%); }
.hero-copy { position: absolute; left: 0; right: 0; bottom: 0; padding: 36px 38px; color: #fff; }
.hero-copy h2 { font-size: 27px; font-weight: 800; letter-spacing: -.6px; line-height: 1.2; margin: 12px 0 9px; }
.hero-copy p { font-size: 13.5px; color: rgba(255,255,255,.82); margin: 0 0 16px; max-width: 420px; line-height: 1.55; }
.hero-brand { display: flex; align-items: center; gap: 9px; font-family: 'Montserrat', var(--sans); font-weight: 700; font-size: 18px; letter-spacing: -.2px; }
.hero-brand img { width: 32px; height: 30px; object-fit: contain; }
.hero-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hero-points li { display: flex; gap: 10px; align-items: center; font-size: 13px; color: rgba(255,255,255,.92); }
.hero-points li::before {
  content: "✓"; flex: none; width: 19px; height: 19px; border-radius: 50%;
  background: rgba(255,255,255,.18); display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
}

.auth-right { flex: 1; display: flex; padding: 14px; }
.auth-panel {
  flex: 1; max-width: 470px; margin: auto; background: var(--white);
  border-radius: 20px; box-shadow: var(--shadow); padding: 44px 48px;
}
.auth-panel.wide { max-width: 590px; padding: 36px 42px; }
@media (max-width: 640px) { .auth-panel { padding: 30px 24px; } .auth-panel.wide { padding: 28px 22px; } }

.ap-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 26px; }
.ap-brand img { width: 34px; height: 32px; object-fit: contain; }
.ap-brand span { font-family: 'Montserrat', var(--sans); font-size: 21px; font-weight: 700; letter-spacing: -.2px; color: #054e8c; }
.ap-title { font-size: 23px; font-weight: 800; letter-spacing: -.4px; margin-bottom: 5px; }
.ap-sub { color: var(--ink2); font-size: 13.5px; line-height: 1.55; margin: 0 0 20px; }
.ap-sub b { color: var(--ink); }
.ap-card { background: var(--card); border-radius: 12px; padding: 15px 17px; margin-bottom: 14px; }
.ap-card h3 { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.ap-card .steps { margin: 0; padding-left: 18px; color: var(--ink2); font-size: 12.5px; line-height: 1.7; }

.ok-icon {
  width: 52px; height: 52px; border-radius: 50%; margin-bottom: 16px;
  background: var(--green-soft); color: var(--green);
  display: flex; align-items: center; justify-content: center;
}
.ok-icon.warn { background: rgba(217,119,6,.12); color: var(--amber); }
.step-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px;
  color: var(--blue); background: var(--blue-soft); border-radius: 999px; padding: 3px 10px;
  margin-bottom: 14px;
}
.code-input {
  font-size: 26px !important; font-weight: 700; letter-spacing: 14px; text-align: center;
  padding: 13px 12px 13px 26px !important;
}
.check-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink2); margin: 4px 0 16px; cursor: pointer; }
.check-row input { width: 15px; height: 15px; accent-color: var(--blue); }
.stack-links { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; align-items: center; }
.linklike { border: none; background: none; font: inherit; font-size: 13px; color: var(--blue); cursor: pointer; padding: 0; }
.linklike:hover { text-decoration: underline; }
.mini-link { font-size: 11.5px; font-weight: 600; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.label-row label { margin-bottom: 0; }
.gbtn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink);
  background: var(--white); border: 1px solid var(--border2); border-radius: 10px;
  padding: 10px 18px; text-decoration: none; transition: background .15s;
}
.gbtn:hover { background: var(--card); text-decoration: none; }
.devlink { background: var(--blue-soft); border-radius: 10px; padding: 11px 14px; font-size: 12.5px; color: var(--ink2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

/* ============ profile page ============ */
.sb-user { color: inherit; text-decoration: none; cursor: pointer; }
.sb-user:hover { background: rgba(16,24,40,.05); }
.profile-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.profile-col { display: flex; flex-direction: column; gap: 16px; }
.profile-id { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px; padding: 30px 24px 26px; }
.profile-id h2 { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
.profile-id .mail { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.profile-id .btn { margin-top: 14px; }
.sb-avatar.big { width: 64px; height: 64px; font-size: 24px; }
@media (max-width: 900px) { .profile-grid { grid-template-columns: 1fr; } }

/* ============ in-app setup wizard (2-step, plain white page) ============ */
body.setup-page { background: var(--white); }
.setup-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  height: 54px; padding: 0 26px; border-bottom: 1px solid var(--border);
}
.setup-head .ap-brand { margin: 0; }
.setup-head .ap-brand img { width: 28px; height: 26px; }
.setup-head .ap-brand span { font-size: 18px; }
.setup-user { position: relative; display: flex; align-items: center; gap: 10px; }
.setup-uname { font-size: 13px; font-weight: 600; color: var(--ink); }
.setup-stage {
  min-height: calc(100vh - 116px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 22px 92px;
}
/* step 1: centered modal-style card (wide — multi-column field rows) */
.step-card {
  width: 100%; max-width: 880px;
  border: 1px solid var(--border); border-radius: 16px;
  padding: 34px 38px 30px; background: var(--white);
}
.setup-grid { display: grid; gap: 14px; margin-bottom: 15px; }
.setup-grid .field { margin-bottom: 0; }
.g2 { grid-template-columns: 1fr 1fr; }
.g2a { grid-template-columns: 1fr 1.5fr; }
.g2b { grid-template-columns: 1.8fr 1.3fr; align-items: end; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.setup-h { font-size: 10.5px; letter-spacing: 1.2px; font-weight: 700; color: var(--blue); margin: 22px 0 12px; }
.setup-h:first-of-type { margin-top: 4px; }
.bill-type-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 0; }
.bill-type {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid var(--border2); border-radius: 10px; padding: 12px;
  font-size: 13px; font-weight: 600; color: var(--ink2); cursor: pointer;
}
.bill-type input { position: absolute; opacity: 0; }
.bill-type:has(input:checked) { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.field-note { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.field input[readonly] { background: #f6f7f9; color: var(--ink2); cursor: default; }
.field select { appearance: none; -webkit-appearance: none; }
@media (max-width: 760px) {
  .g2, .g2a, .g2b, .g3 { grid-template-columns: 1fr; }
  .step-card { padding: 26px 22px; }
}
/* step 2: wide pricing section */
.step-plans { width: 100%; max-width: 1060px; }
.step-plans .step-badge,
.step-plans .ap-title,
.step-plans .ap-sub { text-align: center; }
.step-plans .ap-sub { margin-bottom: 0; }
.billing-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 20px 0 24px; flex-wrap: wrap; }
.billing { display: inline-flex; background: #f1f3f6; border-radius: 999px; padding: 4px; gap: 2px; }
.billing button {
  border: none; background: none; cursor: pointer;
  font: 600 12.5px/1 var(--sans); color: var(--ink2); padding: 9px 20px; border-radius: 999px;
}
.billing button.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px rgba(16,24,40,.14); }
.save-tag { background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 700; padding: 5px 11px; border-radius: 999px; }
/* plan cards (v2 — setup pricing) */
.plan-card {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  border: 1.5px solid var(--border2); border-radius: 16px; padding: 20px 20px 18px;
  background: var(--white); cursor: pointer;
}
.plan-card input { position: absolute; opacity: 0; }
.plan-card:not(.soon):hover { border-color: var(--blue); }
.plan-card.soon { opacity: .62; cursor: not-allowed; }
.plan-badge {
  position: absolute; top: -9px; right: 14px; font-size: 9px; letter-spacing: 1px; font-weight: 800;
  color: var(--muted); background: var(--card); border: 1px solid var(--border2);
  border-radius: 999px; padding: 3px 9px;
}
.setup-page .plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: stretch; }
.plan-card .pn { font-size: 12px; letter-spacing: 1.1px; font-weight: 800; color: var(--ink2); }
.plan-card .pp { font-size: 27px; font-weight: 800; letter-spacing: -.5px; margin-top: 3px; }
.plan-card .pp .per { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.plan-card .pnote { font-size: 12px; color: var(--muted); min-height: 18px; }
.plan-card .psave { display: none; color: var(--green); font-weight: 700; }
body.bill-yearly .plan-card .psave { display: block; }
.plan-card ul { list-style: none; margin: 12px 0 0; padding: 14px 0 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 7px; }
.plan-card li { display: flex; gap: 8px; font-size: 12.5px; color: var(--ink2); align-items: flex-start; line-height: 1.4; }
.plan-card li::before { content: "✓"; flex: none; color: var(--green); font-weight: 800; font-size: 12px; line-height: 1.45; }
.plan-card li.head { font-weight: 700; color: var(--ink); }
.plan-card li.head::before { content: ""; }
.plan-card.feat { border-color: var(--blue); box-shadow: 0 10px 28px rgba(37,99,235,.10); }
.plan-badge.blue { background: var(--blue); color: #fff; }
.plan-cta {
  margin-top: 16px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px; font-weight: 700;
  background: #f2f4f7; color: var(--muted);
}
.plan-card.feat .plan-cta { background: var(--blue-soft); color: var(--blue); }
/* fixed bottom action bar — one per step, setup.js toggles */
.setup-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--white); border-top: 1px solid var(--border);
  padding: 12px 26px;
}
.setup-foot .btn-primary { margin: 0; padding: 12px 26px; white-space: nowrap; }
.setup-note { font-size: 12.5px; color: var(--muted); }
@media (max-width: 980px) {
  .setup-page .plan-grid { grid-template-columns: 1fr; }
  .setup-stage { align-items: flex-start; }
}
@media (max-width: 640px) {
  .setup-head { padding: 0 16px; }
  .setup-stage { padding: 22px 16px 108px; }
  .step-card { padding: 26px 22px; }
  .setup-foot { flex-wrap: wrap; }
  .setup-foot .setup-note { display: none; }
  .setup-foot .btn { flex: 1; }
}
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

.field { margin-bottom: 15px; }
.field label { display: block; color: var(--ink2); font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.field input, .field select {
  width: 100%; background: var(--white); border: 1px solid var(--border2); border-radius: 10px;
  color: var(--ink); font: inherit; font-size: 14px; padding: 10px 12px; outline: none;
}
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.field input::placeholder { color: #b6bcc4; }
.field .hint { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.btn-block { width: 100%; }
/* auth form messages appear as top-right toasts, never inline in the form */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px)); }
.toast { background: var(--white); border-radius: 12px; box-shadow: 0 14px 34px rgba(8,12,26,.18); padding: 13px 16px; font-size: 13.5px; font-weight: 600; line-height: 1.45; border-left: 4px solid; animation: toast-in .3s cubic-bezier(.2,.9,.3,1.15); }
.toast.err { color: var(--red); border-left-color: var(--red); }
.toast.ok { color: var(--green); border-left-color: var(--green); }
.toast.hide { opacity: 0; transform: translateX(16px); transition: opacity .45s, transform .45s; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } }
.form-error { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 15px; }
.form-ok { background: var(--green-soft); color: var(--green); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 15px; }
.auth-alt { text-align: center; color: var(--ink2); font-size: 13px; margin-top: 16px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.muted { color: var(--ink2); }
.small { font-size: 12px; }
.mt { margin-top: 18px; }
.center { text-align: center; }

/* brand lockup (auth pages) */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 16px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand .logo-dot { width: 11px; height: 11px; border-radius: 3.5px; background: var(--blue); }
.brand .dim { color: var(--muted); font-weight: 500; }

/* ============ dashboard analytics ============ */
.seg a {
  display: inline-block; font: inherit; font-size: 13px; font-weight: 500; color: var(--ink2);
  padding: 6px 14px; border-radius: 8px; text-decoration: none;
}
.seg a:hover { color: var(--ink); text-decoration: none; }
.seg a.active { background: var(--white); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.08); }

.grid.dash-main { grid-template-columns: 1.9fr 1fr; }
@media (max-width: 1100px) { .grid.dash-main, .grid.grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .grid.dash-main, .grid.grid-3 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.panel {
  background: var(--white); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px 18px 14px; min-width: 0;
  box-shadow: 0 1px 2px rgba(16,24,40,.03);
}
.panel-h { display: flex; align-items: center; gap: 10px; margin: 2px 2px 12px; flex-wrap: wrap; }
.panel-h h3 { font-size: 14px; font-weight: 700; letter-spacing: -.15px; }
.panel-h .sub { font-size: 12px; color: var(--muted); }
.panel-h .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.panel .viewall { font-size: 12.5px; font-weight: 600; color: var(--blue); margin-left: auto; }
.panel-foot { font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.panel-sep { height: 1px; background: var(--border); margin: 10px 0 8px; }
.mini-h { font-size: 10.5px; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; margin: 2px 0 4px; }

.chart { width: 100%; height: auto; display: block; }
svg .ax { font-size: 10.5px; fill: #a2a8b0; font-family: var(--sans); }
.donut { flex: none; width: 150px; }
.donut-svg { width: 150px; height: 150px; }
.donut-big { font-size: 16px; font-weight: 800; fill: var(--ink); letter-spacing: -.3px; }
.donut-sub { font-size: 10px; fill: var(--muted); }
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.dlegend { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dlegend .row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.dlegend .nm { color: var(--ink2); font-weight: 500; }
.dlegend .pct { margin-left: auto; font-weight: 700; }
.dlegend .amt { color: var(--muted); font-size: 11.5px; min-width: 60px; text-align: right; }

.legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink2); font-weight: 500; }
.legend .dot, .dlegend .dot, .kv .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }

.kpi { display: flex; flex-direction: column; gap: 7px; }
.kpi-foot { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi-sub { font-size: 11.5px; color: var(--muted); }
.kpi-value.sm { font-size: 20px; }
.spark-wrap .spark, .spark { width: 100%; height: auto; display: block; }
.mt-s { height: 8px; }

.hbar { margin-bottom: 12px; }
.hbar:last-child { margin-bottom: 2px; }
.hbar .t { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; margin-bottom: 5px; }
.hbar .t .n { font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .t .v { color: var(--muted); font-size: 11.5px; flex: none; }
.hbar .track { height: 7px; border-radius: 999px; background: #eef1f4; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: var(--blue); }
.hbar .fill.slate { background: #64748b; }
.hbar .fill.amber { background: var(--amber); }
.hbar.slim .track { height: 5px; }
.hbar.slim { margin-bottom: 10px; }

.stackbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin: 4px 0 12px; background: #eef1f4; }
.stackbar i { height: 100%; }
.stackbar .in { background: var(--blue); }
.stackbar .low { background: var(--amber); }
.stackbar .out { background: var(--red); }

.kv { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 5px 0; }
.kv .n { color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv .v { margin-left: auto; font-weight: 700; }
.kv .lowv { color: var(--amber); font-size: 12px; }

.pill.vio { background: rgba(124,58,237,.09); color: #7c3aed; }
.ta-r { text-align: right; }
.cell-strong { font-weight: 600; }
.cell-sub { font-size: 11px; color: var(--muted); }


/* ============ panel shell architecture (grid: sidebar + fluid main) ============
   Desktop ≥1200px: 250px sidebar + minmax(0,1fr) content — content can shrink,
   never squeezes. 992–1199px: 220px sidebar. <992px: sidebar becomes the
   off-canvas drawer, main goes edge-to-edge (rules in the phone media block). */
@media (min-width: 992px) {
  body.pnl .shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    height: calc(100vh - 28px);
  }
  body.pnl .sidebar { width: auto; min-width: 0; }
}
@media (min-width: 992px) and (max-width: 1199px) {
  body.pnl .shell { grid-template-columns: 220px minmax(0, 1fr); }
}
/* cap very wide screens so tables don't stretch absurdly */
@media (min-width: 992px) {
  body.pnl .content { max-width: 1360px; width: 100%; margin-inline: auto; }
}

/* responsive SVG charts: every chart carries a viewBox, so it scales */
.panel svg.chart, .panel svg.spark { max-width: 100%; height: auto; }

/* ============ panel shell extras: brand stack, menu/theme toggles ============ */
.sb-brand { display: flex; flex-direction: column; gap: 1px; line-height: 1.05; }
.brand-sub { font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: .16em; color: var(--muted); }
.shell.collapsed .sb-brand { display: none; }
body.pnl .sidebar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
}
body.pnl .sb-label {
  display: flex; align-items: center; gap: 8px;
}
body.pnl .sb-label::after {
  content: ""; height: 1px; flex: 1; background: var(--border);
}

/* old-project model: borderless ghost icon buttons in the header;
   the three-line menu button exists on phones only */
.tb-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: transparent; border: none;
  color: var(--ink2); cursor: pointer;
}
.tb-icon:hover { background: var(--card); color: var(--ink); }
.tb-icon svg { display: block; }
.tb-menu .i-x { display: none; }
.shell.nav-open .tb-menu .i-x { display: block; }
.shell.nav-open .tb-menu .i-burger { display: none; }
@media (min-width: 992px) { body.pnl .tb-menu { display: none; } }
.tb-user {
  max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; color: var(--ink2);
}
@media (max-width: 700px) { .tb-user { display: none; } }
.dark-btn .i-sun { display: none; }
html.dark .dark-btn .i-sun { display: block; }
html.dark .dark-btn .i-moon { display: none; }

.sb-backdrop { display: none; }

/* header brand: CELONIX with PANEL stacked under it */
.tb-brand { display: flex; align-items: center; gap: 8px; flex: none; }
.tb-brand img { width: 27px; height: 26px; object-fit: contain; }
.tb-brand-text { display: flex; flex-direction: column; line-height: 1.08; }
.tb-brand-text b {
  font-family: 'Montserrat', var(--sans); font-size: 14px; font-weight: 700;
  letter-spacing: -.2px; color: #054e8c;
}
.tb-brand-text i { font-style: normal; font-size: 8.5px; font-weight: 700; letter-spacing: .2em; color: var(--muted); }
html.dark .tb-brand-text b { color: #7fb3ef; }

/* long emails / notes must never blow out a card or table */
.field-note { overflow-wrap: anywhere; }
.table td { overflow-wrap: break-word; }

/* ============ phone: drawer nav, edge-to-edge main ============ */
@media (max-width: 991px) {
  body.pnl .shell-frame { padding: 0; }
  body.pnl .shell { height: 100vh; }
  body.pnl .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: min(280px, 85vw); padding: 12px 12px 14px 6px;
    background: var(--white);
    box-shadow: 0 0 44px rgba(8, 12, 26, .28);
    transform: translateX(-106%);
    transition: transform .22s ease;
  }
  body.pnl .shell.nav-open .sidebar { transform: none; }
  body.pnl .sb-backdrop {
    position: fixed; inset: 0; z-index: 55;
    background: rgba(8, 12, 26, .42);
    display: block; opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .22s ease, visibility .22s ease;
  }
  body.pnl .shell.nav-open .sb-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
  /* a desktop-collapsed state must not hide labels inside the drawer */
  body.pnl .shell.collapsed .sb-brand,
  body.pnl .shell.collapsed .sb-name,
  body.pnl .shell.collapsed .sb-label,
  body.pnl .shell.collapsed .sb-link span,
  body.pnl .shell.collapsed .sb-user .who { display: revert; }
  body.pnl .shell.collapsed .sidebar { width: min(280px, 85vw); }
  body.pnl .shell.collapsed .sb-link { justify-content: flex-start; padding: 9px 12px; }

  body.pnl .main { border-radius: 0; }
  body.pnl .topbar { padding: 13px 16px 10px; flex-wrap: wrap; gap: 10px; }
  body.pnl .topbar h1 { font-size: 19px; }
  body.pnl .topbar .right { flex-wrap: wrap; gap: 8px; }
  body.pnl .content { padding: 4px 16px 22px; }
  body.pnl .grid { gap: 12px; }
  body.pnl .kpi-value { font-size: 22px; }
  body.pnl .panel { overflow-x: auto; }
  body.pnl .table { min-width: 640px; }
  /* stacked card mode must not inherit the wide-table min-width */
  body.pnl .table.t-cards { min-width: 0; }
  body.pnl .toolbar-form { margin-left: 0; width: 100%; }
  body.pnl .toolbar-form .field { flex: 1; }
}

/* ============ phone header: [☰] [brand] ......... [theme]; title on row 2 ============ */
@media (max-width: 767px) {
  /* many segmented tabs (leads stages) wrap instead of clipping */
  body.pnl .seg { flex-wrap: wrap; }
  body.pnl .topbar { padding: 12px 16px 6px; align-items: center; }
  body.pnl .topbar h1 {
    flex-basis: 100%; order: 9;
    font-size: 20px; margin: 0;
    overflow-wrap: anywhere;
  }
  body.pnl .topbar .right { margin-left: auto; }
}

/* ---- touch targets: 44px on phones ---- */
@media (max-width: 767px) {
  body.pnl .btn { min-height: 44px; }
  body.pnl .btn-sm { min-height: 44px; padding: 10px 14px; }
  body.pnl .sb-link { min-height: 44px; }
  body.pnl .tb-icon { width: 44px; height: 44px; }
  body.pnl .field input, body.pnl .field select { min-height: 44px; }
}

.sb-mobile-toggle { display: none; }
@media (max-width: 991px) { .sb-mobile-toggle { display: inline-flex; } }

/* ── global mobile polish (reference: old system's mobile-first rules) ── */
html { -webkit-text-size-adjust: 100%; }
* { -webkit-tap-highlight-color: transparent; }
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.pt-safe { padding-top: env(safe-area-inset-top); }
.pb-safe { padding-bottom: env(safe-area-inset-bottom); }

/* pick/suggestion dropdowns: touch rows, capped height, never overflow */
.results { max-height: 42vh; overflow-y: auto; }
.results .result-item { min-height: 44px; display: flex; flex-direction: column;
  justify-content: center; gap: 2px; padding: 8px 12px; }
/* pick rows are <button>s (POS / spare pickers): drop the browser's grey
   button chrome so they read as full-width list rows */
button.result-item { width: 100%; margin: 0; border: 0; border-bottom: 1px solid var(--line-soft,#f1f5f9);
  border-radius: 0; background: var(--white,#fff); color: inherit; font: inherit;
  text-align: left; align-items: flex-start; cursor: pointer; }
button.result-item:last-child { border-bottom: 0; }
button.result-item:hover { background: var(--blue-soft); }
button.result-item > span { font-size: 12px; color: var(--muted); }

/* card names clamp so grids stay uniform however long the name is */
.pcard .p-name, .ccard .c-name, .wcard .w-name, .ocard .o-name,
.rcard .r-name, .phcard .p-name, .scard .s-name, .dcard .d-name, .opcard .o-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 991px) {
  /* iOS: 16px inputs stop the auto-zoom on focus */
  .field input, .field select, .field textarea,
  .searchbar input, .filterbar input, .filterbar select,
  input[type="text"], input[type="search"], input[type="number"],
  input[type="date"], input[type="month"], input[type="email"],
  select, textarea { font-size: 16px !important; }

  /* sticky topbar with notch clearance — translucent + blurred so content
     glides under it while scrolling (old-system shell feel) */
  .topbar { position: sticky; top: 0; z-index: 40;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: var(--page);
    background: color-mix(in srgb, var(--page) 82%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px); }
  html.dark .topbar { background: #14161a;
    background: color-mix(in srgb, #14161a 82%, transparent); }

  /* tab strips + filter chips: swipeable single-line (old no-scrollbar) */
  .stat-tabs, .rtabs, .chips, .seg { flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; -ms-overflow-style: none; margin-left: -14px;
    margin-right: -14px; padding: 0 14px 4px; }
  .stat-tabs::-webkit-scrollbar, .rtabs::-webkit-scrollbar,
  .chips::-webkit-scrollbar, .seg::-webkit-scrollbar { display: none; }
  .stat-tabs a, .rtabs a, .chips a { white-space: nowrap; flex: none; }
  .seg label.check { white-space: nowrap; flex: none; padding: 8px 12px; }

  /* dialogs slide up like sheets */
  dialog.dlg { animation: dlg-sheet .22s ease-out; }
  @keyframes dlg-sheet { from { transform: translateY(28px); opacity: .4; } }

  /* filter selects go full width, stacked */
  .filterbar .fb-search, .searchbar input[type="search"] { flex-basis: 100%; }
  .filterbar select, .searchbar select { flex: 1 1 44%; }

  /* suggestion dropdowns pin inside their field, not the page */
  .field { position: relative; }
  .results { position: absolute; left: 0; right: 0; top: calc(100% + 4px);
    z-index: 30; background: var(--white); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 12px 32px rgba(8,12,26,.18); }
  .results .result-item { border-bottom: 1px solid var(--line-soft,#f1f5f9); text-align: left; }
  html.dark .results { background: var(--card); border-color: var(--border); }

  /* icon buttons never shrink below the touch floor */
  .btn.btn-sm { padding: 9px 13px; }
  .pcard .p-money b { font-size: 12.5px; }

  /* tables: sticky headers while scrolling wide tables */
  .panel { -webkit-overflow-scrolling: touch; }
}

/* FAB clears the iOS home bar */
.fab { bottom: calc(26px + env(safe-area-inset-bottom)); }

/* ── PWA smoothness pass (reference: old system's app-shell behaviour) ── */

/* No-flash section changes: cross-document view transitions give the closest
   feel to the old SPA's no-remount swaps. No-op where unsupported. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: .13s; animation-timing-function: ease-out; }

/* Navigation feedback for standalone PWA windows (no browser loading UI):
   a 2px line slides across the very top; app.js fades it in only after 120ms. */
.navline { position: fixed; top: 0; left: 0; right: 0; height: 2.5px; z-index: 90;
  pointer-events: none; overflow: hidden; opacity: 0; transition: opacity .2s ease; }
.navline::before { content: ""; position: absolute; top: 0; left: 0; height: 100%; width: 34%;
  border-radius: 0 3px 3px 0; background: var(--blue);
  animation: navslide 1s ease-in-out infinite; }
.navline.on { opacity: 1; }
@keyframes navslide { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }

/* colour state changes glide instead of snapping on every interactive strip */
.seg a, .seg label.check, .stat-tabs a, .rtabs a, .chips a, .sb-link, .pill,
.bnav a, .bnav button { transition: color .15s ease, background-color .15s ease; }

/* press feedback on touch devices — the tap "gives" slightly like a native app */
@media (pointer: coarse) {
  .btn:active { transform: scale(.96); }
  .fab:active { transform: scale(.9); }
  .tile:active, .stile:active, .pcard:active, .ccard:active, .wcard:active,
  .ocard:active, .rcard:active, .phcard:active, .scard:active, .dcard:active,
  .opcard:active, .trow:active, .srow:active { transform: scale(.985); }
  .tile, .stile, .pcard, .ccard, .wcard, .ocard, .rcard, .phcard, .scard,
  .dcard, .opcard, .trow, .srow, .fab { transition: transform .1s ease; }
}

/* modals contain their own scroll — the page behind must not rubber-band */
dialog.dlg { overscroll-behavior: contain; }

/* ── bottom quick-nav bar (app portal, phones) — old-system PWA pattern ── */
.bnav { display: none; }
@media (max-width: 991px) {
  .bnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: 58px; padding-bottom: env(safe-area-inset-bottom);
    background: var(--white);
    background: color-mix(in srgb, var(--white) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px rgba(8, 12, 26, .06);
  }
  html.dark .bnav { background: color-mix(in srgb, var(--white) 92%, transparent);
    border-top-color: var(--border); }
  .bnav a, .bnav button {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; min-width: 0;
    font: inherit; font-size: 10.5px; font-weight: 600; color: var(--muted);
    background: none; border: 0; cursor: pointer; padding: 6px 2px 4px;
    -webkit-user-select: none; user-select: none;
  }
  .bnav a span:last-child, .bnav button span:last-child {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bnav .b-ico { font-size: 21px; line-height: 1; }
  .bnav a.active { color: var(--blue); }
  .bnav a:active, .bnav button:active { transform: scale(.92); }

  /* the bar never covers content or the FAB */
  body.has-bnav .content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.has-bnav .fab { bottom: calc(74px + env(safe-area-inset-bottom)); }
}

/* motion-sensitive users get none of it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .navline { display: none; }
}

/* ============ app/shop surfaces: same phone treatment (mobile-first) ============ */
@media (max-width: 991px) {
  .shell-frame { padding: 0; }
  .shell { height: 100vh; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: min(280px, 85vw); padding: 12px 12px 14px 6px;
    background: var(--white);
    box-shadow: 0 0 44px rgba(8, 12, 26, .28);
    transform: translateX(-106%);
    transition: transform .22s ease;
  }
  .shell.nav-open .sidebar { transform: none; }
  .sb-backdrop {
    position: fixed; inset: 0; z-index: 55;
    background: rgba(8, 12, 26, .42);
    display: block; opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .22s ease, visibility .22s ease;
  }
  .shell.nav-open .sb-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
  .shell.collapsed .sb-brand, .shell.collapsed .sb-name,
  .shell.collapsed .sb-label, .shell.collapsed .sb-link span,
  .shell.collapsed .sb-user .who { display: revert; }
  .shell.collapsed .sidebar { width: min(280px, 85vw); }
  .shell.collapsed .sb-link { justify-content: flex-start; padding: 9px 12px; }

  .main { border-radius: 0; }
  .topbar { padding: 13px 16px 10px; flex-wrap: wrap; gap: 10px; }
  .topbar h1 { font-size: 19px; }
  .topbar .right { flex-wrap: wrap; gap: 8px; }
  .content { padding: 4px 14px 90px; }
  .grid { gap: 12px; }
  .panel { overflow-x: auto; }
  .table { min-width: 640px; }
  .table.t-cards { min-width: 0; }
  .toolbar-form { margin-left: 0; width: 100%; }
  .toolbar-form .field { flex: 1; }
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .sum-row { flex-wrap: wrap; gap: 8px; }
  .sum-item { min-width: 44%; }

  /* compact tiles on phones */
  .tile-grid, .stile { gap: 8px; }
  .tile { padding: 12px; }
  .tile .t-value { font-size: 19px; }
  .stile { padding: 10px 12px; }
  .stile .t-value { font-size: 17px; }
  .opcard, .pcard, .ccard, .wcard, .ocard, .rcard, .phcard, .scard, .dcard { padding: 11px 12px; }
  .rcard .r-name, .pcard .p-name, .ccard .c-name, .wcard .w-name,
  .ocard .o-name, .phcard .p-name, .scard .s-name, .dcard .d-name { font-size: 13.5px; }
  .opcard .o-bal { font-size: 19px; }
  .shell .pgrid, .shell .ogrid, .shell .rgrid, .shell .wgrid, .shell .cgrid,
  .shell .shopgrid, .shell .dgrid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  .opgrid { grid-template-columns: 1fr; }
  /* stat tiles 2-up on phones too */
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  dialog#saleDlg iframe { min-height: 70vh; }

  /* section rows flatten */
  .trow { grid-template-columns: 78px 1fr auto auto; gap: 4px 8px; padding: 8px 10px; }
  .srow { grid-template-columns: 1fr auto; padding: 9px 10px; }
  .exrow { grid-template-columns: 22px 1fr auto auto; padding: 9px 10px; gap: 6px; }
  .exrow .ex-amt { font-size: 13px; }
  .mrow { grid-template-columns: 38px 1fr auto; padding: 9px 10px; }
  .mrow .m-ava { width: 38px; height: 38px; font-size: 15px; }
  .plan-line, .bo-line, .plan-line { grid-template-columns: 1fr; }
  .kv { font-size: 12.5px; }
  .kv td:first-child { width: 108px; }

  /* dialogs: true mobile modals */
  dialog.dlg { width: calc(100vw - 16px) !important; max-width: 100% !important;
    max-height: calc(100dvh - 24px); margin: auto; }
  dialog.dlg .dlg-card { max-height: calc(100dvh - 24px); }
  .dlg-card h3 { padding: 14px 16px 10px; font-size: 15.5px; }
  .dlg-card .field, .dlg-card .fgrid, .dlg-card .seg, .dlg-card .sum-row,
  .dlg-card .hint, .dlg-card .panel-h, .dlg-card .kv, .dlg-card table { margin-left: 16px; margin-right: 16px; }
  .dlg-card .ov-box { margin-left: 16px; margin-right: 16px; }
  .dlg-actions { padding: 10px 16px; }
  .dlg-actions .btn { flex: 1; }
  .fgrid { grid-template-columns: 1fr !important; }
  .searchbar, .filterbar { padding: 6px 10px; }
  .searchbar input[type=search], .filterbar input, .filterbar select { min-width: 130px; font-size: 13px; }
  .stat-tabs a, .rtabs a { padding: 5px 11px; font-size: 11.5px; }
  .chips a { padding: 5px 11px; font-size: 11.5px; }
  .datebar input { font-size: 13px; }
  .fab { right: 16px; bottom: 16px; width: 52px; height: 52px; font-size: 26px; }
  .pcard .p-money, .bal-grid { font-size: 11.5px; }
  .cm-wrap { max-width: 100%; }
  .acts2 { position: static; }
  .acts { gap: 6px; }
  .acts .btn { flex: 1 1 45%; }
}

/* touch targets on the app surfaces too */
@media (max-width: 767px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; padding: 9px 12px; }
  .sb-link { min-height: 44px; }
  .tb-icon { width: 44px; height: 44px; }
  .field input, .field select { min-height: 44px; }
  .seg { flex-wrap: wrap; }
  .topbar { padding: 12px 16px 6px; align-items: center; }
  .topbar h1 { flex-basis: 100%; order: 9; font-size: 19px; margin: 0; overflow-wrap: anywhere; }
  .topbar .right { margin-left: auto; }
  .kv td:first-child { width: 96px; }
}

/* ---- keyboard focus, visible everywhere on the panel ---- */
body.pnl a:focus-visible,
body.pnl button:focus-visible,
body.pnl input:focus-visible,
body.pnl select:focus-visible,
body.pnl summary:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}

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

/* ============ panel dashboard components (design system) ============ */
.att-list { display: flex; flex-direction: column; }
.att-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 2px; border-bottom: 1px solid #f1f2f4;
}
.att-item:last-child { border-bottom: none; }
.att-count { min-width: 30px; text-align: center; }
.att-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.att-txt b { font-size: 13.5px; }
.att-txt span { font-size: 12.5px; color: var(--ink2); overflow-wrap: anywhere; }
.att-item .btn { flex: none; }
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 4px; padding: 30px 16px;
}
.empty-state b { font-size: 14px; }
.empty-state span { font-size: 12.5px; color: var(--muted); max-width: 320px; }
.empty-dot {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; margin-bottom: 6px;
}
.empty-dot.ok { background: var(--green-soft); color: var(--green); }
.sub-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.sub-label { width: 118px; flex: none; font-size: 12.5px; font-weight: 600; color: var(--ink2); }
.sub-row .hbar { flex: 1; }
.sub-row b { min-width: 34px; text-align: right; }
.act-total { font-size: 13px; color: var(--ink2); margin: 2px 0 8px; }
.act-total b { font-size: 20px; color: var(--ink); font-weight: 800; margin-right: 4px; }
.hbar .fill { background: var(--blue); }
.hbar .fill.ok { background: var(--green); }
.hbar .fill.warn { background: var(--amber); }
.hbar .fill.bad { background: var(--red); }
@media (max-width: 640px) {
  .att-item { flex-wrap: wrap; }
  .sub-label { width: 92px; }
}

/* compact summary strip (list pages) */
.page-sub { color: var(--ink2); font-size: 13.5px; margin: 2px 2px 16px; max-width: 640px; }
.sum-row { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--card2); margin-bottom: 16px; }
.sum-item { display: flex; flex-direction: column; gap: 1px; }
.sum-v { font-size: 21px; font-weight: 800; letter-spacing: -.3px; }
.sum-l { font-size: 11.5px; font-weight: 600; color: var(--ink2); }

/* native modal dialog — every surface (panel/app/dealer/staff) */
dialog.dlg {
  border: 1px solid var(--border); border-radius: 20px; padding: 0;
  background: var(--white); color: var(--ink);
  box-shadow: 0 24px 64px rgba(8, 12, 26, .3);
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  /* the * reset strips the UA's margin:auto centering — restore it */
  margin: auto;
}
dialog.dlg[open] { animation: dlg-pop .16s ease-out; }
@keyframes dlg-pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
dialog.dlg::backdrop {
  background: rgba(8, 12, 26, .45);
  backdrop-filter: blur(2px);
}
.dlg-card { padding: 0; display: flex; flex-direction: column; max-height: inherit; }
.dlg-card h3 { font-size: 16px; font-weight: 750; padding: 18px 22px 12px; margin: 0;
  position: sticky; top: 0; background: var(--white); z-index: 2;
  border-bottom: 1px solid var(--border); }
.dlg-card > form { display: flex; flex-direction: column; }
.dlg-card p { font-size: 13.5px; color: var(--ink2); line-height: 1.55; margin: 10px 22px 14px; overflow-wrap: anywhere; }
.dlg-card .field, .dlg-card .fgrid, .dlg-card .seg, .dlg-card .sum-row,
.dlg-card .hint, .dlg-card .panel-h, .dlg-card .kv, .dlg-card table { margin-left: 22px; margin-right: 22px; }
.dlg-card .field:first-child, .dlg-card form .field:first-child { margin-top: 14px; }
.dlg-card .hint { margin-bottom: 10px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px;
  position: sticky; bottom: 0; background: var(--white); z-index: 2;
  padding: 12px 22px; margin-top: 14px; border-top: 1px solid var(--border); }
dialog.dlg { padding: 0; }
dialog.dlg::backdrop { background: rgba(8, 12, 26, .5); backdrop-filter: blur(3px); }

/* plan cards + sectioned plan form */
.plan-card { display: flex; flex-direction: column; gap: 6px; }
.plan-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.plan-card-badges { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: none; }
.plan-price { font-size: 24px; font-weight: 800; letter-spacing: -.4px; }
.plan-price .per { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.plan-meta { font-size: 12.5px; color: var(--ink2); }
.plan-card-actions { display: flex; gap: 8px; margin-top: 8px; }
.plan-form { display: flex; flex-direction: column; gap: 14px; max-width: 860px; }
.plan-checks { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 4px 0; }
.plan-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.plan-check input { width: auto; min-height: 44px; width: 18px; height: 18px; }
.feat-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 10px; }
@media (max-width: 767px) { .plan-form .grid { grid-template-columns: 1fr; } }

/* device catalog cards */
.device-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 16px 12px; gap: 8px; text-decoration: none; color: inherit;
  transition: border-color .12s;
}
.device-card:hover { border-color: var(--blue); text-decoration: none; }
.device-card img {
  width: 80px; height: 80px; object-fit: contain; border-radius: 8px;
}
.device-card .device-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.device-card b { font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.device-card span { font-size: 12px; color: var(--ink2); }
@media (max-width: 640px) { .device-card img { width: 64px; height: 64px; } }

/* analytics: custom-range form + combinable filter row */
.an-custom { margin-left: 0; width: auto; }
.an-custom .field { width: 140px; }
.an-filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  margin: 0 2px 14px; background: var(--card2);
}
.an-filters .field { margin: 0; flex: 1; min-width: 130px; }
.an-filters .field:first-child { flex: 2; }
.an-filters .btn { margin-bottom: 1px; }
@media (max-width: 767px) {
  .an-custom { width: 100%; }
  .an-custom .field { flex: 1; width: auto; }
  .an-filters .field { min-width: calc(50% - 10px); }
  .an-filters .field:first-child { min-width: 100%; }
}

/* ============ responsive tables: two modes ============
   Default tables live in their .panel scroll container on phones (bounded,
   page never scrolls sideways). Tables marked .t-cards are list-shaped:
   on ≤640px each row becomes a labelled card (td[data-l] = its label). */
@media (max-width: 640px) {
  .t-cards thead { display: none; }
  .t-cards tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    margin: 0 0 10px;
    background: var(--card2);
  }
  .t-cards tr:last-child { margin-bottom: 0; }
  .t-cards td {
    display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
    border-bottom: none; padding: 3px 0; text-align: right;
  }
  .t-cards td:first-child { text-align: left; }
  .t-cards td[data-l]::before {
    content: attr(data-l);
    flex: none; margin-right: auto;
    font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--muted); text-align: left;
  }
  .t-cards td[data-l] ~ td:not([data-l]):not(:first-child) { justify-content: flex-end; }
}

/* ============ dealer sales ============ */
.banner-warn {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  background: rgba(217,119,6,.1); color: var(--amber);
  border: 1px solid rgba(217,119,6,.3); border-radius: 12px;
  padding: 11px 16px; font-size: 13px; margin-bottom: 14px;
}
.pos { color: var(--green); }
.neg { color: var(--red); }
.amb { color: var(--amber); }
.sum-item.hl .sum-v { color: var(--blue); }
.kpi-click { cursor: pointer; }
.kpi-click:hover { border-color: var(--blue); }

/* dialog forms */
.dlg-form .grid { gap: 0 12px; }
.dlg-form .field { margin-bottom: 12px; }

/* new-sale line editor */
.line-head, .line-row {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: 1fr 64px 110px 110px 96px 36px;
}
.line-head {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
  padding: 6px 2px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.line-row { margin-bottom: 8px; }
.line-row input { min-width: 0; }
.line-total { text-align: right; font-weight: 700; font-size: 13.5px; }
.line-del { padding: 8px 10px; }
@media (max-width: 760px) {
  .line-head { display: none; }
  .line-row {
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--border); border-radius: 12px;
    padding: 10px; background: var(--card2); margin-bottom: 10px;
  }
  .line-row input:first-child { grid-column: 1 / -1; }
  .line-total { text-align: left; }
}

/* device catalog picker (new sale) */
.device-pick { position: relative; }
.device-pick .results {
  position: absolute; top: calc(100% + 6px); right: 0; width: min(340px, calc(100vw - 48px));
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); z-index: 40; max-height: 300px; overflow: auto; padding: 4px;
}
.device-pick .result {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 9px; cursor: pointer; font-size: 13px;
}
.device-pick .result:hover { background: var(--blue-soft); }
.device-pick .result img { width: 30px; height: 30px; object-fit: contain; flex: none; }
.device-pick .result span { min-width: 0; overflow-wrap: anywhere; }

/* ============ dealer counter sale (POS) ============ */
.pos-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 0 14px; align-items: start; }
@media (max-width: 980px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-cust-box {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  background: var(--card2); margin-top: 10px;
}
.pos-cust-box.new { border-style: dashed; }
.pos-cust-box .field-note { margin-top: 4px; }
.device-pick .result.hi, .device-pick .result:hover { background: var(--blue-soft); }
.pos-line {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: 1fr 74px 110px 96px 36px;
  padding: 8px 2px; border-bottom: 1px solid #f1f2f4;
}
.pos-line:last-child { border-bottom: none; }
.pos-line-name { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pos-line-name .pill { flex: none; }
.pos-line input { min-width: 0; }
.pos-qty, .pos-rate { text-align: right; }
.pos-line-total { text-align: right; font-weight: 700; font-size: 13.5px; }
.pos-payseg { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
.pos-payseg button { font-size: 13.5px; min-height: 44px; }
.pos-done { border-color: rgba(22,163,74,.4); }
.pos-done-head { display: flex; gap: 14px; align-items: center; }
.pos-done-check { color: var(--green); flex: none; }
.pos-done-title { font-size: 17px; font-weight: 800; letter-spacing: -.3px; }
@media (max-width: 640px) {
  .pos-done-head { align-items: flex-start; }
  .pos-done-title { font-size: 15.5px; }
}
@media (max-width: 760px) {
  .pos-line { grid-template-columns: 1fr 64px 96px 36px; }
  .pos-line-total { display: none; }
  .pos-payseg { grid-template-columns: 1fr 1fr; }
  .topbar .pill.dim { display: none; }
}

/* ============ dealer supplier ledger ============ */
.panel-scroll { max-height: 560px; overflow: auto; }
.panel-scroll::-webkit-scrollbar { width: 6px; }
.panel-scroll::-webkit-scrollbar-thumb { background: #d7dce3; border-radius: 3px; }
html.dark .panel-scroll::-webkit-scrollbar-thumb { background: #3d434d; }

/* ============ dark mode (html.dark — panel toggle, persisted) ============ */
html.dark {
  --page: #14161a;
  --white: #1d2026;
  --card: #262a31;
  --card2: #22252b;
  --border: #32363e;
  --border2: #3d434d;
  --ink: #e7e9ee;
  --ink2: #a6adb8;
  --muted: #7b8290;
  --blue-soft: rgba(59, 130, 246, .16);
  --green-soft: rgba(22, 163, 74, .15);
  --red-soft: rgba(229, 72, 77, .15);
  --amber-soft: rgba(217, 119, 6, .15);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  --chart-grid: #2c3037;
  --chart-base: #33383f;
  --chart-axis: #8b929c;
}
html.dark .seg { background: #262a31; }
html.dark .seg a.active { background: #323743; }
html.dark .sb-link.active { background: #2b303a; }
html.dark .table td { border-bottom-color: #2a2e35; }
html.dark .field input[readonly] { background: #171a1f; color: var(--ink2); }
html.dark .field input::placeholder { color: #5b626d; }
html.dark .field select { background: var(--white); }
html.dark .field select option { background: var(--white); color: var(--ink); }
html.dark .sb-name { color: #7fb3ef; }
html.dark .sb-nav::-webkit-scrollbar-thumb, html.dark .content::-webkit-scrollbar-thumb { background: #3d434d; }
html.dark .sb-nav, html.dark .content { scrollbar-color: #3d434d transparent; }
html.dark .bars i { background: #3a4049; }
html.dark .bars.soft i { background: #434a55; }
html.dark .sidebar { box-shadow: 0 0 44px rgba(0, 0, 0, .55); }
/* dark: the shared search bars, filter tabs, chips and inputs */
html.dark .searchbar, html.dark .filterbar { background: var(--white); border-color: var(--border); box-shadow: none; }
html.dark .searchbar input, html.dark .filterbar input, html.dark .filterbar select,
html.dark .searchbar select { background: var(--card); border-color: var(--border); color: var(--ink); }
html.dark .stat-tabs a, html.dark .chips a { background: var(--white); border-color: var(--border); color: var(--ink); }
html.dark .stat-tabs a .n { background: #2c3037; color: var(--ink2); }
html.dark .stat-tabs a.active, html.dark .chips a.active { background: #2563eb; border-color: #2563eb; color: #fff; }
html.dark .stat-tabs a.active .n { background: rgba(255,255,255,.25); color: #fff; }
html.dark input, html.dark select, html.dark textarea { background: var(--white); color: var(--ink); }
html.dark input[type="search"], html.dark input[type="text"], html.dark input[type="email"],
html.dark input[type="password"], html.dark input[type="number"], html.dark input[type="date"],
html.dark input[type="month"], html.dark input:not([type]), html.dark select, html.dark textarea {
  background: var(--card); border-color: var(--border); color: var(--ink);
}
html.dark input::placeholder, html.dark textarea::placeholder { color: #5b626d; }
html.dark input[readonly] { background: #171a1f; color: var(--ink2); }
html.dark .field input, html.dark .field select, html.dark .field textarea { background: var(--card); }
html.dark .results .result-item { background: var(--card); border-color: var(--border); }
html.dark .tile, html.dark .stile, html.dark .pcard, html.dark .ccard, html.dark .wcard,
html.dark .ocard, html.dark .rcard, html.dark .phcard, html.dark .opcard { background: var(--white); border-color: var(--border); }
html.dark .tile.hl, html.dark .stile.hl { background: linear-gradient(135deg, #1c2536 0%, var(--white) 60%); }
html.dark .alert-strip { background: #3a2020; border-color: #5b2b2b; }
html.dark .alert-plan { background: #3a2f1c; border-color: #5b4522; }
html.dark .ov-box { background: var(--card); border-color: var(--border); }
html.dark .trow, html.dark .srow { border-bottom-color: #2a2e35; }
html.dark .srow:hover, html.dark .pcard:hover { background: #22262d; }
html.dark .sup-row { background: var(--card); border-color: var(--border); }
html.dark .sup-row:hover { background: #232a38; }
html.dark .cm { background: #2c3037; }
html.dark mark { background: #8a6d1a; color: #ffe9a8; }
html.dark .fab { box-shadow: 0 10px 26px rgba(0,0,0,.5); }
/* dark: expenses + the shared soft-surface classes every new section uses */
html.dark .plan-note { background: #1a2333; border-color: #2b3b55; }
html.dark .plan-note .pos { color: #4ade80; }
html.dark .plan-note .neg { color: #f87171; }
html.dark .stile.hl, html.dark .tile.hl { background: linear-gradient(135deg, #1c2536 0%, var(--white) 60%); border-color: #2b4a8a; }
html.dark .sum-item.hl { background: #1c2533; }
html.dark .pill.mon { background: #2e2547; color: #b7a6f3; }
html.dark .alert-strip, html.dark .alert-sim { background: #3a2020; border-color: #5b2b2b; }
html.dark .alert-plan { background: #3a2f1c; border-color: #5b4522; }
html.dark .o-tag.ok { background: #143524; color: #4ade80; }
html.dark .o-tag.low { background: #3f1d1d; color: #f87171; }
html.dark .rt.open { background: #1c2740; color: #7fb3ef; }
html.dark .rt.pending { background: #262a45; color: #a5b0f5; }
html.dark .rt.checking { background: #12333a; color: #67d5e8; }
html.dark .rt.waiting_parts { background: #3a2f16; color: #f5c66b; }
html.dark .rt.repairing { background: #3a1e31; color: #f19bd0; }
html.dark .rt.ready { background: #143524; color: #4ade80; }
html.dark .rt.delivered { background: #2a2e35; color: #9aa4b2; }
html.dark .rt.returned { background: #3f1d1d; color: #f87171; }
html.dark .ot.requested { background: #262a45; color: #a5b0f5; }
html.dark .ot.ordered { background: #3a2f16; color: #f5c66b; }
html.dark .ot.arrived { background: #12333a; color: #67d5e8; }
html.dark .ot.fulfilled { background: #143524; color: #4ade80; }
html.dark .ot.cancelled { background: #3f1d1d; color: #f87171; }
html.dark .w-tag.active { background: #143524; color: #4ade80; }
html.dark .w-tag.expiring { background: #3a2f16; color: #f5c66b; }
html.dark .w-tag.expired { background: #3f1d1d; color: #f87171; }
html.dark .p-tag.avail { background: #143524; color: #4ade80; }
html.dark .p-tag.res { background: #3a2f16; color: #f5c66b; }
html.dark .p-tag.sold { background: #2a2e35; color: #9aa4b2; }
html.dark .sup-tag.owe { background: #3a2f16; color: #f5c66b; }
html.dark .sup-tag.ok { background: #143524; color: #4ade80; }
html.dark .seg-tgl label { background: var(--card); }
html.dark .seg-tgl label:has(input:checked) { background: #1c2536; }
html.dark .month-head input[type="month"] { background: var(--card); }
html.dark .ov-box, html.dark .dlg-card .ov-box { background: #171a20; border-color: var(--border); }
html.dark .pos { color: #4ade80; }
html.dark .neg { color: #f87171; }
html.dark .amb { color: #f5c66b; }
html.dark dialog.dlg { background: var(--white); }
html.dark .dlg-card h3, html.dark .dlg-actions { background: var(--white); }
html.dark dialog.dlg::backdrop { background: rgba(0, 0, 0, .6); }

/* ============ Item Master ============ */
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px 16px; }
.fgrid .field { margin: 0; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; min-height: 40px; }
label.check input { width: 16px; height: 16px; accent-color: var(--blue); flex: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; letter-spacing: .2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 12.5px;
  text-decoration: none; color: var(--ink); background: var(--white);
}
.chip:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.row-dim td { opacity: .62; }
.row-bad td { background: rgba(229,72,77,.05); }
.warn-ico { color: var(--amber); margin-left: 2px; }
.empty-state.sm { padding: 18px 14px; text-align: left; }
.device-pick .result .result-mid { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.device-pick .result .result-mid .dim { font-size: 11.5px; }
.device-pick .result em.result-tag { font-style: normal; font-size: 11px; color: var(--blue); margin-left: 8px; white-space: nowrap; }
.device-pick .result .num { margin-left: auto; font-size: 11.5px; white-space: nowrap; flex: none; }
.dev-link-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 0;
  border-bottom: 1px dashed var(--line); font-size: 13px; flex-wrap: wrap;
}
.dev-link-row select { max-width: 140px; }
.dev-link-row b { min-width: 0; overflow-wrap: anywhere; }

/* ============ Godowns / inventory foundation ============ */
.godown-cards { margin-bottom: 16px; }
.godown-card { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 10px; }
.godown-card:hover { border-color: var(--blue); }
.godown-card.sel { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.godown-card.off { opacity: .55; }
.gc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gc-head b { font-size: 14px; }
.gc-nums { display: flex; gap: 14px; }
.gc-nums > div { display: flex; flex-direction: column; gap: 2px; min-width: 58px; }
.gc-nums .num { font-size: 17px; font-weight: 800; }
.gc-nums label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.xfer-lines { display: flex; flex-direction: column; gap: 6px; }
.xfer-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13px; }
.xfer-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.xfer-row .pos-qty { width: 74px; flex: none; }
.banner-ok { background: var(--green-soft, #ecfdf3); border: 1px solid rgba(35,160,84,.3); color: #14713b; border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.device-card .spec-dot { font-style: normal; color: var(--blue); font-size: 11px; }
.cnt-in { width: 84px; text-align: right; }
#countForm tbody tr td { vertical-align: middle; }
#countForm input[name="count_remark"] { min-width: 120px; }
@media (max-width: 430px) {
  .toolbar-form { flex-wrap: wrap; margin-left: 0; width: 100%; }
  .toolbar-form .field { flex: 1 1 100% !important; min-width: 0 !important; }
  .toolbar .seg { flex-wrap: wrap; }
}
@media (max-width: 430px) {
  .toolbar-form select, .an-filters select { width: 100%; max-width: 100%; }
  .toolbar-form .field input, .toolbar-form .field select { max-width: 100%; }
}
@media (max-width: 430px) {
  .toolbar-form > .btn { flex: 1 1 100%; }
}

/* ============ remaining dealer modules ============ */
.alert-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 13.5px; }
.alert-row:last-child { border-bottom: none; }
.alert-row:hover { background: var(--blue-soft); }
.alert-row.critical b { color: var(--red); }
.alert-row.warning b { color: var(--amber); }
.mv-row, .jv-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.mv-row .mv-party { max-width: 220px; }
.mv-row .mv-narr { flex: 1; min-width: 120px; }
.mv-alloc { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mv-alloc .pos-qty { width: 84px; }
.mv-alloc-note { font-size: 11.5px; min-width: 110px; }
.jv-row select { max-width: 240px; flex: 1; }
.sb-label { font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }
.panel-scroll { max-height: 460px; overflow: auto; }
@media (max-width: 430px) {
  .toolbar-form input[type="month"] { width: 100%; max-width: 100%; }
}

/* ---- statements (P&L / balance sheet) + shares + print ---- */
.stmt-tot td { border-top: 2px solid var(--line); padding-top: 10px; }
.wa-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.wa-box select { width: auto; }
.wa-box .hint { flex-basis: 100%; margin: 2px 0 0; }

/* Print: the browser's own dialog against a clean sheet — "print" and "save
   as PDF" are the same button (old model). Chrome, sidebar and controls go. */
@media print {
  body { background: #fff; }
  .sidebar, .sb-backdrop, .tb-menu, .toasts, .no-print, .toolbar, .bnav, .navline, dialog { display: none !important; }
  .shell-frame, .shell, .main { display: block !important; }
  .main { margin: 0 !important; padding: 0 !important; max-width: 100% !important; }
  .content { padding: 0 !important; max-width: 100% !important; }
  .panel { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  .panel-scroll { max-height: none; overflow: visible; }
  .sum-row { gap: 12px; }
}

/* ---- shop cart bar (dealer price list) ---- */
.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; background: #fff; border-top: 2px solid var(--blue, #2563eb);
  box-shadow: 0 -4px 18px rgba(15, 23, 42, .08);
}
.cart-bar .cart-info { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cart-bar .field-note { margin: 0; color: var(--amber, #d97706); font-weight: 600; }
@media print { .cart-bar { display: none !important; } }
@media (max-width: 640px) {
  .main { padding-bottom: 84px; } /* keep content clear of the cart bar */
}

/* ---- dataset typeahead (ds-suggest.js) ---- */
.ds-wrap { position: relative; }
.ds-sug {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 70;
  background: var(--white); border: 1px solid var(--border2); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.ds-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; background: transparent; border: none; cursor: pointer;
  text-align: left; font: inherit;
}
.ds-item:hover, .ds-item.active { background: var(--blue-soft); }
.ds-item img { width: 30px; height: 30px; object-fit: contain; flex: none; }
.ds-ph {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--ink2); font-size: 11px; font-weight: 700;
}
.ds-txt { display: flex; flex-direction: column; min-width: 0; }
.ds-name {
  font-size: 13px; color: var(--ink); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ds-meta { font-size: 11px; color: var(--ink2); }
.ds-none { padding: 10px 12px; font-size: 12.5px; color: var(--ink2); }
.ds-hint {
  padding: 6px 12px; font-size: 10.5px; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--card2);
}

/* Portal parity pass, 2026-10-16: one usable shell across every role. */
:root { --muted: #707783; }
html.dark { --muted: #a0a8b5; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--blue); outline-offset: 3px;
}
[hidden] { display: none !important; }
.skip-link { position: fixed; z-index: 200; top: 8px; left: 8px; padding: 10px 16px;
  background: var(--white); border: 2px solid var(--blue); border-radius: 8px;
  transform: translateY(-160%); font-weight: 600; }
.skip-link:focus { transform: none; }
.main:focus { outline: none; }
.shell-frame { height: 100dvh; }
.shell { height: calc(100dvh - 28px); }
.content { scrollbar-gutter: stable; overflow-x: hidden; overscroll-behavior-y: contain; }
.content > .panel + .panel, .content > form.panel + .panel { margin-top: 18px; }
.topbar { flex-wrap: wrap; }
.topbar h1 { min-width: 0; overflow-wrap: anywhere; }
.topbar .right { flex-wrap: wrap; justify-content: flex-end; }
.panel-h .sub, .page-sub, .field-note, .hint { overflow-wrap: anywhere; }
.toolbar-form { flex-wrap: wrap; min-width: 0; }
.toolbar-form .field { min-width: 0; }
.field { min-width: 0; }
.field input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
.field select, .field textarea { max-width: 100%; font: inherit; color: var(--ink); }
.field textarea { width: 100%; min-height: 96px; resize: vertical; background: var(--white);
  border: 1px solid var(--border2); border-radius: 9px; padding: 10px 12px; }
.field select { padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23707883' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.field input[type=checkbox], .field input[type=radio] { width: auto; min-height: 0; accent-color: var(--blue); }
.btn:disabled, button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
a.btn:hover { text-decoration: none; }
.ux-table-scroll { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: thin; border-radius: 8px; }
.ux-table-scroll .table { min-width: 100%; }
.table th { white-space: nowrap; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td { vertical-align: middle; overflow-wrap: anywhere; }
.table td .field { margin-bottom: 0; }
.table tbody tr:hover { background: var(--blue-soft); }
.table td .btn + .btn, .table td form + form { margin-left: 4px; }
.nav-close { display: none; }
.toast { position: relative; padding-right: 42px; overflow-wrap: anywhere; }
.toast-dismiss { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px;
  border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer;
  font: inherit; font-size: 22px; line-height: 1; }
.toast-dismiss:hover { background: rgba(0,0,0,.06); }
dialog.dlg { border: 1px solid var(--border); }
.dlg-card > p { padding: 0 22px 18px; color: var(--ink2); }
.dlg-actions { gap: 10px; flex-wrap: wrap; }
.empty-state { gap: 8px; padding: 36px 20px; }
.empty-state span { max-width: 430px; line-height: 1.6; }
.empty-state .btn { margin-top: 8px; }
.section-intro { color: var(--ink2); margin: 0 0 18px; max-width: 76ch; line-height: 1.6; }
.profile-photo { width: 80px; height: 80px; border-radius: 18px; object-fit: cover; border: 1px solid var(--border); }
.profile-media { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.certificate-list { display: grid; gap: 10px; padding: 0; list-style: none; }
.certificate-list a { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px; background: var(--card); border-radius: 10px; }
body.authpage, body.setup-page, body.status-page { height: auto; min-height: 100dvh; overflow-y: auto; }
body.authpage .auth-split { min-height: 100dvh; }
body.status-page { padding: 20px; }
@media (max-width: 991px) {
  .shell-frame { height: 100dvh; }
  .shell { height: 100dvh; }
  .shell.collapsed .sidebar { width: min(280px, 85vw); padding: 12px; }
  .sidebar { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .nav-close { display: inline-flex; align-self: flex-end; flex: none; margin-bottom: 4px; font-size: 26px; }
  .topbar { gap: 10px; }
  .topbar h1 { flex: 1 1 150px; order: 0; font-size: 20px; }
  .topbar .right { gap: 8px; }
  .toolbar-form { width: 100%; margin-left: 0; gap: 8px; }
  .toolbar-form .field { flex: 1 1 160px; }
  .toolbar-form .field input, .toolbar-form .field select { width: 100%; }
  .content { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .content[style*="max-width"] { width: 100%; }
  .bnav { height: calc(58px + env(safe-area-inset-bottom)); }
  .toasts { max-width: calc(100vw - 24px); right: 12px; top: calc(12px + env(safe-area-inset-top)); }
}
@media (max-width: 600px) {
  .shell .pgrid, .shell .ogrid, .shell .rgrid, .shell .wgrid, .shell .cgrid,
  .shell .shopgrid, .shell .dgrid { grid-template-columns: minmax(0, 1fr) !important; }
  .topbar .right { flex: 1 1 100%; justify-content: flex-start; }
  .topbar .right:empty { display: none; }
  .topbar .right .btn { flex: 1 1 auto; }
  .panel { padding: 14px; border-radius: 12px; }
  .btn-sm { min-height: 44px; }
  .dlg-card > p { padding: 0 16px 16px; }
  .t-cards td { overflow-wrap: anywhere; min-width: 0; }
  .t-cards td::before { flex-shrink: 0; }
  .t-cards input, .t-cards select { max-width: 100%; min-width: 0; }
  .profile-media { align-items: flex-start; flex-wrap: wrap; }
}
@media print {
  .skip-link, .nav-close, .toast-dismiss { display: none !important; }
  .ux-table-scroll { overflow: visible; }
  .content { overflow: visible; }
  .table tbody tr:hover { background: transparent; }
}
body.standalone-portal { height: auto; min-height: 100dvh; overflow-y: auto; padding: 14px; }
body.standalone-portal > .main { min-height: calc(100dvh - 28px); overflow: visible; }
@media (max-width: 600px) { body.standalone-portal { padding: 0; } body.standalone-portal > .main { min-height: 100dvh; border-radius: 0; } }
.password-field { position: relative; }
.password-field input { padding-right: 66px; width: 100%; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 36px; padding: 4px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--blue); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.password-toggle:hover { background: var(--blue-soft); }

/* ---- AI assistant (shown only when the server has an AI key) ---- */
.ai-fab { position: fixed; right: 18px; bottom: 18px; z-index: 60; border: none; border-radius: 999px;
  background: var(--blue); color: #fff; font: 600 13px var(--sans); padding: 11px 16px; box-shadow: var(--shadow); cursor: pointer; }
.ai-fab:focus-visible { outline: 3px solid var(--blue-soft); outline-offset: 2px; }
.ai-box { position: fixed; right: 18px; bottom: 72px; z-index: 61; width: min(380px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 120px)); display: flex; flex-direction: column; background: var(--white);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.ai-box[hidden] { display: none; }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.ai-head b { font-size: 14px; }
.ai-close { border: none; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.ai-log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.ai-msg { max-width: 88%; padding: 8px 10px; border-radius: 10px; white-space: pre-wrap; line-height: 1.45; }
.ai-msg.user { align-self: flex-end; background: var(--blue-soft); }
.ai-msg.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--border); }
.ai-msg.err { align-self: flex-start; background: var(--red-soft); color: var(--red); }
.ai-form { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.ai-form textarea { flex: 1; resize: none; height: 40px; font: inherit; font-size: 13px; padding: 8px; border: 1px solid var(--border2); border-radius: 8px; }
.ai-note { font-size: 11px; color: var(--muted); padding: 0 12px 8px; }

/* keyboard-highlighted row in any search result list */
.result.hi, .result-item.hi { background: var(--blue-soft); }

/* ---- platform announcements (owner + staff) ---- */
.ann-stack { position: fixed; top: 14px; right: 14px; z-index: 59; width: min(360px, calc(100vw - 28px)); display: flex; flex-direction: column; gap: 8px; }
.ann-card { position: relative; background: var(--white); border: 1px solid var(--border); border-left: 4px solid var(--blue); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; }
.ann-card b { display: block; font-size: 14px; padding-right: 20px; }
.ann-card p { margin: 4px 0 8px; font-size: 13px; color: var(--ink2); white-space: pre-wrap; }
.ann-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ann-x { position: absolute; top: 6px; right: 8px; border: none; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }

/* ---- staff attendance month calendar ---- */
.att-day { border: 1px solid var(--border); background: var(--white); border-radius: 8px; padding: 6px 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; }
.att-day b { font-size: 13px; }
.att-day span { font-size: 11px; color: var(--ink2); min-height: 14px; }
.att-day:disabled { opacity: .35; cursor: default; }
.att-day.att-off { background: var(--card); }
.att-day.att-present { background: var(--green-soft); border-color: #16a34a; }
.att-day.att-half_day { background: rgba(217, 119, 6, .12); border-color: #d97706; }
.att-day.att-absent { background: var(--red-soft); border-color: var(--red); }
.att-day.att-leave { background: var(--blue-soft); border-color: var(--blue); }
