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

:root {
  --bg: #f8f9fb;
  --bg-card: #ffffff;
  --fg: #1a1a2e;
  --fg-secondary: #4a4a68;
  --muted: #5f6368;
  --border: #e2e5eb;
  --border-subtle: #eef0f4;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success-bg: #dcfce7;
  --success-fg: #166534;
  --success-border: #bbf7d0;
  --error-bg: #fef2f2;
  --error-fg: #991b1b;
  --error-border: #fecaca;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --mono-bg: #f4f4f5;
  --nav-bg: var(--bg-card);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --bg-card: #1a1c25;
    --fg: #e4e5e9;
    --fg-secondary: #a1a3b0;
    --muted: #9395a1;
    --border: #2a2d38;
    --border-subtle: #22242e;
    --accent: #5b8def;
    --accent-hover: #7ba4f7;
    --accent-soft: rgba(91, 141, 239, 0.1);
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success-bg: #052e16;
    --success-fg: #86efac;
    --success-border: #14532d;
    --error-bg: #450a0a;
    --error-fg: #fca5a5;
    --error-border: #7f1d1d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
    --mono-bg: #22242e;
    --nav-bg: #161821;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

.content {
  flex: 1;
  padding: 2rem 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.content>.btn {
  align-self: flex-start;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Forms */
form {
  margin: 1rem 0;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  font-size: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  margin-bottom: 0.75rem;
  background: var(--bg-card);
  color: var(--fg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
}

/* Buttons */
button,
.btn {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

button:hover,
.btn:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

button:active,
.btn:active {
  transform: translateY(1px);
}

button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.danger,
.btn.danger {
  background: var(--danger);
}

button.danger:hover,
.btn.danger:hover {
  background: var(--danger-hover);
}

button.small,
.btn.small {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

button+.btn,
.btn+.btn {
  margin-left: 0.5rem;
}

/* Alerts */
.flash {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.flash.success {
  background: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid var(--success-border);
}

.flash.error {
  background: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid var(--error-border);
}

.token-value {
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  background: var(--mono-bg);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  word-break: break-all;
  font-size: 0.85rem;
}

/* Card list */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

.card {
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

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

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-meta {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.card-domains {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.domain-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.card-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.card-actions form {
  margin: 0;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Stat cards */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Nav */
nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

nav a {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--fg-secondary);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

nav a:hover {
  color: var(--fg);
  background: var(--accent-soft);
  text-decoration: none;
}

nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Footer */
footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 0;
  margin-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--muted);
  font-size: 0.8rem;
}

footer a {
  color: var(--muted);
}

footer a:hover {
  color: var(--fg);
}

footer svg {
  height: 28px;
  width: auto;
  opacity: 0.7;
  transition: opacity 0.15s;
  vertical-align: middle;
}

footer a:hover svg {
  opacity: 1;
}

/* Login page */
.login-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.login-card h1 {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-card label {
  margin-bottom: 0.35rem;
}

.login-card input {
  padding: 0.65rem 0.85rem;
  margin-bottom: 1.1rem;
}

.login-card button {
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  body {
    padding: 0 0.75rem;
  }

  .login-card {
    padding: 1.5rem;
  }
}