/* The Tattered Folio - dashboard demo. Same brand tokens as the
   redemption-site demo (privatebooks.clvaughan.com). */

:root {
  --ink: #221d1a;
  --ink-2: #453c36;
  --cream: #f7f1e8;
  --cream-2: #efe5d7;
  --paper: #fffdf8;
  --line: #e3d8c5;
  --accent: #7a3b2e;
  --accent-2: #a05a3c;
  --gold: #b8893d;
  --muted: #8a7f72;
  --ok: #3f6b3f;
  --err: #a33a2f;
  --warn: #8a6d1f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(34, 29, 26, 0.04), 0 10px 30px -18px rgba(34, 29, 26, 0.25);
  --shadow-lift: 0 1px 0 rgba(34, 29, 26, 0.06), 0 18px 40px -22px rgba(34, 29, 26, 0.4);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  background-image:
    radial-gradient(circle at 12% -10%, rgba(184, 137, 61, 0.10), transparent 40%),
    radial-gradient(circle at 92% 0%, rgba(122, 59, 46, 0.08), transparent 38%);
  line-height: 1.55;
  font-size: 15px;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; }
.muted { color: var(--muted); }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-2);
  margin: 0 0 0.4rem;
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.06s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--cream); box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--accent); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent-2); color: var(--accent-2); text-decoration: none; }
.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.88rem; }
.btn[disabled] { opacity: 0.5; cursor: wait; }

/* ---------------- Login ---------------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-card {
  max-width: 420px;
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 2.4rem;
}
.login-card h1 { margin: 0.2rem 0 0.6rem; font-size: 1.9rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.6rem; }
.login-form .field span {
  font-size: 0.78rem; font-weight: 600; color: var(--muted);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.login-form input {
  margin-top: 0.35rem;
  width: 100%;
  padding: 0.8rem 1rem;
  font: inherit;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.login-form input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 59, 46, 0.18);
}
.hint { margin-top: 1.2rem; color: var(--muted); font-size: 0.9rem; }
.hint code {
  background: var(--cream-2); border: 1px solid var(--line);
  padding: 0.1rem 0.45rem; border-radius: 6px; font-size: 0.88em;
}
.alert { padding: 0.8rem 1rem; border-radius: var(--radius-sm); font-weight: 500; margin: 1rem 0 0; }
.alert-error { background: #f6e9e7; color: var(--err); border: 1px solid #e9c9c3; }

/* ---------------- Header ---------------- */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.1rem 1.6rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-family: var(--serif); font-size: 1.12rem; font-weight: 600;
  color: var(--ink); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  background: var(--ink); color: var(--cream);
  border-radius: 9px; box-shadow: var(--shadow);
}
.login-card .brand-mark { margin-bottom: 1rem; }
.cassol {
  display: block; font-size: 0.7em; font-style: italic; color: #44434391;
  line-height: 1.1; margin-top: 2px;
}
.dash-header-right { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.sync-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; font-size: 0.85rem; color: var(--ink-2);
  box-shadow: var(--shadow);
}
.demo-status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 137, 61, 0.18);
  flex-shrink: 0;
}
.sync-badge.syncing .demo-status-dot { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------------- Tabs ---------------- */
.tab-nav {
  display: flex; gap: 0.35rem; flex-wrap: wrap;
  max-width: 1280px; margin: 0 auto; padding: 0 1.6rem;
  border-bottom: 1px solid var(--line);
}
.tab-btn {
  font: inherit; font-weight: 600; font-size: 0.95rem;
  color: var(--ink-2);
  background: transparent; border: 0; cursor: pointer;
  padding: 0.7rem 1rem;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--accent); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------------- Filter bar ---------------- */
.filter-bar {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 0.9rem;
  max-width: 1280px; margin: 1.1rem auto 0; padding: 0.9rem 1.2rem;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: calc(1280px - 3.2rem);
}
.filter-field { display: flex; flex-direction: column; gap: 0.3rem; }
.filter-field span {
  font-size: 0.72rem; font-weight: 600; color: var(--muted);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.filter-field select, .filter-field input {
  font: inherit; font-size: 0.92rem; color: var(--ink);
  background: var(--cream); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0.5rem 0.6rem;
}
.filter-field select:focus, .filter-field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 59, 46, 0.15);
}
.demo-tag {
  margin-left: auto;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--gold); border: 1px dashed var(--gold);
  padding: 0.25rem 0.6rem; border-radius: 999px;
}

/* ---------------- Main / cards ---------------- */
.dash-main { max-width: 1280px; margin: 0 auto; padding: 1.4rem 1.6rem 3rem; }
.loading { color: var(--muted); padding: 2rem 0; text-align: center; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.metric-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1rem;
}
.metric-card .label {
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
}
.metric-card .value {
  font-family: var(--serif); font-size: 1.75rem; font-weight: 600;
  margin-top: 0.3rem; font-variant-numeric: tabular-nums;
}
.metric-card .sub { font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.chart-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.2rem 1.3rem;
}
.chart-card h3 { margin: 0 0 0.8rem; font-size: 1.15rem; }
.chart-wrap { position: relative; height: 260px; }

/* ---------------- Tables ---------------- */
.table-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.table-card .table-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; padding: 1.1rem 1.3rem 0.6rem;
}
.table-card h3 { margin: 0; font-size: 1.15rem; }
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse;
  font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  text-align: left; padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  background: var(--cream);
  position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--cream); }
table.data td.num, table.data th.num { text-align: right; }

.pager {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.8rem 1.3rem;
}
.pager .info { color: var(--muted); font-size: 0.88rem; margin-left: auto; }

/* ---------------- Pills & misc ---------------- */
.pill {
  display: inline-block; font-size: 0.76rem; font-weight: 600;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  background: var(--cream-2); color: var(--ink-2); border: 1px solid var(--line);
}
.pill.ok { background: #eaf2ea; color: var(--ok); border-color: #c5dac5; }
.pill.err { background: #f6e9e7; color: var(--err); border-color: #e9c9c3; }
.pill.warn { background: #f7f0dc; color: var(--warn); border-color: #e4d5ac; }
.pill.gold { background: rgba(184,137,61,0.12); color: var(--gold); border-color: var(--gold); }

.src-tags { display: inline-flex; gap: 0.3rem; }
.empty-state {
  padding: 3rem 1.5rem; text-align: center; color: var(--muted);
}
.section-note { color: var(--muted); font-size: 0.88rem; margin: 0 0 1rem; }

.site-footer {
  max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.6rem 2.5rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .dash-header { align-items: flex-start; }
}
@media (max-width: 600px) {
  .tab-nav { overflow-x: auto; flex-wrap: nowrap; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .demo-tag { margin-left: 0; }
}
