:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #2563eb;
  --accent-2: #3b82f6;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
  --nav-height: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

header.topbar {
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header.topbar h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 600;
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 24px);
}

nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--surface-2);
  display: flex;
  z-index: 10;
}

nav.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
}

nav.bottom-nav button .icon { font-size: 1.25rem; }

nav.bottom-nav button.active { color: var(--accent-2); }

h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  background: var(--surface-2);
  color: var(--text);
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.9rem;
  min-height: 40px;
  cursor: pointer;
}

.chip.selected { background: var(--accent); }

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 10px 0 4px;
}

input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
  min-height: 44px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}

.btn-primary { background: var(--accent); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-2);
}
.list-item:last-child { border-bottom: none; }

.muted { color: var(--text-dim); font-size: 0.85rem; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  background: var(--surface-2);
}
.badge.pending { background: var(--warning); color: #1a1200; }
.badge.synced { background: var(--success); color: white; }
.badge.error { background: var(--danger); color: white; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button {
  flex: 1;
  background: var(--surface);
  border: none;
  color: var(--text-dim);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}
.tabs button.active { background: var(--accent); color: white; }

.date-group h3 {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 6px 0;
  margin: 0 0 6px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.modal {
  background: var(--surface);
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 18px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 30;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 32px 16px;
}

@media (min-width: 720px) {
  main { max-width: 640px; margin: 0 auto; width: 100%; }
  nav.bottom-nav { max-width: 640px; margin: 0 auto; left: 0; right: 0; }
}
