/* Reports — same design system as Stock Take (copied from stock-take/public/style.css).
   Styled to match the Shining Stone storefront (shiningstone.net):
   cream / ink / gold palette, Playfair Display headings, Montserrat text, square buttons.
   Keep the two apps looking the same: change tokens here, not one-off colours in components. */

@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/fonts/montserrat.woff2) format("woff2");
}
@font-face {
  font-family: "Playfair Display"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url(/fonts/playfair-display.woff2) format("woff2");
}
@font-face {
  font-family: "Playfair Display"; font-style: italic; font-weight: 400; font-display: swap;
  src: url(/fonts/playfair-display-italic.woff2) format("woff2");
}

:root {
  /* store palette */
  --cream: #FAF3EC;
  --ink-brand: #1E1B18;
  --gold: #C9A063;
  --gold-dim: #C29450;
  --gold-light: #D6B789;      /* storefront --colorBtnPrimaryLight (primary button hover) */
  --blush: #F3C9BC;
  --sand: #E8D6C9;

  --bg: var(--cream);
  --card: #FDF9F4;
  --ink: var(--ink-brand);
  --muted: #6E6258;
  --line: var(--sand);
  --soft: #F5E6D8;
  --accent: #7A5C2B;          /* gold darkened so text and links stay readable on cream */
  --accent-ink: var(--ink-brand);
  --accent-soft: #F3E6CF;
  --btn: var(--gold);
  --btn-hover: var(--gold-dim);
  --btn-ink: #FFFFFF;          /* storefront --colorBtnPrimaryText */
  --btn-radius: 3px;          /* storefront .btn { border-radius: 3px } */
  --btn-caps: .2em;           /* storefront --typeUppercaseSpacing */
  --warn: #8A5A12; --warn-soft: #F7E7C8;
  --bad: #A33A2C;  --bad-soft: #F8DDD4;
  --good: #3C6B4A; --good-soft: #E3EDDF;
  --info: #3D5A7A; --info-soft: #E3E9EF;
  --radius: 2px;
  --shadow: none;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Montserrat", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --caps: .14em;
  font-family: var(--sans);
  /* Always the storefront's light look, even when the device is in dark mode. */
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 15px; line-height: 1.5; letter-spacing: .015em; min-height: 100vh; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0 0 .5rem; line-height: 1.15; letter-spacing: .015em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.15rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); text-underline-offset: 3px; }
small, .muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.right { text-align: right; }
.hide { display: none !important; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .9rem; }
.grow { flex: 1 1 auto; }
.eyebrow { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .2em; color: var(--accent); margin-bottom: .35rem; }

/* ---------- logo ---------- */
.logo { display: inline-flex; }
.logo img { display: block; height: 100%; width: auto; }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1140px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1.2rem; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--ink); white-space: nowrap; }
/* Branding sizes (Settings → Branding): logo-small/medium/large and name-small/medium/large. */
.brand { --logo-h: 38px; --name-fs: 1.3rem; --by-fs: .72rem; --scale: 1; }
.brand.logo-small { --logo-h: 28px; } .brand.logo-large { --logo-h: 50px; }
.brand.name-small { --name-fs: 1rem; --by-fs: .62rem; } .brand.name-large { --name-fs: 1.65rem; --by-fs: .85rem; }
.brand .logo, .auth-logo .logo { height: calc(var(--logo-h) * var(--scale)); }
.sublogo { display: flex; flex-direction: column; justify-content: center; line-height: 1; }
.sublogo-name { font-family: var(--serif); font-size: calc(var(--name-fs) * var(--scale)); font-weight: 400; letter-spacing: .02em; color: var(--ink); }
.sublogo-by { font-family: var(--serif); font-style: italic; font-size: calc(var(--by-fs) * var(--scale)); color: var(--accent); margin-top: .22rem; letter-spacing: .02em; }
.brand .logo + .sublogo { padding-left: .8rem; border-left: 1px solid var(--line); min-height: calc(min(var(--logo-h), 40px) * var(--scale)); }
.nav { display: flex; gap: .15rem; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: .55rem .6rem; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; display: inline-flex; gap: .4rem; align-items: center;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); border-bottom-color: var(--gold); }
.count-pill { background: var(--blush); color: var(--ink-brand); border-radius: 999px; font-size: .68rem; padding: .02rem .45rem; font-weight: 600; letter-spacing: 0; }
.page { max-width: 1140px; margin: 0 auto; padding: 1.6rem 1rem 5rem; }
.who { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); text-decoration: none; transition: border-color .15s; }
.who:hover { border-color: var(--gold); }
.who-icon { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
/* Narrower screens: menu gets its own full-width row under the logo. */
/* --topbar-h = measured header height, for anything sticky under the header. */
:root { --topbar-h: 58px; }
@media (max-width: 1100px) {
  :root { --topbar-h: 91px; }
  .topbar-in { flex-wrap: wrap; row-gap: 0; padding-bottom: 0; }
  .who { margin-left: auto; }
  /* Phones/tablets: hide the dashboard greeting and make its main button full width. */
  .dash-head .greet { display: none; }
  .dash-head > .btn { width: 100%; justify-content: center; text-align: center; }
  .nav { order: 3; flex-basis: 100%; margin: .35rem -.6rem 0; }
}
@media (max-width: 720px) { :root { --topbar-h: 102px; } }

/* ---------- cards & layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
a.card { display: block; text-decoration: none; color: inherit; transition: border-color .15s; }
a.card:hover { border-color: var(--gold); }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { padding: 1rem 1.2rem; }
.stat .n { font-family: var(--serif); font-size: 2.2rem; font-weight: 400; line-height: 1.1; font-variant-numeric: lining-nums; }
.stat .l { color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: var(--caps); margin-top: .2rem; }
.pagehead { display: flex; gap: .8rem; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1.3rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.pagehead h1 { margin-bottom: .15rem; }
.pagehead p { margin: 0; color: var(--muted); }
.brand-preview { display: flex; align-items: center; min-height: 76px; padding: .8rem 1rem; background: var(--bg); border: 1px dashed var(--line); overflow-x: auto; }
.empty { text-align: center; padding: 2.4rem 1rem; color: var(--muted); }

/* ---------- form ---------- */
label.field { display: block; }
.field > span { display: block; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: var(--caps); margin-bottom: .35rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 0;
  padding: .6rem .75rem; width: 100%; min-height: 44px;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line), var(--ink) 25%); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.btn:focus-visible, a:focus-visible, .chip:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--gold); }
textarea { min-height: 84px; resize: vertical; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 500; }
.check small { display: block; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }

.btn {
  /* Matches the storefront buttons (shiningstone.net, e.g. "Build your set"). */
  font: inherit; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: var(--btn-caps);
  border: 1px solid var(--ink); background: transparent; color: var(--ink);
  border-radius: var(--btn-radius); padding: .65rem 1.25rem; min-height: 44px; cursor: pointer; display: inline-flex; gap: .45rem;
  align-items: center; justify-content: center; text-decoration: none; white-space: nowrap;
  /* Storefront "Add to Cart": gold sweeps in from the left on hover. */
  background-image: linear-gradient(var(--gold), var(--gold));
  background-repeat: no-repeat; background-position: left center; background-size: 0% 100%;
  transition: background-size .6s cubic-bezier(.22, 1, .36, 1), color .4s ease, border-color .4s ease, box-shadow .4s ease;
}
.btn:hover, .btn:active { background-size: 100% 100%; border-color: var(--gold); color: var(--btn-ink); box-shadow: 0 8px 24px -8px rgba(201, 160, 99, .7); }

/* Storefront primary button: solid gold, white bold text. On hover a soft gold glow appears
   and a white glint sweeps across (the storefront's hx-shimmer). */
.btn.primary {
  position: relative; overflow: hidden;
  background-color: var(--btn); background-image: none; border-color: var(--btn); color: var(--btn-ink);
  transition: background-color .2s ease;
}
.btn.primary::after {
  content: ""; position: absolute; top: 0; left: 150%; width: 200%; height: 100%; pointer-events: none;
  background-image: linear-gradient(90deg, transparent, hsla(0, 0%, 100%, .45), transparent);
  transform: skewX(-20deg);
}
.btn.primary:hover, .btn.primary:active { background-color: var(--btn); border-color: var(--btn); color: var(--btn-ink); box-shadow: 0 8px 24px -8px rgba(201, 160, 99, .7); }
.btn.primary:hover::after { animation: shine .75s cubic-bezier(.01, .56, 1, 1); }
@keyframes shine { to { left: -200%; } }

.btn.danger { color: var(--bad); border-color: var(--bad); background-image: linear-gradient(var(--bad), var(--bad)); }
.btn.danger:hover { color: #fff; border-color: var(--bad); box-shadow: none; }
.btn.ghost { background-image: none; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { color: var(--ink); background-color: var(--soft); box-shadow: none; }
.btn.sm { min-height: 36px; padding: .3rem .8rem; font-size: .7rem; letter-spacing: .14em; }
.btn[disabled], .btn[disabled]:hover { opacity: .45; cursor: not-allowed; background-size: 0% 100%; box-shadow: none; }
.btn.primary[disabled]:hover { background-color: var(--btn); border-color: var(--btn); }
.btn.primary[disabled]:hover::after { animation: none; }
.btn.block { width: 100%; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; padding: .18rem .55rem; border-radius: 0; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.var-neg { color: var(--bad); font-weight: 600; }
.var-pos { color: var(--info); font-weight: 600; }
.var-zero { color: var(--good); font-weight: 600; }

.progress { height: 6px; background: var(--soft); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--gold); transition: width .3s; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 0 0 1.1rem; overflow-x: auto; }
.tabs a, .tabs button {
  font: inherit; font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: var(--caps);
  background: none; border: 0; border-bottom: 2px solid transparent; padding: .7rem .9rem; color: var(--muted); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs .on { color: var(--ink); border-bottom-color: var(--gold); }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { font: inherit; font-size: .8rem; font-weight: 500; border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px; padding: .32rem .85rem; cursor: pointer; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- tables / lists ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: var(--caps); color: var(--muted); padding: .7rem .9rem; border-bottom: 1px solid var(--line); background: var(--soft); position: sticky; top: 0; }
.table td { padding: .75rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--soft); }
.scroll { overflow-x: auto; }
.item-title { font-weight: 600; }
.item-sub { font-size: .8rem; color: var(--muted); }
@media (max-width: 720px) {
  .table.stack-sm thead { display: none; }
  .table.stack-sm, .table.stack-sm tbody, .table.stack-sm tr, .table.stack-sm td { display: block; width: 100%; }
  .table.stack-sm tr { padding: .75rem .9rem; border-bottom: 1px solid var(--line); }
  .table.stack-sm td { border: 0; padding: .1rem 0; }
  .table.stack-sm td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .78rem; }
  .brand { gap: .55rem; --scale: .8; }
  .brand .logo + .sublogo { padding-left: .55rem; }
  .topbar-in { gap: .8rem; }
  h1 { font-size: 1.6rem; }
}

/* ---------- overlays ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); padding: 0; width: min(520px, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(30, 27, 24, .25); }
dialog::backdrop { background: rgba(243, 201, 188, .6); }
dialog .dlg-head { padding: 1.2rem 1.3rem .4rem; }
dialog .dlg-body { padding: .4rem 1.3rem 1.1rem; }
dialog .dlg-foot { padding: .9rem 1.3rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; left: 0; right: 0; bottom: 1rem; display: flex; flex-direction: column; align-items: center; gap: .5rem; z-index: 50; pointer-events: none; padding: 0 1rem; }
.toast { background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: var(--radius); box-shadow: 0 6px 24px rgba(30, 27, 24, .25); max-width: 520px; pointer-events: auto; font-weight: 500; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.good { background: var(--good); color: #fff; }
.banner { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; background: var(--warn-soft); color: var(--warn); font-weight: 500; border-left: 3px solid currentColor; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--info-soft); color: var(--info); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--gold); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.auth { max-width: 420px; margin: 7vh auto 0; padding: 0 1rem; }
.auth .card { padding: 1.8rem 1.6rem; border-top: 3px solid var(--gold); }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: .9rem; margin: 0 0 1.4rem; }
.auth-logo { --logo-h: 64px; --name-fs: 1.5rem; --by-fs: .8rem; --scale: 1; }
.auth-logo.logo-small { --logo-h: 44px; } .auth-logo.logo-large { --logo-h: 88px; }
.auth-logo.name-small { --name-fs: 1.15rem; --by-fs: .7rem; } .auth-logo.name-large { --name-fs: 1.9rem; --by-fs: .95rem; }
.auth-logo .sublogo { align-items: center; }
.auth-logo .logo + .sublogo { padding-top: .9rem; border-top: 1px solid var(--line); min-width: 60%; }
.auth h1 { margin-bottom: .2rem; text-align: center; }
.auth .sub { color: var(--muted); margin-bottom: 1.4rem; text-align: center; }

/* ---------- charts (hand-drawn SVG, see public/charts.js) ---------- */
:root {
  /* Series colours, in order. Picked from the brand palette and checked against --card. */
  --c1: #A57F45;  /* deep gold */
  --c2: #3D5A7A;  /* slate blue  (= --info) */
  --c3: #3C6B4A;  /* green       (= --good) */
  --c4: #8C5A6E;  /* plum */
  --c5: #6E6258;  /* taupe       (= --muted) */
  --c6: #C08457;  /* copper */
  --grid: #EADFD3;
}
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--line); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.prev { stroke-dasharray: 4 4; opacity: .55; }
.chart .bar:hover, .chart .pt:hover { opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .78rem; color: var(--muted); margin-top: .5rem; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: .35rem; vertical-align: -1px; }
.chart-tip { position: fixed; z-index: 40; pointer-events: none; background: var(--ink); color: var(--bg); font-size: .78rem; padding: .4rem .6rem; border-radius: var(--radius); white-space: nowrap; }
.widget { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.widget-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.widget-head h3 { margin: 0; }
.delta { font-size: .78rem; font-weight: 600; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--muted); }
.grid.widgets { grid-template-columns: repeat(12, 1fr); }
.grid.widgets > .w-3 { grid-column: span 3; } .grid.widgets > .w-4 { grid-column: span 4; }
.grid.widgets > .w-6 { grid-column: span 6; } .grid.widgets > .w-12 { grid-column: span 12; }
@media (max-width: 900px) { .grid.widgets > .w-3 { grid-column: span 6; } .grid.widgets > .w-4, .grid.widgets > .w-6 { grid-column: span 12; } }
@media (max-width: 520px) { .grid.widgets > .w-3 { grid-column: span 12; } }

/* ---------- access grid (who can do what on a report) ---------- */
.access th.c, .access td.c { text-align: center; width: 5.5rem; }
.access input[type=checkbox] { width: 20px; height: 20px; }
.access tr.owner td { color: var(--muted); }
@media (max-width: 720px) {
  .access.stack-sm td.c { display: inline-flex; width: auto; gap: .35rem; align-items: center; margin-right: 1rem; padding: .35rem 0; }
  .access.stack-sm td.c[data-l]::before { content: attr(data-l); color: var(--ink); font-size: .8rem; order: 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}

/* ---------- templates gallery ---------- */
.tpl-card h3 { margin-bottom: .2rem; }
.tpl-card details summary { cursor: pointer; color: var(--accent); font-size: .85rem; font-weight: 600; }
.tpl-list { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .88rem; }
.tpl-list li + li { margin-top: .2rem; }
a.card.choice h2 { margin-bottom: 0; }
a.card.choice p { margin: 0; }
a.card.choice .btn { align-self: flex-start; }
a.card.choice { display: flex; flex-direction: column; }
.new-grid { align-items: start; }

/* ---------- Settings → Shopify data ---------- */
.facts { gap: .8rem 1.5rem; }
.facts .eyebrow { margin-bottom: .1rem; }
.progress.indeterminate > i { width: 35%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }

/* ---------- report page: controls, widgets, charts (Stage 4) ---------- */
/* Report bar: Dates · Compare · Location · Filters on one line, Save as PDF (▾ Download CSV) on the right.
   Phones: a two-column grid with labels above, Location and the buttons full width. */
.report-bar { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.controls { display: flex; flex-direction: column; gap: .6rem; min-width: 0; flex: 1 1 auto; }
.controls-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.ctl { display: inline-flex; align-items: center; gap: .45rem; min-width: 0; }
.ctl-l { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.ctl select { width: auto; max-width: 15rem; min-height: 36px; padding: .3rem .6rem; text-overflow: ellipsis; }
.ctl-btns { display: flex; gap: .5rem; }
.controls .custom-dates input { width: auto; min-height: 36px; }
.export-btns { flex: none; }

/* Split button + its small menu */
.split { display: inline-flex; position: relative; }
.split > .btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-more > summary { list-style: none; border-left: 0; border-radius: 0 var(--btn-radius) var(--btn-radius) 0; padding: .3rem .65rem; height: 100%; }
.split-more > summary::-webkit-details-marker { display: none; }
.split-more > summary > span { font-size: 1rem; line-height: 1; }
.split-more[open] > summary { background-size: 100% 100%; border-color: var(--gold); color: var(--btn-ink); }
.split-more .menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 12rem; padding: .25rem 0; background: var(--card); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(30, 27, 24, .12); }
.menu-item { display: flex; align-items: center; min-height: 44px; padding: 0 1rem; color: var(--ink); text-decoration: none; font-size: .85rem; white-space: nowrap; }
.menu-item:hover, .menu-item:focus-visible { background: var(--soft); }

@media (max-width: 720px) {
  .report-bar { flex-direction: column; align-items: stretch; }
  .controls-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
  .ctl { flex-direction: column; align-items: stretch; gap: .25rem; }
  .ctl-l { font-size: .75rem; }
  .ctl select { width: 100%; max-width: none; min-height: 44px; }
  .ctl-loc, .ctl-btns { grid-column: 1 / -1; }
  .ctl-btns > .btn { flex: 1 1 0; min-height: 44px; }
  .controls .custom-dates { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .5rem; align-items: center; }
  .controls .custom-dates input { width: 100%; min-height: 44px; }
  .controls .custom-dates .btn { grid-column: 1 / -1; min-height: 44px; }
  .split { width: 100%; }
  .split > .btn { flex: 1 1 auto; min-height: 44px; }
  .split-more > summary { min-height: 44px; min-width: 48px; display: flex; align-items: center; justify-content: center; }
  .split-more .menu { left: 0; right: 0; }
}
.caption { margin: .2rem 0 1rem; font-size: .85rem; }
.widgets-box { position: relative; transition: opacity .2s; }
.widgets-box.loading { opacity: .45; pointer-events: none; }
.widget { padding: 1rem 1.1rem; }
.widget-head h3 { font-size: 1.05rem; }
.kpi-n { font-family: var(--serif); font-size: 2.1rem; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.kpi-sub { font-size: .8rem; display: flex; flex-wrap: wrap; gap: .1rem .3rem; align-items: baseline; }
.empty-sm { margin: .4rem 0; }
.chart-host { width: 100%; min-height: 40px; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.chart.bars .bar-label { fill: var(--ink); font-size: 12px; }
.chart.bars .bar-value { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart.bars .bar-row:hover .bar { opacity: .8; }
.legend i.key { width: 18px; height: 0; border-top: 2px solid var(--c1); vertical-align: middle; }
.legend i.key.prev { border-top-style: dashed; opacity: .55; }
.chart-tip[hidden] { display: none; }
.chart-tip .tip-head { font-weight: 600; margin-bottom: .1rem; }
.data-table th, .data-table td { padding: .5rem .7rem; }
.data-table tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.data-table th .th-sort { font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.data-table th[aria-sort="ascending"] .th-sort::after { content: " ▲"; }
.data-table th[aria-sort="descending"] .th-sort::after { content: " ▼"; }
.filter-dlg fieldset { border: 1px solid var(--line); padding: .6rem .8rem; margin: 0; }
.filter-dlg legend { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: var(--caps); color: var(--muted); padding: 0 .3rem; }
.filter-list { max-height: 180px; overflow-y: auto; display: grid; gap: .35rem; }
@media (max-width: 720px) {
  .kpi-n { font-size: 1.7rem; }
  .export-btns { width: 100%; }
}

/* ---------- print / save as PDF ----------
   "Save as PDF" should look like the screen: landscape A4 (about the width of the desktop page),
   the same 12-column widget layout, and the cream/gold colours printed as they are. */
@page { size: A4 landscape; margin: 10mm; }
/* Portrait is chosen in the Save as PDF dialog: it puts class "print-portrait" on <html>. */
@page a4portrait { size: A4 portrait; margin: 10mm; }
@media print {
  html.print-portrait .page { page: a4portrait; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .tabs, .report-bar, .toasts, .btn, .pagehead .eyebrow, .status-menu, .chart-tip { display: none !important; }
  .page { padding: 0; max-width: none; }
  .pagehead { margin-bottom: 1rem; }
  /* Small widgets stay whole. Tables may run over several pages (otherwise a long table jumps
     to the next page and leaves the first one empty), with the column names repeated on each page. */
  .widget { break-inside: avoid; }
  .widget.t-table { break-inside: auto; }
  .widget-head { break-after: avoid; }
  .table th { position: static; }
  .table thead { display: table-header-group; }
  /* The Total row once, at the very end (browsers otherwise repeat it on every page). */
  .table tfoot { display: table-row-group; }
  .table tr { break-inside: avoid; }
  .widgets-box.loading { opacity: 1; }
  /* Keep the desktop column widths even if the paper is narrower than the phone/tablet breakpoints. */
  .grid.widgets > .w-3 { grid-column: span 3; } .grid.widgets > .w-4 { grid-column: span 4; }
  .grid.widgets > .w-6 { grid-column: span 6; } .grid.widgets > .w-12 { grid-column: span 12; }
  .scroll { overflow: visible; }
}

/* New report: both choice cards keep their button on the bottom line, so they line up. */
a.card.choice > .btn { margin-top: auto; }
a.card.choice > p { flex: 1 0 auto; margin-bottom: .9rem; }
.tpl-actions { gap: .5rem; }
/* Status menu at the top of a report (people with Edit). */
.status-menu { display: flex; flex-direction: column; gap: .3rem; }
.status-menu > span { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: var(--caps); color: var(--muted); }
.status-menu select { width: auto; min-width: 9rem; }
.report-actions { align-items: flex-end; }
.report-actions .btn.sm { min-height: 44px; }

/* Templates gallery: the same 3 columns in every category (2 on tablets, 1 on phones), and every
   card laid out top-to-bottom with its buttons on the bottom line, so cards always line up. */
.grid.tpl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
@media (max-width: 1000px) { .grid.tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid.tpl-grid { grid-template-columns: minmax(0, 1fr); } }
.tpl-card { display: flex; flex-direction: column; gap: .8rem; }
.tpl-card .tpl-body { flex: 1 0 auto; display: flex; flex-direction: column; gap: .3rem; }
.tpl-card .tpl-body h3 { margin: 0; }
.tpl-card .tpl-meta { margin-top: auto; padding-top: .3rem; }
.tpl-card .tpl-actions { display: grid; gap: .5rem; }
.tpl-card .tpl-actions .btn { width: 100%; }

/* Spacing helpers (instead of inline style attributes). Two steps only:
   1rem between a block and its action row, 1.5rem between sections. */
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.mt-section, .card.mt-section { margin-top: 1.5rem; }
.mb-section { margin-bottom: 1.5rem; }
.spacer { height: 1.5rem; }

.scope-list { margin-top: .8rem; }
.scope-list summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.scope-list .table { margin-top: .5rem; }
