/*
 * Raibs Command Center — "Day sheet" design (v2.1)
 * Layout: dark ink rail on the left, a quiet working surface on the right; the dashboard opens on
 * today's sheet, like the tear-off daily calendar on every shop wall in the delta.
 * One typeface (Schibsted Grotesk), RAIBS blue for action, leaf / turmeric / kumkum for state.
 */

:root {
  /* palette */
  --ground: #ECEFF5;          /* page */
  --surface: #FFFFFF;         /* panels */
  --surface-2: #F5F7FB;       /* table heads, inputs at rest */
  --ink: #18203A;             /* text */
  --muted: #5A6482;
  --faint: #8A93AD;
  --line: #DCE1EC;
  --line-strong: #C6CDDC;
  --brand: #2747C7;           /* RAIBS blue */
  --brand-ink: #1B35A0;
  --brand-soft: #E6EBFB;
  --on-brand: #FFFFFF;
  --leaf: #1E7A4C;   --leaf-soft: #E1F2E8;
  --turmeric: #A86B00; --turmeric-soft: #FBEFD6;
  --kumkum: #BC2B22; --kumkum-soft: #FBE5E2;
  --violet: #6247B8; --violet-soft: #ECE7FA;
  --sky: #1D64B0;    --sky-soft: #E2EEFA;
  --grey-soft: #EBEEF4;
  --rail: #141B33;            /* sidebar */
  --rail-ink: #C3CBE2;
  --rail-faint: #77809E;
  --rail-hover: #1F2847;
  --chart-a: #2A9A64;
  --chart-b: #DB6A5E;
  --shadow-pop: 0 12px 32px rgba(20, 27, 51, .18), 0 2px 6px rgba(20, 27, 51, .08);
  --focus: 0 0 0 3px rgba(39, 71, 199, .28);

  /* type */
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", Arial, sans-serif;
  --font-tamil: "Noto Sans Tamil", "Latha", "Nirmala UI", sans-serif;
  --step--1: .8125rem;
  --step-0: .9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.375rem;
  --step-3: 1.75rem;

  /* shape */
  --r-panel: 14px;
  --r-ctl: 9px;
  --rail-w: 252px;
  --bar-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0C111E; --surface: #141A2A; --surface-2: #1A2133; --ink: #E6EAF4; --muted: #A1AAC3; --faint: #6F7896;
    --line: #262E44; --line-strong: #343D57; --brand: #8AA2FF; --brand-ink: #A9BBFF; --brand-soft: #1F2A55; --on-brand: #0C1330;
    --leaf: #5CC78D; --leaf-soft: #133325; --turmeric: #E7B44C; --turmeric-soft: #3A2C0E; --kumkum: #FF7D73; --kumkum-soft: #3D1A18;
    --violet: #AE9BF5; --violet-soft: #2A2350; --sky: #79B4F2; --sky-soft: #142C46; --grey-soft: #1E2538;
    --rail: #090D18; --rail-ink: #BAC3DC; --rail-faint: #646D8B; --rail-hover: #161D31;
    --chart-a: #4CC283; --chart-b: #F08479; --shadow-pop: 0 12px 32px rgba(0, 0, 0, .5); --focus: 0 0 0 3px rgba(138, 162, 255, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0C111E; --surface: #141A2A; --surface-2: #1A2133; --ink: #E6EAF4; --muted: #A1AAC3; --faint: #6F7896;
  --line: #262E44; --line-strong: #343D57; --brand: #8AA2FF; --brand-ink: #A9BBFF; --brand-soft: #1F2A55; --on-brand: #0C1330;
  --leaf: #5CC78D; --leaf-soft: #133325; --turmeric: #E7B44C; --turmeric-soft: #3A2C0E; --kumkum: #FF7D73; --kumkum-soft: #3D1A18;
  --violet: #AE9BF5; --violet-soft: #2A2350; --sky: #79B4F2; --sky-soft: #142C46; --grey-soft: #1E2538;
  --rail: #090D18; --rail-ink: #BAC3DC; --rail-faint: #646D8B; --rail-hover: #161D31;
  --chart-a: #4CC283; --chart-b: #F08479; --shadow-pop: 0 12px 32px rgba(0, 0, 0, .5); --focus: 0 0 0 3px rgba(138, 162, 255, .35);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 var(--step-0)/1.55 var(--font); color: var(--ink); background: var(--ground); font-feature-settings: "ss01"; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; letter-spacing: -.012em; }
h1 { font-size: var(--step-3); font-weight: 750; }
h2 { font-size: var(--step-1); font-weight: 680; }
h3 { font-size: var(--step-0); font-weight: 650; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--leaf); }
.neg { color: var(--kumkum); }
.warn { color: var(--turmeric); }
.ic { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- rail (sidebar) ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--rail-w); background: var(--rail); color: var(--rail-ink);
  display: flex; flex-direction: column; z-index: 40; overflow-y: auto; scrollbar-width: thin;
  padding-top: env(safe-area-inset-top, 0px); padding-left: env(safe-area-inset-left, 0px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 20px 16px; color: #FFFFFF; text-decoration: none !important; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: #2747C7; display: grid; place-items: center; font-weight: 800; color: #FFFFFF; font-size: 1.05rem; }
.brand strong { display: block; letter-spacing: .06em; font-size: 1rem; font-weight: 800; }
.brand strong b, .brand-mini b { color: #5BD5A6; }
.brand small { display: block; font-size: .75rem; color: var(--rail-faint); }
.sidebar nav { padding: 4px 12px 16px; flex: 1; display: grid; align-content: start; gap: 1px; }
.nav-section { font-size: .75rem; font-weight: 600; color: var(--rail-faint); padding: 16px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--rail-ink); font-size: .92rem; font-weight: 500; position: relative; }
.nav-link .ic { opacity: .75; }
.nav-link:hover { background: var(--rail-hover); color: #FFFFFF; text-decoration: none; }
.nav-link.is-active { background: #2747C7; color: #FFFFFF; font-weight: 600; }
.nav-link.is-active .ic { opacity: 1; }
.version { padding: 0 22px 16px; font-size: .75rem; color: var(--rail-faint); }
.me { display: none; }

/* ---------- main column & app bar ---------- */
.main { margin-left: var(--rail-w); min-height: 100vh; display: flex; flex-direction: column; }
.page { width: 100%; max-width: none; padding-block: 8px 56px; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); }
body.bare .main { margin: 0; }

.appbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; display: flex; align-items: center; gap: 10px;
  height: var(--bar-h); padding-inline: max(28px, env(safe-area-inset-left, 0px)) max(28px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--ground) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
}
body.scrolled .appbar { border-bottom-color: var(--line); }
body.has-nav::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 45; background: var(--ground); }
.appbar .nav-toggle, .appbar .brand-mini { display: none; }
.search-trigger {
  flex: 0 1 420px; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--faint); font: inherit; font-size: .9rem; cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--line-strong); color: var(--muted); }
.search-trigger span { flex: 1; }
.search-trigger kbd, .cmdk kbd { font: 600 .72rem/1 var(--font); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: var(--surface-2); }
.appbar .spacer { flex: 1; }
.bar-btn { height: 40px; min-width: 40px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; padding: 0 10px; font: inherit; }
.bar-btn:hover { border-color: var(--line-strong); }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-toggle .sun { display: none; } :root:not([data-theme="light"]) .theme-toggle .moon { display: block; } }

/* menus built on <details> */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px; z-index: 50; display: grid;
}
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); font: inherit; font-size: .9rem; background: none; border: 0; text-align: left; cursor: pointer; width: 100%; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop .ic { color: var(--muted); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu-pop .who { padding: 8px 10px 6px; display: grid; }
.menu-pop .who strong { font-size: .92rem; }
.menu-pop .who small { color: var(--muted); font-size: .8rem; }
.new-btn { background: var(--brand); color: var(--on-brand); border-color: var(--brand); font-weight: 650; gap: 6px; display: inline-flex; align-items: center; }
.new-btn:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: .82rem; font-weight: 750; border: 1px solid var(--line); }

/* page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 14px 0 22px; }
.page-head > div:first-child { min-width: 0; }
.page-head .sub { margin: 6px 0 0; color: var(--muted); max-width: 72ch; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- mobile shell ---------- */
.tabbar { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-104%); transition: transform .22s ease, visibility .22s; width: min(300px, 86vw); visibility: hidden; }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 60px rgba(0, 0, 0, .35); }
  .scrim { display: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(9, 13, 24, .45); z-index: 35; }
  .main { margin-left: 0; }
  .appbar { padding-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px)); gap: 8px; }
  .appbar .nav-toggle { display: inline-grid; }
  .appbar .brand-mini { display: block; font-weight: 800; letter-spacing: .05em; color: var(--ink); margin-right: auto; }
  .search-trigger { flex: 0 0 40px; width: 40px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .appbar .spacer { display: none; }
  .new-btn .label { display: none; }
  .page { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  h1 { font-size: var(--step-2); }
  .page-head { margin-top: 6px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset: auto 0 0 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; color: var(--muted); font: 600 .7rem/1.2 var(--font); background: none; border: 0; border-radius: 10px; cursor: pointer; }
  .tabbar a.is-active { color: var(--brand); }
  .tabbar .ic { width: 22px; height: 22px; }
  .tabbar a:hover { text-decoration: none; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 14px; border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 600 .88rem/1.2 var(--font);
  cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn .ic { width: 16px; height: 16px; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: var(--on-brand); }
.btn--danger { color: var(--kumkum); border-color: color-mix(in srgb, var(--kumkum) 35%, var(--line)); }
.btn--danger:hover { background: var(--kumkum); color: var(--surface); border-color: var(--kumkum); }
.btn--sm { min-height: 30px; padding: 4px 10px; font-size: .8rem; border-radius: 8px; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; }

/* ---------- panels & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 20px 22px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .small a { white-space: nowrap; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-60-40 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (max-width: 1150px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-60-40 { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .card { padding: 16px; } }
.section { margin-top: 18px; }
.section-title { font-size: var(--step-1); font-weight: 680; color: var(--ink); margin: 30px 0 12px; }

/* figures band (was KPI tiles): one panel, figures divided by rules */
.kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden;
}
.kpi { display: block; padding: 16px 20px 18px; color: var(--ink); text-decoration: none !important; position: relative; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
a.kpi:hover { background: var(--surface-2); }
.kpi small { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .84rem; font-weight: 550; }
.kpi small::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; }
.kpi strong { display: block; font-size: 1.75rem; font-weight: 760; margin: 6px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.kpi strong small { display: inline; font-size: .8rem; font-weight: 500; color: var(--muted); }
.kpi strong small::before { display: none; }
.kpi-foot { font-size: .84rem; color: var(--muted); }
.kpi--green small::before { background: var(--leaf); }
.kpi--red small::before { background: var(--kumkum); }
.kpi--amber small::before { background: var(--turmeric); }
.kpi--violet small::before { background: var(--violet); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi { padding: 14px; } .kpi strong { font-size: 1.35rem; } }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 650; line-height: 1.55; white-space: nowrap; }
.badge--grey { background: var(--grey-soft); color: var(--muted); }
.badge--blue { background: var(--sky-soft); color: var(--sky); }
.badge--green { background: var(--leaf-soft); color: var(--leaf); }
.badge--amber { background: var(--turmeric-soft); color: var(--turmeric); }
.badge--red { background: var(--kumkum-soft); color: var(--kumkum); }
.badge--violet { background: var(--violet-soft); color: var(--violet); }

/* flash & notices */
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .92rem; border: 1px solid; }
.flash--ok { background: var(--leaf-soft); border-color: color-mix(in srgb, var(--leaf) 30%, transparent); color: var(--leaf); }
.flash--err { background: var(--kumkum-soft); border-color: color-mix(in srgb, var(--kumkum) 30%, transparent); color: var(--kumkum); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; background: var(--turmeric-soft); color: var(--ink); margin-bottom: 12px; font-size: .92rem; border: 1px solid color-mix(in srgb, var(--turmeric) 25%, transparent); }
.notice .ic { color: var(--turmeric); margin-top: 2px; }
.notice--info { background: var(--sky-soft); border-color: color-mix(in srgb, var(--sky) 25%, transparent); }
.notice--info .ic { color: var(--sky); }
.notice p { margin: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-strong); border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
td.actions > * + * { margin-left: 4px; }
th.r, td.r { text-align: right; }
.row-muted td { color: var(--faint); }
.date.is-overdue { color: var(--kumkum); font-weight: 650; }
.date.is-soon { color: var(--turmeric); font-weight: 650; }
td .sub-line { display: block; font-size: .8rem; color: var(--muted); }

/* lists turn into stacked rows on phones */
@media (max-width: 720px) {
  .table-wrap.stackable { border: 0; background: none; overflow: visible; }
  .stackable table, .stackable tbody, .stackable tr, .stackable td { display: block; }
  .stackable thead { display: none; }
  .stackable tr { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
  .stackable tbody tr:hover { background: var(--surface); }
  .stackable td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .stackable td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 550; text-align: left; flex: none; }
  .stackable td .sub-line { display: inline; margin-left: 6px; }
  .stackable td:first-child .sub-line { display: block; margin: 0; }
  .stackable td:first-child { display: block; text-align: left; font-size: 1rem; padding-bottom: 6px; }
  .stackable td:first-child::before { display: none; }
  .stackable td.actions { justify-content: flex-end; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 6px; }
  .stackable td.actions::before { display: none; }
  .stackable td.empty-cell { display: none; }
  .stackable tfoot, .stackable tfoot tr, .stackable tfoot td { display: block; }
  .stackable tfoot tr { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; }
  .stackable tfoot td { border: 0; padding: 2px 0; text-align: left; }
  .stackable tfoot td:empty { display: none; }
}

/* list toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar form.search { display: flex; gap: 6px; flex: 1 1 260px; max-width: 440px; }
.toolbar input[type=search] { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: .82rem; color: var(--ink); font-weight: 600; }
.chip:hover { border-color: var(--brand); text-decoration: none; }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip .count { opacity: .6; margin-left: 4px; font-weight: 500; }
.sum-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.sum-strip > div { padding: 10px 16px; border-right: 1px solid var(--line); margin-right: -1px; }
.sum-strip small { display: block; color: var(--muted); font-size: .8rem; font-weight: 550; }
.sum-strip strong { font-size: 1.12rem; font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  padding: 8px 11px; width: 100%; min-height: 40px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.field label, .field .label { display: block; font-size: .86rem; font-weight: 600; margin-bottom: 6px; }
.field--wide { grid-column: 1 / -1; }
.field .help { display: block; color: var(--muted); font-size: .8rem; margin-top: 5px; }
.field .error { display: block; color: var(--kumkum); font-size: .82rem; margin-top: 5px; font-weight: 600; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--kumkum); }
.req { color: var(--kumkum); }
.affix { display: flex; align-items: stretch; }
.affix > span { display: grid; place-items: center; padding: 0 11px; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--muted); font-size: .9rem; }
.affix > span:first-child { border-right: 0; border-radius: var(--r-ctl) 0 0 var(--r-ctl); }
.affix > span:last-child { border-left: 0; border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
.affix input { border-radius: 0; }
.affix input:first-child { border-radius: var(--r-ctl) 0 0 var(--r-ctl); }
.affix > span:first-child + input { border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
.affix > span:first-child + input:not(:last-child) { border-radius: 0; }
.affix-btn { border: 1px solid var(--line-strong); border-left: 0; background: var(--surface-2); border-radius: 0 var(--r-ctl) var(--r-ctl) 0; padding: 0 11px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.affix-btn:hover { color: var(--brand); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }
@media (max-width: 900px) {
  form.card > .form-actions {
    position: sticky; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); background: var(--surface); margin: 18px -16px -16px; padding: 12px 16px;
    border-radius: 0 0 var(--r-panel) var(--r-panel); box-shadow: 0 -8px 20px rgba(20, 27, 51, .06); z-index: 5;
  }
}
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { min-width: 150px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); }
.check-label { display: inline-flex; align-items: center; gap: 7px; font-size: .9rem; font-weight: 500; cursor: pointer; }
.check-label input, .perm-table input[type=checkbox] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--brand); }

/* ---------- charts ---------- */
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 36%) 1fr auto; gap: 12px; align-items: center; font-size: .88rem; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 999px; }
.hbar-fill--brand { background: var(--brand); }
.hbar-fill--red { background: var(--chart-b); }
.hbar-fill--green { background: var(--chart-a); }
.hbar-val { font-weight: 650; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.cols-legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); margin-bottom: 10px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw--a { background: var(--chart-a); }
.sw--b { background: var(--chart-b); }
.cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; align-items: end; }
.col-group { display: grid; justify-items: center; gap: 5px; }
.col-bars { height: 150px; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; border-bottom: 1px solid var(--line-strong);
  background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 25%; }
.col { width: 36%; max-width: 22px; min-height: 2px; border-radius: 5px 5px 0 0; }
.col--a { background: var(--chart-a); }
.col--b { background: var(--chart-b); }
.col-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.col-vals { display: grid; font-size: .72rem; text-align: center; line-height: 1.3; font-variant-numeric: tabular-nums; }
.progress { height: 8px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--leaf); border-radius: 999px; }

/* ---------- agenda ---------- */
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li a { display: flex; gap: 14px; padding: 10px 6px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; border-radius: 8px; }
.agenda li:last-child a { border-bottom: 0; }
.agenda li a:hover { background: var(--surface-2); }
.ag-date { width: 96px; flex: none; }
.ag-date strong { display: block; font-size: .92rem; font-variant-numeric: tabular-nums; }
.ag-date small { color: var(--muted); font-size: .76rem; }
.agenda li.is-overdue .ag-date small { color: var(--kumkum); font-weight: 650; }
.agenda li.is-soon .ag-date small { color: var(--turmeric); font-weight: 650; }
.ag-body { min-width: 0; font-size: .9rem; }
.ag-body small { display: block; color: var(--muted); font-size: .82rem; }

/* ---------- dashboard: the day sheet ---------- */
.today { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.daysheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; display: flex; flex-direction: column; position: relative;
}
.daysheet-top { background: var(--brand); color: var(--on-brand); padding: 12px 18px 14px; display: flex; justify-content: space-between; align-items: baseline; position: relative; }
.daysheet-top::after { /* the perforation along the tear line */
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -4px; height: 8px;
  background: radial-gradient(circle at 4px 4px, var(--ground) 2.6px, transparent 3px) 0 0 / 12px 8px repeat-x;
}
.daysheet-top strong { font-size: 1rem; font-weight: 750; letter-spacing: .02em; }
.daysheet-top span { font-size: .85rem; opacity: .85; font-variant-numeric: tabular-nums; }
.daysheet-body { padding: 26px 18px 24px; display: grid; justify-items: center; text-align: center; flex: 1; align-content: center; }
.daysheet .dnum { font-size: 6.4rem; font-weight: 800; line-height: .95; letter-spacing: -.05em; color: var(--ink); font-variant-numeric: tabular-nums; }
.daysheet .wday { font-size: 1.15rem; font-weight: 700; margin-top: 4px; }
.daysheet .wday-ta { font-family: var(--font-tamil); font-size: 1rem; color: var(--muted); }
.daysheet.is-sunday .dnum, .daysheet.is-sunday .wday { color: var(--kumkum); }
.daysheet-foot { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px dashed var(--line-strong); }
.daysheet-foot > a, .daysheet-foot > div { padding: 12px 14px; color: var(--ink); text-decoration: none !important; display: grid; gap: 1px; }
.daysheet-foot > * + * { border-left: 1px dashed var(--line-strong); }
.daysheet-foot small { color: var(--muted); font-size: .78rem; }
.daysheet-foot strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.daysheet-foot a:hover { background: var(--surface-2); }
.today .card { margin: 0; }
@media (max-width: 1000px) {
  .today { grid-template-columns: 1fr; }
  .daysheet-body { grid-template-columns: auto 1fr; justify-items: start; text-align: left; column-gap: 16px; }
  .daysheet .dnum { grid-row: span 2; font-size: 4.2rem; }
  .daysheet .wday { align-self: end; margin: 0; }
  .daysheet .wday-ta { align-self: start; }
}

/* ---------- pipeline board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; scroll-snap-type: x proximity; }
.lane { background: color-mix(in srgb, var(--grey-soft) 70%, var(--ground)); border-radius: var(--r-panel); padding: 10px; min-height: 120px; scroll-snap-align: start; border: 1px solid var(--line); }
.lane-head { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 6px 10px; }
.lane-head h2 { font-size: .92rem; }
.lane-head small { color: var(--muted); font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.deal { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px; margin-bottom: 8px; }
.deal h3 { font-size: .94rem; margin-bottom: 3px; }
.deal h3 a { color: var(--ink); }
.deal .meta { font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.deal .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .84rem; flex-wrap: wrap; }
.deal select { min-height: 32px; padding: 4px 8px; font-size: .82rem; margin-top: 10px; }
.deal .convert { margin-top: 8px; }
.lane-empty { font-size: .82rem; color: var(--faint); text-align: center; padding: 18px 4px; }

/* ---------- timeline ---------- */
.week { margin-bottom: 20px; }
.week-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; }
.task form { margin: 0; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line-strong); background: var(--surface); cursor: pointer; display: grid; place-items: center; padding: 0; color: var(--on-brand); flex: none; margin-top: 1px; }
.check:hover { border-color: var(--leaf); }
.check.is-done { background: var(--leaf); border-color: var(--leaf); color: var(--surface); }
.check svg { width: 14px; height: 14px; }
.task-body { flex: 1; min-width: 0; }
.task-body a.title { color: var(--ink); font-weight: 600; }
.task.is-done .task-body a.title { text-decoration: line-through; color: var(--faint); }
.task-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.task-notes { font-size: .84rem; color: var(--muted); margin-top: 4px; }

/* ---------- debt ---------- */
.debt-row-bar { height: 6px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; margin-top: 5px; min-width: 80px; }
.debt-row-bar span { display: block; height: 100%; background: var(--chart-b); }
.planner .inline-form .field { flex: 1 1 160px; }

/* ---------- login ---------- */
body.bare { background: var(--ground); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-art { background: var(--rail); color: #E6EAF4; padding: 44px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login-art .brand { padding: 0; }
.login-art h2 { font-size: 2.1rem; line-height: 1.15; max-width: 16ch; font-weight: 760; color: #FFFFFF; letter-spacing: -.02em; }
.login-art p { color: #A8B1CC; max-width: 44ch; margin-top: 14px; }
.login-art .mini-sheet { width: 150px; background: #FFFFFF; color: #18203A; border-radius: 12px; overflow: hidden; text-align: center; }
.login-art .mini-sheet b { display: block; background: #2747C7; color: #FFFFFF; font-size: .8rem; padding: 6px; letter-spacing: .04em; }
.login-art .mini-sheet span { display: block; font-size: 3.4rem; font-weight: 800; line-height: 1.05; padding: 8px 0 2px; letter-spacing: -.04em; }
.login-art .mini-sheet i { display: block; font-style: normal; font-size: .85rem; font-weight: 650; padding-bottom: 10px; }
.login-art small { color: var(--rail-faint); }
.login-form { display: grid; place-items: center; padding: 32px max(20px, env(safe-area-inset-left, 0px)); }
.login-form .card { width: 100%; max-width: 400px; padding: 30px; }
.login-form h1 { margin-bottom: 6px; }
.login-form .field { margin-top: 16px; }
.login-form .btn { width: 100%; margin-top: 22px; min-height: 44px; }
@media (max-width: 820px) { .login-wrap { grid-template-columns: 1fr; } .login-art { padding: 24px 20px; } .login-art h2 { font-size: 1.45rem; } .login-art .mini-sheet, .login-art p { display: none; } }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty p { margin: 0 auto 14px; max-width: 52ch; }
.detail-list, .kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; font-size: .92rem; margin: 0; }
.detail-list dt, .kv dt { color: var(--muted); }
.detail-list dd, .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 7px; padding: 5px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { color: var(--brand); border-color: var(--line); background: var(--surface); }
.icon-btn .ic { width: 16px; height: 16px; }
.icon-btn.is-done { color: var(--leaf); }

/* ---------- apps ---------- */
.app-group + .app-group { margin-top: 6px; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.app-card { --c: var(--brand); --c-soft: var(--brand-soft); position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s; }
.app-card:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.app-open { display: flex; gap: 13px; align-items: flex-start; padding: 15px 15px 13px; color: var(--ink); text-decoration: none !important; flex: 1; }
.app-open:hover strong { color: var(--c); }
.app-icon { width: 46px; height: 46px; border-radius: 13px; background: var(--c-soft); color: var(--c); display: grid; place-items: center; font-weight: 800; font-size: 1rem; flex: none; letter-spacing: .01em; }
.app-text { min-width: 0; flex: 1; }
.app-text strong { display: block; font-size: .96rem; line-height: 1.3; }
.app-text small { display: block; color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-host { display: flex !important; align-items: center; gap: 4px; margin-top: 4px; color: var(--c) !important; font-weight: 550; }
.app-host .ic { width: 13px; height: 13px; }
.app-status { position: absolute; top: 12px; right: 12px; }
.app-login { border-top: 1px dashed var(--line-strong); padding: 9px 15px; display: grid; gap: 4px; background: var(--surface-2); }
.cred { display: flex; align-items: center; gap: 6px; font-size: .84rem; }
.cred-label { width: 40px; color: var(--muted); font-size: .76rem; font-weight: 600; }
.cred-val { flex: 1; min-width: 0; font: 500 .84rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-edit { position: absolute; bottom: 10px; right: 14px; font-size: .8rem; }
.app-login + .app-edit { position: static; align-self: flex-end; padding: 0 15px 10px; background: var(--surface-2); width: 100%; text-align: right; }
.app--blue   { --c: #2747C7; --c-soft: #E6EBFB; }
.app--green  { --c: #1E7A4C; --c-soft: #E1F2E8; }
.app--orange { --c: #B95A07; --c-soft: #FCEBDB; }
.app--purple { --c: #6247B8; --c-soft: #ECE7FA; }
.app--red    { --c: #BC2B22; --c-soft: #FBE5E2; }
.app--teal   { --c: #0A7783; --c-soft: #DDF1F2; }
.app--pink   { --c: #B23874; --c-soft: #FAE4EE; }
.app--grey   { --c: #4C5671; --c-soft: #EBEEF4; }
/* dark mode: tint app colours instead of using the light pastels */
:root[data-theme="dark"] .app-icon, :root[data-theme="dark"] .app-chip { background: color-mix(in srgb, var(--c) 24%, var(--surface)); color: color-mix(in srgb, var(--c) 45%, #FFFFFF); }
:root[data-theme="dark"] .app-host, :root[data-theme="dark"] .app-open:hover strong { color: color-mix(in srgb, var(--c) 45%, #FFFFFF) !important; }
:root[data-theme="dark"] .app-chip i { background: color-mix(in srgb, var(--c) 45%, #FFFFFF); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app-icon, :root:not([data-theme="light"]) .app-chip { background: color-mix(in srgb, var(--c) 24%, var(--surface)); color: color-mix(in srgb, var(--c) 45%, #FFFFFF); }
  :root:not([data-theme="light"]) .app-host, :root:not([data-theme="light"]) .app-open:hover strong { color: color-mix(in srgb, var(--c) 45%, #FFFFFF) !important; }
  :root:not([data-theme="light"]) .app-chip i { background: color-mix(in srgb, var(--c) 45%, #FFFFFF); }
}
.app-grid.quick { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.app-grid.quick .app-open { padding: 11px 13px; align-items: center; }
.app-grid.quick .app-icon { width: 38px; height: 38px; border-radius: 11px; font-size: .9rem; }

/* ---------- businesses ---------- */
.biz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 420px) { .biz-grid { grid-template-columns: 1fr; } }
.biz { display: flex; flex-direction: column; gap: 6px; margin: 0 !important; }
.biz-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.biz-head p { margin: 3px 0 0; }
.biz-sub { font-size: .84rem; font-weight: 650; color: var(--muted); margin-top: 12px; }
.biz-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: .9rem; }
.biz-list li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.app-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.app-chip { --c: var(--brand); --c-soft: var(--brand-soft); display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; background: var(--c-soft); color: var(--c); font-size: .84rem; font-weight: 650; text-decoration: none !important; max-width: 100%; }
.app-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.app-chip small { font-weight: 500; opacity: .8; }
.biz-actions { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- roles, updates ---------- */
.perm-table th.c, .perm-table td.c { text-align: center; width: 110px; }
.perm-group td { background: var(--surface-2); font-size: .82rem; font-weight: 700; color: var(--muted); padding: 8px 14px; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--r-panel); padding: 24px; text-align: center; background: var(--surface-2); color: var(--muted); }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input[type=file] { border: 0; padding: 0; min-height: 0; max-width: 340px; margin: 12px auto 0; display: block; background: none; }
.inline-details { display: inline-block; vertical-align: middle; }
.inline-details > summary { list-style: none; display: inline-flex; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] > summary { opacity: .7; }
.inline-details input[type=password] { width: 150px; min-height: 30px; padding: 4px 8px; font-size: .82rem; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 12px; font-size: .9rem; z-index: 90; box-shadow: var(--shadow-pop); max-width: calc(100vw - 32px); }
@media (max-width: 900px) { .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }

/* ---------- quick search (Ctrl/⌘ K) ---------- */
.cmdk { border: 0; padding: 0; background: transparent; width: min(620px, calc(100vw - 24px)); max-height: min(560px, 80vh); margin: 12vh auto auto; color: var(--ink); }
.cmdk::backdrop { background: rgba(9, 13, 24, .45); }
.cmdk-box { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-pop); overflow: hidden; display: flex; flex-direction: column; max-height: min(560px, 80vh); }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-bottom: 1px solid var(--line); color: var(--muted); }
.cmdk-input input { border: 0; box-shadow: none !important; font-size: 1.02rem; min-height: 50px; padding: 0; background: transparent; }
.cmdk-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.cmdk-list li a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.cmdk-list li a .ic { color: var(--muted); }
.cmdk-list li a small { margin-left: auto; color: var(--faint); font-size: .78rem; }
.cmdk-list li.is-sel a { background: var(--brand-soft); color: var(--brand); }
.cmdk-list li.is-sel a .ic { color: var(--brand); }
.cmdk-group { font-size: .78rem; font-weight: 650; color: var(--faint); padding: 10px 12px 4px; }
.cmdk-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); color: var(--faint); font-size: .78rem; }
.cmdk-empty { padding: 22px 14px; color: var(--muted); text-align: center; }

@media print {
  .sidebar, .appbar, .tabbar, .head-actions, .toolbar, td.actions, .form-actions { display: none !important; }
  .main { margin: 0; }
}
body.bare .page { padding: 0; max-width: none; }

/* ---------- full-width layouts on large screens ---------- */
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
@media (min-width: 1500px) {
  .kpis { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .kpi strong { font-size: 1.6rem; }
  .today { grid-template-columns: 340px minmax(0, 1fr); }
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page { padding-left: max(36px, env(safe-area-inset-left, 0px)); padding-right: max(36px, env(safe-area-inset-right, 0px)); }
  .appbar { padding-inline: max(36px, env(safe-area-inset-left, 0px)) max(36px, env(safe-area-inset-right, 0px)); }
}
@media (min-width: 2200px) { :root { font-size: 17px; } }
.fs-toggle .shrink { display: none; }
:root.is-fullscreen .fs-toggle .grow { display: none; }
:root.is-fullscreen .fs-toggle .shrink { display: block; }
@media (max-width: 900px) { .fs-toggle { display: none !important; } }
.grid > .card + .card, .stack > .card + .card { margin-top: 0; }
.grid-auto { align-items: start; }

/* ---------- 2.2: businesses as even tiles that open the ERP ---------- */
.biz-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); align-items: stretch; }
.biz { position: relative; display: flex; flex-direction: column; gap: 14px; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 18px 20px; transition: border-color .15s, box-shadow .15s; }
.biz.is-linked:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: 0 6px 20px rgba(20, 27, 51, .08); }
.biz.is-planned { background: color-mix(in srgb, var(--surface) 70%, var(--ground)); }
.biz-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.biz-link:focus-visible { box-shadow: var(--focus); }
.biz a:not(.biz-link), .biz button, .biz form { position: relative; z-index: 2; }
.biz-head { display: flex; gap: 12px; align-items: flex-start; }
.biz-mark { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; flex: none; }
.biz.is-planned .biz-mark { background: var(--grey-soft); color: var(--muted); }
.biz-title { flex: 1; min-width: 0; }
.biz-title h2 { font-size: 1.05rem; }
.biz-title p { margin: 2px 0 0; color: var(--muted); font-size: .84rem; }
.biz-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.biz-figs > div { background: var(--surface-2); padding: 10px 12px; display: grid; gap: 1px; min-width: 0; }
.biz-figs small { color: var(--muted); font-size: .76rem; font-weight: 550; }
.biz-figs strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.biz-figs span { font-size: .74rem; color: var(--muted); }
.biz-spark { display: flex; align-items: center; gap: 10px; color: var(--chart-a); }
.biz-spark .spark { flex: 1 1 0; min-width: 0; width: 100%; height: 36px; }
.biz-spark span { font-size: .74rem; color: var(--faint); white-space: nowrap; }
.biz-empty { border: 1px dashed var(--line-strong); border-radius: 11px; padding: 14px; color: var(--muted); font-size: .86rem; background: var(--surface-2); }
.biz-empty p { margin: 0; }
.biz-note { color: var(--muted); font-size: .88rem; margin: 0; }
.biz-meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .84rem; margin: 0; flex: 1; align-content: start; }
.biz-meta dt { color: var(--muted); }
.biz-meta dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.biz-actions { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); margin-top: auto; }
.biz-open { pointer-events: none; }
.spark { display: block; color: var(--chart-a); overflow: visible; }
.spark-line { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: currentColor; opacity: .12; stroke: none; }
.spark-dot { fill: currentColor; }
.scoreboard td .spark { color: var(--chart-a); }
.cols--dense .col-vals { display: none; }
.cols--dense .col-label { font-size: .68rem; white-space: nowrap; }
.cols--dense { gap: 4px; }

/* connection page */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-opt { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; font-size: .9rem; font-weight: 550; background: var(--surface); }
.seg-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.seg-opt input { width: 16px; height: 16px; min-height: 0; accent-color: var(--brand); }
.q-list { display: grid; gap: 14px; margin-top: 12px; }
.q-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.q-head label { margin: 0; }
.q-res { font-size: .84rem; font-weight: 650; }
.mono, textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
.schema { max-height: 420px; overflow-y: auto; display: grid; gap: 2px; }
.schema summary { cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.schema summary:hover { background: var(--surface-2); }
.schema p { margin: 2px 0 8px 14px; color: var(--muted); overflow-wrap: anywhere; }
.toggle-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.toggle-row:has(input:checked) { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); background: var(--brand-soft); }
.toggle-row input { width: 18px; height: 18px; min-height: 0; margin-top: 2px; accent-color: var(--brand); flex: none; }
.toggle-row span { display: grid; gap: 2px; }
.toggle-row small { color: var(--muted); font-size: .82rem; }
.copy-line { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.copy-line code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .8rem; }
.cols { grid-auto-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .grid-auto > .span-2 { grid-column: span 2; } }
.preset-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding: 12px 14px; border-radius: 11px; background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.preset-box > div { flex: 1; min-width: 220px; display: grid; gap: 2px; }
.preset-box small { color: var(--muted); font-size: .82rem; }
