/* ==========================================================================
   Aveney Vendor Review — App Stylesheet
   See docs/brandbook.md for full design system rationale/tokens.
   ========================================================================== */

:root {
  /* Color */
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-muted: #f1efe9;
  --border: #e5e2da;
  --border-strong: #d6d2c6;
  --text: #211f1c;
  --text-muted: #6f6a60;
  --text-faint: #9a9488;

  --accent: #2f5233;
  --accent-soft: #e7efe6;

  --approve: #1f7a4d;
  --approve-soft: #e5f3ea;
  --reject: #b23b3b;
  --reject-soft: #faeaea;
  --pending: #8a7a3f;
  --pending-soft: #f6f1e2;
  --flagged: #a1652f;

  --focus-ring: #2f5233;

  /* Type */
  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.875rem;

  /* Spacing (8px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow-sm: 0 1px 2px rgba(33, 31, 28, 0.05);
  --shadow-md: 0 4px 16px rgba(33, 31, 28, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
  color: var(--text);
}

a {
  color: var(--accent);
}

button {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-small { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: #26421f; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface-muted);
  color: var(--text);
}

/* ==========================================================================
   Login page
   ========================================================================== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background: radial-gradient(circle at top, #fbfaf7 0%, var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--sp-7) var(--sp-6);
}

.login-title {
  font-size: var(--fs-xl);
  margin-bottom: var(--sp-2);
}

.login-sub {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin: 0 0 var(--sp-6);
}

.login-error {
  background: var(--reject-soft);
  color: var(--reject);
  font-size: var(--fs-sm);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-5);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.field-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field input {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.field input:focus-visible {
  border-color: var(--accent);
}

/* ==========================================================================
   App shell
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-header {
  padding: var(--sp-6) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.brand-title {
  font-size: var(--fs-lg);
}

.brand-sub {
  margin: var(--sp-1) 0 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.overall-progress {
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.overall-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--sp-2);
}

.overall-progress-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  font-weight: 600;
}

.overall-progress-count {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 300ms ease;
}

.vertical-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-3);
}

.nav-loading {
  color: var(--text-faint);
  font-size: var(--fs-sm);
  padding: var(--sp-4);
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  margin-bottom: var(--sp-1);
  transition: background 150ms ease;
}

.nav-item:hover {
  background: var(--surface-muted);
}

.nav-item.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.nav-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.nav-item-name {
  font-family: var(--font-serif);
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item-count {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.nav-item-track {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.nav-item-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 300ms ease;
}

.nav-item.complete .nav-item-fill {
  background: var(--approve);
}

.sidebar-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
}

/* ---------- Main ---------- */
.main {
  height: 100vh;
  overflow-y: auto;
}

.main-header {
  position: sticky;
  top: 0;
  background: rgba(247, 246, 243, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-6) var(--sp-7) var(--sp-5);
  z-index: 5;
}

.main-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--sp-5);
  margin-bottom: var(--sp-4);
  max-width: 880px;
}

.vertical-title {
  font-size: var(--fs-2xl);
}

.vertical-meta {
  margin: var(--sp-2) 0 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.filter-toggle-wrap {
  flex-shrink: 0;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.filter-toggle input {
  width: 34px;
  height: 20px;
  appearance: none;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 150ms ease;
  flex-shrink: 0;
}

.filter-toggle input::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 150ms ease;
  box-shadow: var(--shadow-sm);
}

.filter-toggle input:checked {
  background: var(--accent);
}

.filter-toggle input:checked::after {
  transform: translateX(14px);
}

.progress-track-vertical {
  max-width: 880px;
}

.vendor-list {
  padding: var(--sp-6) var(--sp-7) var(--sp-8);
  max-width: 880px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.empty-state {
  color: var(--text-faint);
  font-size: var(--fs-base);
  padding: var(--sp-8) 0;
  text-align: center;
}

/* ---------- Vendor Card ---------- */
.vendor-card {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 200ms ease, transform 200ms ease;
}

.vendor-card:hover {
  box-shadow: var(--shadow-md);
}

.vendor-card-accent {
  width: 4px;
  flex-shrink: 0;
  background: transparent;
  transition: background 200ms ease;
}

.vendor-card[data-review-status="approved"] .vendor-card-accent {
  background: var(--approve);
}

.vendor-card[data-review-status="rejected"] .vendor-card-accent {
  background: var(--reject);
}

.vendor-card-body {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp-6);
  padding: var(--sp-5) var(--sp-6);
  flex: 1;
  min-width: 0;
}

.vendor-card-top {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.vendor-rank {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  font-weight: 600;
  flex-shrink: 0;
}

.vendor-brand {
  font-size: var(--fs-lg);
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

.review-badge {
  flex-shrink: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: var(--sp-1) var(--sp-3);
  border-radius: 999px;
  background: var(--pending-soft);
  color: var(--pending);
}

.review-badge[data-status="approved"] {
  background: var(--approve-soft);
  color: var(--approve);
}

.review-badge[data-status="rejected"] {
  background: var(--reject-soft);
  color: var(--reject);
}

.vendor-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3) var(--sp-4);
  margin: 0 0 var(--sp-4);
}

.fact dt {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  margin-bottom: 2px;
}

.fact dd {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text);
}

.vendor-links {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.vendor-link-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  margin: 0;
  font-size: var(--fs-sm);
}

.link-label {
  color: var(--text-faint);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  flex-shrink: 0;
  width: 78px;
}

.vendor-link-row a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.vendor-link-row a:hover {
  text-decoration: underline;
}

.vendor-link-row.is-note a {
  display: none;
}

.url-note-text {
  color: var(--text-muted);
  font-style: italic;
}

/* Right column */
.vendor-card-right {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.research-note {
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
}

.research-note-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.research-note-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--approve);
  flex-shrink: 0;
}

.research-note-dot[data-status="flagged"] {
  background: var(--flagged);
}

.research-note-status {
  margin: 0 0 var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}

.research-note-text {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.research-note-text:empty::before {
  content: 'No additional notes.';
  color: var(--text-faint);
  font-style: italic;
}

.review-actions {
  display: flex;
  gap: var(--sp-2);
}

.review-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 150ms ease;
}

.review-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.review-btn-approve.is-active {
  background: var(--approve);
  border-color: var(--approve);
  color: #fff;
}

.review-btn-reject.is-active {
  background: var(--reject);
  border-color: var(--reject);
  color: #fff;
}

.review-btn-reset {
  flex: 0.6;
}

.review-updated {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-faint);
  text-align: right;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .vendor-card-body {
    grid-template-columns: 1fr;
  }
  .vendor-card-right {
    border-top: 1px solid var(--border);
    padding-top: var(--sp-4);
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .vertical-nav {
    max-height: 260px;
  }
  .main {
    height: auto;
  }
  .main-header {
    position: static;
  }
  .vendor-facts {
    grid-template-columns: 1fr;
  }
}
