/* Agents of the Shield Competitive Comparison
   Brand palette lives in these variables; swap the hex values to re-theme. */
:root {
  --navy: #0b2a4a;        /* primary */
  --navy-2: #163d66;
  --teal: #00838f;        /* accent */
  --teal-soft: #e3f3f4;
  --silver: #aaabad;
  --gray: #707172;
  --ink: #1d2530;
  --ink-2: #4d5866;
  --line: #dde2e8;
  --bg: #f4f6f8;
  --card: #ffffff;
  /* Chart diverging pair (validated for color-blind separation and contrast) */
  --up: #c2410c;          /* rate increase */
  --down: #0277a8;        /* rate decrease */
  --flat: #b8b8b8;
  /* Comparison verdicts (always shown with an icon + word, never color alone) */
  --win: #0f7a3a; --win-bg: #e6f4ea;
  --lose: #b42318; --lose-bg: #fdecea;
  --same-bg: #f1f3f5;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--teal); }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
.hidden { display: none !important; }

/* Header */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 22px; height: 60px; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--teal); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.brand small { display: block; font-weight: 500; color: var(--silver); font-size: 12px; }
.tabs { display: flex; gap: 4px; margin-left: 18px; }
.tabs button { background: none; border: 0; color: #cfd8e3; padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--navy-2); color: #fff; box-shadow: inset 0 -3px 0 var(--teal); }
.tabs button:hover { color: #fff; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; color: #cfd8e3; }
.who button { background: transparent; color: #fff; border: 1px solid #ffffff55; border-radius: 8px; padding: 5px 10px; }

main { max-width: 1360px; margin: 0 auto; padding: 22px; }
h1 { font-size: 22px; margin: 0 0 4px; color: var(--navy); }
h2 { font-size: 17px; margin: 0 0 10px; color: var(--navy); }
.sub { color: var(--ink-2); margin: 0 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.banner { background: #fff8e6; border: 1px solid #f3d48a; color: #6b4e00; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.banner.info { background: var(--teal-soft); border-color: #a9d8dc; color: #0b4f56; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.field select, .field input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 220px; max-width: 100%; }
.field label.check { display: flex; align-items: center; gap: 6px; text-transform: none; font-weight: 500; font-size: 14px; letter-spacing: 0; color: var(--ink-2); padding: 9px 0; margin: 0; }
.field label.check input { min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: #fff; padding: 8px 14px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 13px; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.mine { border-color: var(--teal); }
.btn { background: var(--teal); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.danger { background: #fff; color: var(--lose); border: 1px solid #f1c2bd; }

/* Comparison matrix */
.matrix-wrap { overflow-x: auto; }
table.matrix { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 760px; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); padding: 10px 12px; vertical-align: top; text-align: left; font-size: 14px; }
.matrix thead th { background: #fff; border-bottom: 2px solid var(--navy); }
.matrix th.attr { width: 190px; font-weight: 700; color: var(--navy); background: #fafbfc; }
.matrix td.mine-col, .matrix th.mine-col { background: #f3fafb; }
.colhead .carrier { font-weight: 800; color: var(--navy); }
.colhead .prod { font-size: 13px; color: var(--ink-2); }
.colhead .form { font-size: 12px; color: var(--gray); }
.tag { display: inline-block; font-size: 11px; background: var(--same-bg); color: var(--ink-2); border-radius: 4px; padding: 1px 6px; margin: 4px 4px 0 0; }
.verdict { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; margin-bottom: 4px; }
.verdict.win { background: var(--win-bg); color: var(--win); }
.verdict.lose { background: var(--lose-bg); color: var(--lose); }
.verdict.same { background: var(--same-bg); color: var(--ink-2); }
.cite { display: block; font-size: 11px; color: var(--gray); margin-top: 4px; }
.cite a { color: var(--gray); }

/* Talking points */
.tp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.tp h3 { margin: 0 0 8px; font-size: 16px; color: var(--navy); }
.tp h4 { margin: 12px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.tp h4.win { color: var(--win); } .tp h4.lose { color: var(--lose); }
.tp ol { margin: 0; padding-left: 20px; }
.tp li { margin-bottom: 9px; font-size: 14px; }
.tp li b { color: var(--navy); }
.tp .vs { color: var(--ink-2); font-size: 13px; display: block; margin-top: 2px; }
.tp .pitch { display: block; margin-top: 3px; }
.tp-actions { display: flex; gap: 8px; margin-top: 10px; }

/* Rate watch */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--ink-2); letter-spacing: .4px; }
.stat .v { font-size: 26px; font-weight: 800; color: var(--navy); }
.stat .d { font-size: 13px; color: var(--ink-2); }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) {
  .cols2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; position: static; }
  .tabs { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .tabs button { white-space: nowrap; }
  main { padding: 14px; }
  .bars { grid-template-columns: 110px 1fr; }
}
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); margin: 4px 0 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.legend .up { background: var(--up); } .legend .down { background: var(--down); } .legend .flat { background: var(--flat); }
.bars { display: grid; grid-template-columns: minmax(150px, 230px) 1fr; row-gap: 2px; column-gap: 10px; align-items: center; }
.bars .name { font-size: 13px; text-align: right; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 3px 0; cursor: pointer; }
.bars .name.mine { font-weight: 800; color: var(--navy); }
.bars .track { position: relative; height: 22px; cursor: pointer; }
.bars .zero { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--ink-2); }
.bars .bar { position: absolute; top: 4px; height: 14px; }
.bars .bar.up { background: var(--up); border-radius: 0 4px 4px 0; }
.bars .bar.down { background: var(--down); border-radius: 4px 0 0 4px; }
.bars .bar.flat { background: var(--flat); width: 2px; }
.bars .val { position: absolute; top: 2px; font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bars .track:hover .bar, .bars .track:focus .bar { filter: brightness(.85); }
.tooltip { position: fixed; pointer-events: none; background: var(--navy); color: #fff; font-size: 12px; padding: 8px 10px; border-radius: 6px; max-width: 320px; z-index: 50; white-space: pre-line; box-shadow: 0 4px 16px #0003; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--ink-2); border-bottom: 2px solid var(--line); padding: 6px 8px; }
table.list td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
table.list td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pct-up { color: var(--up); font-weight: 700; } .pct-down { color: var(--down); font-weight: 700; } .pct-flat { color: var(--gray); }
.drill { background: #fafbfc; }

/* News */
.news-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.news-item:last-child { border-bottom: 0; }
.news-item a.t { font-weight: 700; color: var(--navy); text-decoration: none; font-size: 15px; }
.news-item a.t:hover { text-decoration: underline; }
.news-item .meta { font-size: 12px; color: var(--gray); margin: 2px 0 4px; }
.news-item p { margin: 0; color: var(--ink-2); font-size: 14px; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 60%, var(--teal) 140%); }
.login-card { background: #fff; width: 380px; max-width: calc(100vw - 32px); border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px #0005; }
.login-card h1 { font-size: 20px; }
.login-card .field input { width: 100%; min-width: 0; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; padding: 10px; }
.err { color: var(--lose); font-size: 14px; min-height: 20px; margin: 6px 0; }
.ok { color: var(--win); font-size: 14px; }
.muted { color: var(--gray); font-size: 13px; }
.pending li { margin-bottom: 4px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-actions input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; width: 180px; }
.tag.tag-rc { background: var(--win-bg); color: var(--win); font-weight: 700; }
.tag.tag-acv { background: var(--lose-bg); color: var(--lose); font-weight: 700; }
