:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand a {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary);
  text-decoration: none;
}
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { background: #eff6ff; color: var(--primary); }
.nav-user { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 0.85rem; color: var(--text-muted); }
.btn-logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Typography */
h1 { font-size: 1.6rem; margin-bottom: 16px; }
h2 { font-size: 1.15rem; margin-bottom: 12px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 16px; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }

/* Flash messages */
.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-full { width: 100%; }
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  text-decoration: underline;
}
.btn-link:hover { color: var(--primary-dark); }

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.page-header-actions { display: flex; gap: 8px; }

/* Stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.8rem; font-weight: 700; margin-top: 4px; }

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 768px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

/* Status bars */
.status-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.status-bar-row .status-label { width: 110px; font-size: 0.85rem; }
.status-bar-track {
  flex: 1;
  height: 24px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}
.status-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.status-bar-fill.status-searched { background: #94a3b8; }
.status-bar-fill.status-watching { background: #f59e0b; }
.status-bar-fill.status-purchased { background: #3b82f6; }
.status-bar-fill.status-holding { background: #8b5cf6; }
.status-bar-fill.status-legal_process { background: #ec4899; }
.status-bar-fill.status-registered { background: #22c55e; }
.status-count { width: 30px; text-align: right; font-weight: 600; font-size: 0.85rem; }

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table tr:hover td { background: #f8fafc; }
.table a { color: var(--primary); text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* Status tags */
.status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-tag.status-searched { background: #f1f5f9; color: #475569; }
.status-tag.status-watching { background: #fef3c7; color: #92400e; }
.status-tag.status-purchased { background: #dbeafe; color: #1e40af; }
.status-tag.status-holding { background: #ede9fe; color: #5b21b6; }
.status-tag.status-legal_process { background: #fce7f3; color: #9d174d; }
.status-tag.status-registered { background: #dcfce7; color: #166534; }

/* Score badges */
.score-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
}
.score-high { background: #dcfce7; color: #166534; }
.score-mid { background: #fef9c3; color: #854d0e; }
.score-low { background: #fee2e2; color: #991b1b; }

/* Score display */
.score-display {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 16px;
}
.score-big { font-size: 3rem; font-weight: 800; }
.score-big.score-high { color: #16a34a; }
.score-big.score-mid { color: #d97706; }
.score-big.score-low { color: #dc2626; }
.score-max { font-size: 1.2rem; color: var(--text-muted); }

/* Forms */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 700px;
}
.form-card.compact { padding: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group small { display: block; color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: 8px; margin-top: 20px; }
.full-width { width: 100%; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar select, .filter-bar input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }

/* Detail table */
.detail-table { width: 100%; font-size: 0.9rem; }
.detail-table td { padding: 6px 0; }
.detail-table td:first-child { color: var(--text-muted); width: 40%; }
.detail-table th { text-align: left; padding: 6px 8px; font-size: 0.78rem; color: var(--text-muted); border-bottom: 1px solid var(--border); }

/* Status pipeline */
.status-pipeline {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.pipeline-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  background: #f1f5f9;
  color: var(--text-muted);
}
.pipeline-step.active { background: #dbeafe; color: var(--primary); font-weight: 600; }
.pipeline-step.done { background: #dcfce7; color: #166534; }
.pipeline-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Countdowns */
.countdowns { display: flex; flex-direction: column; gap: 10px; }
.countdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid var(--border);
}
.countdown-item.urgent { border-color: #fbbf24; background: #fffbeb; }
.countdown-item.past { border-color: #fca5a5; background: #fef2f2; }
.countdown-label { font-weight: 600; font-size: 0.85rem; }
.countdown-date { font-size: 0.85rem; color: var(--text-muted); }
.countdown-days { font-size: 0.85rem; font-weight: 600; }
.countdown-item.urgent .countdown-days { color: var(--warning); }
.countdown-item.past .countdown-days { color: var(--danger); }

/* Inline forms */
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.inline { display: inline; }

/* Add lien details */
.add-lien { margin-top: 16px; }
.add-lien summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Empty state */
.empty-state {
  color: var(--text-muted);
  font-style: italic;
  padding: 20px 0;
}
.empty-state a { color: var(--primary); font-style: normal; }

/* Urgent */
.urgent { color: var(--warning); font-weight: 600; }

/* Admin tabs */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.admin-tabs a {
  padding: 8px 16px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.admin-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Weight table */
.weight-table input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Login */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 56px - 60px);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.login-card h1 { color: var(--primary); margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-form label { font-size: 0.85rem; font-weight: 600; }

/* Footer */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.footer a { color: var(--primary); text-decoration: none; }

/* Radio group */
.radio-group { display: flex; gap: 20px; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-weight: normal; cursor: pointer; }
.radio-group input[type="radio"] { margin: 0; }
