/* CRA Review Hub — desert + river palette */
:root {
  --bg: #f6f1e8;
  --surface: #fffdf9;
  --surface-2: #efe7da;
  --line: #e0d5c3;
  --ink: #2b2620;
  --ink-2: #5f564b;
  --muted: #8a7f71;
  --river: #1f6f78;
  --river-ink: #ffffff;
  --river-soft: #d9ecec;
  --sun: #e08a2e;
  --good: #2f7d4a;   --good-bg: #e2f1e6;
  --warn: #9a6a00;   --warn-bg: #fbefcf;
  --bad: #b3261e;    --bad-bg: #fbe3e0;
  --star: #d9921a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(60,40,10,.06), 0 2px 8px rgba(60,40,10,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181614;
    --surface: #221f1c;
    --surface-2: #2c2824;
    --line: #3a352f;
    --ink: #efe9e0;
    --ink-2: #c4bab0;
    --muted: #978d82;
    --river: #5bb3ba;
    --river-ink: #0f1f21;
    --river-soft: #1d3638;
    --sun: #f0a24c;
    --good: #7cc692;   --good-bg: #1e3526;
    --warn: #e5bd55;   --warn-bg: #3a3017;
    --bad: #f08a80;    --bad-bg: #402320;
    --star: #f0b24c;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--river); }
h1 { font-size: 1.45rem; margin: 0 0 .75rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a { padding: .4rem .7rem; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.mainnav a:hover { background: var(--surface-2); }
.mainnav a.on { background: var(--river-soft); color: var(--river); }
.who { margin-left: auto; color: var(--muted); font-size: .9rem; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }

/* Forms */
.stack { display: grid; gap: .8rem; }
label { display: grid; gap: .3rem; font-weight: 500; font-size: .9rem; color: var(--ink-2); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; width: 100%;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--river); outline-offset: 1px; }
.btn {
  display: inline-flex; align-items: center; gap: .35rem; justify-content: center;
  font: inherit; font-weight: 600; padding: .5rem .9rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--river); color: var(--river-ink); border-color: var(--river); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: .3rem .6rem; font-size: .85rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; }

/* Flash */
.flash { padding: .6rem .8rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-ok { background: var(--good-bg); color: var(--good); }
.flash-err { background: var(--bad-bg); color: var(--bad); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: var(--river); }
.kpi .label { color: var(--ink-2); font-size: .85rem; font-weight: 500; }
.kpi .value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: .8rem; }
.kpi.alert .value { color: var(--bad); }

/* Filters */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters label { font-size: .8rem; }
.filters select, .filters input { width: auto; min-width: 140px; padding: .4rem .5rem; }

/* Review list */
.rlist { display: grid; gap: .6rem; }
.ritem {
  display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: .8rem 1rem; text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.ritem:hover { border-color: var(--river); }
.ritem.neg { border-left-color: var(--bad); }
.ritem.pos { border-left-color: var(--good); }
.ritem .meta { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); }
.ritem .body { grid-column: 1 / -1; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ritem .side { text-align: right; font-size: .8rem; color: var(--muted); }

.stars { color: var(--star); letter-spacing: 1px; font-size: 1rem; }
.stars .off { color: var(--line); }
.rec { font-size: .8rem; font-weight: 600; padding: .1rem .45rem; border-radius: 99px; }
.rec-pos { background: var(--good-bg); color: var(--good); }
.rec-neg { background: var(--bad-bg); color: var(--bad); }

.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .5rem; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.pill.p-google { background: #e8f0fe; color: #1a55b8; }
.pill.p-facebook { background: #e7edfb; color: #2a4fa3; }
.pill.p-yelp { background: #fde8e6; color: #a8231a; }
@media (prefers-color-scheme: dark) {
  .pill.p-google { background: #1d2a44; color: #9dbcf5; }
  .pill.p-facebook { background: #1e2640; color: #a6b8ee; }
  .pill.p-yelp { background: #3d1f1c; color: #f2a39b; }
}
.st { font-size: .75rem; font-weight: 600; padding: .12rem .5rem; border-radius: 99px; }
.st-new { background: var(--bad-bg); color: var(--bad); }
.st-in_progress { background: var(--warn-bg); color: var(--warn); }
.st-replied { background: var(--good-bg); color: var(--good); }
.st-no_reply { background: var(--surface-2); color: var(--ink-2); }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--river); border-radius: 4px; }

/* Review detail */
.detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }
.quote { font-size: 1.02rem; white-space: pre-wrap; margin: .5rem 0 0; }
.reply-box { background: var(--river-soft); border-radius: 8px; padding: .8rem 1rem; white-space: pre-wrap; }
.notes { display: grid; gap: .5rem; margin-bottom: .75rem; }
.note { background: var(--surface-2); border-radius: 8px; padding: .5rem .7rem; font-size: .9rem; }
.note .by { font-size: .78rem; color: var(--muted); }
.tpl-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .5rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.pager { display: flex; gap: .5rem; justify-content: center; margin-top: 1rem; }
code { background: var(--surface-2); padding: .05rem .35rem; border-radius: 4px; font-size: .88em; }
details summary { cursor: pointer; font-weight: 600; }

.filters label.check { display: flex; flex-direction: row; align-items: center; gap: .4rem; font-weight: 500; padding-bottom: .45rem; }
.filters label.check input { width: auto; min-width: 0; }
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .who { margin-left: 0; width: 100%; }
  .filters > label, .filters select, .filters input[type=search] { width: 100%; }
}
