* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #0a0a0f;
  --paper: #fafaf8;
  --accent: #e63946;
  --accent-hover: #d62b39;
  --muted: #6b6b7b;
  --subtle: #e8e8e4;
  --glow: rgba(230, 57, 70, 0.08);
  --card-bg: #ffffff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

.space { font-family: 'Space Grotesk', sans-serif; }

/* ── Layout ──────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--ink);
  color: var(--paper);
  padding: 2rem 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.3s;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  padding: 0 1.5rem;
  margin-bottom: 2rem;
}

.sidebar-logo span { color: var(--accent); }

.sidebar-nav { flex: 1; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: rgba(250, 250, 248, 0.5);
  text-decoration: none;
  font-size: 0.95rem;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover { color: var(--paper); background: rgba(255,255,255,0.05); }
.sidebar-link.active { color: var(--paper); background: rgba(255,255,255,0.08); border-right: 2px solid var(--accent); }

.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-bottom {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  font-size: 0.85rem;
  color: rgba(250, 250, 248, 0.5);
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(250, 250, 248, 0.6);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover { background: rgba(255,255,255,0.08); color: var(--paper); }

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 2rem 2.5rem;
  max-width: 1000px;
}

/* ── Page Header ─────────────────────────────────────── */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.page-header p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ── Stats Grid ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--subtle);
  border-radius: 12px;
  padding: 1.5rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: 'Space Grotesk', sans-serif;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--subtle);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: 'DM Sans', sans-serif;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

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

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--subtle);
}

.btn-secondary:hover { background: rgba(0,0,0,0.03); border-color: var(--muted); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 0.4rem 0.6rem;
}

.btn-ghost:hover { color: var(--ink); background: rgba(0,0,0,0.03); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.08); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

.form-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--subtle);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}

.form-input::placeholder { color: var(--muted); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* ── Competitor List ─────────────────────────────────── */
.competitor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--subtle);
}

.competitor-item:last-child { border-bottom: none; }

.competitor-info { flex: 1; min-width: 0; }

.competitor-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.competitor-url {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.competitor-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-right: 1rem;
}

.competitor-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-weight: 500;
}

.badge-changes { background: var(--glow); color: var(--accent); }
.badge-ok { background: rgba(34, 197, 94, 0.1); color: var(--success); }

.competitor-time {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.competitor-actions { display: flex; gap: 0.5rem; }

/* ── Briefing List ───────────────────────────────────── */
.briefing-item {
  padding: 1.25rem;
  border: 1px solid var(--subtle);
  border-radius: 10px;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card-bg);
}

.briefing-item:hover { border-color: var(--accent); box-shadow: 0 2px 8px var(--glow); }

.briefing-subject {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.briefing-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.briefing-content {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--paper);
  border: 1px solid var(--subtle);
  border-radius: 10px;
  line-height: 1.8;
}

.briefing-content h2, .briefing-content h3 {
  font-family: 'Space Grotesk', sans-serif;
}

/* ── Auth Screens ────────────────────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.8rem;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-logo span { color: var(--accent); }

.auth-tagline {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 2.5rem;
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--subtle);
  border-radius: 16px;
  padding: 2rem;
}

.auth-card h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.auth-card .btn-primary {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  justify-content: center;
}

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.auth-switch a:hover { text-decoration: underline; }

/* ── Empty States ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.empty-state h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.empty-state p { font-size: 0.95rem; margin-bottom: 1.5rem; }

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 2rem;
}

.modal {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Toast ───────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--success); color: white; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Loading ─────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(230, 57, 70, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-full {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  gap: 0.75rem;
  color: var(--muted);
}

/* ── Mobile ──────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.25rem;
  z-index: 60;
  align-items: center;
  justify-content: space-between;
}

.mobile-header .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
}

.mobile-header .logo span { color: var(--accent); }

.burger {
  background: none;
  border: none;
  color: var(--paper);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 45;
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar { transform: translateX(-100%); z-index: 55; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; padding: 4.5rem 1.25rem 2rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .competitor-item { flex-wrap: wrap; gap: 0.75rem; }
  .competitor-meta { margin-right: 0; }
}

/* ── Utility ─────────────────────────────────────────── */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
