/* Endure Analytics — shared design system.
   Tokens and components extend the original index.html so the login, homepage,
   reset flow, and admin panel all read as one product. */

:root {
  --bg: #fafaf7;
  --bg-elev: #ffffff;
  --bg-sunk: #f4f3ee;
  --ink: #0a0a0a;
  --ink-soft: #4a4a48;
  --ink-mute: #8a8a86;
  --line: rgba(10, 10, 10, 0.08);
  --line-strong: rgba(10, 10, 10, 0.14);
  --accent: #b8623d;
  --accent-soft: rgba(184, 98, 61, 0.08);
  --accent-ink: #8f4a2e;
  --error: #b54848;
  --error-soft: rgba(181, 72, 72, 0.08);
  --ok: #5fb37e;
  --ok-ink: #3f7a56;
  --ok-soft: rgba(95, 179, 126, 0.12);
  --warn-soft: rgba(184, 98, 61, 0.10);
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(10,10,10,0.04), 0 1px 0 rgba(10,10,10,0.02);
  --shadow-md: 0 1px 3px rgba(10,10,10,0.04), 0 8px 24px rgba(10,10,10,0.06);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
  letter-spacing: -0.005em;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(184, 98, 61, 0.06), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(60, 80, 100, 0.05), transparent 60%);
  z-index: 0;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ───────────── Centered single-card screens (login/reset/etc) ───────────── */
.screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 1;
}

/* ───────────── Brand mark ───────────── */
.brand { display: inline-flex; align-items: center; gap: 10px; user-select: none; }
.brand-mark { width: 22px; height: 22px; position: relative; }
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1.25px solid var(--ink);
}
.brand-mark::after { transform: scale(0.45); background: var(--ink); border: none; }
.brand-word { font-family: 'Fraunces', serif; font-weight: 400; font-size: 18px; letter-spacing: -0.01em; color: var(--ink); }
.brand-word em { font-style: italic; font-weight: 300; color: var(--ink-soft); margin-left: 2px; }

/* ───────────── Auth card ───────────── */
.auth-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; gap: 36px; }
.auth-head { display: flex; flex-direction: column; align-items: center; gap: 26px; text-align: center; }
.auth-head h1 { font-family: 'Fraunces', serif; font-weight: 300; font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; margin: 0; color: var(--ink); }
.auth-head p { margin: 8px 0 0; font-size: 14px; color: var(--ink-mute); letter-spacing: 0; }

form.stack { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.field { position: relative; display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12.5px; color: var(--ink-soft); letter-spacing: 0; padding-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%; height: 48px; padding: 0 16px;
  border: 1px solid var(--line); background: var(--bg-elev);
  border-radius: var(--radius); font-family: inherit; font-size: 14.5px; color: var(--ink);
  outline: none; transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field textarea { height: auto; padding: 12px 16px; resize: vertical; min-height: 76px; line-height: 1.5; }
.field input::placeholder { color: var(--ink-mute); }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--line-strong); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(10,10,10,0.04); }
.field .help { font-size: 11.5px; color: var(--ink-mute); padding-left: 2px; }

/* ───────────── Buttons ───────────── */
.btn {
  height: 44px; padding: 0 18px; border: 1px solid transparent;
  font-family: inherit; font-size: 14px; font-weight: 500; letter-spacing: -0.005em;
  border-radius: var(--radius); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s var(--ease), color .2s var(--ease);
  text-decoration: none;
}
.btn:active { transform: scale(0.99); }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--ink); color: #fafaf7; }
.btn-primary:hover { background: #1a1a1a; text-decoration: none; }
.btn-secondary { background: var(--bg-elev); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: #fff; border-color: var(--ink); text-decoration: none; }
.btn-ghost { background: none; color: var(--ink-soft); }
.btn-ghost:hover { background: rgba(10,10,10,0.04); color: var(--ink); text-decoration: none; }
.btn-danger { background: var(--bg-elev); color: var(--error); border-color: rgba(181,72,72,0.3); }
.btn-danger:hover { background: var(--error-soft); border-color: var(--error); text-decoration: none; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; height: 48px; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary svg { transition: transform 0.25s var(--ease); }
.btn-primary:hover svg { transform: translateX(2px); }

/* ───────────── Messages ───────────── */
.error-line { min-height: 18px; font-size: 12.5px; color: var(--error); text-align: center; letter-spacing: 0; }
.alert { width: 100%; padding: 12px 16px; border-radius: var(--radius); font-size: 13px; line-height: 1.5; border: 1px solid var(--line); }
.alert-error { background: var(--error-soft); border-color: rgba(181,72,72,0.25); color: #7d3535; }
.alert-ok { background: var(--ok-soft); border-color: rgba(95,179,126,0.3); color: var(--ok-ink); }
.alert-info { background: var(--accent-soft); border-color: rgba(184,98,61,0.2); color: var(--accent-ink); }
.muted-foot { font-size: 12px; color: var(--ink-mute); letter-spacing: 0; text-align: center; }

/* ───────────── App shell (homepage + admin) ───────────── */
.shell { position: relative; z-index: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 40px 32px 64px; display: flex; flex-direction: column; gap: 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.userchip { font-size: 13px; color: var(--ink-soft); margin-right: 6px; }
.navlink { font-size: 13px; color: var(--ink-soft); padding: 7px 12px; border-radius: var(--radius-sm); transition: background 0.2s var(--ease), color 0.2s var(--ease); }
.navlink:hover { background: rgba(10,10,10,0.04); color: var(--ink); text-decoration: none; }
.navlink.active { color: var(--ink); background: rgba(10,10,10,0.05); }
form.inline { display: inline; }

.hello { display: flex; flex-direction: column; gap: 10px; }
.eyebrow { font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-mute); }
.hello h2 { font-family: 'Fraunces', serif; font-weight: 300; font-size: 40px; letter-spacing: -0.025em; line-height: 1.1; margin: 0; color: var(--ink); }
.hello h2 em { font-style: italic; color: var(--ink-soft); }
@media (max-width: 820px) { .hello h2 { font-size: 32px; } }

/* ───────────── Category sections + tiles ───────────── */
.category { display: flex; flex-direction: column; gap: 20px; }
.category-head { display: flex; align-items: baseline; gap: 12px; }
.category-head h3 { font-family: 'Fraunces', serif; font-weight: 400; font-size: 22px; letter-spacing: -0.015em; margin: 0; color: var(--ink); }
.category-head .count { font-size: 12px; color: var(--ink-mute); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 28px 26px 26px; min-height: 200px;
  cursor: pointer; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  transition: transform 0.35s var(--ease), border-color 0.25s var(--ease), box-shadow 0.35s var(--ease);
  text-decoration: none; color: inherit;
}
.card::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px 200px at var(--mx, 50%) var(--my, 0%), var(--accent-soft), transparent 70%);
  opacity: 0; transition: opacity 0.4s var(--ease); pointer-events: none;
}
.card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-md); text-decoration: none; }
.card:hover::after { opacity: 1; }
.card-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: var(--ink); margin-bottom: 24px; }
.card-icon svg { width: 22px; height: 22px; }
.card h4 { font-family: 'Fraunces', serif; font-weight: 400; font-size: 19px; letter-spacing: -0.01em; margin: 0 0 6px; color: var(--ink); }
.card p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-mute); }
.card-cta { margin-top: 22px; font-size: 12px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; letter-spacing: 0; }
.card-cta svg { width: 12px; height: 12px; transition: transform 0.25s var(--ease); }
.card:hover .card-cta svg { transform: translateX(3px); }

.empty-state {
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
  padding: 36px; text-align: center; color: var(--ink-mute); font-size: 13.5px; background: rgba(255,255,255,0.4);
}

/* ───────────── Panels / cards for admin ───────────── */
.panel { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 26px; }
.panel + .panel { margin-top: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h3 { font-family: 'Fraunces', serif; font-weight: 400; font-size: 20px; letter-spacing: -0.015em; margin: 0; }
.panel-head .sub { font-size: 12.5px; color: var(--ink-mute); margin-top: 4px; }

/* ───────────── Tables ───────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 500; color: var(--ink-mute); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding: 0 14px 12px; border-bottom: 1px solid var(--line); }
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--line); color: var(--ink-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(10,10,10,0.015); }
table.data .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
table.data td.right, table.data th.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* ───────────── Pills / badges ───────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.01em; border: 1px solid transparent; }
.pill-ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill-mute { background: rgba(10,10,10,0.05); color: var(--ink-mute); }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill-error { background: var(--error-soft); color: #7d3535; }

/* ───────────── Forms inline grid (admin add rows) ───────────── */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.form-row .field { flex: 1; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-soft); height: 48px; }
.checkline input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ───────────── Footer ───────────── */
.foot { display: flex; justify-content: space-between; align-items: center; padding-top: 22px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-mute); letter-spacing: 0.04em; }
.foot .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-right: 8px; box-shadow: 0 0 0 4px rgba(95,179,126,0.15); }

.section-title { font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-mute); margin: 0 0 4px; }
.note { font-size: 12.5px; color: var(--ink-mute); line-height: 1.55; }
.spacer { flex: 1; }
.stack-gap { display: flex; flex-direction: column; gap: 16px; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ───────────── Homepage personalization (top-right settings menu) ───────────── */
.iconbtn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: none; background: none; color: var(--ink-soft); border-radius: 9px; cursor: pointer; padding: 0; transition: background 0.2s var(--ease), color 0.2s var(--ease); }
.iconbtn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.iconbtn svg { width: 18px; height: 18px; }
.settings-menu { position: relative; display: inline-flex; }
.settings-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: 244px;
  background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.settings-pop[hidden] { display: none; }
.settings-pop-head { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-mute); }
.darkswitch { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-soft); cursor: pointer; user-select: none; }
.darkswitch input { width: 16px; height: 16px; accent-color: var(--accent); }
#customizeHint { display: none; }
.customizing #customizeHint { display: block; }

/* Tiles wrap the cards so per-tile controls can sit outside the <a>. */
.tile { position: relative; display: flex; }
.tile .card { width: 100%; }
.tile-controls {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  display: none; gap: 6px; align-items: center;
}
.customizing .tile-controls { display: inline-flex; }
.tile-ctl {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--ink-soft);
  border-radius: 9px; cursor: pointer; padding: 0; box-shadow: var(--shadow-sm);
}
.tile-ctl svg { width: 16px; height: 16px; }
.tile-ctl:hover { color: var(--accent-ink); border-color: rgba(184, 98, 61, 0.4); background: var(--accent-soft); }
.tile-grip { display: inline-flex; align-items: center; color: var(--ink-mute); cursor: grab; }
.tile-grip svg { width: 18px; height: 18px; }
.customizing .tile .card { cursor: default; }
.customizing .tile { outline: 1px dashed var(--line-strong); outline-offset: 4px; border-radius: var(--radius-lg); }
.tile.dragging { opacity: 0.45; }

/* Hidden tiles vanish normally; in customize mode they show dimmed to un-hide. */
.tile.is-hidden { display: none; }
.customizing .tile.is-hidden { display: flex; opacity: 0.4; }
.customizing .tile.is-hidden .tile-ctl[data-act="hide"] { color: var(--accent); border-color: var(--accent); }

/* Minimized tiles collapse to icon + title. */
.tile.is-min .card { min-height: 0; }
.tile.is-min .card p, .tile.is-min .card .card-cta { display: none; }
.tile.is-min .card .card-icon { margin-bottom: 14px; }

/* ───────────── Dark mode ───────────── */
html.theme-dark {
  --bg: #15140f;
  --bg-elev: #1d1b15;
  --bg-sunk: #100f0b;
  --ink: #f3f1ea;
  --ink-soft: #cbc7bc;
  --ink-mute: #8f8b80;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --accent: #d98a5f;
  --accent-soft: rgba(217, 138, 95, 0.16);
  --accent-ink: #e6a079;
}
html.theme-dark body { background: var(--bg); }
html.theme-dark body::before {
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(217, 138, 95, 0.10), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(80, 110, 140, 0.10), transparent 60%);
}
html.theme-dark .btn-primary { background: var(--accent); color: #15140f; }
html.theme-dark .btn-primary:hover { background: var(--accent-ink); }
html.theme-dark .empty-state { background: rgba(255, 255, 255, 0.025); }
html.theme-dark .field input, html.theme-dark .field select, html.theme-dark .field textarea { background: var(--bg-elev); color: var(--ink); }
html.theme-dark table.data tr:hover td { background: rgba(255, 255, 255, 0.03); }
