@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lora:wght@600&display=swap');

:root {
  --bg: #F6F2E7;
  --card: #FAF8F1;
  --card-subtle: #F5F3E8;
  --row: #FCFBF5;
  --border: #DFD9C4;
  --text: #2A2A22;
  --text-muted: #8A8672;
  --green: #3F5136;
  --green-light: #5C7355;
  --sage: #8B9A78;
  --gold: #C9A227;
  --gold-soft: #F0E6C8;
  --destructive: #B5563C;
  --white: #FAF8F1;
  --radius: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 {
  font-family: 'Lora', Georgia, serif;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

/* ---------- Shell layout ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--green);
  color: var(--bg);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 10px 20px;
}

.brand-row {
  font-family: 'Lora', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--bg);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  height: 22px;
  width: auto;
  object-fit: contain;
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: #A9A387;
  margin-top: 4px;
}

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #D9D4BE;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  transition: background 0.12s ease;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--bg); }

.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--bg);
}

.nav-icon { width: 14px; text-align: center; opacity: 0.4; font-size: 18px; line-height: 1; flex-shrink: 0; }
.nav-item.active .nav-icon { opacity: 1; color: var(--gold); }

.nav-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.12);
  color: #D9D4BE;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 100px;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user { padding: 0 10px 10px; }
.sidebar-user-name { font-size: 12.5px; color: var(--bg); font-weight: 600; }
.sidebar-user-title { font-size: 11px; color: #A9A387; margin-top: 2px; }

.logout-form button {
  width: 100%;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #D9D4BE;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.logout-form button:hover { background: rgba(255, 255, 255, 0.08); }

.main {
  flex: 1;
  padding: 32px 40px 60px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header > .btn-primary { margin-top: 10px; }
.page-header > .date-range-form { margin-top: 10px; }
.page-header .page-header-actions { margin-top: 10px; }

.page-header .meta { color: var(--text-muted); font-size: 13px; }

/* ---------- Cards / stats ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }

.stat-value { font-family: 'Lora', Georgia, serif; font-size: 28px; font-weight: 600; }

.stat-value.accent { color: var(--green); }

.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot-white { background: #EDE9DD; border: 1px solid var(--border); }
.dot-black { background: var(--text); }
.dot-self { background: #C9782E; }
.dot-known { background: var(--green); }
.dot-unknown { background: #5B7A9E; }

/* ---------- Trend bars ---------- */

.trend-card { margin-bottom: 28px; }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; margin-top: 16px; }
.trend-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend-bar { width: 100%; max-width: 16px; background: var(--green); border-radius: 3px 3px 0 0; min-height: 2px; }
.trend-count { font-size: 11px; color: var(--text-muted); }
.trend-day { font-size: 11px; color: var(--text-muted); }
.trend-day-num { font-size: 10.5px; color: var(--text-muted); }

/* ---------- Dashboard (research console) additions ---------- */

.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.stat-grid-5 { grid-template-columns: repeat(5, 1fr); }
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 20px; }
.dashboard-grid .card { margin-bottom: 0; }

.wolf-result-section { background: rgb(243, 241, 227); }
.wolf-result-row { display: flex; flex-direction: row; gap: 14px; margin-top: 12px; }
.wolf-result-card {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.wolf-icon { width: 16px; height: 16px; vertical-align: middle; margin-right: 6px; object-fit: contain; }

/* ---------- Wolf choice badge (circular icon + label, table rows) ---------- */

.wolf-choice { display: flex; align-items: center; gap: 10px; }
.wolf-choice-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wolf-choice-badge.white { background: none; }
.wolf-choice-badge.black { background: none; }
.wolf-choice-badge img { width: 18px; height: 18px; object-fit: contain; }

/* ---------- Account detail page ---------- */

.back-link { display: inline-block; margin-bottom: 16px; }

.profile-card { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
.profile-identity { display: flex; align-items: center; gap: 16px; }
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sage);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  flex-shrink: 0;
}
.profile-identity h3 { font-size: 19px; margin: 0; }
.profile-identity .meta { font-size: 13.5px; }
.profile-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.profile-stats .mini-card { min-width: 90px; margin-bottom: 0; }

.badges-section-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.badge-card {
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  border: 1px solid var(--border);
}
.badge-card.earned { background: var(--gold-soft); border-color: var(--gold); }
.badge-card.locked { background: var(--card-subtle); opacity: 0.6; }
.badge-card .badge-icon { width: 56px; height: 56px; object-fit: contain; display: block; margin: 0 auto 8px; }
.badge-card.locked .badge-icon { filter: grayscale(1); }
.badge-card .badge-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.badge-card .badge-threshold { font-size: 11.5px; color: var(--text-muted); }

.wolf-calendar { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 8px; margin-bottom: 18px; }
.wolf-calendar-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wolf-calendar-cell.white { background: #E4E8DA; }
.wolf-calendar-cell.black { background: #6B6B63; }
.wolf-calendar-cell.none { background: var(--card); border: 1px solid var(--border); }
.wolf-calendar-cell img { width: 55%; height: 55%; object-fit: contain; }

.wolf-calendar-legend {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 13px;
  color: var(--text);
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.wolf-calendar-legend-item { display: flex; align-items: center; gap: 8px; }
.wolf-calendar-legend .wolf-calendar-cell { width: 26px; height: 26px; flex-shrink: 0; }
.wolf-result-card .stat-value { margin-top: 10px; }
.wolf-result-card .stat-sub { margin-top: 8px; }

.category-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 16px; font-size: 13.5px; }
.category-row:first-of-type { margin-top: 4px; }
.category-label { color: var(--text); }
.category-pct { font-weight: 600; color: var(--text); }

.progress-track { height: 8px; background: var(--card-subtle); border-radius: 100px; margin-top: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 100px; }
.fill-self { background: #C9782E; }
.fill-known { background: var(--green); }
.fill-unknown { background: #5B7A9E; }

.coins-issued-note { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  padding: 14px 16px;
  background: var(--card-subtle);
  border-bottom: 1px solid var(--border);
}

td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--row); }

.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge-tag {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 100px;
  background: var(--card-subtle);
  border: 1px solid var(--border);
  color: var(--text);
}

.badge-tag.white { background: #EDE9DD; }
.badge-tag.black { background: #3A3A32; color: #EDE9DD; border-color: #3A3A32; }
.badge-tag.self { background: #E7EFE3; border-color: #C7D9BE; }
.badge-tag.known { background: #E7EEF2; border-color: #C3DAE3; }
.badge-tag.unknown { background: #F2E9E2; border-color: #E3CBB4; }

/* ---------- Forms ---------- */

.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

input[type="text"], input[type="password"], input[type="number"], input[type="email"], select {
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
}

input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: -1px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.btn:hover { background: var(--row); }

.btn-primary { background: var(--green); border-color: var(--green); color: var(--bg); }
.btn-primary:hover { background: #354730; }

.btn-destructive { background: none; border-color: var(--destructive); color: var(--destructive); }
.btn-destructive:hover { background: rgba(181, 86, 60, 0.08); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }

/* ---------- Pagination ---------- */

.pagination { display: flex; gap: 6px; margin-top: 18px; align-items: center; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid var(--border); }
.pagination a:hover { background: var(--card); }
.pagination .current { background: var(--green); color: var(--bg); border-color: var(--green); }
.pagination .disabled { color: var(--text-muted); opacity: 0.5; }

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 40px 36px;
  width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { color: var(--text-muted); font-size: 12.5px; margin-top: 6px; }
.login-logo {
  width: 44px;
  height: 44px;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--green);
  border-radius: 50%;
  object-fit: contain;
}
.research-console { letter-spacing: 0.12em; font-size: 11px !important; text-transform: uppercase; }
.login-footer-note {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

.login-card label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; margin-top: 14px; }
.login-card input { width: 100%; }
.login-card .btn-primary { width: 100%; justify-content: center; margin-top: 22px; padding: 10px; }

.login-error {
  background: rgba(181, 86, 60, 0.1);
  color: var(--destructive);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 14px;
}

/* ---------- Detail page ---------- */

.detail-grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }

.detail-field { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.detail-field:last-child { border-bottom: none; }
.detail-field .label { color: var(--text-muted); font-size: 11.5px; margin-bottom: 3px; }

.section-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 0 0 12px; text-transform: none; }

.mini-card-row { display: flex; gap: 10px; margin-bottom: 20px; }
.mini-card { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-align: center; }
.mini-card .stat-value { font-size: 20px; }

.empty-state { padding: 32px 0; text-align: center; color: var(--text-muted); font-size: 13.5px; }

.error-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; flex-direction: column; gap: 10px; }
.error-screen a { color: var(--green); text-decoration: underline; }

/* ---------- Date range picker ---------- */

.date-range-form {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
}

.date-range-form label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.date-range-form label span { font-size: 12.5px; color: var(--text-muted); }

.date-range-form input[type="date"] {
  border: none;
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--text);
}

.date-range-form input[type="date"]:focus { outline: none; }

.date-range-sep { color: var(--text-muted); font-size: 13px; }

/* ---------- Search pill (page-level search, e.g. Accounts) ---------- */

.header-card { width: 100%; box-sizing: border-box; margin-bottom: 20px; }

.search-pill-form {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 11px 16px;
  width: 260px;
}

.search-pill svg { flex-shrink: 0; color: var(--text-muted); }

.search-pill input[type="text"] {
  border: none;
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--text);
  width: 100%;
}

.search-pill input[type="text"]:focus { outline: none; }

.privacy-note {
  margin-top: 18px;
  padding: 14px 18px;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--text);
}

/* ---------- Category tabs (Notes page) ---------- */

.tab-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-item {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
}
.tab-item.active { background: var(--green); border-color: var(--green); color: var(--bg); }
.tab-item:not(.active):hover { background: var(--row); }

/* ---------- Note cards (Notes page) ---------- */

.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.note-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.note-card-header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.note-card-title { font-size: 12.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; }
.note-card-date { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.note-card-content { font-size: 13.5px; color: var(--text); line-height: 1.6; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.note-card-email { font-size: 12px; color: var(--text-muted); }

/* ---------- Wolf dashboard: question breakdown ---------- */

.question-block { margin-bottom: 22px; }
.question-block:last-child { margin-bottom: 0; }
.question-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.question-option-row { display: flex; justify-content: space-between; font-size: 12.5px; margin-top: 10px; }
.question-option-row:first-of-type { margin-top: 0; }
.question-option-pct { font-weight: 600; color: var(--text-muted); }
.question-progress-track { height: 6px; background: var(--card-subtle); border-radius: 100px; margin-top: 5px; overflow: hidden; }
.question-progress-fill { height: 100%; border-radius: 100px; background: var(--sage); }

/* ---------- Wolf dashboard: stacked daily chart ---------- */

.stacked-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.stacked-bar-white { width: 100%; max-width: 16px; background: #D8D2BC; border-radius: 3px 3px 0 0; min-height: 0; }
.stacked-bar-black { width: 100%; max-width: 16px; background: var(--text); border-radius: 3px 3px 0 0; }
.stacked-bar-black:only-child { border-radius: 3px 3px 0 0; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-muted); margin-top: 10px; justify-content: flex-end; }

/* ---------- Export & logs page ---------- */

.export-card-row { display: flex; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.export-card { flex: 1; min-width: 220px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.export-card h3 { font-size: 14px; margin-bottom: 6px; }
.export-card p { font-size: 12.5px; color: var(--text-muted); margin: 0 0 14px; }

.log-row { font-size: 12.5px; }
.log-action { font-weight: 600; color: var(--text); }
.log-meta { color: var(--text-muted); }
.log-detail { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }

/* ---------- Create account form ---------- */

.form-card { max-width: 560px; display: flex; flex-direction: column; gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.form-field input[type="text"], .form-field input[type="email"], .form-field input[type="password"] { width: 100%; }
.form-field-row { display: flex; gap: 14px; }
.form-label { font-size: 12.5px; color: var(--text-muted); }
.form-hint { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.form-radio-row { display: flex; gap: 18px; }
.form-radio { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.form-radio input { accent-color: var(--green); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.form-error {
  background: rgba(181, 86, 60, 0.1);
  color: var(--destructive);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.notice-success {
  background: rgba(92, 115, 85, 0.12);
  color: var(--green);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
@media (max-width: 640px) {
  .form-field-row { flex-direction: column; }
}
