:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --border: #e7e9ed;
  --border-soft: #f0f1f4;
  --text: #14161a;
  --text-muted: #6b7280;
  --text-faint: #9aa0aa;
  --accent: #2f5dff;
  --accent-soft: #eef2ff;
  --accent-dark: #1f3fcc;
  --green: #0e9f6e;
  --green-soft: #e7f9f1;
  --amber: #d97706;
  --amber-soft: #fef3e2;
  --red: #dc2626;
  --red-soft: #fde8e8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.04);
  --shadow-md: 0 6px 20px -8px rgba(20, 22, 26, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

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

/* ---------- Top bar ---------- */
header.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(180%) blur(8px);
}
header.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
header.topbar .brand .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c9bff);
  flex-shrink: 0;
}
header.topbar h1 {
  font-size: 15px;
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}
header.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
}
header.topbar nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 550;
  padding: 7px 13px;
  border-radius: 7px;
  transition: background .15s ease, color .15s ease;
}
header.topbar nav a:hover { background: var(--surface); color: var(--text); }
header.topbar nav a.active { background: var(--accent-soft); color: var(--accent-dark); }

/* ---------- Layout ---------- */
.container {
  max-width: 1320px;
  margin: 28px auto;
  padding: 0 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}
h2.page-title {
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}
p.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 4px 0;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border-soft); }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th, td {
  padding: 11px 13px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-soft);
}
th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.empty-cell { color: var(--text-faint); }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  background: var(--accent-soft);
  color: var(--accent-dark);
  white-space: nowrap;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.pill.fresh { background: var(--green-soft); color: var(--green); }
.pill.stale { background: var(--amber-soft); color: var(--amber); }
.pill.none  { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border-soft); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Buttons ---------- */
a.btn, button.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, box-shadow .15s ease, transform .05s ease;
}
a.btn:hover, button.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
a.btn:active, button.btn:active { transform: translateY(1px); }
a.btn.secondary, button.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
a.btn.secondary:hover { background: var(--surface-2); }
a.btn.danger, button.btn.danger { background: var(--red); border-color: var(--red); }
a.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
a.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 6px 10px;
  font-size: 12.5px;
}
a.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 6px 11px; font-size: 12px; }

/* ---------- Forms ---------- */
form .field { margin-bottom: 15px; }
label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}
input[type=text], input[type=date], input[type=url], input[type=password],
input[type=number], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 60px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  header.topbar { padding: 12px 16px; }
  .container { padding: 0 14px; }
}

/* ---------- Flash messages ---------- */
.flash {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash.success { background: var(--green-soft); color: var(--green); border-color: #c8efde; }
.flash.error { background: var(--red-soft); color: var(--red); border-color: #f6cbcb; }

/* ---------- Login ---------- */
.login-wrap { max-width: 380px; margin: 110px auto; }
.login-wrap .brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c9bff);
  margin-bottom: 16px;
}

/* ---------- Misc ---------- */
.actions-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input { width: auto; min-width: 160px; }
.link-cell a { color: var(--accent); word-break: break-all; text-decoration: none; }
.link-cell a:hover { text-decoration: underline; }
small.hint { color: var(--text-faint); display: block; margin-top: 6px; font-size: 12px; }
footer.foot { text-align: center; color: var(--text-faint); font-size: 12px; padding: 30px; }
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 720px) { .stat-row { grid-template-columns: 1fr; } }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: box-shadow .15s ease, transform .15s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .icon-wrap {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card .icon-wrap svg { width: 20px; height: 20px; }
.stat-card.tone-accent .icon-wrap { background: var(--accent-soft); color: var(--accent); }
.stat-card.tone-green .icon-wrap { background: var(--green-soft); color: var(--green); }
.stat-card.tone-amber .icon-wrap { background: var(--amber-soft); color: var(--amber); }
.stat-card .stat-body { display: flex; flex-direction: column; gap: 1px; }
.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
}
.stat-card .stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-card.tone-amber .stat-value { color: var(--amber); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.checkbox-row input { width: auto; }
.history-link { font-size: 11px; color: var(--text-faint); text-decoration: none; }
.history-link:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb { font-size: 12.5px; color: var(--text-faint); margin-bottom: 14px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
