/* AppraiserOps styles. Colours, fonts and radius come from the account theme (public/themes.js),
   applied as CSS custom properties on <html>. The :root values below are the Clean Light fallback. */
@import url('/fonts.css');
:root {
  --font-head: 'Inter', system-ui, sans-serif; --font-body: 'Inter', system-ui, sans-serif; --head-weight: 700; --radius: 10px;
  --bg: #f5f6f8; --card: #fff; --card-2: #f1f3f6; --line: #e3e6eb; --line-2: #c9d0d9; --text: #1b2430; --muted: #556070; --heading: #111827; --link: #1d4ed8;
  --navy: #1f2937; --navy-2: #2d3a4d; --navy-3: #46546a; --on-navy: #fff; --on-navy-muted: #c8d0db;
  --gold: #2563eb; --gold-2: #1d4ed8; --gold-soft: #e8f0fe; --on-gold: #fff; --gold-text: #1e40af;
  --ok: #1a7340; --ok-bg: #e6f4ec; --warn: #8a4b00; --warn-bg: #fdf1d8; --bad: #b42318; --bad-bg: #fdecea; --info: #2f5597; --info-bg: #e8eef9;
  --ai: #5b3db0; --ai-bg: #efe9fb; --urgent: #b42318; --on-urgent: #fff; --passed: #374151; --on-passed: #fff;
  --row-bad: #fff4f2; --row-warn: #fffaef; --track: #e9edf2;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font-body); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .serif { font-family: var(--font-head); font-weight: var(--head-weight); color: var(--heading); letter-spacing: .1px; }
h1 { font-size: 32px; margin: 0 0 4px; line-height: 1.15; }
h2 { font-size: 24px; margin: 0 0 8px; line-height: 1.2; }
h3 { font-size: 19px; margin: 0 0 6px; line-height: 1.25; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* Top bar */
.topbar { background: var(--navy); color: var(--on-navy); position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.topbar-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--on-navy); white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--gold); display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; color: var(--on-navy); font-size: 15px; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-mark.logo { border-radius: 8px; width: auto; min-width: 34px; max-width: 120px; padding: 0; border: 0; }
.brand-name { font-family: var(--font-head); font-size: 19px; font-weight: var(--head-weight); color: var(--on-navy); line-height: 1; }
.brand-sub { font-size: 11px; color: var(--on-navy-muted); letter-spacing: .12em; text-transform: uppercase; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--on-navy-muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.nav a:hover { background: var(--navy-2); color: var(--on-navy); }
.nav a.active { color: var(--on-gold); background: var(--gold); }
.nav .count { background: var(--urgent); color: var(--on-urgent); border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; font-weight: 600; }
.nav a.active .count { background: var(--navy); color: var(--on-navy); }
.who { font-size: 12px; color: var(--on-navy-muted); white-space: nowrap; display: flex; align-items: center; gap: 10px; }
.who button { background: transparent; border: 1px solid var(--navy-3); color: var(--on-navy); border-radius: 8px; padding: 4px 10px; cursor: pointer; }

main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; color: var(--muted); }
.demo-note { font-size: 12px; color: var(--muted); background: var(--gold-soft); color: var(--gold-text); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }

/* Cards and layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { align-items: flex-end; }
.spacer { flex: 1; }
.section { margin-top: 26px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* Buttons and inputs */
.btn { border: 1px solid var(--line-2); background: var(--card); color: var(--text); border-radius: 9px; padding: 8px 14px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; line-height: 1.3; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--gold); background: var(--card-2); }
.btn.primary { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.btn.gold:hover { background: var(--gold-2); border-color: var(--gold-2); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 0; }
.input, select.input, textarea.input { border: 1px solid var(--line-2); border-radius: calc(var(--radius) - 2px); padding: 8px 10px; background: var(--card); color: var(--text); font-size: 14px; min-width: 0; width: 100%; }
.input:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
textarea.input { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--navy-3); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--navy-3); }
.toggle input { accent-color: var(--gold); width: 16px; height: 16px; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--card-2); color: var(--text); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.gold { background: var(--gold-soft); color: var(--gold-text); }
.pill.navy { background: var(--navy); color: var(--on-navy); }

/* Metrics */
.metric { padding: 16px 18px; }
.metric .v { font-family: var(--font-head); font-size: 28px; font-weight: var(--head-weight); color: var(--heading); line-height: 1.1; }
.metric .l { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.metric .d { color: var(--muted-2); font-size: 12px; margin-top: 2px; }
.metric.warn .v { color: var(--warn); }
.metric.bad .v { color: var(--bad); }
.metric { border-top: 3px solid var(--gold); }

/* Queue */
.queue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.qcard { display: flex; flex-direction: column; gap: 12px; position: relative; }
.qcard.spam { border-color: var(--bad); background: var(--row-bad); }
.qcard.urgent { border-color: var(--urgent); box-shadow: 0 0 0 2px var(--urgent), var(--shadow); }
.qcard.fwdconfirm { border: 2px dashed var(--gold); background: var(--card); }
.qmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.qtitle { font-family: var(--font-head); font-size: 19px; font-weight: var(--head-weight); color: var(--heading); line-height: 1.2; }
.qsub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.props { display: grid; grid-template-columns: 120px 1fr; gap: 5px 12px; font-size: 13px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.props dd.missing { color: var(--warn); font-weight: 400; font-style: italic; }
.conf { display: flex; align-items: center; gap: 8px; }
.conf-bar { flex: 1; height: 6px; background: var(--track); border-radius: 99px; overflow: hidden; max-width: 140px; }
.conf-bar span { display: block; height: 100%; border-radius: 99px; }
.flags { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.flags li { font-size: 12.5px; padding: 6px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); }
.flags li.bad { background: var(--bad-bg); color: var(--bad); }
.files { display: flex; gap: 6px; flex-wrap: wrap; }
.deadline { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--info-bg); color: var(--info); font-size: 13px; }
.deadline b { font-size: 15px; }
.deadline.soon { background: var(--warn-bg); color: var(--warn); }
.deadline.urgent { background: var(--urgent); color: var(--on-urgent); animation: pulse 2s ease-in-out infinite; }
.deadline.passed { background: var(--passed); color: var(--on-passed); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--bad-bg); } }
@media (prefers-reduced-motion: reduce) { .deadline.urgent { animation: none; } }
.platform-note { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; background: var(--card-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--card-2); }
table.t tr.row-bad td { background: var(--row-bad); }
table.t tr.row-bad td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
table.t tr.row-warn td { background: var(--row-warn); }
table.t tr.row-warn td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
table.t tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
table.t tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.jobno { font-weight: 600; color: var(--heading); white-space: nowrap; }

/* Charts */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { display: block; height: 12px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.bar-row .fill.navy { background: var(--info); }
.bar-row .fill.bad { background: var(--bad); }
.bar-row .fill.warn { background: var(--warn); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.bar-row .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols { display: flex; align-items: flex-end; gap: 8px; height: 200px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.cols .m { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.cols .pair { display: flex; align-items: flex-end; gap: 2px; height: 100%; width: 100%; justify-content: center; }
.cols .c { width: 42%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 1px; }
.cols .c.inc { background: var(--gold); }
.cols .c.exp { background: var(--info); }
.cols-labels { display: flex; gap: 8px; }
.cols-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Job detail */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ''; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.timeline li::after { content: ''; position: absolute; left: 10px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.done::before { background: var(--gold); }
.timeline li.alert::before { background: var(--bad); }
.timeline .tt { font-weight: 600; color: var(--heading); }
.timeline .td { font-size: 12.5px; color: var(--muted); }
pre.draft { white-space: pre-wrap; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-family: var(--font-body); font-size: 13px; margin: 0; }

/* Modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,22,33,.55); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--card); border-radius: 14px; width: min(980px, 100%); height: min(88vh, 1000px); display: flex; flex-direction: column; overflow: hidden; }
.modal.small { height: auto; width: min(560px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-body { flex: 1; overflow: auto; }
.modal iframe { width: 100%; height: 100%; border: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: var(--on-navy); padding: 12px 18px; border-radius: 12px; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.25); display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px); }
.toast a { color: var(--gold); font-weight: 600; }
.toast.err { background: var(--bad); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--navy); padding: 20px; }
.login .card { width: min(420px, 100%); padding: 32px; }
.login .brand-name { font-size: 30px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--heading); }
.callout { padding: 12px 14px; border-radius: 10px; background: var(--info-bg); color: var(--info); font-size: 13px; }
.callout.warn { background: var(--warn-bg); color: var(--warn); }
details.panel > summary { cursor: pointer; list-style: none; font-weight: 600; color: var(--heading); display: flex; align-items: center; gap: 8px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: '+'; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--gold-soft); color: var(--gold-2); font-weight: 700; }
details.panel[open] > summary::before { content: '−'; }

/* Phone */
@media (max-width: 860px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .topbar-inner { height: auto; flex-wrap: wrap; padding: 10px 14px 0; gap: 10px; }
  .brand-sub, .who span { display: none; }
  .who { margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 8px; }
  main { padding: 16px 12px 60px; }
  h1 { font-size: 26px; }
  .queue-grid { grid-template-columns: 1fr; }
  .metric .v { font-size: 24px; }
  .bar-row { grid-template-columns: 100px 1fr 70px; }
  /* stacked table rows */
  table.t.stackable thead { display: none; }
  table.t.stackable, table.t.stackable tbody, table.t.stackable tr, table.t.stackable td { display: block; width: 100%; }
  table.t.stackable tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.t.stackable td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.t.stackable td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex-shrink: 0; }
  table.t.stackable td.num { text-align: right; }
  table.t.stackable tr.row-bad td:first-child, table.t.stackable tr.row-warn td:first-child { box-shadow: none; }
  table.t.stackable tr.row-bad { box-shadow: inset 3px 0 0 var(--bad); }
  table.t.stackable tr.row-warn { box-shadow: inset 3px 0 0 var(--warn); }
  .modal { height: 92vh; }
}

.pill.ai { background: var(--ai-bg); color: var(--ai); font-size: 11px; padding: 1px 7px; vertical-align: 1px; }

/* Theme picker */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.swatch { display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 2px solid var(--line); cursor: pointer; text-align: left; font-size: 12px; }
.swatch.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.swatch:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.sw-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-radius: 6px; font-size: 15px; }
.sw-acc { font-size: 11px; padding: 1px 8px; border-radius: 99px; font-weight: 600; }
.sw-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid; border-radius: 6px; }
.sw-title { font-size: 15px; line-height: 1.2; }
.sw-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.sw-chip { font-size: 10.5px; padding: 1px 6px; border-radius: 99px; font-weight: 600; }
.sw-desc { font-size: 11.5px; line-height: 1.35; }
.logo-preview { height: 34px; max-width: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.intake-addr { background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; word-break: break-all; }
ul.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.login-brand { color: var(--heading); }
.login-brand .brand-mark { background: var(--navy); color: var(--on-navy); border-color: var(--gold); }
.login-brand .brand-name { color: var(--heading); }
[data-theme="high-contrast"] .card, [data-theme="high-contrast"] .table-wrap { border-width: 2px; }
[data-theme="high-contrast"] a { text-decoration: underline; }
[data-theme="high-contrast"] :focus-visible { outline: 3px solid #0039a6; outline-offset: 2px; }
