/* ============================================================
   The Feedback Ledger  -  editorial dashboard
   Palette: parchment, deep emerald, saffron, terracotta
   Type: Fraunces (display serif) + Hanken Grotesk (body)
   ============================================================ */

:root {
  --parchment: #f3ead9;
  --parchment-2: #ede1cb;
  --card: #fbf6ea;
  --ink: #22271f;
  --ink-soft: #5b6154;
  --emerald: #16452b;
  --emerald-deep: #0e3320;
  --saffron: #c9971f;
  --saffron-bright: #e6b53c;
  --terracotta: #b5502f;
  --line: rgba(34, 39, 31, 0.14);
  --line-soft: rgba(34, 39, 31, 0.08);
  --shadow: 0 24px 60px -30px rgba(14, 51, 32, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--parchment);
  background-image:
    radial-gradient(1100px 500px at 100% -5%, rgba(201, 151, 31, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(22, 69, 43, 0.10), transparent 60%);
  color: var(--ink);
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Fine paper grain over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

.kicker {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--terracotta);
}
.kicker.light { color: var(--saffron-bright); }

/* Kilim motif strip (Afghan carpet inspired) */
.kilim {
  height: 8px;
  width: 100%;
  background:
    repeating-linear-gradient(135deg,
      var(--saffron) 0 10px,
      var(--emerald) 10px 20px,
      var(--terracotta) 20px 30px);
  opacity: 0.9;
}

/* ---------------- LOGIN ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.login-inner { padding: 40px 38px 34px; }
.login-mark { display: block; border-radius: 12px; margin-bottom: 18px; box-shadow: 0 8px 20px -8px rgba(14,51,32,0.6); }
.login-title {
  font-family: "Fraunces", serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 44px;
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 14px 0 12px;
  color: var(--emerald-deep);
}
.login-sub { color: var(--ink-soft); font-size: 15px; margin: 0 0 22px; }

.field {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf7;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 4px rgba(22, 69, 43, 0.10);
}

.btn-primary {
  width: 100%;
  margin-top: 12px;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fdf7e9;
  background: linear-gradient(180deg, var(--emerald) 0%, var(--emerald-deep) 100%);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.2s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }

.back-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { color: var(--emerald); }

.error-line { color: var(--terracotta); font-size: 14px; min-height: 20px; margin-top: 10px; font-weight: 500; }
.error-line.center { text-align: center; }

/* ---------------- MASTHEAD ---------------- */
.masthead {
  background:
    radial-gradient(700px 260px at 90% -40%, rgba(230, 181, 60, 0.22), transparent),
    linear-gradient(180deg, var(--emerald) 0%, var(--emerald-deep) 100%);
  color: #f4ecdb;
  border-bottom: 1px solid rgba(0,0,0,0.2);
}
.masthead-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 28px 30px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.mast-brand { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.mast-mark { border-radius: 11px; box-shadow: 0 8px 20px -8px rgba(0,0,0,0.6); flex: none; }
.mast-title {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.01em;
  margin: 0;
  color: #fdf7e9;
}
.mast-right { display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.mast-date { font-size: 13px; color: rgba(244, 236, 219, 0.75); letter-spacing: 0.02em; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(244, 236, 219, 0.3);
  color: #fdf7e9;
  border-radius: 999px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.18); }

/* ---------------- PAGE ---------------- */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 28px 20px;
}
.dash-loading {
  text-align: center;
  padding: 90px 0;
  color: var(--ink-soft);
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-style: italic;
}

/* ---------------- STAT BAND ---------------- */
.stat-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 48px;
}
.stat {
  padding: 26px 26px 24px;
  border-right: 1px solid var(--line-soft);
  position: relative;
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
.stat:last-child { border-right: none; }
.stat .stat-num {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 52px;
  line-height: 0.95;
  color: var(--emerald-deep);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .stat-num .suffix { font-size: 26px; color: var(--saffron); margin-left: 2px; }
.stat .stat-label {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.stat .stat-foot { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; opacity: 0.85; }

/* ---------------- SECTION HEADINGS ---------------- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin: 0 0 22px;
}
.section-head h2 {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 27px;
  color: var(--emerald-deep);
  margin: 0;
  white-space: nowrap;
}
.section-head .rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

/* ---------------- CHARTS ---------------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 52px;
}
.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px 24px;
  box-shadow: 0 10px 30px -24px rgba(14, 51, 32, 0.5);
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
.chart-card h3 {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 19px;
  margin: 0 0 4px;
  color: var(--ink);
}
.chart-card .chart-total {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.bar-row { margin-bottom: 15px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 7px;
  gap: 12px;
}
.bar-top .opt { font-size: 14px; color: var(--ink); font-weight: 500; }
.bar-top .val {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--emerald);
  font-variant-numeric: tabular-nums;
}
.bar-top .val .pct { color: var(--ink-soft); font-size: 12px; font-family: "Hanken Grotesk"; margin-left: 6px; }
.track {
  height: 8px;
  background: rgba(34, 39, 31, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.fill {
  height: 100%;
  border-radius: 999px;
  width: 0;
  background: linear-gradient(90deg, var(--emerald) 0%, var(--saffron) 100%);
  transition: width 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.fill.lead { background: linear-gradient(90deg, var(--emerald) 0%, var(--saffron-bright) 60%, var(--terracotta) 130%); }

/* ---------------- LEDGER TABLE ---------------- */
.ledger {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 30px;
}
.table-scroll { overflow-x: auto; }
.resp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 900px;
}
.resp-table thead th {
  background: var(--parchment-2);
  text-align: left;
  padding: 14px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}
.resp-table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  color: var(--ink);
}
.resp-table tbody tr:last-child td { border-bottom: none; }
.resp-table tbody tr:nth-child(even) td { background: rgba(237, 225, 203, 0.4); }
.resp-table tbody tr:hover td { background: rgba(201, 151, 31, 0.12); }
.resp-table td.name { font-family: "Fraunces", serif; font-weight: 600; font-size: 15px; color: var(--emerald-deep); white-space: nowrap; }
.resp-table td.muted { color: var(--ink-soft); }

.chip {
  display: inline-block;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  margin: 1px 3px 1px 0;
  white-space: nowrap;
  color: var(--ink);
}
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.great { background: rgba(22, 69, 43, 0.14); color: var(--emerald-deep); }
.pill.good  { background: rgba(201, 151, 31, 0.18); color: #8a6510; }
.pill.okay  { background: rgba(34, 39, 31, 0.08); color: var(--ink-soft); }
.pill.bad   { background: rgba(181, 80, 47, 0.16); color: var(--terracotta); }

.dash-foot {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  padding: 28px 20px 46px;
  font-family: "Fraunces", serif;
  font-style: italic;
}

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 860px) {
  .stat-band { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: none; }
  .stat:nth-child(1), .stat:nth-child(2) { border-bottom: 1px solid var(--line-soft); }
  .charts-grid { grid-template-columns: 1fr; }
  .mast-title { font-size: 32px; }
}
@media (max-width: 520px) {
  .stat-band { grid-template-columns: 1fr 1fr; }
  .stat .stat-num { font-size: 42px; }
  .masthead-inner { flex-direction: column; align-items: flex-start; }
  .login-title { font-size: 38px; }
}
