/* Analytics admin view. Plain CSS on Backoffice's design tokens (tokens.css is a copy of
   apps/backoffice/public/styles/tokens.css); no Tailwind build step in this app. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  color: var(--text-primary);
  background: var(--surface-page);
}
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: var(--weight-semibold); }
h1 { font-size: var(--text-2xl); line-height: var(--leading-2xl); }
h2 { font-size: var(--text-lg); line-height: var(--leading-lg); }
code, .mono { font-family: var(--font-mono); font-size: var(--text-sm); }
.muted { color: var(--text-secondary); }
.small { font-size: var(--text-sm); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Shell ── */
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shell { display: grid; grid-template-columns: var(--sidebar-width, 240px) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  z-index: var(--z-overlay, 40);
}
/* The sidebar's logo block and the page header are the same height, so their bottom borders form one line across the shell. */
:root { --shell-head-h: 96px; }
.sidebar-logo { box-sizing: border-box; height: var(--shell-head-h); padding: 0 var(--sp-5); display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--sidebar-border); }
/* The product mark: "Spotlight" in Monoton, lit by a beam from a stage lamp, with "by NutriPetPlan" small underneath on the right.
   The container (.sidebar-logo, .auth-card__brand) holds the beam, so it clips it. */
.sidebar-logo, .auth-card__brand { position: relative; overflow: hidden; isolation: isolate; }
.bs-beam { position: absolute; z-index: -1; top: 0; left: 50%; width: 92%; height: 100%; transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(255, 241, 190, 0.5) 0%, rgba(255, 241, 190, 0.16) 55%, rgba(255, 241, 190, 0.04) 100%);
  clip-path: polygon(41% 0, 59% 0, 100% 100%, 0 100%); filter: blur(1.5px); }
.bs-floor { position: absolute; z-index: -1; left: 50%; bottom: -14px; width: 78%; height: 40px; transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255, 241, 190, 0.34), transparent 70%); }
.bs-lamp { position: absolute; top: -2px; left: 50%; width: 28px; height: 10px; transform: translateX(-50%);
  background: #ffe9a8; border-radius: 0 0 16px 16px; box-shadow: 0 0 20px 6px rgba(255, 241, 190, 0.7); }
.bs-lockup { position: relative; display: inline-flex; flex-direction: column; align-items: flex-end; gap: 2px; max-width: 100%; }
.bs-word { font-family: "Monoton", Impact, sans-serif; font-size: 1.5rem; line-height: 1.05; white-space: nowrap; padding: 0 0.12em 0.04em;
  background: linear-gradient(180deg, #ffffff 30%, #ffeeb4 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 241, 190, 0.6)); }
.bs-by { display: inline-flex; align-items: center; gap: 4px; font-size: 9px; line-height: 1; color: rgba(255, 255, 255, 0.72); padding-right: 2px; }
.bs-by img { display: block; height: 9px; width: auto; }
.bs-sp { position: absolute; width: 11px; height: 11px; color: #fff3c4; filter: drop-shadow(0 0 4px rgba(255, 241, 190, 0.9)); animation: bs-twinkle 3.2s ease-in-out infinite; }
.bs-sp--a { top: -8px; right: -10px; }
.bs-sp--b { top: 26%; left: -12px; width: 8px; height: 8px; animation-delay: -1.2s; }
.bs-sp--c { bottom: 14px; right: -14px; width: 7px; height: 7px; animation-delay: -2.1s; }
@keyframes bs-twinkle { 0%, 100% { opacity: 0.25; transform: scale(0.7) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(12deg); } }
@media (prefers-reduced-motion: reduce) { .bs-sp { animation: none; opacity: 0.9; } }
.sidebar-user { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: var(--weight-semibold);
}
.sidebar-user__text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user__name { color: #fff; font-size: var(--text-sm); font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user__email { font-size: var(--text-xs); color: var(--sidebar-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-2) var(--sp-2); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding: var(--sp-3) var(--sp-2) var(--sp-4); border-top: 1px solid var(--sidebar-border); }
.sidebar-footer form { margin: 0; }
.sidebar-item {
  position: relative; display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); border: 0; background: none; font: inherit;
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--sidebar-text); cursor: pointer; text-align: left;
}
.sidebar-item:hover { background: var(--sidebar-item-hover); color: var(--sidebar-text-hover); text-decoration: none; }
.sidebar-item.active { background: var(--sidebar-item-active); color: var(--sidebar-text-active); }
.sidebar-item.active::before { content: ""; position: absolute; left: -8px; top: 20%; height: 60%; width: 3px; border-radius: 0 3px 3px 0; background: #fff; }
.sidebar-item.is-soon { opacity: 0.5; cursor: not-allowed; }
.sidebar-item.is-soon:hover { background: none; }
.sidebar-item .soon { margin-left: auto; font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: var(--tracking-wide); padding: 1px 6px; border-radius: var(--r-full); background: #ffc107; color: #3d2f00; }
.sidebar-item--danger:hover { background: rgba(239, 68, 68, 0.2); color: #fecaca; }
/* One of each pair is visible, by theme. */
[data-theme="dark"] .theme-icon-moon, [data-theme="dark"] .theme-label-moon { display: none; }
:root:not([data-theme="dark"]) .theme-icon-sun, :root:not([data-theme="dark"]) .theme-label-sun { display: none; }
.sidebar-overlay { display: none; }
.menu-btn { display: none; background: none; border: 0; padding: var(--sp-1); color: var(--text-primary); cursor: pointer; border-radius: var(--r-md); }
.menu-btn:hover { background: var(--surface-hover); }

.content { min-width: 0; display: flex; flex-direction: column; }
.page-header {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-7);
  background: var(--surface-card); border-bottom: 1px solid var(--border-subtle); box-shadow: var(--shadow-sm);
}
@media (min-width: 901px) { .page-header { box-sizing: border-box; min-height: var(--shell-head-h); } }
.page-header h1 { font-size: var(--text-xl); line-height: var(--leading-xl); }
.page-header__sub { margin: 2px 0 0; font-size: var(--text-sm); color: var(--text-secondary); }
.main { padding: var(--sp-6) var(--sp-7); min-width: 0; display: flex; flex-direction: column; gap: var(--sp-5); flex: 1; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }

/* ── Filter bar ── */
.filters {
  display: flex; flex-wrap: wrap; align-items: end; gap: var(--sp-3);
  background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
}
.filters label { display: flex; flex-direction: column; gap: 2px; font-size: var(--text-xs); color: var(--text-secondary); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.filters input, .filters select {
  font: inherit; font-size: var(--text-sm); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 6px 8px; background: var(--surface);
}
.filters .presets { display: flex; gap: var(--sp-1); flex-wrap: wrap; margin-left: auto; }
.btn {
  display: inline-block; font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium);
  border-radius: var(--r-md); padding: 6px 12px; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.chip { font-size: var(--text-xs); padding: 4px 10px; border-radius: var(--r-full); border: 1px solid var(--border-default); background: var(--surface); color: var(--text-secondary); }
.chip:hover { border-color: var(--brand-muted); color: var(--text-brand); text-decoration: none; }

/* ── Cards, KPIs ── */
.card { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-xs); }
.card > h2 { margin-bottom: var(--sp-3); }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr; }
.kpis { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.kpi { position: relative; background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-xs); }
.kpi .label { font-size: var(--text-xs); color: var(--text-secondary); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.kpi .value { font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.delta-up { color: var(--success); }
.delta-down { color: var(--error); }
.delta-flat { color: var(--text-muted); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border-subtle); text-align: left; vertical-align: top; }
th { font-size: var(--text-xs); color: var(--text-secondary); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: var(--weight-medium); background: var(--surface-page); }
tr:hover td { background: var(--surface-hover); }
tr.selected td { background: var(--surface-selected); }
.empty { padding: var(--sp-6); text-align: center; color: var(--text-secondary); }

.badge { display: inline-block; font-size: var(--text-xs); font-weight: var(--weight-medium); padding: 1px 8px; border-radius: var(--r-full); }
.badge-ok { background: var(--success-bg); color: var(--success-dark); }
.badge-warn { background: var(--warning-bg); color: var(--warning-dark); }
.badge-fail { background: var(--error-bg); color: var(--error-dark); }
.badge-neutral { background: var(--surface-hover); color: var(--text-secondary); }

.notice { border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); font-size: var(--text-sm); }
.notice-warn { background: var(--warning-bg); color: var(--warning-dark); }
.notice-error { background: var(--error-bg); color: var(--error-dark); }

.bar { height: 8px; background: var(--brand-subtle); border-radius: var(--r-full); overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--brand); }

.chart { min-height: 280px; }

dl.defs { display: grid; grid-template-columns: 220px 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; }
dl.defs dt { font-weight: var(--weight-semibold); }
dl.defs dd { margin: 0; }
dl.defs dd dl.defs { grid-template-columns: 160px 1fr; }

/* ── Login / plain pages ── */
.plain { position: relative; isolation: isolate; min-height: 100vh; display: grid; place-items: center; padding: var(--sp-5); }
/* Soft pet-shop pattern: pattern.svg is only a mask, the colour comes from the theme. */
.plain::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--brand); opacity: 0.08;
  -webkit-mask: url("/static/pattern.svg") 0 0 / 220px 220px repeat; mask: url("/static/pattern.svg") 0 0 / 220px 220px repeat;
}
[data-theme="dark"] .plain::before { opacity: 0.16; }
.auth-card {
  width: 100%; max-width: 400px; overflow: hidden;
  background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--r-xl, 16px); box-shadow: var(--shadow-lg);
}
.auth-card__brand { display: flex; justify-content: center; padding: var(--sp-6) var(--sp-5); background: var(--sidebar-bg); }
.auth-card__brand { padding-block: calc(var(--sp-6) + 6px) var(--sp-6); }
.auth-card__brand .bs-word { font-size: 2.5rem; }
.auth-card__brand .bs-by { font-size: 11px; gap: 5px; }
.auth-card__brand .bs-by img { height: 11px; }
.auth-card__brand .bs-sp { width: 15px; height: 15px; }
.auth-card__body { padding: var(--sp-6) var(--sp-6) var(--sp-5); }
.auth-card h1 { font-size: var(--text-xl); text-align: center; margin-bottom: var(--sp-1); }
.auth-card p.lead { text-align: center; color: var(--text-secondary); margin: 0 0 var(--sp-5); }
.auth-footer { margin: 0; padding: 0 var(--sp-5) var(--sp-5); text-align: center; font-size: var(--text-xs); color: var(--text-muted); }
.security-notice { display: flex; gap: var(--sp-3); align-items: flex-start; margin-top: var(--sp-5); padding: var(--sp-3); border-radius: var(--r-md); background: var(--info-bg); color: var(--info-dark); }
.security-notice .icon { margin-top: 2px; }
.security-notice p { margin: 0; font-size: var(--text-xs); line-height: var(--leading-xs, 1.4); }
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--sp-4); }
.form-row label { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.form-row input { font: inherit; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text-primary); }
.form-row input:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--shadow-focus); }
.auth-card .btn { width: 100%; padding: 10px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-width, 240px); transform: translateX(-100%); transition: transform var(--duration-normal, 0.2s) ease; }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: calc(var(--z-overlay, 40) - 1); background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity var(--duration-normal, 0.2s) ease; }
  .sidebar-overlay.active { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex; }
  .page-header { padding: var(--sp-3) var(--sp-4); }
  .main { padding: var(--sp-4); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Retail Media forms and states ── */
.stack { display: flex; flex-direction: column; gap: var(--sp-5); }
.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: end; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: var(--text-sm); }
.field > span { font-size: var(--text-xs); color: var(--text-secondary); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.field input, .field select, .field textarea {
  font: inherit; font-size: var(--text-sm); color: var(--text-primary); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 7px 9px; min-width: 0;
}
.field textarea { min-height: 70px; }
.field .hint { font-size: var(--text-xs); color: var(--text-muted); text-transform: none; letter-spacing: 0; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--brand); color: var(--text-brand); }
.btn-danger { background: var(--surface); color: var(--error); border-color: var(--error-light); }
.btn-small { font-size: var(--text-xs); padding: 3px 8px; }
.inline { display: inline; }
.status { white-space: nowrap; display: inline-block; font-size: var(--text-xs); font-weight: var(--weight-medium); padding: 1px 8px; border-radius: var(--r-full); background: var(--surface-hover); color: var(--text-secondary); }
.status-active, .status-approved { background: var(--success-bg); color: var(--success-dark); }
.status-scheduled, .status-submitted { background: var(--info-bg); color: var(--info-dark); }
.status-paused, .status-capped_today, .status-paused_budget { background: var(--warning-bg); color: var(--warning-dark); }
.status-rejected { background: var(--error-bg); color: var(--error-dark); }
.notice-ok { background: var(--success-bg); color: var(--success-dark); }
.money-neg { color: var(--error); }
.money-pos { color: var(--success); }
.preview { max-width: 100%; max-height: 180px; border-radius: var(--r-md); border: 1px solid var(--border-default); display: block; }
.pack-results { font-size: var(--text-xs); margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
/* Banner slot picker of the creative form (multi-select dropdown, public/retail.js keeps the summary in step). */
.slot-dropdown { position: relative; }
.slot-dropdown > summary { list-style: none; cursor: pointer; padding: 7px 32px 7px 9px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); font-size: var(--text-sm); color: var(--text-primary); position: relative; }
.slot-dropdown > summary::-webkit-details-marker { display: none; }
.slot-dropdown > summary::after { content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; margin-top: -5px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.slot-dropdown[open] > summary { border-color: var(--border-focus); }
.slot-dropdown__menu { position: absolute; z-index: 20; left: 0; right: 0; margin-top: 4px; padding: 6px; display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: 0 6px 18px rgba(16, 24, 40, 0.12); }
.slot-dropdown__menu label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: var(--text-sm); cursor: pointer; }
.slot-dropdown__menu label:hover { background: var(--surface-hover); }
.slot-dropdown__menu input[type="checkbox"] { width: auto; padding: 0; border: 0; margin: 0; }
/* A select whose options are still being fetched (public/retail.js): an animated spinner at its right edge, text "Loading…". */
select[aria-busy="true"] { cursor: progress; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6' fill='none' stroke='%23d0d5dd' stroke-width='2'/%3E%3Cpath d='M8 2a6 6 0 0 1 6 6' fill='none' stroke='%231f4fbf' stroke-width='2' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 8 8' to='360 8 8' dur='0.8s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px 16px; }
.pack-results button { text-align: left; background: none; border: 0; padding: 2px 0; color: var(--text-link); cursor: pointer; font: inherit; }
.problems { margin: 0; padding-left: 18px; }

/* ── Slots page ── */
.slot-intro p { margin: 0 0 var(--sp-3); }
.slot-filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.slot-filters .chip { cursor: pointer; font: inherit; font-size: var(--text-xs); }
.slot-filters .chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.slot-group { padding: 0; overflow: hidden; }
.slot-group > p { margin: 0; padding: 0 var(--sp-5) var(--sp-3); }
.slot-group-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
}
.slot-group-head h2 { margin: 0; }
.slot-list { list-style: none; margin: 0; padding: 0; }
.slot {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, 220px) 110px auto;
  gap: var(--sp-2) var(--sp-4); align-items: center;
  padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border-subtle);
}
.slot:hover { background: var(--surface-hover); }
.slot-sellable { box-shadow: inset 3px 0 0 var(--brand); }
.slot-name { font-weight: var(--weight-semibold); }
.slot-key { font-size: var(--text-xs); color: var(--text-secondary); overflow-wrap: anywhere; }
.slot-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.slot-booking { min-width: 0; overflow-wrap: anywhere; }
.slot-dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--r-full); margin-right: 4px; vertical-align: middle; }
.slot-dot-free { background: var(--success); }
.slot-dot-booked { background: var(--info); }
.slot-price { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.slot-price strong { font-size: var(--text-md); }
.slot-edit { justify-self: end; }
.slot-edit > summary { list-style: none; }
.slot-edit > summary::-webkit-details-marker { display: none; }
.slot-edit[open] { grid-column: 1 / -1; justify-self: stretch; }
.slot-edit[open] > summary { margin-bottom: var(--sp-3); }
.slot-form {
  display: flex; flex-wrap: wrap; align-items: end; gap: var(--sp-3);
  padding: var(--sp-3); background: var(--surface-page); border: 1px solid var(--border-default); border-radius: var(--r-md);
}
.slot-form .field input[name="price"] { width: 90px; }
.slot-form .slot-label { flex: 1 1 220px; }
.slot-toggle { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: var(--weight-medium); padding-bottom: 8px; }
@media (max-width: 720px) {
  .slot { grid-template-columns: minmax(0, 1fr) auto; padding: var(--sp-3) var(--sp-4); }
  .slot-booking { grid-column: 1 / -1; order: 3; }
  .slot-price { order: 2; }
  .slot-edit { grid-column: 1 / -1; order: 4; justify-self: start; }
  .slot-group-head { padding: var(--sp-3) var(--sp-4); }
}

/* ── Campaign kind picker ── */
.kind-picker { border: 0; padding: 0; margin: 0; display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kind-picker legend { font-size: var(--text-xs); color: var(--text-secondary); text-transform: uppercase; letter-spacing: var(--tracking-wide); margin-bottom: var(--sp-2); padding: 0; }
.kind-option {
  display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: start; cursor: pointer;
  border: 1px solid var(--border-default); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); background: var(--surface);
}
.kind-option input { margin: 3px 0 0; grid-row: span 2; }
.kind-option:has(input:checked) { border-color: var(--brand); background: var(--brand-subtle); }
.kind-title { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.kind-sub { font-size: var(--text-xs); color: var(--text-secondary); }
.status-ours { background: var(--brand-subtle); color: var(--text-brand); }
[hidden] { display: none !important; }

/* Collection tree of the slot forms (SW-361): the store menu's hierarchy with checkboxes. */
.tree { margin-top: 6px; max-height: 340px; overflow: auto; border: 1px solid var(--border-subtle); border-radius: 8px; padding: 8px; }
.tree ul { list-style: none; margin: 2px 0; padding-left: 18px; }
.tree > ul { padding-left: 0; }
.tree .tree-row { display: flex; align-items: center; gap: 4px; padding: 2px 0; }
.tree .tree-row label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.tree .tree-caret { width: 20px; flex: none; background: none; border: 0; padding: 0; cursor: pointer; color: inherit; text-align: center; }
.tree input[type="search"] { flex: 1; }

/* ── Home and lists (SW-362) ── */
.kpi__icon { position: absolute; top: var(--sp-4); right: var(--sp-4); display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-full); background: var(--brand-subtle); color: var(--text-brand); }
.kpi__icon .icon { width: 17px; height: 17px; }
.kpi .value { margin-top: var(--sp-1); }
.kpi:has(.kpi__icon) .label { padding-right: 42px; }
.kpi-section { display: flex; flex-direction: column; gap: var(--sp-3); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.section-head h2 { font-size: var(--text-md); }
.section-head--pad { padding: var(--sp-4) var(--sp-5) var(--sp-2); }
.chips { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.chip[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.card--flush { padding: 0; overflow: hidden; }
.card--flush > .empty { padding: var(--sp-6); }
/* Thick rows: a logo, two lines of text and the period's figures. */
.table-xl th { padding: var(--sp-3); white-space: nowrap; }
.table-xl th:first-child, .table-xl td:first-child { padding-left: var(--sp-5); }
.table-xl th:last-child, .table-xl td:last-child { padding-right: var(--sp-5); }
.table-xl td { padding: var(--sp-4) var(--sp-3); vertical-align: middle; white-space: nowrap; }
.table-xl .who-cell { white-space: normal; }
.row-link { cursor: pointer; }
.who-cell { display: flex; align-items: center; gap: var(--sp-3); min-width: 220px; }
.who-cell__text { display: flex; flex-direction: column; min-width: 0; }
.who-cell__name { font-weight: var(--weight-semibold); color: var(--text-primary); }
.who-cell__sub, .cell-sub { font-size: var(--text-xs); color: var(--text-muted); }
.avatar-logo { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border-default); background: #fff; font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.avatar-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.avatar-logo--initials { border: 0; background: hsl(var(--hue) 70% 90%); color: hsl(var(--hue) 55% 28%); }
[data-theme="dark"] .avatar-logo--initials { background: hsl(var(--hue) 40% 24%); color: hsl(var(--hue) 70% 85%); }
.avatar-logo--ours { border: 0; background: var(--brand); }
.avatar-logo--ours img { padding: 7px; }
.progress { height: 5px; margin-top: 6px; min-width: 90px; border-radius: var(--r-full); background: var(--brand-subtle); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: var(--r-full); }

/* ── Modals (native <dialog>, SW-362) ── */
dialog.modal {
  border: 0; padding: 0; color: var(--text-primary); background: var(--surface-card);
  width: min(var(--modal-width-md, 560px), calc(100vw - 32px)); max-height: calc(100vh - 48px);
  border-radius: var(--r-xl, 16px); box-shadow: var(--shadow-xl);
}
dialog.modal--wide { width: min(760px, calc(100vw - 32px)); }
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: var(--modal-backdrop, rgba(0, 0, 0, 0.5)); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border-subtle); }
.modal__head h2 { font-size: var(--text-lg); }
.modal__body { padding: var(--sp-5); overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border-subtle); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--r-md); background: none; color: var(--text-secondary); cursor: pointer; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

/* ── Campaign page (SW-362) ── */
.campaign-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.campaign-head__meta { color: var(--text-secondary); font-size: var(--text-sm); }
.campaign-head__actions { margin-left: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
/* Settings that apply to the whole campaign sit in one bar under the head, like filters, not in cards of their own. */
.settings-bar { display: flex; flex-wrap: wrap; gap: var(--sp-5) var(--sp-7); align-items: flex-start; }
.settings-group { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; margin: 0; }
.settings-group--dates { flex: 2 1 640px; }
.settings-group:not(.settings-group--dates) { flex: 1 1 340px; }
.settings-group select { max-width: 100%; }
.settings-group__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.settings-group .row { align-items: end; }
.settings-group .hint-line { max-width: 560px; margin: 0; font-size: var(--text-xs); color: var(--text-muted); }
.explain { font-size: var(--text-sm); color: var(--text-secondary); }
.explain summary { cursor: pointer; color: var(--text-link); }
.explain p { margin: var(--sp-2) 0 0; max-width: 860px; }

/* Four cards to a row, the last row stretching to the full width (the campaign page has 7-8 per section). */
.kpis--4 { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.kpis--4 .kpi { flex: 1 1 calc((100% - 3 * var(--sp-3)) / 4); min-width: 170px; }

/* ── Item cards (bookings, creatives, candidate packs; SW-362) ── */
.card-section { display: flex; flex-direction: column; gap: var(--sp-4); }
.card-section__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.card-section__sub { margin: 0; font-size: var(--text-sm); color: var(--text-secondary); max-width: 860px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.toolbar select, .toolbar input[type="search"] { font: inherit; font-size: var(--text-sm); color: var(--text-primary); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 5px 8px; }
.toolbar .chip { cursor: pointer; font: inherit; font-size: var(--text-xs); }
.toolbar .chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.item-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.item-card {
  position: relative; display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; padding: var(--sp-4);
  background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
  transition: box-shadow var(--duration-fast, 0.15s) ease, border-color var(--duration-fast, 0.15s) ease;
}
.item-card:hover { box-shadow: var(--shadow-md); border-color: var(--brand-muted); }
.item-card__top { display: flex; gap: var(--sp-3); align-items: flex-start; }
.item-card__title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.item-card__title strong { font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.item-card__key { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); overflow-wrap: anywhere; }
.item-card__thumb { flex: none; width: 52px; height: 52px; border-radius: var(--r-md); border: 1px solid var(--border-default); background: #fff; display: grid; place-items: center; overflow: hidden; color: var(--text-muted); }
.item-card__thumb img { width: 100%; height: 100%; object-fit: contain; }
.item-card__banner { width: 100%; aspect-ratio: 16 / 7; border-radius: var(--r-md); border: 1px solid var(--border-default); background: var(--surface-page); overflow: hidden; display: grid; place-items: center; color: var(--text-muted); }
.item-card__banner img { width: 100%; height: 100%; object-fit: contain; }
.item-card__facts { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--sp-3); margin: 0; font-size: var(--text-sm); }
.item-card__facts dt { color: var(--text-muted); }
.item-card__facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.item-card__line { font-size: var(--text-xs); color: var(--text-secondary); display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.item-card__actions { margin-top: auto; display: flex; gap: var(--sp-2); justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.item-card__actions form { margin: 0; }
.item-card--add {
  align-items: center; justify-content: center; gap: var(--sp-2); min-height: 150px; cursor: pointer; font: inherit; color: var(--text-secondary);
  background: transparent; border: 2px dashed var(--border-strong); box-shadow: none;
}
.item-card--add:hover { border-color: var(--brand); color: var(--text-brand); background: var(--brand-subtle); box-shadow: none; }
.item-card--add .icon { width: 28px; height: 28px; }
.item-card--ended { opacity: 0.7; }
.modal-section { display: flex; flex-direction: column; gap: var(--sp-3); padding-bottom: var(--sp-4); margin-bottom: var(--sp-4); border-bottom: 1px solid var(--border-subtle); }
.modal-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.modal-section > h3 { font-size: var(--text-md); }
.modal-section--danger > h3 { color: var(--error); }
.empty-filter { padding: var(--sp-5); text-align: center; color: var(--text-secondary); border: 1px dashed var(--border-default); border-radius: var(--r-lg); }

/* ── Dates change: what to do with the bookings left outside (SW-362) ── */
.resolve-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.resolve-row { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--border-default); border-radius: var(--r-md); }
.resolve-row__title { font-weight: var(--weight-semibold); }
.resolve-row__dates { font-size: var(--text-xs); color: var(--text-secondary); }
.resolve-row label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-sm); cursor: pointer; }
.resolve-row label.is-disabled { opacity: 0.5; cursor: not-allowed; }

/* One chevron for every single-choice dropdown, with room on the right: the native arrow sat against the border and did not line up with the text. */
select:not([multiple]):not([aria-busy="true"]) {
  -webkit-appearance: none; appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%235a6290' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 12px 12px;
}
[data-theme="dark"] select:not([multiple]):not([aria-busy="true"]) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%239aa3d6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
