/* Urban Greens dashboard: base, layout and components.
   Phone first. Breakpoints (see docs/ui-components.md):
     < 481px   phone: sticky header, sticky bottom tab bar, 22px side padding, single column
     >= 481px  tablet/desktop structure: top nav, centred container, page header, grids stacked
     >= 900px  two-column grids and the four-column KPI strip (spec section 14.3)
     >= 1024px the full desktop gutter (44px) and larger type
   No shadows, no transitions, no animations. 1px hairlines only. */

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/InstrumentSans-variable.woff2") format("woff2");
}
@font-face {
  font-family: "Instrument Sans";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/InstrumentSans-italic.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/IBMPlexMono-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/IBMPlexMono-500.woff2") format("woff2");
}
/* Left and right arrows (U+2190, U+2192) are not in the latin subsets above. */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/InstrumentSans-arrows.woff2") format("woff2");
  unicode-range: U+2190, U+2192;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("fonts/IBMPlexMono-arrows.woff2") format("woff2");
  unicode-range: U+2190, U+2192;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ug-surface);
  color: var(--ug-ink-body);
  font-family: var(--ug-font-sans);
  font-size: 14px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  --pad-x: var(--ug-phone-pad-x);
}
a {
  color: var(--ug-link);
  text-decoration: none;
}
a:hover {
  color: var(--ug-link-hover);
}
:focus-visible {
  outline: 2px solid var(--ug-link);
  outline-offset: 2px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
svg {
  display: block;
  max-width: 100%;
}
.mono {
  font-family: var(--ug-font-mono);
}
.num {
  font-variant-numeric: tabular-nums;
}
.tone-good {
  color: var(--ug-good);
}
.tone-bad {
  color: var(--ug-bad);
}
.tone-warn {
  color: var(--ug-warn);
}
.tone-muted {
  color: var(--ug-ink-muted);
}

/* ---------- Shell: phone header, tab bar, desktop nav ---------- */

.badge-example {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 7px;
  border: 1px solid var(--ug-badge-border);
  border-radius: var(--ug-r-pill);
  background: var(--ug-badge-bg);
  white-space: nowrap;
}
.badge-example::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ug-badge-dot);
}
.badge-example span {
  font-family: var(--ug-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.07em;
  color: var(--ug-badge-text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ug-brand);
  flex-shrink: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 20px var(--ug-phone-pad-x) 12px;
  background: var(--ug-surface);
  border-bottom: 1px solid var(--ug-line-divider);
}
.app-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ug-ink-title);
}

.app-main {
  flex: 1;
  padding: 22px var(--pad-x) 34px;
  width: 100%;
}

.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  background: var(--ug-surface);
  border-top: 1px solid var(--ug-line-divider);
}
.tabbar a {
  flex: 1;
  padding: 15px 10px 22px;
  text-align: center;
  border-top: 2px solid transparent;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ug-ink-tab-off);
}
.tabbar a:hover {
  background: var(--ug-panel);
}
.tabbar a[aria-current="page"] {
  border-top-color: var(--ug-nav-active);
  color: var(--ug-ink-name);
}

.top-nav {
  display: none;
  background: var(--ug-surface);
  border-bottom: 1px solid var(--ug-line-divider);
}
.top-nav-inner {
  max-width: var(--ug-desk-max);
  margin: 0 auto;
  padding: 0 var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.top-nav-left {
  display: flex;
  align-items: center;
  gap: 40px;
}
.top-nav .brand {
  padding: 16px 0;
}
.top-nav .brand-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ug-ink-title);
}
.top-nav-tabs {
  display: flex;
  gap: 26px;
}
.top-nav-tabs a {
  padding: 17px 0 14px;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--ug-ink-tab-off);
}
.top-nav-tabs a:hover {
  color: var(--ug-ink-name);
}
.top-nav-tabs a[aria-current="page"] {
  border-bottom-color: var(--ug-nav-active);
  color: var(--ug-ink-name);
}
.top-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ug-avatar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ug-font-mono);
  font-size: 9.5px;
  color: var(--ug-avatar-text);
}

.container {
  width: 100%;
  max-width: var(--ug-desk-max);
  margin: 0 auto;
}

/* Page header (desktop and tablet only; on phone the title lives in the sticky header). */
.page-head {
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding: 36px 0 24px;
}
.page-head-text {
  display: grid;
  gap: 6px;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ug-ink-heading);
}
.page-sub {
  font-size: 13px;
  color: var(--ug-ink-note);
}

.btn-outline {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--ug-line-chip-off);
  background: transparent;
  font-family: var(--ug-font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ug-link);
  cursor: pointer;
}
.btn-outline:hover {
  background: var(--ug-panel);
}
.link-mono {
  font-family: var(--ug-font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--ug-line-link);
}
.back-link {
  display: inline-block;
  font-family: var(--ug-font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}
.btn {
  display: inline-block;
  padding: 11px 18px;
  border: 1px solid var(--ug-forest);
  border-radius: var(--ug-r-seg);
  background: var(--ug-forest);
  color: var(--ug-on-forest);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover {
  background: var(--ug-forest-hover);
  border-color: var(--ug-forest-hover);
  color: var(--ug-on-forest);
}
.btn-quiet {
  background: transparent;
  color: var(--ug-ink-title);
  border-color: var(--ug-line-chip-off);
}
.btn-quiet:hover {
  background: var(--ug-panel);
  color: var(--ug-ink-title);
  border-color: var(--ug-line-chip-off);
}

/* ---------- Typography helpers ---------- */

.eyebrow {
  font-family: var(--ug-font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ug-ink-muted);
}
.caveat {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.45;
  font-style: italic;
  color: var(--ug-ink-caveat);
}
.caveat-faint {
  color: var(--ug-ink-faint);
}

/* ---------- Section header ---------- */

.section {
  padding-top: 28px;
}
.section:first-child {
  padding-top: 0;
}
.sec-head {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}
.sec-head-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.sec-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ug-ink-title);
}
.sec-eyebrow {
  font-family: var(--ug-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ug-ink-faint);
}
.sec-sub {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ug-ink-sub);
}

/* ---------- KPI strip: headline and metric rows ---------- */

.kpi-strip {
  display: grid;
  gap: 18px;
}
.kpi-label {
  font-size: 13.5px;
  color: var(--ug-ink-label);
}
.kpi-hero {
  display: grid;
  gap: 6px;
}
.kpi-hero .kpi-label {
  font-size: 12.5px;
  color: var(--ug-ink-secondary);
}
.kpi-hero .kpi-value {
  font-size: 52px;
  line-height: 0.9;
  font-weight: 600;
  letter-spacing: -0.035em;
  color: var(--ug-ink-heading);
}
.kpi-hero .kpi-delta-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 4px;
}
.kpi-hero .kpi-delta {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.kpi-aside {
  font-size: 13px;
  color: var(--ug-ink-subtle);
}
.kpi-note {
  font-size: 12px;
  font-style: italic;
  color: var(--ug-ink-faint);
}
.kpi {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}
.kpi-value {
  font-size: 17px;
  font-weight: 600;
  color: var(--ug-ink-heading);
}
.kpi-delta {
  font-size: 12.5px;
  width: 96px;
  text-align: right;
}
.kpi-rule {
  height: 1px;
  background: var(--ug-line-divider);
  margin: 26px 0 20px;
}

.leader {
  flex: 1;
  min-width: 12px;
  border-bottom: 1px dotted var(--ug-line-leader);
  transform: translateY(-3px);
}

/* ---------- Leader rows, site rows ---------- */

.lrows {
  display: grid;
}
.leader-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 0;
  border-top: 1px solid var(--ug-line-row-soft);
  color: inherit;
}
.lrows.is-plain .leader-row {
  border-top: 0;
  padding: 0;
}
.lrows.is-plain {
  gap: 11px;
}
a.leader-row:hover {
  background: var(--ug-panel);
  color: inherit;
}
.lr-label {
  font-size: 13px;
  color: var(--ug-ink-body);
}
.lr-label.is-mono {
  font-family: var(--ug-font-mono);
  font-size: 10.5px;
  color: var(--ug-ink-muted);
}
.lr-value {
  font-size: 13px;
  color: var(--ug-ink-subtle);
}
.lr-strong {
  font-size: 13.5px;
  font-weight: 600;
  min-width: 40px;
  text-align: right;
  color: var(--ug-ink-figure);
}
.lr-delta {
  font-size: 13.5px;
  min-width: 52px;
  text-align: right;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: var(--ug-r-seg);
  flex-shrink: 0;
  background: var(--ug-prod-salads);
}
.lrows span.swatch.seg-0 {
  background: var(--ug-prod-salads);
}
.lrows span.swatch.seg-1 {
  background: var(--ug-prod-bowls);
}
.lrows span.swatch.seg-2 {
  background: var(--ug-prod-trays);
}
.lrows span.swatch.seg-3 {
  background: var(--ug-prod-breakfast);
}
.lrows span.swatch.seg-4 {
  background: var(--ug-prod-drinks);
}
span.swatch.sw-sales {
  background: var(--ug-series-sales);
}
span.swatch.sw-labour {
  background: var(--ug-series-labour);
}
span.swatch.sw-wastage {
  background: var(--ug-series-wastage);
}
span.swatch.sw-food {
  background: var(--ug-series-food);
}
span.swatch.sw-price {
  background: var(--ug-series-price);
}
span.swatch.sw-spend {
  background: var(--ug-series-spend);
}
span.swatch.sw-share {
  background: var(--ug-series-share);
}

.site-list {
  display: grid;
}
.site-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 2px;
  border-top: 1px solid var(--ug-line-row);
  color: inherit;
}
.site-row:hover {
  background: var(--ug-panel);
  color: inherit;
}
.site-row-name {
  display: grid;
  gap: 3px;
}
.site-row-name strong {
  font-size: 14.5px;
  font-weight: 400;
  color: var(--ug-ink-name);
}
.site-note {
  font-size: 11px;
  color: var(--ug-ink-caveat);
}
.site-figures {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.site-sales {
  font-size: 14px;
  color: var(--ug-ink-value);
}
.site-variance {
  font-size: 14px;
  font-weight: 600;
  width: 54px;
  text-align: right;
}
.site-row .state {
  margin-left: 6px;
}

/* ---------- Stacked bars and legends (SVG comes from web.charts) ---------- */

.bar-block {
  display: grid;
  gap: 10px;
}
/* ---------- Chart frame, period tabs, series chips ---------- */

.chart-frame {
  position: relative;
}
.chart-frame svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.seg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  margin-bottom: 14px;
  background: var(--ug-canvas);
  border-radius: var(--ug-r-track);
}
.seg-tab {
  flex: 1;
  min-width: 62px;
  padding: 7px 4px;
  border: 1px solid transparent;
  border-radius: var(--ug-r-seg);
  text-align: center;
  font-family: var(--ug-font-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ug-ink-muted);
}
.seg-tab:hover {
  color: var(--ug-ink-heading);
}
.seg-tab[aria-current="true"] {
  background: var(--ug-surface);
  border-color: var(--ug-line-seg-on);
  color: var(--ug-ink-heading);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--ug-line-chip-off);
  border-radius: var(--ug-r-pill);
  background: transparent;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ug-ink-muted);
  cursor: pointer;
}
.chip .swatch {
  width: 7px;
  height: 7px;
}
.chip:hover {
  color: var(--ug-ink-heading);
  background: var(--ug-panel);
}
.chip[aria-pressed="true"],
.chip[aria-pressed="true"]:hover {
  background: var(--ug-forest);
  border-color: var(--ug-forest);
  color: var(--ug-on-forest);
}

.empty {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
  padding: 28px 20px;
  background: var(--ug-empty);
  border: 1px dashed var(--ug-line-chip-off);
}
.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ug-good-soft);
}
.empty-body {
  max-width: 260px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ug-ink-subtle);
}
.empty.is-plain {
  min-height: 224px;
  align-content: center;
  border-color: var(--ug-line-dashed);
}
.empty.is-plain .empty-title {
  font-size: 12px;
  font-weight: 400;
  color: var(--ug-ink-subtle);
}

/* ---------- Green block: flags and suggestions ---------- */

.green-block {
  margin: 30px calc(-1 * var(--pad-x)) 0;
  padding: 24px var(--pad-x) 26px;
  background: var(--ug-forest);
  color: var(--ug-on-forest);
}
.green-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}
.green-title {
  font-family: var(--ug-font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ug-on-forest-label);
}
.green-count {
  font-family: var(--ug-font-mono);
  font-size: 10px;
  color: var(--ug-on-forest-count);
}
.green-items {
  display: grid;
  gap: 16px;
}
.flag-item {
  display: grid;
  gap: 6px;
  padding-left: 14px;
  border-left: 2px solid var(--ug-flag-rule);
}
.flag-item.is-suggestion {
  border-left-color: var(--ug-sugg-rule);
}
.flag-eyebrow {
  font-family: var(--ug-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ug-flag-label);
}
.flag-item.is-suggestion .flag-eyebrow {
  color: var(--ug-on-forest-label);
}
.flag-text {
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
.flag-action {
  font-size: 13px;
  line-height: 1.4;
  color: var(--ug-on-forest-act);
  text-wrap: pretty;
}
.flag-meta {
  font-family: var(--ug-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ug-on-forest-meta);
}
.green-note {
  margin-top: 20px;
  padding-top: 0;
  font-size: 11.5px;
  line-height: 1.45;
  font-style: italic;
  color: var(--ug-on-forest-note);
}
.green-empty {
  font-size: 14px;
  color: var(--ug-on-forest-note);
}
.card-forest {
  display: block;
  padding: 20px;
  background: var(--ug-forest);
  color: var(--ug-on-forest);
}
.card-forest:hover {
  background: var(--ug-forest-hover);
  color: var(--ug-on-forest);
}

/* ---------- Tiles, callout, status panel, data-status rows ---------- */

.tiles {
  display: flex;
  gap: 8px;
}
.tile {
  flex: 1;
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 12px 6px;
  background: var(--ug-tile);
  border-radius: var(--ug-r-tile);
}
.tile-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--ug-ink-figure);
}
.tile-label {
  font-family: var(--ug-font-mono);
  font-size: 9px;
  color: var(--ug-ink-faint);
}
.tiles-note {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ug-ink-muted);
}

.callout {
  padding: 16px 16px 17px;
  background: var(--ug-panel);
  border-left: 2px solid var(--ug-brand);
}
.callout.is-warn {
  padding: 18px 18px 20px;
  border-left-color: var(--ug-warn-rule);
}
.callout-eyebrow {
  margin-bottom: 10px;
  font-family: var(--ug-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ug-warn-ink);
}
.callout-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ug-ink-callout);
  text-wrap: pretty;
}
.callout.is-warn .callout-body {
  line-height: 1.55;
  color: var(--ug-ink-body);
}

.status-list {
  display: grid;
}
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--ug-line-row-soft);
}
.status-name {
  display: grid;
  gap: 3px;
}
.status-name strong {
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ug-ink-site);
}
.status-rhythm {
  font-size: 11px;
  color: var(--ug-ink-caveat);
}
.status-state {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ug-live-dot);
  flex-shrink: 0;
}
.status-text {
  font-size: 12px;
  max-width: 140px;
  text-align: right;
  color: var(--ug-ink-secondary);
}
.status-row.is-pending .status-dot,
.status-row.is-problem .status-dot {
  background: var(--ug-pending-dot);
}
.status-row.is-pending .status-text,
.status-row.is-problem .status-text {
  color: var(--ug-warn);
}
.status-row.is-live .status-text {
  color: var(--ug-good);
}
.status-note {
  grid-column: 1 / -1;
  font-size: 11px;
  font-style: italic;
  color: var(--ug-ink-caveat);
}

/* ---------- Metric state markers (spec section 14.4) ---------- */

.state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--ug-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  color: var(--ug-warn);
}
.state::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ug-pending-dot);
}
.state-restated {
  color: var(--ug-ink-secondary);
}
.state-restated::before {
  background: var(--ug-ink-faint);
}
a.state-gap {
  color: var(--ug-bad);
  border-bottom: 1px solid var(--ug-line-link);
}
a.state-gap::before {
  background: var(--ug-bad);
}
.state-estimated,
.state-partial-history,
.state-no-budget {
  font-family: var(--ug-font-sans);
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0;
  color: var(--ug-ink-caveat);
}
.state-estimated::before,
.state-partial-history::before,
.state-no-budget::before {
  display: none;
}
.states {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
}
.state-note {
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--ug-warn-rule);
  font-size: 12px;
  font-style: italic;
  color: var(--ug-ink-secondary);
}
details.reason {
  display: inline-block;
}
details.reason summary {
  display: inline;
  cursor: pointer;
  list-style: none;
  color: var(--ug-ink-faint);
}
details.reason summary::-webkit-details-marker {
  display: none;
}
details.reason .reason-text {
  display: block;
  margin-top: 4px;
  max-width: 260px;
  font-size: 11px;
  font-weight: 400;
  font-style: italic;
  line-height: 1.4;
  color: var(--ug-ink-caveat);
}

/* ---------- Tables (Marketing spend next to revenue) ---------- */

.tbl-row {
  display: grid;
  grid-template-columns: 1fr 68px 76px 52px;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--ug-line-row-end);
  font-size: 13px;
  color: var(--ug-ink-value);
}
.tbl-row > :not(:first-child) {
  text-align: right;
}
.tbl-row > :first-child,
.tbl-row > :last-child {
  color: var(--ug-ink-site);
}
.tbl-head {
  padding: 0 0 9px;
  border-bottom: 1px solid var(--ug-line-head);
  font-family: var(--ug-font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ug-ink-faint);
}
.tbl-head > :first-child,
.tbl-head > :last-child {
  color: var(--ug-ink-faint);
}

/* ---------- Per-screen grids: stacked below 900px ---------- */

.cols {
  display: grid;
  gap: 0;
}
.col {
  min-width: 0;
}
.green-block.is-wide .green-items {
  grid-template-columns: 1fr;
}

/* ---------- Auth pages ---------- */

body.auth {
  background: var(--ug-surface);
}
.auth-main {
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  padding: 10vh 22px 40px;
}
.auth-main .brand {
  margin-bottom: 28px;
}
.auth-main .brand-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ug-ink-title);
}
.auth-main h1 {
  margin-bottom: 18px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ug-ink-heading);
}
.auth-main p {
  margin-bottom: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ug-ink-body);
}
.auth-main label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--ug-ink-secondary);
}
.auth-main input[type="email"] {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--ug-line-chip-off);
  border-radius: var(--ug-r-seg);
  background: var(--ug-surface);
  font: inherit;
  font-size: 15px;
  color: var(--ug-ink-heading);
}
.auth-main button {
  margin-top: 14px;
  padding: 11px 18px;
  border: 1px solid var(--ug-forest);
  border-radius: var(--ug-r-seg);
  background: var(--ug-forest);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ug-on-forest);
  cursor: pointer;
}
.auth-main button:hover {
  background: var(--ug-forest-hover);
}
.auth-main .note {
  font-size: 12px;
  color: var(--ug-ink-muted);
}
.auth-main .error {
  padding: 10px 0 10px 12px;
  border-left: 2px solid var(--ug-bad);
  font-weight: 600;
  color: var(--ug-bad);
}

/* ---------- Tablet and desktop structure (>= 481px) ---------- */

@media (min-width: 481px) {
  body {
    --pad-x: var(--ug-tablet-pad-x);
  }
  .app-header,
  .tabbar {
    display: none;
  }
  .top-nav {
    display: block;
  }
  .app-main {
    max-width: calc(var(--ug-desk-max) + 2 * var(--pad-x));
    margin: 0 auto;
    padding: 0 var(--pad-x) 72px;
  }
  .page-head {
    display: flex;
  }
  .green-block {
    margin: 0;
    padding: 24px 26px 26px;
  }
  .kpi-hero .kpi-value {
    font-size: 60px;
    line-height: 0.85;
    letter-spacing: -0.04em;
  }
  .sec-title {
    font-size: 16px;
    letter-spacing: -0.015em;
    color: var(--ug-ink-name);
  }
  .sec-sub {
    font-size: 12.5px;
    color: var(--ug-ink-hist);
  }
  .auth-main {
    padding-top: 14vh;
  }
}

/* ---------- Two columns (>= 900px, spec section 14.3) ---------- */

@media (min-width: 900px) {
  .kpi-strip {
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 0;
    border-top: 1px solid var(--ug-line-strong);
    border-bottom: 1px solid var(--ug-line-row);
  }
  .kpi-strip > * {
    padding: 26px 30px 28px;
    align-content: start;
  }
  .kpi-strip > :first-child {
    padding-left: 0;
  }
  .kpi-strip > :last-child {
    padding-right: 0;
  }
  .kpi-strip > :not(:first-child) {
    border-left: 1px solid var(--ug-line-row);
  }
  .kpi {
    display: grid;
    gap: 10px;
  }
  .kpi .leader {
    display: none;
  }
  .kpi .kpi-label {
    font-size: 12.5px;
    color: var(--ug-ink-kpi-label);
  }
  .kpi .kpi-value {
    font-size: 34px;
    line-height: 0.9;
    letter-spacing: -0.03em;
  }
  .kpi .kpi-delta {
    width: auto;
    text-align: left;
    font-size: 13px;
  }
  .kpi-hero .kpi-label {
    font-size: 12.5px;
    color: var(--ug-ink-kpi-label);
  }
  .kpi-hero {
    gap: 10px;
  }
  .kpi-hero .kpi-aside,
  .kpi-hero .kpi-note {
    display: none;
  }
  .kpi-rule {
    display: none;
  }
  .cols {
    grid-template-columns: 1.55fr 1fr;
    column-gap: 56px;
    align-items: start;
  }
  .cols-site {
    grid-template-columns: 1.3fr 1fr;
    column-gap: 44px;
  }
  .cols-marketing {
    grid-template-columns: 1.3fr 1fr;
    column-gap: 56px;
  }
  .cols-theme {
    grid-template-columns: 1.4fr 1fr;
    column-gap: 48px;
  }
  .green-block.is-wide .green-items {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px 36px;
  }
  .flag-text {
    font-size: 16px;
  }
}

/* ---------- Full desktop (>= 1024px) ---------- */

@media (min-width: 1024px) {
  body {
    --pad-x: var(--ug-desk-pad-x);
  }
  .page-title {
    font-size: 24px;
  }
}

/* ======================================================================================
   Pages (Task 1.4): group, site, marketing, attribution, status, no publication.
   Phone first; the same breakpoints as above.
   ====================================================================================== */

.only-desktop {
  display: none;
}
.phone-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.stale-note {
  margin: 0 0 18px;
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--ug-warn-rule);
  font-size: 12px;
  font-style: italic;
  color: var(--ug-ink-secondary);
}
.kpi-hero-wrap,
.kpi-cell {
  display: grid;
  gap: 8px;
  align-content: start;
}
.kpi-budget-note {
  font-size: 11.5px;
  font-style: italic;
  color: var(--ug-ink-caveat);
}

/* History section */
.history {
  padding-top: 34px;
}
.history-head {
  display: grid;
  gap: 4px;
}
.history-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
}
.history-controls .chips {
  margin-bottom: 14px;
}
.view-switch {
  margin-bottom: 14px;
}

/* Two-column pages: the side column (flags) comes first on phone, second from 900 px. */
.col-side .green-block {
  margin-top: 30px;
}
.by-site {
  margin-top: 22px;
}

/* Flags block groups */
.flag-group {
  display: grid;
  gap: 16px;
  align-content: start;
}
.flag-group-title {
  font-family: var(--ug-font-mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ug-on-forest-count);
}
.domain-lines {
  margin: 0;
  padding: 14px 0 0;
  list-style: none;
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--ug-forest-rule);
  font-size: 12px;
  color: var(--ug-on-forest-note);
}
.green-block.is-wide .domain-lines {
  grid-column: 1 / -1;
}

/* Site, status and attribution headers */
.site-top {
  display: grid;
  gap: 14px;
  padding: 0 0 20px;
}
.site-head {
  display: grid;
  gap: 18px;
}
.site-head-text {
  display: grid;
  gap: 6px;
}
.site-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--ug-ink-heading);
}
.site-wtd {
  display: grid;
  gap: 8px;
}
.site-wtd-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.site-wtd-value {
  font-size: 34px;
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--ug-ink-heading);
}
.site-wtd-side {
  display: grid;
  gap: 2px;
}
.site-wtd-variance {
  font-size: 18px;
  font-weight: 600;
}
.site-wtd-budget {
  font-size: 11.5px;
  color: var(--ug-ink-muted);
}
.site-top + .green-block {
  margin-top: 0;
}

/* Marketing */
.tbl {
  display: grid;
}
.two-up {
  display: grid;
  gap: 0 36px;
}
.platform-rows {
  margin-top: 14px;
}
.loyalty-rows {
  display: grid;
}
.loyalty-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--ug-line-row-soft);
}
.loyalty-label {
  font-size: 13px;
  color: var(--ug-ink-body);
}
.loyalty-value {
  font-size: 13.5px;
  font-weight: 600;
  text-align: right;
  color: var(--ug-ink-figure);
}
.loyalty-note {
  font-size: 11.5px;
  text-align: right;
  color: var(--ug-ink-muted);
}
.attributed-card {
  display: grid;
  gap: 10px;
  margin-top: 26px;
  padding: 22px;
}
.attributed-eyebrow {
  display: flex;
  justify-content: space-between;
  font-family: var(--ug-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ug-on-forest-label);
}
.attributed-figure {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.attributed-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ug-on-forest-note);
}

/* Attribution */
.attribution .site-title {
  margin-bottom: 6px;
}
.match-hero {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 24px 0 14px;
}
.match-rate {
  font-size: 44px;
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--ug-ink-heading);
}
.match-label {
  font-size: 13px;
  color: var(--ug-ink-secondary);
}
.split-bar {
  margin: 14px 0 16px;
}
.split-bar .seg-0 {
  fill: var(--ug-forest);
}
.split-bar .seg-1 {
  fill: var(--ug-split-uncertain);
  stroke: var(--ug-split-uncertain-edge);
  stroke-dasharray: 3 2;
}
.match-counts .lr-value {
  font-weight: 600;
}
.explain {
  display: grid;
  gap: 12px;
  margin-top: 30px;
  padding: 22px;
  background: var(--ug-panel);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ug-ink-explain);
}

/* Status */
.recon-row {
  border-top: 1px solid var(--ug-line-row-soft);
}
.recon-detail {
  margin: 0 0 10px;
}
.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ug-ink-body);
}
.awaiting {
  margin-top: 18px;
}
.status-flags {
  padding: 4px 0;
}
.skips {
  margin-top: 16px;
  font-size: 12px;
  color: var(--ug-ink-secondary);
}
.skips summary {
  cursor: pointer;
  font-family: var(--ug-font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ug-link);
}
.skips .plain-list {
  margin-top: 10px;
  font-size: 11.5px;
}
.skip-rule {
  font-family: var(--ug-font-mono);
  font-size: 10.5px;
}
.live-strip {
  margin-top: 40px;
  padding: 18px 18px 8px;
  border: 1px solid var(--ug-line-frame);
  background: var(--ug-empty);
}
.live-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 14px;
  margin-bottom: 10px;
}
.live-build {
  margin-bottom: 10px;
}

/* No publication, error, account footer */
.no-publication,
.error-page {
  display: grid;
  gap: 16px;
  padding-top: 8px;
}
.no-publication .site-title {
  display: none;
}
.account-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-top: 48px;
  padding-top: 14px;
  border-top: 1px solid var(--ug-line-row-soft);
  font-size: 11.5px;
  color: var(--ug-ink-muted);
}
.logout-form {
  display: inline;
}
.link-button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ug-link);
  cursor: pointer;
}
.link-button:hover {
  color: var(--ug-link-hover);
}

@media (max-width: 480px) {
  .site-top {
    padding-top: 0;
  }
}

@media (min-width: 481px) {
  .only-phone {
    display: none;
  }
  .only-desktop {
    display: block;
  }
  .phone-bar {
    display: none;
  }
  .stale-note {
    margin-top: 20px;
  }
  .history {
    padding-top: 40px;
  }
  .site-top {
    padding-top: 30px;
  }
  .site-head {
    grid-template-columns: 1fr auto;
    align-items: end;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--ug-line-row);
  }
  .site-title {
    font-size: 30px;
  }
  .site-wtd {
    justify-items: end;
  }
  .site-wtd-value {
    font-size: 40px;
  }
  .two-up {
    grid-template-columns: 1fr 1fr;
  }
  .no-publication .site-title {
    display: block;
  }
}

@media (min-width: 900px) {
  .history-head {
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 24px;
  }
  .history-head .seg-tabs {
    min-width: 280px;
  }
  .cols > .col-side {
    order: 2;
  }
  .col-side .green-block {
    margin-top: 36px;
  }
  .attributed-card {
    margin-top: 30px;
  }
  .explain {
    margin-top: 0;
  }
}

/* Page fixes after the visual check against design/reference/screens (Task 1.4). */
.kpi.kpi-hero {
  display: grid;
  justify-content: stretch;
}
.lbl-long {
  display: none;
}
.kpi .kpi-delta {
  overflow-wrap: anywhere;
}
.cols {
  margin-top: 6px;
}
.cols > .col > .section:first-child {
  padding-top: 30px;
}
@media (min-width: 900px) {
  .green-block.is-wide .green-items {
    grid-template-columns: 1fr;
  }
  .green-block.is-wide .flag-group {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px 36px;
  }
  .green-block.is-wide .flag-group-title,
  .green-block.is-wide .flag-group .green-empty {
    grid-column: 1 / -1;
  }
  .lbl-long {
    display: inline;
  }
  .lbl-short {
    display: none;
  }
  .cols > .col > .section:first-child {
    padding-top: 36px;
  }
}
.two-up > .section,
.two-up > .section:first-child {
  padding-top: 28px;
}

/* Phone KPI strip: the hero variance is not a right-aligned 96px column, the week suffix is
   a quiet tag, and the figures stay on one line like v3. */
.kpi-hero .kpi-delta {
  width: auto;
  text-align: left;
  white-space: nowrap;
}
.kpi-week {
  font-family: var(--ug-font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ug-ink-faint);
}
@media (max-width: 899px) {
  .kpi:not(.kpi-hero) .kpi-delta {
    width: auto;
    max-width: 50%;
  }
}
@media (min-width: 900px) {
  /* Desktop hero: 60px figure and 22px variance (handoff), not the 34px secondary KPI size. */
  .kpi.kpi-hero .kpi-value {
    font-size: 60px;
    line-height: 0.85;
    letter-spacing: -0.04em;
  }
  .kpi.kpi-hero .kpi-delta {
    font-size: 22px;
  }
}
