:root {
  color-scheme: light;
  --ink: #21312e;
  --muted: #63736f;
  --line: #dce4df;
  --teal: #216a59;
  --wash: #edf5f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: #f8faf8;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, summary, select { cursor: pointer; }
button, input, select, textarea { border: 1px solid #bdcbc4; border-radius: 6px; background: #fff; color: var(--ink); }
button { min-height: 38px; padding: 8px 13px; font-weight: 600; }
button:hover, summary:hover { background: var(--wash); }
button:disabled { cursor: not-allowed; opacity: .5; }
input, select, textarea { padding: 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 82px; line-height: 1.5; }
label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; }
:focus-visible { outline: 3px solid #429b85; outline-offset: 3px; }
.primary { background: var(--teal); border-color: var(--teal); color: white; }
.primary:hover { background: #165342; }
.quiet { background: transparent; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.6; }
.error { color: #9b322a; font-size: 13px; line-height: 1.5; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 26px; letter-spacing: -.7px; line-height: 1.3; }
h2 { font-size: 18px; line-height: 1.4; }
h3 { font-size: 14px; }
p { line-height: 1.6; }
.demo { position: sticky; top: 0; z-index: 30; padding: 7px 24px; color: #325348; background: #e8f0e9; font-size: 11px; font-weight: 700; letter-spacing: .5px; }
.demo span { font-weight: 400; letter-spacing: 0; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 8px; z-index: 100; background: white; padding: 12px; }
.topbar { min-height: 65px; display: flex; align-items: center; padding: 0 28px; gap: 42px; border-bottom: 1px solid var(--line); background: #fff; }
.wordmark { font-size: 25px; letter-spacing: -1px; font-weight: 750; text-decoration: none; color: var(--ink); }
.wordmark span { font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
nav { display: flex; gap: 25px; }
nav a { color: var(--muted); text-decoration: none; font-weight: 600; padding: 22px 0; }
nav a[aria-current] { color: var(--teal); box-shadow: inset 0 -2px var(--teal); }
.account { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--muted); }
.account #account { overflow-wrap: anywhere; }
.account button { min-height: 32px; font-size: 12px; padding: 5px 9px; }
.layout { display: grid; grid-template-columns: minmax(390px, 43%) minmax(0, 1fr); height: calc(100dvh - 94px); }
.queue-panel { container-type: inline-size; padding: 14px 20px 14px 28px; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.queue-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.queue-heading h1 { margin: 0; font-size: 20px; }
.queue-heading .eyebrow { display: none; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--muted); margin-bottom: 7px; }
.tag { font-size: 10px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px; white-space: nowrap; }
.filters { display: grid; gap: 6px; }
.search-label { font-size: 0; gap: 0; }
.search-label input { font-size: 14px; min-height: 36px; padding: 8px; }
.filter-row { display: flex; align-items: end; gap: 8px; }
.filter-row > label { flex: 1; min-width: 0; gap: 3px; }
.filter-row label { font-size: 11px; }
.filter-row select { min-height: 36px; padding: 7px 6px; font-size: 13px; }
.filter-row > button { min-height: 36px; padding: 7px 9px; font-size: 13px; }
.view-menu { position: relative; }
.view-menu > summary { min-height: 36px; border: 1px solid #bdcbc4; padding: 8px 9px; border-radius: 6px; background: white; font-size: 13px; }
.view-options { position: absolute; right: 0; top: 43px; z-index: 10; display: grid; gap: 12px; width: 290px; max-height: 65vh; overflow: auto; padding: 18px; border: 1px solid var(--line); box-shadow: 0 8px 30px #18312818; border-radius: 8px; background: white; }
.view-options-header { position: sticky; top: -18px; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -18px -18px 0; padding: 8px 12px; background: white; border-bottom: 1px solid var(--line); font-size: 13px; }
#close-view-menu { min-height: 44px; flex-shrink: 0; }
.intake { margin-top: 6px; font-size: 12px; line-height: 1.5; }
.intake summary { color: #805e27; }
.intake a { display: block; padding: 4px 0; }
.list-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0 6px; font-size: 10px; color: var(--muted); }
.list-meta span:first-child { font-size: 12px; font-weight: 600; }
#mail-group { min-height: 32px; padding: 5px 9px; font-size: 12px; }
#mail-group[aria-pressed="true"] { background: var(--wash); border-color: var(--teal); color: var(--teal); }
.list { overflow-y: auto; min-height: 0; flex: 1; overscroll-behavior: contain; padding-right: 3px; }
.group-title { font-size: 11px; color: #4b655b; background: #eff3ef; padding: 9px 10px; margin: 12px 0 0; font-weight: 700; border-radius: 4px; }
.group-title:first-child { margin-top: 0; }
.group-title a { color: inherit; }
.group-title small { display: block; font-weight: 400; margin-top: 4px; line-height: 1.5; }
.queue-row { display: grid; grid-template-columns: minmax(0, 1fr) 94px; gap: 3px 12px; position: relative; padding: 11px 12px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); background: white; border-left: 3px solid transparent; }
.queue-row:hover { background: #f3f7f3; }
.queue-row.selected { border-left-color: var(--teal); background: #eaf3ed; }
.row-title { font-weight: 650; font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-buyer { grid-column: 1; font-size: 11px; color: var(--muted); line-height: 1.5; }
.row-deadline { grid-column: 2; grid-row: 1 / 3; text-align: right; font-size: 12px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.row-deadline small { font-size: 10px; color: var(--muted); display: block; }
.row-context { grid-column: 1 / -1; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-action { grid-column: 1 / -1; font-size: 11px; color: #375e50; line-height: 1.5; }
.row-meta { grid-column: 1 / -1; color: var(--muted); font-size: 10px; line-height: 1.5; }
.row-meta:empty { display: none; }
.row-statuses { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0; }
.status-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 7px; border: 1px solid #b8c8c0; border-radius: 4px; font-size: 12px; font-weight: 650; line-height: 1.4; background: #f0f3f1; color: #374a42; }
.status-final { background: #e2f4e8; border-color: #72ac87; color: #155232; }
.status-rejected { background: #fde9e7; border-color: #cf918b; color: #922c26; }
.status-needs_decision, .status-pending, .status-zapytaj { background: #fff0c5; border-color: #caa64c; color: #754800; }
.status-in_progress { background: #e4efff; border-color: #86abd9; color: #234f8c; }
.status-watchlist { background: #f0ebfb; border-color: #b5a0d7; color: #62408d; }
.status-duplicate { background: #edf0f4; border-color: #a2afbf; color: #435269; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; font-size: 12px; }
.inspector { min-width: 0; overflow-y: auto; background: white; padding: 26px clamp(22px, 3vw, 52px) 50px; }
.placeholder { display: grid; align-content: center; text-align: center; height: 80%; color: var(--muted); }
.placeholder h2 { color: var(--ink); }
.placeholder-mark { font-size: 38px; color: #9bb8a9; margin-bottom: 16px; }
.detail-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; font-size: 12px; }
.detail-nav span { margin-left: auto; color: var(--muted); }
.detail-header h1 { font-size: clamp(23px, 2.1vw, 30px); margin-bottom: 12px; }
.detail-header .buyer { font-size: 14px; }
#duplicate-jump { margin: 6px 0 16px; min-height: 44px; font-size: 12px; }
.detail-facts { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 16px 0; padding-bottom: 20px; border-bottom: 1px solid var(--line); font-size: 12px; line-height: 1.5; }
.detail-facts b { display: block; margin-bottom: 3px; }
.notice { border-left: 3px solid #b29867; background: #fbf8f0; padding: 12px 15px; margin: 12px 0; line-height: 1.6; font-size: 12px; }
.rationale { font-size: 13px; color: #465d53; line-height: 1.7; }
.review { border-bottom: 1px solid var(--line); padding-bottom: 22px; }
.delivery-brief { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 10px 12px; margin: 0 0 16px; background: var(--wash); border-radius: 5px; font-size: 12px; line-height: 1.6; }
.delivery-brief span { color: var(--muted); }
#decision-comment { font-size: 12px; }
#decision-comment summary { padding: 8px 0; }
#decision-comment label { margin-top: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.actions button[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--teal); background: var(--wash); color: var(--teal); }
.review-state { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 12px; margin: 14px 0; }
.delivery { padding: 20px 0; border-bottom: 1px solid var(--line); }
.delivery h2 { font-size: 15px; }
.delivery p { font-size: 12px; margin-bottom: 8px; }
.delivery .owner { color: var(--teal); font-weight: 600; }
.delivery details { margin-top: 12px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 24px 0 10px; }
.section-heading h2 { margin: 0; }
.section-heading button { font-size: 11px; }
.field { display: grid; grid-template-columns: minmax(100px, 30%) minmax(0, 1fr) 36px; gap: 8px; padding: 13px 0; border-bottom: 1px solid #e9eeea; font-size: 12px; }
.field-name { color: var(--muted); padding-top: 4px; }
.field-value { white-space: pre-wrap; line-height: 1.7; overflow-wrap: anywhere; }
.field .copy { padding: 4px; min-height: 32px; height: 32px; background: transparent; border-color: var(--line); font-size: 14px; }
.fallback { display: block; color: #886022; font-size: 10px; }
.evidence { grid-column: 2 / -1; font-size: 11px; color: var(--muted); }
.evidence summary { padding: 4px 0; }
.evidence p { margin: 8px 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.expand { border-bottom: 1px solid var(--line); padding: 18px 0; }
.expand > summary { font-weight: 600; padding: 4px 0; }
.expand > div { margin-top: 16px; }
.feedback { margin: 24px 0; }
.feedback h2 { margin-bottom: 6px; }
.feedback label { margin-bottom: 12px; }
.feedback select { width: auto; min-width: 130px; }
.history-item, .occurrence, .ref-item { border-bottom: 1px solid var(--line); padding: 14px 0; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.history-item p { margin: 5px 0; white-space: pre-wrap; }
.reference { max-width: 950px; padding: 35px 28px; margin: auto; }
.reference h1 { margin-top: 20px; }
.reference pre { white-space: pre-wrap; font-family: inherit; font-size: 12px; }
.reference form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin: 18px 0; }
.reference form label { flex: 1; min-width: 150px; }
.sync { padding: 9px 28px; font-size: 12px; background: #fff4dc; }
.sync button { min-height: 28px; font-size: 12px; margin-left: 12px; padding: 4px 8px; }
body:has(.sync:not([hidden])) .layout { height: calc(100dvh - 140px); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); padding: 12px 22px; background: #244e3f; color: white; border-radius: 8px; box-shadow: 0 5px 25px #0002; z-index: 20; max-width: 90vw; }
.login { max-width: 410px; margin: 11vh auto; padding: 28px; }
.login .wordmark { margin-bottom: 40px; }
.login h1 { font-size: 28px; }
.login form { display: grid; gap: 18px; margin: 30px 0 24px; }
.login form .error { margin: 0; }
#add-user { min-height: 44px; white-space: nowrap; }
#user-dialog { width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
#user-dialog::backdrop { background: #18312880; }
.user-dialog-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; background: white; border-bottom: 1px solid var(--line); }
.user-dialog-header h2 { margin: 0; }
#close-user-dialog { flex-shrink: 0; }
#user-form { display: grid; gap: 16px; padding: 20px; }
#user-form .error { margin: 0; overflow-wrap: anywhere; }
#user-dialog button, #user-dialog input, #user-dialog select { min-height: 44px; }
/* Fit search beside the filters only when the queue itself is wide enough. */
@container (min-width: 500px) {
  .filters { grid-template-columns: minmax(140px, 1fr) minmax(0, 1.7fr); align-items: end; gap: 8px; }
}
@media (min-width: 1500px) {
  .layout { grid-template-columns: minmax(460px, 39%) minmax(0, 1fr); }
  .inspector { padding-left: 64px; padding-right: 64px; }
  .queue-panel { padding-left: 38px; padding-right: 30px; }
}
@media (max-width: 1050px) {
  .topbar { padding: 0 20px; gap: 24px; }
  nav { gap: 18px; }
  .wordmark span { display: none; }
  .layout { grid-template-columns: minmax(340px, 42%) minmax(0, 1fr); }
  .queue-panel { padding-left: 18px; padding-right: 14px; }
  .inspector { padding: 22px; }
  .field { grid-template-columns: 110px minmax(0, 1fr) 32px; }
}
@media (max-width: 880px) {
  .layout { display: block; height: auto !important; }
  .queue-panel { display: block; height: auto; max-width: 740px; margin: auto; padding: 14px 24px 24px; border-right: 0; }
  .list { overflow: visible; }
  .layout.has-selection .queue-panel { display: none; }
  .inspector { display: none; overflow: visible; }
  .layout.has-selection .inspector { display: block; max-width: 740px; margin: auto; padding: 28px; }
  .account { flex-wrap: wrap; justify-content: flex-end; gap: 3px 8px; }
  .account #account { flex-basis: 100%; text-align: right; font-size: 11px; }
}
@media (max-width: 520px) {
  :root { font-size: 14px; }
  .demo { padding: 8px 14px; font-size: 10px; }
  .demo span { display: block; padding-top: 3px; }
  .topbar { padding: 2px 14px; gap: 0 14px; flex-wrap: wrap; }
  .wordmark { font-size: 23px; }
  nav { order: 3; width: 100%; gap: 22px; }
  nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: 12px; padding: 10px 0; }
  .account button { min-height: 44px; }
  .account { margin-left: auto; max-width: calc(100% - 75px); }
  .queue-panel { padding: 12px 14px; }
  .queue-heading .eyebrow { display: none; }
  .filter-row { gap: 6px; }
  .search-label input, .filter-row select { min-height: 44px; font-size: 16px; }
  .filter-row > button, .view-menu > summary, #mail-group { min-height: 44px; }
  .filter-row > button { padding: 8px; }
  .list-meta { font-size: 9px; }
  .queue-row { padding: 10px 9px; grid-template-columns: minmax(0, 1fr) 80px; }
  .row-title { font-size: 13px; }
  .layout.has-selection .inspector { padding: 10px 18px 120px; }
  .detail-header h1 { font-size: 22px; line-height: 1.25; margin-bottom: 10px; }
  .detail-nav { margin-bottom: 10px; }
  .detail-facts { margin: 12px 0; padding-bottom: 12px; gap: 8px 18px; }
  .decision-actions { position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; margin: 0; padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px #21312e10; }
  .decision-actions button { flex: 1; min-height: 44px; }
  .detail-nav a { display: inline-flex; align-items: center; min-height: 44px; }
  .field { grid-template-columns: minmax(0, 1fr) 40px; }
  .field-name { grid-column: 1 / -1; font-size: 11px; }
  .field-value { grid-column: 1; }
  .evidence { grid-column: 1 / -1; }
  button, summary { min-height: 44px; }
  .field .copy { min-height: 44px; }
  .reference { padding: 24px 18px; }
  .view-options { position: fixed; top: 180px; left: 14px; right: 14px; width: auto; }
  .sync { padding: 10px 14px; }
}
@media (prefers-reduced-motion: no-preference) {
  button, a { transition: background-color .12s; }
}
/* Compact local management, also on narrow phones. Dialogs own their scroll. */
#edit-dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto; border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
#edit-dialog::backdrop { background: #101b2c88; }
#edit-dialog .user-dialog-header, #user-dialog .user-dialog-header { position: sticky; top: -20px; background: var(--surface, #fff); z-index: 2; padding-block: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin: 12px 0; }
.form-grid p, .form-grid .check { grid-column: 1 / -1; }
.form-grid label { min-width: 0; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; min-width: 0; box-sizing: border-box; }
.form-grid .check input { width: auto; }
#edit-dialog button, .buyer-row button, .channel-row button, .ref-item button { min-height: 44px; }
.buyer-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 16px; border-bottom: 1px solid var(--line); padding: 12px 0; overflow-wrap: anywhere; }
.buyer-row small, .channel-row small { display: block; color: var(--muted); }
.buyer-row details { grid-column: 1 / -1; }
.row-buttons { display: flex; flex-wrap: wrap; align-items: start; gap: 6px; }
.channel-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); background: #f4f7fb; }
.channel-row span { min-width: 0; }
.channel-row button { flex-shrink: 0; align-self: start; }
.family { padding: 8px 16px; border-bottom: 1px solid var(--line); }
.family a { display: block; padding: 8px 0; }
.duplicate-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.duplicate-controls [aria-pressed=true] { background: #dceaf8; border-color: #517aab; }
.clipboard-fallback { position: fixed; left: -10000px; top: 0; }
@media (max-width: 520px) {
  .form-grid { grid-template-columns: minmax(0,1fr); }
  .buyer-row { grid-template-columns: minmax(0,1fr); }
  .channel-row { flex-wrap: wrap; }
  #edit-dialog { padding: 16px; }
}

#edit-dialog .user-dialog-header h2 { min-width: 0; overflow-wrap: anywhere; margin: 0; }
#edit-dialog .user-dialog-header button { flex-shrink: 0; }

/* Persistent environment provenance, including login and mobile. */
.demo { position: sticky; top: 0; z-index: 1000; }
.delivery pre, #domain pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 32rem; overflow: auto; }
