/* Appaloosa Deal Feed: one stylesheet, no build step. */
:root {
  --brand: #1f3864;
  --brand-2: #2b4c86;
  --brand-tint: #eaf0fa;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --line: #e3e7ee;
  --line-strong: #cfd6e1;
  --ink: #18202e;
  --ink-2: #3d4757;
  --muted: #6a7486;
  --good: #11704a;  --good-bg: #e5f5ed;
  --warn: #8f5d00;  --warn-bg: #fdf1d6;
  --bad: #b42318;   --bad-bg: #fdeceb;
  --info: #1f4e8c;  --info-bg: #e7effb;
  --mark: #fff0a8;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--ink); line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
p { margin: 0 0 8px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1440px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
.nav a { color: rgba(255, 255, 255, .78); padding: 8px 12px; border-radius: 7px; font-weight: 550; white-space: nowrap; display: flex; align-items: center; gap: 7px; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .09); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(255, 255, 255, .16); }
.nav .count { background: #f6c453; color: #3d2a00; border-radius: 10px; padding: 0 7px; font-size: 11.5px; font-weight: 700; line-height: 18px; }
.nav .count.alert { background: #ffb4ab; color: #5c0b05; }
.user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: rgba(255, 255, 255, .85); white-space: nowrap; }
.user form { margin: 0; }
.user button { background: none; border: 1px solid rgba(255, 255, 255, .35); color: #fff; border-radius: 7px; padding: 5px 10px; font: inherit; cursor: pointer; }
.user button:hover { background: rgba(255, 255, 255, .1); }
.user a { color: rgba(255, 255, 255, .85); }

/* ---------- page */
.page { max-width: 1440px; margin: 0 auto; padding: 24px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- messages */
.flash { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }
.flash.success { background: var(--good-bg); color: var(--good); border-color: #bfe3cf; }
.flash.info { background: var(--info-bg); color: var(--info); border-color: #c8d8f0; }
.flash.error, .flash.warning { background: var(--bad-bg); color: var(--bad); border-color: #f4c7c3; }

/* ---------- panels and stat tiles */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.panel-body { padding: 16px 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); min-width: 0; overflow-wrap: anywhere; }
.tile .pill { white-space: normal; }
.tile .n { font-size: 24px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.tile .l { font-size: 12px; color: var(--muted); font-weight: 550; }
a.tile:hover { text-decoration: none; border-color: var(--line-strong); }
.tile.warn .n { color: var(--warn); }

/* ---------- buttons and inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: var(--radius-sm); padding: 7px 13px; font: 550 13.5px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f7f9fc; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: #f0c2bd; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=search], input[type=email], input[type=url], input[type=number], input[type=date], input[type=password], select, textarea {
  font: 14px var(--font); color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(43, 76, 134, .15); }
textarea { resize: vertical; }
label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field .help { font-size: 12px; color: var(--muted); }
.field .errors, .errorlist { color: var(--bad); font-size: 12.5px; margin: 0; padding: 0; list-style: none; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 16px; }
.form-section + .form-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-section > h2 { margin-bottom: 12px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.checks label { display: flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; cursor: pointer; background: #fff; }
.checks input { margin: 0; }
.toggle { display: flex; gap: 10px; align-items: flex-start; }
.toggle input { margin-top: 3px; }

/* ---------- filters */
.filters { padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-row .search { flex: 1 1 260px; min-width: 200px; }
.filter-row select { width: auto; min-width: 150px; }
.segmented { display: inline-flex; max-width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow-x: auto; background: #fff; }
.segmented label { padding: 6px 12px; font-weight: 550; font-size: 13px; color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line); white-space: nowrap; position: relative; }
.segmented label:last-child { border-right: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--brand); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); background: #fff; border-radius: 16px; padding: 3px 11px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 4px; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
.table-wrap > table.data { min-width: 640px; }  /* scroll inside the panel rather than squeeze columns */
.table-wrap > table.data.wide { min-width: 1000px; }
table.data td.practice { min-width: 240px; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f8fafc; white-space: nowrap; position: sticky; top: 0; }
table.data th.num { text-align: right; }
table.data th a { color: inherit; }
table.data th a.sorted { color: var(--brand); }
table.data td { padding: 11px 12px; border-bottom: 1px solid #eef1f5; vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #fafbfd; }
.cell-title { font-weight: 600; color: var(--ink); }
.cell-title:hover { color: var(--brand-2); }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--ink-2); margin-bottom: 6px; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- pills */
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 12px; padding: 1px 9px; font-size: 11.5px; font-weight: 650; white-space: nowrap; line-height: 20px; }
.pill.good { background: var(--good-bg); color: var(--good); }
.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.muted { background: #eef1f5; color: #4b5565; }
.pill.brand { background: var(--brand); color: #fff; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 5px; margin-left: 5px; vertical-align: 1px; }
.down { color: var(--bad); font-weight: 650; }
.up { color: var(--good); font-weight: 650; }
.score { display: inline-flex; align-items: center; gap: 6px; }
.score b { font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }

/* ---------- listing detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.detail > *, .stack > * { min-width: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0; }
.fact { padding: 12px 16px; border-bottom: 1px solid #eef1f5; border-right: 1px solid #eef1f5; }
.fact .l { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.fact .v { font-size: 16px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.fact .v small { font-size: 12px; font-weight: 600; color: var(--muted); }
.fact .s { font-size: 12px; color: var(--muted); margin-top: 1px; }
.timeline { list-style: none; margin: 0; padding: 4px 0; }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li:last-child { padding-bottom: 2px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); box-shadow: 0 0 0 3px #fff; }
.timeline li::after { content: ""; position: absolute; left: 10.5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.price_change::before { background: var(--bad); }
.timeline li.new::before { background: var(--good); }
.timeline li.status_change::before, .timeline li.stale::before, .timeline li.relisted::before { background: #e3a008; }
.timeline .when { font-size: 12px; color: var(--muted); }
.score-bars { display: grid; gap: 8px; }
.score-bar { display: grid; grid-template-columns: 96px 1fr 34px; gap: 8px; align-items: center; font-size: 12.5px; }
.score-bar .track { background: #eef1f5; border-radius: 4px; height: 8px; overflow: hidden; }
.score-bar .fill { background: var(--brand-2); height: 100%; }
.big-score { display: flex; align-items: baseline; gap: 8px; }
.big-score b { font-size: 30px; color: var(--brand); font-variant-numeric: tabular-nums; }

/* ---------- review */
.review-card { margin-bottom: 18px; }
.review-card .panel-head { align-items: flex-start; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.review-grid > div { padding: 16px 18px; }
.review-grid > div + div { border-left: 1px solid var(--line); background: #fbfcfe; }
.match { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; }
.match.new { background: var(--good-bg); color: var(--good); }
.match.update { background: var(--info-bg); color: var(--info); }
.match.choose { background: var(--warn-bg); color: var(--warn); }
.match label { font-weight: 500; color: var(--ink); display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 13px; }
.checks-failed { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.checks-failed ul { margin: 4px 0 0; padding-left: 18px; }
.quote { font-size: 12px; color: var(--muted); border-left: 2px solid var(--line-strong); padding-left: 7px; margin-top: 2px; font-style: italic; overflow-wrap: anywhere; }
.email-text { white-space: pre-wrap; font: 13px/1.6 var(--font); color: var(--ink-2); max-height: 560px; overflow: auto; overflow-wrap: anywhere; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.review-actions { display: flex; gap: 10px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.review-actions input[type=text] { flex: 0 1 260px; min-width: 160px; }
.done { padding: 14px 18px; display: flex; align-items: center; gap: 10px; }

/* ---------- inbox / email */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .n { font-size: 11.5px; background: #eef1f5; color: var(--ink-2); border-radius: 9px; padding: 0 6px; }
.email-frame { width: 100%; height: 620px; border: 0; background: #fff; border-radius: 0 0 var(--radius) var(--radius); }
dl.meta { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
dl.meta dt { color: var(--muted); font-weight: 600; }
dl.meta dd { margin: 0; overflow-wrap: anywhere; }
dl.meta.counts { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
dl.meta.counts dd { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
details > summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }

/* ---------- login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #1f3864 0%, #2b4c86 55%, #f4f6fa 55.1%); }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(16, 24, 40, .18); padding: 28px; }
.auth-card .brand { color: var(--ink); margin-bottom: 18px; }
.auth-card .brand-mark { background: var(--brand); color: #fff; }

/* ---------- footer */
.foot { max-width: 1440px; margin: 0 auto; padding: 0 24px 28px; color: var(--muted); font-size: 12px; }

@media (max-width: 1100px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
  .review-grid { grid-template-columns: minmax(0, 1fr); }
  .review-grid > div + div { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .topbar { position: static; }
  .topbar-inner { flex-wrap: wrap; height: auto; gap: 4px 12px; padding: 10px 12px 6px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -6px; }
  .nav { gap: 0; }
  .nav a { padding: 6px 7px; font-size: 13px; }
  .user .name { display: none; }
  .page { padding: 16px 12px 48px; }
  .foot { padding: 0 12px 24px; }
  .filter-row select { flex: 1 1 140px; min-width: 0; }
  dl.meta { grid-template-columns: 96px minmax(0, 1fr); }
}
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { opacity: 1; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
