/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f0ede8;
  --border: rgba(0,0,0,0.1);
  --border-med: rgba(0,0,0,0.18);
  --text: #1a1a18;
  --text2: #6b6a65;
  --text3: #9b9a95;
  --accent: #2a5f3f;
  --accent-light: #e8f2ec;
  --accent-text: #1d4a2f;
  --warn: #92500e;
  --warn-bg: #fef3e2;
  --warn-border: #f59e0b;
  --danger: #991b1b;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;
  --radius: 10px;
  --radius-lg: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1e1d1b;
    --surface2: #252420;
    --border: rgba(255,255,255,0.1);
    --border-med: rgba(255,255,255,0.18);
    --text: #edecea;
    --text2: #9b9a95;
    --text3: #6b6a65;
    --accent: #4a9a6a;
    --accent-light: #1a2e22;
    --accent-text: #7dc49a;
    --warn: #f59e0b;
    --warn-bg: #1c1505;
    --warn-border: #92500e;
    --danger: #f87171;
    --danger-bg: #1c0505;
    --danger-border: #7f1d1d;
  }
}

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

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Shared components ─────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 18px;
  font-family: 'Georgia', serif;
  font-size: 14px;
  border: 0.5px solid var(--border-med);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .12s;
  margin-top: .5rem;
}
.btn:hover { background: var(--surface2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { opacity: .88; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.btn.ghost { border-color: transparent; color: var(--text2); font-size: 13px; }
.btn.ghost:hover { background: var(--surface2); }
.btn.sm { padding: 6px 12px; font-size: 12px; width: auto; margin-top: 0; }

select, input[type="text"], input[type="password"], input[type="datetime-local"] {
  width: 100%;
  padding: 9px 12px;
  font-family: 'Georgia', serif;
  font-size: 14px;
  border: 0.5px solid var(--border-med);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  margin-bottom: .5rem;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

label { display: block; font-size: 12px; color: var(--text2); margin-bottom: .25rem; }

.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}
.card-label {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: .75rem;
}

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text2);
  font-style: italic;
  font-size: 14px;
}

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 1.25rem;
  width: 100%;
  max-width: 400px;
}
.modal-title { font-size: 16px; font-weight: normal; margin-bottom: 1rem; }

.warn-tag {
  display: inline-block;
  font-size: 10px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 0.5px solid var(--warn-border);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 5px;
  vertical-align: middle;
}
.offline-badge {
  display: inline-block;
  font-size: 10px;
  background: var(--surface2);
  color: var(--text3);
  border: 0.5px solid var(--border-med);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 5px;
  vertical-align: middle;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: .85rem 0;
}
.divider span { font-size: 11px; color: var(--text3); white-space: nowrap; }
.divider::before, .divider::after { content: ''; flex: 1; height: 0.5px; background: var(--border); }
