/* ===== Design tokens (light + dark) ===== */
:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --hint: #6b7280;
}
[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #334155;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --danger: #f87171;
  --success: #4ade80;
  --hint: #94a3b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.topnav { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.topnav a {
  color: var(--text);
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}
.topnav a.active { background: var(--primary); color: #fff; }
.topnav a:hover { background: var(--border); }
.topnav a.active:hover { background: var(--primary-hover); }

/* ===== Auth card (login/register) ===== */
.auth-card {
  max-width: 420px;
  margin: 2.5rem auto;
  padding: 1.75rem 1.5rem 2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.auth-card h1 { margin: 0 0 1.25rem; font-size: 1.4rem; }
.auth-card h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }

label {
  display: block;
  margin: 0.85rem 0 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
}
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
input:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
}
input:user-invalid {
  border-color: var(--danger);
}
.hint { display: block; color: var(--hint); font-size: 0.78rem; margin-top: 0.2rem; }

/* ===== Buttons ===== */
.btn-primary, .btn-ghost {
  margin-top: 1rem;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  width: 100%;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--border); }

/* ===== Messages ===== */
.msg { min-height: 1.2rem; margin-top: 0.6rem; font-size: 0.85rem; }
.msg.error { color: var(--danger); }
.msg.success { color: var(--success); }

.footer-link {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
}
.footer-link a { color: var(--primary); text-decoration: none; }
.footer-link a:hover { text-decoration: underline; }

/* ===== Theme toggle ===== */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  font-size: 1rem;
}

/* ===== Dashboard pages ===== */
.page { max-width: 760px; margin: 2rem auto; padding: 0 1.25rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h2 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.status-row { margin-bottom: 0.75rem; color: var(--muted); }
.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { padding: 0.4rem 0; }
.link-list a { color: var(--primary); text-decoration: none; }
.link-list a:hover { text-decoration: underline; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background: var(--card);
}
th, td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
th { color: var(--muted); font-weight: 600; }
tbody tr:hover { background: var(--bg); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
}
.pagination button { width: auto; margin-top: 0; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-body {
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.modal-body img { max-width: 200px; margin: 0.75rem auto; display: block; }
.modal-body code {
  background: var(--bg);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
}
.modal-body input { text-align: center; letter-spacing: 0.25rem; font-size: 1.1rem; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .auth-card { margin: 1rem; padding: 1.25rem 1rem 1.5rem; }
  .topnav { gap: 0.35rem; }
  .topnav a { padding: 0.3rem 0.4rem; font-size: 0.85rem; }
  .page { margin: 1rem auto; }
}
