/* =====================================================================
   Magazine Tracker — styles
   1. Tokens (edit colours/fonts here)   5. Components
   2. Base                               6. Views
   3. Layout (sidebar / main)            7. Responsive
   4. Tones (status colours)             8. Print
   ===================================================================== */

/* ---------- 1. Tokens ----------
   KPX Group colours (same as the KPX Group Rental site, taken from kpx-group.com):
   indigo brand #4f39f6 / #432dd7, zinc greys, near-black ink #09090b. */
:root {
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --ink: #09090b;
  --ink-2: #52525c;
  --ink-3: #71717b;
  --line: #e4e4e7;
  --line-2: #d4d4d8;
  --accent: #4f39f6;
  --accent-dark: #432dd7;
  --accent-ink: #fff;
  --focus: #4f39f6;
  --alert: #dc2626;
  --warn: #b45309;
  --good: #15803d;
  /* Colours the owner can change in Settings → Ngjyrat. /theme.css (server/theme.js) overrides them;
     these are the defaults. "brand" is the accent that stays the same by day and by night. */
  --brand: #4f39f6; --brand-dark: #432dd7; --brand-ink: #fff; --brand-soft: #7c86ff;
  --bar: #09090b; --bar-2: #18181b; --bar-3: #27272a; --bar-line: #3f3f46;
  --bar-ink: #fafafa; --bar-ink-2: #e4e4e7; --bar-ink-3: #9f9fa9; --bar-link: #a3b3ff;
  --sale: #dc2626; --sale-text: var(--alert); --sale-on-bar: #fca5a5;
  --banner: radial-gradient(60% 60% at 85% 20%, rgb(255 182 193 / .55) 0%, rgb(255 182 193 / 0) 70%), radial-gradient(120% 100% at 20% 0%, #fdead2 0%, #fde3df 45%, #fdf3e8 100%);
  --banner-ink: #09090b; --banner-ink-2: #3f3f46;
  --offer-banner: linear-gradient(115deg, #4f39f6 0%, #7c3aed 55%, #c026d3 100%);
  --shadow: 0 1px 2px rgb(9 9 11 / .05), 0 4px 16px rgb(9 9 11 / .05);
  --shadow-lg: 0 12px 48px rgb(9 9 11 / .18);
  --radius: 12px;
  --radius-sm: 8px;
  --side: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b; --surface: #18181b; --surface-2: #27272a; --ink: #fafafa; --ink-2: #d4d4d8; --ink-3: #9f9fa9;
    --line: #27272a; --line-2: #3f3f46; --accent: #7c86ff; --accent-dark: #a3b3ff; --accent-ink: #09090b; --focus: #7c86ff;
    --alert: #f87171; --warn: #fbbf24; --good: #4ade80;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-lg: 0 12px 48px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09090b; --surface: #18181b; --surface-2: #27272a; --ink: #fafafa; --ink-2: #d4d4d8; --ink-3: #9f9fa9;
  --line: #27272a; --line-2: #3f3f46; --accent: #7c86ff; --accent-dark: #a3b3ff; --accent-ink: #09090b; --focus: #7c86ff;
  --alert: #f87171; --warn: #fbbf24; --good: #4ade80;
  --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-lg: 0 12px 48px rgb(0 0 0 / .6);
  color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font: 700 clamp(1.7rem, 3vw, 2.4rem)/1.1 var(--font-display); letter-spacing: -.03em; }
h2 { font-size: .95rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.big { width: 40px; height: 40px; stroke-width: 1.4; }
.i.faint { color: var(--ink-3); }
.muted { color: var(--ink-3); }
small.muted, td small { display: block; font-size: .78rem; }
.text-alert { color: var(--alert); }
.text-warn { color: var(--warn); }
.text-good { color: var(--good); }
.tiny { font-size: .75rem; }
.path { font-size: .75rem; font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; user-select: all; }
kbd { font: 600 .7rem var(--font-ui); padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--ink-2); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }

/* ---------- 3. Layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 30;
  display: flex; flex-direction: column; gap: 6px; padding: 20px 14px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 700 1.2rem var(--font-display);
}
/* an uploaded logo in place of the letter: shown whole, on white so a see-through logo is always visible */
.brand .brand-mark.has-logo, .brand-mark.has-logo { background: #fff; overflow: hidden; padding: 0; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-text strong { display: block; font: 700 1.1rem/1.1 var(--font-display); }
.brand-text small { color: var(--ink-3); font-size: .75rem; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; margin-bottom: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-3); border-radius: var(--radius-sm); text-align: left;
}
.search-trigger span { flex: 1; }
.search-trigger:hover { border-color: var(--line-2); color: var(--ink-2); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav-plain {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500; border: 0; background: none; width: 100%; text-align: left;
  transition: background-color .15s, color .15s;
}
.nav a:hover, .nav-plain:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on, .nav-plain.on { background: var(--ink); color: var(--bg); }
.nav-badge:empty { display: none; }
.nav-badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--alert); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 20px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.topbar, .scrim { display: none; }
.main { margin-left: var(--side); padding: 32px clamp(16px, 4vw, 48px) 80px; max-width: calc(1360px + var(--side)); outline: none; }
.main > * + * { margin-top: 24px; }

/* ---------- 4. Tones ---------- */
.tone-slate { --t: #64748b; } .tone-blue { --t: #2563eb; } .tone-amber { --t: #d97706; }
.tone-orange { --t: #ea580c; } .tone-violet { --t: #7c3aed; } .tone-teal { --t: #0d9488; }
.tone-green { --t: #16a34a; } .tone-red { --t: #dc2626; } .tone-pink { --t: #db2777; } .tone-ink { --t: var(--ink); }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  font-size: .75rem; font-weight: 600; color: var(--t);
  background: color-mix(in srgb, var(--t) 13%, transparent);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--t, var(--ink-3)); flex: none; }
.dot.hatch { background: repeating-linear-gradient(45deg, var(--ink-3) 0 2px, transparent 2px 4px); border: 1px solid var(--ink-3); border-radius: 2px; }

/* ---------- 5. Components ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface);
  font-weight: 600; font-size: .875rem; white-space: nowrap; user-select: none;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-dark, var(--accent)); border-color: var(--accent-dark, var(--accent)); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--alert); }
.btn.danger:not(.ghost) { background: var(--alert); border-color: var(--alert); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: .8rem; }
.btn .i { width: 16px; height: 16px; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.btn-stack { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: .8rem; font-weight: 600; }
.link:hover { color: var(--accent); }
.link .i { width: 14px; height: 14px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.kicker { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.sub { color: var(--ink-2); margin-top: 6px; font-size: 1rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: .85rem; }
.crumbs a:hover { color: var(--ink); }
.crumbs .i { width: 14px; height: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat p { color: var(--ink-3); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat strong { display: block; font: 700 1.9rem/1.2 var(--font-display); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--ink-3); font-size: .8rem; }
.stat::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: transparent; }
.stat.alert::after { background: var(--alert); } .stat.alert strong { color: var(--alert); }
.stat.warn::after { background: var(--warn); }
.stat.good::after { background: var(--good); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters select, .filters .search { height: 36px; }
select, input:not([type=checkbox]):not([type=color]), textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.filters select { width: auto; max-width: 220px; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
textarea { resize: vertical; min-height: 64px; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 220px; min-width: 180px; max-width: 360px; }
.search .i { position: absolute; left: 10px; color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 34px !important; height: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 10px; flex-wrap: wrap; }
.segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 0; background: transparent; border-radius: 7px; font-weight: 600; font-size: .82rem; color: var(--ink-2); }
.segmented button small { color: var(--ink-3); font-weight: 500; }
.segmented button:hover { color: var(--ink); }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segmented .i { width: 15px; height: 15px; }

.tabs { display: flex; gap: 4px; box-shadow: inset 0 -1px var(--line); overflow-x: auto; overflow-y: hidden; }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-color: var(--accent); }
.tabs small { font-size: .72rem; padding: 1px 6px; border-radius: 8px; background: var(--surface-2); margin-left: 4px; }
.tabs small.alert { background: var(--alert); color: #fff; }
.tab-body { margin-top: 20px !important; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background-color .12s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line-2); border-bottom: 0; background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.th-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; }
.th-sort:hover, .th-sort.on { color: var(--ink); }
.clamp { max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paid { color: var(--good); font-weight: 700; }
.words { white-space: nowrap; }
.words small { color: var(--ink-3); }
.words.ok { color: var(--good); }
.words.over { color: var(--warn); }
.due { white-space: nowrap; }
.due small { display: inline; color: var(--ink-3); margin-left: 2px; }
.due.soon { color: var(--warn); font-weight: 600; }
.due.over { color: var(--alert); font-weight: 600; }
.due.over small, .due.soon small { color: inherit; opacity: .8; }

.person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.person > span:last-child { min-width: 0; }
a.person:hover span { text-decoration: underline; }
.avatar {
  --h: 20; width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: .7rem; font-weight: 700; color: hsl(var(--h) 55% 30%); background: hsl(var(--h) 60% 88%);
}
:root[data-theme="dark"] .avatar { color: hsl(var(--h) 70% 85%); background: hsl(var(--h) 35% 26%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: hsl(var(--h) 70% 85%); background: hsl(var(--h) 35% 26%); } }
.avatar.empty { background: var(--surface-2); color: var(--ink-3); }
.avatar.xl { width: 72px; height: 72px; font: 700 1.6rem var(--font-display); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-2); font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--surface); }
a.chip:hover { border-color: var(--ink-3); }
.chip.lg { padding: 7px 12px; font-size: .85rem; cursor: grab; }
.chip.lg small { color: var(--ink-3); font-weight: 500; }
.chip .i { width: 15px; height: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: .75rem; font-weight: 600; color: var(--ink-3); }
.toggle.on { background: color-mix(in srgb, var(--good) 14%, transparent); border-color: transparent; color: var(--good); }

.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s cubic-bezier(.2, .8, .2, 1); }
.progress.done span { background: var(--good); }
.pipe { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface-2); margin: 14px 0 10px; }
.pipe span { background: var(--t); min-width: 4px; }
.pipe.empty { height: auto; background: none; color: var(--ink-3); font-size: .8rem; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--ink-2); }
.legend li, .legend a { display: inline-flex; align-items: center; gap: 6px; }
.legend a:hover { color: var(--ink); }
.legend b { color: var(--ink); }
.legend.small { font-size: .75rem; gap: 4px 10px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; margin-top: 14px; }
.kv.wide { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.kv span { display: block; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.kv b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.kv small { display: block; color: var(--ink-3); font-size: .75rem; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--ink-2); margin-top: 8px; }
.meta a, .meta span { display: inline-flex; align-items: center; gap: 6px; }
.meta a:hover { color: var(--accent); }
.meta .i { width: 15px; height: 15px; }
.notes { margin-top: 12px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-2); white-space: pre-wrap; }
.hint { color: var(--ink-3); font-size: .8rem; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty-state h3 { color: var(--ink); margin: 10px 0 4px; }
.empty-state .btn { margin-top: 14px; }

/* magazine cover */
.cover {
  --c: #334155; position: relative; aspect-ratio: 3 / 4; border-radius: 6px; overflow: hidden; color: #fff;
  display: flex; flex-direction: column; padding: 0; container-type: inline-size;
  background:
    radial-gradient(120% 80% at 80% 110%, rgb(0 0 0 / .35), transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--c) 80%, #fff) 0%, var(--c) 45%, color-mix(in srgb, var(--c) 70%, #000) 100%);
  box-shadow: 0 1px 1px rgb(0 0 0 / .1), 0 6px 18px -6px color-mix(in srgb, var(--c) 60%, transparent), inset 3px 0 0 rgb(255 255 255 / .12);
}
.cover > * { margin-inline: 9cqw; }
.cover-mast { margin-top: 11cqw; font: 700 var(--mast, 15cqw)/0.9 var(--font-display); letter-spacing: -.02em; text-transform: uppercase; overflow: hidden; white-space: nowrap; text-overflow: clip; }
.cover-no { font-size: 6.5cqw; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; margin-top: 2cqw; opacity: .85; }
.cover-title { margin-top: auto; font: 500 11cqw/1.02 var(--font-display); font-style: italic; }
.cover-foot { font-size: 5.5cqw; letter-spacing: .12em; text-transform: uppercase; margin-top: 4cqw; opacity: .8; border-top: 1px solid rgb(255 255 255 / .35); padding-top: 3cqw; margin-bottom: 11cqw; }
.cover.md { width: 150px; }
.cover.lg { width: 220px; }

/* dialogs */
dialog { padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
dialog::backdrop { background: rgb(15 12 8 / .45); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .18s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-head h2 { font: 700 1.3rem var(--font-display); }
.modal-body { padding: 14px 20px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal.narrow { max-width: 440px; }
.spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide, .check.wide { grid-column: 1 / -1; }
.field label { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.field label b { color: var(--accent); margin-left: 2px; }
.field .err { color: var(--alert); font-size: .78rem; min-height: 0; }
.field .err:empty { display: none; }
.field.invalid input, .field.invalid select { border-color: var(--alert); }
.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); background: var(--c); }
.swatch:hover { transform: scale(1.1); }
.swatches input[type=color] { width: 40px; height: 30px; border: 1px solid var(--line-2); border-radius: 6px; background: none; padding: 2px; }

/* search palette */
.search-modal .search { flex: none; max-width: none; padding: 12px; border-bottom: 1px solid var(--line); }
.search-modal .search .i { left: 24px; }
.search-modal .search input { border: 0; box-shadow: none; font-size: 1.05rem; padding: 10px 10px 10px 40px !important; background: transparent; }
.results { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.results li { display: grid; grid-template-columns: 64px 1fr; column-gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.results li small { grid-column: 2; color: var(--ink-3); font-size: .78rem; }
.results li.sel { background: var(--surface-2); }
.results .kind { grid-row: span 2; align-self: center; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.results .none { display: block; text-align: center; color: var(--ink-3); cursor: default; }
.search-modal .modal-foot { gap: 16px; }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500;
  animation: toast-in .25s cubic-bezier(.2, .8, .2, 1);
}
.toast.error { background: var(--alert); color: #fff; }
.toast .btn { color: inherit; border-color: color-mix(in srgb, currentColor 30%, transparent); }
.toast .btn:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- 6. Views ---------- */
/* dashboard */
.next-issue { display: flex; gap: 20px; }
.next-issue > a { flex: none; transition: transform .2s; }
.next-issue > a:hover { transform: translateY(-2px) rotate(-1deg); }
.next-body { flex: 1; min-width: 0; }
.deadlines { list-style: none; margin: 0; padding: 0; }
.deadlines li + li { border-top: 1px solid var(--line); }
.row-btn { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 6px; border: 0; background: none; text-align: left; border-radius: var(--radius-sm); }
.row-btn:hover { background: var(--surface-2); }
.row-btn.done { opacity: .55; }
.when { width: 44px; flex: none; text-align: center; line-height: 1.1; border: 1px solid var(--line); border-radius: 8px; padding: 5px 0; }
.when b { display: block; font: 700 1.15rem var(--font-display); }
.when small { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.when.over { border-color: var(--alert); color: var(--alert); }
.when.over small { color: inherit; }
.when.today { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.when.today small { color: inherit; opacity: .7; }
.what { flex: 1; min-width: 0; }
.what strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.what small { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: .8rem; }
.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 32px; align-items: center; gap: 12px; padding: 4px 6px; border-radius: 6px; font-size: .875rem; }
.funnel-row:hover { background: var(--surface-2); }
.funnel-row b { text-align: right; font-variant-numeric: tabular-nums; }
.funnel-row .bar { height: 18px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.funnel-row .bar i { display: block; height: 100%; background: var(--t); border-radius: 4px; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .875rem; }
.activity li:last-child { border: 0; }
.activity time { color: var(--ink-3); font-size: .78rem; white-space: nowrap; }

/* issues */
.issue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px; }
.issue-card { display: flex; flex-direction: column; gap: 12px; }
.issue-card .cover { transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s; }
.issue-card:hover .cover { transform: translateY(-4px); box-shadow: 0 16px 30px -10px color-mix(in srgb, var(--c) 70%, transparent); }
.issue-card-body { display: flex; flex-direction: column; gap: 6px; }
.issue-card-body h3 { font: 600 1.15rem var(--font-display); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tiny { display: flex; justify-content: space-between; color: var(--ink-3); }
.issue-hero { display: flex; gap: 32px; align-items: flex-start; }
.issue-hero-body { flex: 1; min-width: 0; }
.issue-hero .actions { margin-top: 18px; }

/* flatplan */
.flat-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.flatplan { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px 14px; margin-top: 14px !important; }
.spread { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.pg {
  position: relative; aspect-ratio: 3 / 4; background: var(--surface); border: 1px solid var(--line-2);
  display: flex; flex-direction: column; font-size: .7rem; overflow: hidden; transition: box-shadow .15s, transform .15s;
}
.pg.l { border-radius: 5px 0 0 5px; border-right-width: 0; box-shadow: inset -8px 0 10px -8px rgb(0 0 0 / .18); }
.pg.r { border-radius: 0 5px 5px 0; box-shadow: inset 8px 0 10px -8px rgb(0 0 0 / .18); }
.pg.blank { background: transparent; border: 0; box-shadow: none; }
.pg-n { position: absolute; bottom: 3px; font-size: .62rem; color: var(--ink-3); z-index: 2; font-variant-numeric: tabular-nums; }
.pg.l .pg-n { left: 5px; } .pg.r .pg-n { right: 5px; }
.pg.free { cursor: pointer; background: repeating-linear-gradient(-45deg, transparent 0 6px, color-mix(in srgb, var(--line) 50%, transparent) 6px 7px), var(--surface); }
.pg.free:hover { border-color: var(--accent); }
.pg-add { margin: auto; color: var(--ink-3); opacity: 0; transition: opacity .15s; }
.pg.free:hover .pg-add { opacity: 1; color: var(--accent); }
.pg.cover-pg { background: var(--c); color: #fff; cursor: pointer; }
.pg.cover-pg .pg-n { color: rgb(255 255 255 / .7); }
.pg-cover { margin: auto; font: 600 .85rem var(--font-display); font-style: italic; }
.pg-art { flex: 1; padding: 6px 7px; background: color-mix(in srgb, var(--t) 14%, var(--surface)); border-top: 3px solid var(--t); cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; }
.pg-art strong { font-size: .72rem; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pg-art small { color: var(--ink-2); font-size: .64rem; line-height: 1.2; }
.pg-art.cont { background: color-mix(in srgb, var(--t) 8%, var(--surface)); border-top-style: dashed; }
.pg-art.cont small { color: var(--ink-3); }
.pg-art[draggable="true"] { cursor: grab; }
.pg-ad {
  flex: 0 0 calc(var(--share) * 100%); padding: 5px 7px 16px; cursor: pointer; display: flex; flex-direction: column; justify-content: flex-end; min-height: 0; overflow: hidden;
  background: repeating-linear-gradient(45deg, var(--surface-2) 0 5px, color-mix(in srgb, var(--ink-3) 18%, var(--surface-2)) 5px 7px);
  border-top: 1px solid var(--line-2);
}
.pg-ad strong { font-size: .7rem; line-height: 1.1; }
.pg-ad small { color: var(--ink-3); font-size: .62rem; }
.pg-ad[draggable="true"] { cursor: grab; }
.pg.conflict { border-color: var(--alert); box-shadow: 0 0 0 2px var(--alert); z-index: 1; }
.pg-warn { position: absolute; top: 4px; right: 4px; color: var(--alert); background: var(--surface); border-radius: 50%; padding: 2px; display: grid; }
.pg-warn .i { width: 14px; height: 14px; }
.pg.over { box-shadow: 0 0 0 3px var(--accent); transform: scale(1.03); z-index: 2; }
.dragging { opacity: .45; }
.unplaced { margin-top: 24px !important; }

/* articles board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; scroll-snap-type: x proximity; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 200px; transition: background-color .15s, box-shadow .15s; scroll-snap-align: start; }
.col.over { background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); box-shadow: inset 0 0 0 2px var(--accent); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 700; font-size: .85rem; }
.col-head small { margin-left: auto; color: var(--ink-3); font-weight: 600; }
.col-body { display: flex; flex-direction: column; gap: 8px; }
.col-empty { text-align: center; color: var(--ink-3); font-size: .8rem; padding: 24px 0; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; cursor: grab; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.kcard:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgb(0 0 0 / .08); }
.kcard:active { cursor: grabbing; }
.kcard h4 { font: 600 .95rem/1.3 var(--font-display); }
.kcard.late { border-left: 3px solid var(--alert); }
.kcard .person span:last-child { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard .avatar { width: 22px; height: 22px; font-size: .6rem; }
.kcard .due { font-size: .78rem; }
.kcard .due small { display: none; }

/* contributors */
.profile { display: flex; gap: 24px; align-items: flex-start; }
.profile > div:nth-child(2) { flex: 1; min-width: 0; }

/* ads */
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: 64px 1fr 90px; align-items: center; gap: 12px; padding: 4px 6px; border-radius: 6px; }
.hbar:hover { background: var(--surface-2); }
.hbar-label { font-weight: 600; font-size: .85rem; }
.hbar-track { display: flex; height: 22px; gap: 2px; min-width: 2px; }
.hbar-track i { background: var(--t); min-width: 3px; }
.hbar-track i:first-child { border-radius: 4px 0 0 4px; }
.hbar-track i:last-child { border-radius: 0 4px 4px 0; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; font-size: .875rem; }
.hbar > span:nth-child(2) { display: flex; }

/* calendar */
.kind-toggles { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.kind-article { --t: var(--accent); } .kind-close { --t: var(--ink); } .kind-issue { --t: #dc2626; } .kind-ad { --t: #db2777; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; box-shadow: var(--shadow); }
.cal-wd { background: var(--surface-2); padding: 8px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.cal-day { background: var(--surface); min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.wkend { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.cal-day.out { background: var(--bg); }
.cal-day.out .cal-n { color: var(--ink-3); opacity: .6; }
.cal-n { font-size: .8rem; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .cal-n { background: var(--accent); color: var(--accent-ink); }
.ev { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--t); padding: 2px 6px; font-size: .72rem; font-weight: 600; border-radius: 3px; background: color-mix(in srgb, var(--t) 12%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.kind-issue { background: #dc2626; color: #fff; border-color: #991b1b; }
.ev.kind-close { background: var(--ink); color: var(--bg); }
.ev.done { opacity: .45; text-decoration: line-through; }
.ev:hover { filter: brightness(.95); }
.more { font-size: .7rem; color: var(--ink-3); padding-left: 6px; }
.kind-toggles .dot { background: var(--t); }

/* settings */
.shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px 24px; margin: 0; }
.shortcuts div { display: flex; flex-direction: column; gap: 4px; }
.shortcuts dd { margin: 0; color: var(--ink-2); }

/* ---------- 7. Responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgb(0 0 0 / .35); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 0; }
  .main { margin-left: 0; padding: 20px 16px 80px; }
  .issue-hero, .profile { flex-direction: column; gap: 20px; }
  .cover.lg { width: 160px; }
  .cal-day { min-height: 64px; padding: 3px; }
  .ev { font-size: 0; padding: 0; height: 6px; border-radius: 3px; border: 0; background: var(--t); }
  .ev.kind-issue, .ev.kind-close { background: var(--t); }
  .cal-wd { padding: 6px 2px; text-align: center; font-size: .62rem; }
  .cal-n { margin: 0 auto; }
  .filters select { flex: 1 1 140px; max-width: none; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat strong { font-size: 1.4rem; }
  .next-issue { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head .actions { width: 100%; }
  .issue-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .flatplan { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .search { max-width: none; }
  input, select, textarea { font-size: 16px; } /* stops iOS zoom on focus */
  .funnel-row { grid-template-columns: 90px 1fr 24px; }
}
@media (hover: none) { .pg.free .pg-add { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- 8. Print ---------- */
@media print {
  .sidebar, .topbar, .toasts, .actions, .tabs, .toolbar, .skip { display: none !important; }
  body { background: #fff; color: #000; }
  .main { margin: 0; padding: 0; }
  .card, .table-wrap, .stat { box-shadow: none; }
  .table tbody tr { break-inside: avoid; }
}
