/* =============================================================================
   Quarry — shared design system
   =============================================================================
   Same tokens/components across every page (sign-in, Settings, Discovery
   Queue, Command Center) — this file is the single source of truth, derived
   from the approved Artifact mockups reviewed earlier. No build step: plain
   CSS, loaded via <link> on every page.
   ============================================================================= */

:root {
  --bg: #F6F4F0;
  --surface: #FFFFFF;
  --surface-2: #FBFAF7;
  --border: #E4DFD5;
  --text: #22201C;
  --text-muted: #6B6558;
  --accent: #A9752C;
  --accent-soft: #F1E4CC;
  --success: #3F7D55;
  --success-soft: #E4F0E7;
  --danger: #A84636;
  --danger-soft: #F5E7E3;
  --pending: #4C6B8A;
  --pending-soft: #E7EDF3;
  --shadow: 0 1px 2px rgba(34, 32, 28, 0.06), 0 8px 24px -12px rgba(34, 32, 28, 0.12);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171A; --surface: #1C1F23; --surface-2: #20242A; --border: #2C3036;
    --text: #EDEAE3; --text-muted: #9C978B; --accent: #D9A552; --accent-soft: #3A2F1C;
    --success: #6FBF8B; --success-soft: #1E2E23; --danger: #E08776; --danger-soft: #33211D;
    --pending: #86A9CC; --pending-soft: #1D2733;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #15171A; --surface: #1C1F23; --surface-2: #20242A; --border: #2C3036;
  --text: #EDEAE3; --text-muted: #9C978B; --accent: #D9A552; --accent-soft: #3A2F1C;
  --success: #6FBF8B; --success-soft: #1E2E23; --danger: #E08776; --danger-soft: #33211D;
  --pending: #86A9CC; --pending-soft: #1D2733;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
}
:root[data-theme="light"] {
  --bg: #F6F4F0; --surface: #FFFFFF; --surface-2: #FBFAF7; --border: #E4DFD5;
  --text: #22201C; --text-muted: #6B6558; --accent: #A9752C; --accent-soft: #F1E4CC;
  --success: #3F7D55; --success-soft: #E4F0E7; --danger: #A84636; --danger-soft: #F5E7E3;
  --pending: #4C6B8A; --pending-soft: #E7EDF3;
  --shadow: 0 1px 2px rgba(34,32,28,0.06), 0 8px 24px -12px rgba(34,32,28,0.12);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
}
h1, h2, h3 { font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif; }
.mono, .tabular { font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace; font-variant-numeric: tabular-nums; }
a { color: var(--accent); }

/* ---- Shell / sidebar nav ---- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; }
.wordmark { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.wordmark .mark { font-family: Georgia, serif; font-size: 21px; letter-spacing: 0.02em; font-weight: 700; }
.wordmark .sub { font-size: 11px; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-muted); text-decoration: none; font-size: 13.5px; font-weight: 500; }
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.active { background: var(--accent-soft); color: var(--accent); }
nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.55; }
.op-chip { margin-top: auto; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: 12px; color: var(--text-muted); }
.op-chip strong { display: block; color: var(--text); font-size: 13px; margin-bottom: 2px; }
.op-chip button.signout { margin-top: 8px; font: inherit; font-size: 11.5px; font-weight: 600; padding: 5px 10px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); }

main { padding: 32px 40px 80px; max-width: 1120px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; margin: 0 0 4px; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 13.5px; max-width: 66ch; }

/* ---- Buttons / forms ---- */
button { font: inherit; }
button.primary {
  font-weight: 600; font-size: 13px; padding: 10px 18px; border-radius: 8px;
  border: none; background: var(--accent); color: #fff; cursor: pointer; white-space: nowrap;
}
button.primary:hover { filter: brightness(1.05); }
button.primary:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn {
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 8px 16px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.approve, .btn.log, .btn.subscribe { background: var(--success); color: #fff; border: none; }
.btn.approve:hover, .btn.log:hover, .btn.subscribe:hover { filter: brightness(1.05); }
.btn.reject, .btn.archive, .btn.unsubscribe { color: var(--danger); }
.btn.reject:hover, .btn.archive:hover, .btn.unsubscribe:hover { background: var(--danger-soft); }
.btn.retry { color: var(--accent); }
.btn.retry:hover { background: var(--accent-soft); }
.btn.override, .btn.pause { color: var(--pending); border-color: var(--pending); }
.btn.override:hover, .btn.pause:hover { background: var(--pending-soft); }
.btn.outcome { color: var(--success); border-color: var(--success); }
.btn.outcome:hover { background: var(--success-soft); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; }
.field .hint { font-weight: 400; color: var(--text-muted); }
.field input, .field select, .field textarea {
  font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); width: 100%;
}
.field textarea { resize: vertical; min-height: 70px; font-family: ui-monospace, monospace; font-size: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Cards / panels ---- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.panel h2 { font-size: 15.5px; margin: 0 0 4px; }
.panel .panel-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 16px; line-height: 1.55; }

.queue-list { display: flex; flex-direction: column; gap: 12px; }
.g-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.g-card > summary {
  list-style: none; cursor: pointer; padding: 16px 20px; display: grid;
  grid-template-columns: 1fr auto auto auto auto auto; align-items: center; gap: 12px;
}
.g-card > summary::-webkit-details-marker { display: none; }
.g-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.g-title .sponsor { font-weight: 700; font-size: 14px; }
.g-title .prize { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-cat {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 700;
  padding: 3px 8px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
  white-space: nowrap;
}
.chev { color: var(--text-muted); font-size: 11px; transition: transform 0.15s; }
.g-card[open] .chev { transform: rotate(90deg); }
.g-detail { padding: 0 20px 20px; border-top: 1px solid var(--border); }
.g-detail-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; padding-top: 16px; }
.g-section { display: flex; flex-direction: column; gap: 8px; }
.g-section h4 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 700; }
.g-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 16px; }

.kv-list { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--text-muted); }
.kv-row .v { text-align: right; font-weight: 600; }
.kv-row .v.positive { color: var(--success); }

.note-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.note-box strong { color: var(--text); }
.note-box.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.note-box.danger strong { color: var(--danger); }
.note-box.flag { background: var(--pending-soft); border-color: transparent; color: var(--pending); }
.note-box.flag strong { color: var(--text); }
.note-box.success { background: var(--success-soft); border-color: transparent; color: var(--success); }

/* ---- Badges ---- */
.tier-badge, .period-badge, .gate-badge { font-size: 10.5px; font-weight: 700; padding: 4px 9px; border-radius: 6px; white-space: nowrap; }
.tier-badge.ideal { background: var(--success-soft); color: var(--success); }
.tier-badge.average { background: var(--accent-soft); color: var(--accent); }
.tier-badge.marginal { background: var(--pending-soft); color: var(--pending); }

.period-badge.live { background: var(--success-soft); color: var(--success); }
.period-badge.closing_soon { background: var(--danger-soft); color: var(--danger); }
.period-badge.scheduled { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.period-badge.expired { background: var(--danger-soft); color: var(--danger); }
.period-badge.unknown { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

.gate-badge.pass { background: var(--success-soft); color: var(--success); }
.gate-badge.fail, .gate-badge.ineligible { background: var(--danger-soft); color: var(--danger); }
.gate-badge.parse-failed { background: var(--pending-soft); color: var(--pending); }

.score-badge { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.score-circle {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 800; font-family: ui-monospace, monospace; flex-shrink: 0;
}
.score-circle.high { background: var(--success-soft); color: var(--success); }
.score-circle.medium { background: var(--pending-soft); color: var(--pending); }
.score-circle.low { background: var(--danger-soft); color: var(--danger); }
.score-meta { font-size: 10.5px; color: var(--text-muted); line-height: 1.3; }
.score-meta strong { display: block; color: var(--text); font-size: 11.5px; }

.profit-strip { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; white-space: nowrap; }
.profit-strip .profit-line { font-size: 14px; font-weight: 800; color: var(--success); }
.profit-strip .profit-line.negative { color: var(--danger); }
.profit-strip .profit-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }

.profit-box { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.profit-box .p-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 8px 12px;
  font-size: 12.5px; border-bottom: 1px dashed var(--border); align-items: baseline;
}
.profit-box .p-row:last-child { border-bottom: none; }
.profit-box .p-row .k { color: var(--text-muted); }
.profit-box .p-row .v { font-weight: 600; text-align: right; }
.profit-box .p-row.total { background: var(--accent-soft); }
.profit-box .p-row.total .k { color: var(--text); font-weight: 700; }
.profit-box .p-row.total .v { font-size: 15px; font-weight: 800; color: var(--success); }

.checkpoint-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.checkpoint-table th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 5px 8px 6px 0; border-bottom: 1px solid var(--border); }
.checkpoint-table th.num, .checkpoint-table td.num { text-align: right; }
.checkpoint-table td { padding: 7px 8px 7px 0; border-bottom: 1px dashed var(--border); vertical-align: top; }
.checkpoint-table tr:last-child td { border-bottom: none; }
.checkpoint-table .target-cell { font-weight: 700; }
.checkpoint-table .unreachable { color: var(--text-muted); }
.checkpoint-table .unreachable-note { display: block; font-size: 10.5px; font-style: italic; color: var(--danger); margin-top: 2px; }
.checkpoint-table .reached-note { display: block; font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

.period-box { display: flex; gap: 18px; flex-wrap: wrap; }
.period-stat { display: flex; flex-direction: column; gap: 2px; }
.period-stat .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 700; }
.period-stat .v { font-size: 13px; font-weight: 700; }
.period-stat .v.urgent { color: var(--danger); }

.pool-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 12px; }
.pool-box .pool-headline { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pool-box .pool-value { font-weight: 700; font-family: ui-monospace, monospace; }
.confidence-chip { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; padding: 2px 7px; border-radius: 5px; }
.confidence-chip.low { background: var(--danger-soft); color: var(--danger); }
.confidence-chip.medium { background: var(--pending-soft); color: var(--pending); }
.confidence-chip.operator_override { background: var(--success-soft); color: var(--success); }
.pool-box .pool-basis { color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.pool-box .set-pool-btn { margin-top: 8px; font-size: 11.5px; font-weight: 600; padding: 6px 11px; border-radius: 6px; cursor: pointer; border: 1px solid var(--accent); background: none; color: var(--accent); }
.pool-box .set-pool-btn:hover { background: var(--accent-soft); }

.evidence-list { display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.evidence-row { display: flex; align-items: flex-start; gap: 7px; }
.evidence-row .flag { width: 14px; flex-shrink: 0; font-weight: 800; text-align: center; }
.evidence-row.yes .flag { color: var(--success); }
.evidence-row.no .flag { color: var(--danger); }
.evidence-row.nc .flag { color: var(--text-muted); }
.evidence-row .item-label { color: var(--text); }
.evidence-row.nc .item-label { color: var(--text-muted); font-style: italic; }

.progress-wrap { display: flex; flex-direction: column; gap: 5px; }
.progress-track { height: 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.progress-fill.capped { background: var(--success); }
.progress-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }
.progress-label strong { color: var(--text); font-family: ui-monospace, monospace; }
.target-reason { font-size: 10.5px; color: var(--text-muted); font-style: italic; margin-top: 2px; }

.recurrence-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--pending-soft); border: 1px solid transparent; border-radius: 8px;
  padding: 9px 14px; margin-bottom: 14px; font-size: 12px; color: var(--pending);
}
.recurrence-banner strong { color: var(--text); }
.recurrence-actions { display: flex; gap: 6px; flex-shrink: 0; }
.recurrence-actions button {
  font-size: 11.5px; font-weight: 600; padding: 5px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
}
.recurrence-actions button.confirm { color: var(--success); }
.recurrence-actions button.dismiss { color: var(--text-muted); }

.sponsor-group { margin-bottom: 18px; }
.sponsor-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--pending-soft); color: var(--pending); border-radius: 8px 8px 0 0;
  padding: 10px 16px; font-size: 12px; border: 1px solid var(--border); border-bottom: none;
}
.sponsor-banner strong { color: var(--text); }
.sponsor-group .queue-list { gap: 0; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; background: var(--surface); }
.sponsor-group .g-card { border: none; border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--border); }
.sponsor-group .g-card:last-child { border-bottom: none; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; color: var(--text-muted); margin: 24px 0 10px; }
.section-label:first-of-type { margin-top: 0; }

.totals-line { font-size: 12.5px; color: var(--text-muted); margin: 14px 0 22px; padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.totals-line strong { color: var(--text); font-family: ui-monospace, monospace; }

/* ---- Status tabs ---- */
.tab-radio { position: absolute; opacity: 0; width: 0; height: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs label {
  display: flex; align-items: center; gap: 6px; padding: 9px 4px; margin-right: 18px;
  font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; user-select: none;
}
.tabs label .count {
  font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-muted); font-family: ui-monospace, monospace;
}

/* ---- Tables (settings ledgers, wins, mail-log) ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 6px 10px 8px 0; border-bottom: 1px solid var(--border); }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table td { padding: 8px 10px 8px 0; border-bottom: 1px dashed var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .row-del { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 12px; }

.empty-state { padding: 48px 20px; text-align: center; color: var(--text-muted); font-size: 13px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.loading-state { padding: 24px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
.error-banner { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 10px 14px; font-size: 12.5px; margin-bottom: 16px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 12.5px; box-shadow: var(--shadow); z-index: 100; max-width: 360px; }
.toast.error { background: var(--danger); color: #fff; }

/* ---- Sign-in page ---- */
.signin-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.signin-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px; }
.signin-card .wordmark { padding: 0; margin-bottom: 22px; }
.signin-card h1 { font-size: 19px; margin: 0 0 6px; }
.signin-card p { font-size: 12.5px; color: var(--text-muted); margin: 0 0 20px; line-height: 1.5; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 14px 16px; }
  .op-chip { display: none; }
  main { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
  .g-card > summary { grid-template-columns: 1fr; row-gap: 8px; }
  .g-detail-grid { grid-template-columns: 1fr; }
  .checkpoint-table, .data-table { display: block; overflow-x: auto; }
}
