/* The shell ("inset" layout), loaded after components.css.
   The sidebar has no box of its own: it sits on the frame colour (--frame). The page (.main) is one large rounded panel inside the
   frame, the top bar sits on the panel with no line of its own, and cards are soft: a hairline border plus one quiet shadow.
   Desktop only (1101px and up); below that the existing drawer layout from site.css is kept. Every colour is a token, so the
   five colour themes and light/dark all work without changes here. Preview that this came from: .scratch/ui-overhaul/ocean-preview-v2.html */

:root { --panel-radius: 22px; --card-radius: 16px; }

/* cards: hairline + faint highlight + soft shadow, no lift on hover */
.card, .kpi-card {
  border-radius: var(--card-radius);
  border-color: var(--border);
  box-shadow: var(--shadow-card);
}
.kpi-card:hover { transform: none; box-shadow: var(--shadow-card); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }

/* round controls in the top bar */
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); }
.icon-btn:hover { background: var(--bg-hover); color: var(--t-base); }
.avatar { background: linear-gradient(140deg, var(--primary-light), var(--primary)); color: var(--on-fill); border: 0; box-shadow: 0 2px 8px -2px var(--primary-ring); }
.dd-menu { border-radius: 14px; box-shadow: var(--shadow-lg); }

/* ---- sidebar, top bar and page header: the same on every screen size ---- */
.d-sidebar { gap: 2px; }
.d-sidebar::-webkit-scrollbar { width: 6px; }
.brand { border-bottom: 0; padding: 6px 10px 16px; }
.brand-logo { background: transparent; }
.brand-name { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }
.brand-tag { color: var(--t-light); font-size: 12px; }
.nav-section { gap: 2px; margin-bottom: 4px; }
.nav-label { font-family: var(--font-ui); text-transform: none; letter-spacing: .02em; font-size: 12px; font-weight: 600; color: var(--t-light); padding: 14px 12px 6px; }
.nav-link { border-radius: 10px; font-size: 14px; font-weight: 500; padding: 8px 12px; gap: 11px; color: var(--t-muted); }
.nav-link > svg { width: 18px; height: 18px; color: var(--t-light); fill: none; stroke: currentColor; }
.nav-link:hover { background: color-mix(in srgb, var(--t-base) 6%, transparent); color: var(--t-base); }
.nav-link.is-active {
  background: var(--bg-card); color: var(--t-base); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 42, 67, .08), 0 0 0 1px var(--border);
}
.nav-link.is-active > svg { color: var(--primary); }
.nav-item-group.is-open > .nav-link { color: var(--t-base); }
.nav-submenu { margin-left: 21px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-submenu a { border-radius: 8px; color: var(--t-light); font-size: 13.5px; }
.nav-submenu a:hover { background: color-mix(in srgb, var(--t-base) 6%, transparent); color: var(--t-base); }
.nav-submenu a.is-active { color: var(--primary); font-weight: 600; background: transparent; }
.nav-sub > summary { color: var(--t-light); }
.sidebar-footer { border-top: 0; padding-top: 12px; }
.workspace { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 10px; box-shadow: var(--shadow-card); }
.workspace-avatar { background: linear-gradient(140deg, var(--primary-light), var(--primary)); color: var(--on-fill); border-radius: 50%; }
.d-topbar { background: color-mix(in srgb, var(--bg-body) 86%, transparent); border-bottom: 0; }
.crumbs { font-size: 13px; color: var(--t-light); }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs .crumb { white-space: nowrap; }
.crumbs a.crumb { color: var(--t-light); text-decoration: none; }
.crumbs a.crumb:hover { color: var(--primary); text-decoration: underline; }
.crumbs .sep { flex: none; }
.crumbs .current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--t-base); font-weight: 600; }
.hero { margin: 6px 0 22px; }
.hero-title { letter-spacing: -.02em; }
.hamburger { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); color: var(--t-muted); }

/* ---- desktop (1101px and up): the sidebar sits on the frame, the page is a rounded panel beside it ---- */
@media (min-width: 1101px) {
  body { background: var(--frame); }
  .shell { background: var(--frame); grid-template-columns: 252px minmax(0, 1fr); }
  .d-sidebar { background: transparent; border-right: 0; padding: 16px 12px 12px 16px; }
  .main { background: var(--bg-body); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); border-radius: var(--panel-radius); margin: 12px 12px 12px 0; min-height: calc(100vh - 24px); }
  .d-topbar { border-radius: var(--panel-radius) var(--panel-radius) 0 0; height: 64px; padding: 0 28px; }
  .content { padding: 4px 28px 24px; max-width: 1380px; }
  .d-footer { padding: 16px 28px 20px; }
}

/* ---- tablet and phone (1100px and down): the sidebar is a drawer that slides over the page ---- */
@media (max-width: 1100px) {
  body { background: var(--frame); }
  .shell { background: var(--frame); }
  /* the drawer is a solid sheet in the frame colour with rounded outer corners; the page behind it is dimmed and blurred a little */
  .d-sidebar {
    background: var(--frame); width: min(300px, 86vw); padding: 16px 12px calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-radius: 0 22px 22px 0; border-right: 1px solid var(--border); box-shadow: var(--shadow-lg);
  }
  body.has-drawer-open .drawer-backdrop { backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
  .d-topbar { height: 60px; }
  .hamburger { margin-right: 4px; }
}

/* tablet (721 to 1100px): the page is still a rounded panel on the frame, with a thin margin */
@media (min-width: 721px) and (max-width: 1100px) {
  .main { background: var(--bg-body); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); border-radius: 18px; margin: 10px; min-height: calc(100dvh - 20px); }
  .d-topbar { border-radius: 18px 18px 0 0; padding: 0 20px; }
  .content { padding: 4px 20px 24px; }
  .d-footer { padding: 16px 20px 20px; }
}

/* phone (720px and down): the page fills the screen, no frame showing, content edge to edge with a little air */
@media (max-width: 720px) {
  body { background: var(--bg-body); }
  .main { background: var(--bg-body); border: 0; border-radius: 0; margin: 0; min-height: 100dvh; }
  .d-topbar { border-radius: 0; height: 56px; border-bottom: 1px solid var(--border-soft); backdrop-filter: saturate(140%) blur(10px); -webkit-backdrop-filter: saturate(140%) blur(10px); }
  .crumbs .sep, .crumbs .crumb { display: none; }
  .content { padding-top: 8px; }
  .hero { margin: 4px 0 16px; }
  .card, .kpi-card { border-radius: 14px; }
  .kpi-value { font-size: 28px; }
}

/* ---------- metric cards ---------- */
.kpi-card { padding: 18px 20px 16px; gap: 10px; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--t-muted); }
.kpi-value { font-size: 30px; letter-spacing: -.03em; margin-top: 4px; }
.kpi-card--hero .kpi-value { font-size: 40px; }
.kpi-icon { width: 32px; height: 32px; border-radius: 10px; background: var(--primary); color: var(--on-fill); }
.kpi-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi-icon.primary { background: var(--primary); color: var(--on-fill); }
.kpi-icon.success { background: var(--success); color: var(--on-fill); }
.kpi-icon.info { background: var(--info); color: var(--on-fill); }
.kpi-icon.warning { background: var(--warning); color: var(--on-fill); }
.kpi-icon.danger { background: var(--danger); color: var(--on-fill); }
.kpi-icon.purple { background: var(--purple); color: var(--on-fill); }
.kpi-icon.teal { background: var(--teal); color: var(--on-fill); }
.kpi-icon.orange { background: var(--orange); color: var(--on-fill); }
/* the change against the previous window is a small pill */
.kpi-delta { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; }
.kpi-delta.is-good { background: var(--success-soft); }
.kpi-delta.is-bad { background: var(--danger-soft); }
.kpi-delta.is-flat { background: var(--bg-muted); }
.kpi-compare { border-top: 1px solid var(--border-soft); font-size: 12.5px; }
.sparkline { width: 112px; height: 30px; }
.sparkline-path { stroke-width: 2; }
.sparkline-area { fill: var(--series-s1); opacity: .12; stroke: none; }

/* ---------- tables ---------- */
/* a quieter header (sentence case, no capital letters or wide spacing), soft rows, and the first column reads as the name of the row */
.table thead th { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 500; color: var(--t-light); padding-top: 8px; padding-bottom: 10px; }
.table tbody td { padding-top: 13px; padding-bottom: 13px; }
.table tbody td:first-child { color: var(--t-base); }
.table tbody td:first-child strong, .table tbody td:first-child a { font-weight: 600; }
.table tbody tr:hover td { background: var(--bg-hover); }
.table tbody tr:hover td:first-child { border-radius: 10px 0 0 10px; }
.table tbody tr:hover td:last-child { border-radius: 0 10px 10px 0; }
.table-scroll > .table tbody tr:hover td:first-child { border-radius: 0; }
.th-sort::after { opacity: .35; }
.tag { font-weight: 600; }
/* no vertical rule beside the pinned first column (it showed on tables that do not even scroll) */
.table-scroll > .table tbody td:first-child:not([colspan]) { box-shadow: none; }

/* the group headings inside the Reports menu (Delivery, Campaigns, ...) were 11px at 60% opacity on the frame colour (2.7:1) */
.nav-sub > summary { opacity: 1; color: var(--t-muted); font-size: 12px; }

/* the hidden labels for empty table headers are absolutely positioned; without a positioned parent they sat at the page edge and made it scroll sideways on phones */
.table-scroll { position: relative; }
.table th { position: relative; }

/* ---------- sidebar search button and the page search dialog (palette.js) ---------- */
.cmd-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 10px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--bg-card) 70%, transparent); color: var(--t-light);
  font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.cmd-trigger:hover { background: var(--bg-card); color: var(--t-base); }
.cmd-trigger svg { width: 15px; height: 15px; flex: none; }
.cmd-trigger kbd, .cmdk-help kbd { margin-left: auto; font: 600 11px var(--font-ui); color: var(--t-light); background: var(--bg-muted); border-radius: 5px; padding: 1px 6px; }
.cmd-trigger:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.cmdk { border: 1px solid var(--border); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); margin: 12vh auto auto; background: var(--bg-card); color: var(--t-base); box-shadow: var(--shadow-lg); }
.cmdk::backdrop { background: rgba(8, 19, 30, .45); backdrop-filter: blur(3px); }
.cmdk-input { width: 100%; border: 0; border-bottom: 1px solid var(--border-soft); background: transparent; color: var(--t-base); font: inherit; font-size: 16px; padding: 16px 18px; outline: none; border-radius: 16px 16px 0 0; }
.cmdk-input::placeholder { color: var(--t-light); }
.cmdk-list { list-style: none; margin: 0; padding: 8px; max-height: min(52vh, 420px); overflow-y: auto; }
.cmdk-list a { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--t-base); text-decoration: none; font-size: 14.5px; font-weight: 500; }
.cmdk-list a small { color: var(--t-light); font-size: 12.5px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-list a.is-active { background: var(--primary-soft); color: var(--primary); }
.cmdk-list a.is-active small { color: var(--t-muted); }
.cmdk-empty { margin: 0; padding: 22px 18px; text-align: center; color: var(--t-muted); }
.cmdk-help { display: flex; gap: 16px; margin: 0; padding: 10px 16px; border-top: 1px solid var(--border-soft); color: var(--t-light); font-size: 12px; }
.cmdk-help kbd { margin-left: 0; }

/* ---------- the "Updated" pill in the top bar (dashboard) ---------- */
.d-topbar .live-pill { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--bg-card); color: var(--t-muted); font-size: 12.5px; margin-right: 4px; white-space: nowrap; }
@media (max-width: 720px) { .d-topbar .live-pill { height: 32px; padding: 0 10px; font-size: 12px; } .d-topbar .live-pill #live-updated { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }

/* ---------- name tiles and rate bars in tables ---------- */
.cell-with-tile { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.name-tile { width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center; flex: none; font: 700 11.5px var(--font-display); letter-spacing: 0; }
.nt-0 { background: var(--primary); color: var(--on-fill); }
.nt-1 { background: var(--success); color: var(--on-fill); }
.nt-2 { background: var(--purple); color: var(--on-fill); }
.nt-3 { background: var(--orange); color: var(--on-fill); }
.nt-4 { background: var(--teal); color: var(--on-fill); }
.nt-5 { background: var(--pink); color: var(--on-fill); }
.rate { display: inline-flex; align-items: center; justify-content: flex-start; gap: 10px; white-space: nowrap; }
.rate-track { display: block; width: 56px; height: 6px; border-radius: var(--radius-pill); background: var(--bg-muted); overflow: hidden; flex: none; }
.rate-fill { display: block; height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--primary-light), var(--primary)); }
@media (max-width: 720px) { .rate-track { width: 40px; } }

/* ---------- charts drawn by charts.js (ECharts) ---------- */
.echart { width: 100%; height: 300px; }
.echart svg { display: block; }
.legend-toggle { border: 0; background: transparent; color: var(--t-muted); font: inherit; font-size: 12.5px; padding: 4px 8px; margin: 0 -8px; border-radius: 8px; cursor: pointer; }
.legend-toggle:hover { background: var(--bg-hover); color: var(--t-base); }
.legend-toggle[aria-pressed="false"] { opacity: .5; text-decoration: line-through; }
.legend-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.legend-swatch { border-radius: 50%; width: 9px; height: 9px; }
.chart-tools { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-top: 12px; }
.chart-table { flex: 1; min-width: 0; }
.chart-table > summary { cursor: pointer; color: var(--primary); font-size: 13px; font-weight: 600; list-style: none; padding: 4px 0; }
.chart-table > summary::-webkit-details-marker { display: none; }
.chart-table[open] > summary { margin-bottom: 8px; }
@media (max-width: 720px) { .echart { height: 260px; } .chart-tools { flex-direction: column; align-items: stretch; } }

/* ---------- ranked bars (HTML, kept on purpose: labels can be links and wrap, the text stays selectable and readable without a script) ---------- */
.hbar-row { padding: 6px 8px; margin: 0 -8px; border-radius: 10px; }
.hbar-row:hover { background: var(--bg-hover); }
.hbar-track { height: 10px; border-radius: var(--radius-pill); }
.hbar-fill { border-radius: var(--radius-pill); }
.hbar-value { color: var(--t-base); font-size: 12.5px; font-weight: 600; }
.echart--funnel { height: 330px; }
@media (max-width: 720px) { .echart--funnel { height: 360px; } }
.echart--donut { width: 168px; height: 168px; flex: none; }

/* One authoritative table spacing (the older rules in site.css and components.css disagreed, so headers and cells did not line up and wide tables scrolled for no reason) */
.table thead th, .table tbody td, .table th:last-child, .table td:last-child { padding-left: 12px; padding-right: 12px; }
.kpi-label { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.3; }
/* wide tables (many numeric columns): tighter cells so they fit the card where they can; the rest scrolls inside the card */
.table--wide thead th, .table--wide tbody td, .table--wide th:last-child, .table--wide td:last-child { padding-left: 6px; padding-right: 6px; }
.table--wide tbody td { font-size: 13px; }
.cell-with-tile { white-space: nowrap; }
[hidden] { display: none !important; }
/* the first column stays in view while a wide table scrolls, so it carries the row stripe itself */
.table-scroll > .table tbody tr:nth-child(even) td:first-child { background: color-mix(in oklab, var(--bg-muted) 45%, var(--bg-card)); }
