:root {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1f2430;
  --border: #2b3142;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --accent: #f59e0b;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
  min-height: 100dvh;
}

code {
  background: rgba(167, 139, 250, 0.14);
  color: var(--primary-light);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.85em;
  word-break: break-word;
}

.hidden {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.header-pills {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.pill {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}

.pill-ok { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.pill-danger { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.pill-muted { background: var(--surface-2); color: var(--muted); }

.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 14px calc(88px + env(safe-area-inset-bottom));
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.tab-panel.active {
  display: flex;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.hero-card {
  background: linear-gradient(155deg, rgba(124, 58, 237, 0.18), var(--surface) 60%);
}

.highlight-card {
  background: linear-gradient(155deg, rgba(245, 158, 11, 0.12), var(--surface) 60%);
}

.timer-card {
  border-color: rgba(124, 58, 237, 0.45);
}

.card h2, .card h3 {
  margin: 0 0 8px;
  font-size: 1.02rem;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.muted { color: var(--muted); }
.small-note { font-size: 0.8rem; color: var(--muted); margin: 4px 0 0; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-accent { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-ok { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.badge-warn { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge-info { background: rgba(124, 58, 237, 0.22); color: var(--primary-light); }

.alert {
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.alert-success { background: rgba(16, 185, 129, 0.14); border: 1px solid rgba(16, 185, 129, 0.35); color: #a7f3d0; }
.alert-info { background: rgba(124, 58, 237, 0.14); border: 1px solid rgba(124, 58, 237, 0.35); color: #ddd6fe; }

.compact-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.compact-list li {
  margin-bottom: 4px;
}

.help-box {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.83rem;
  line-height: 1.45;
}

.install-actions {
  margin: 14px 0 8px;
}

.btn {
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text);
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-lg { width: 100%; padding: 14px 16px; font-size: 1rem; }
.btn-sm { padding: 7px 11px; font-size: 0.8rem; border-radius: 10px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #5b21b6); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn-row-tight {
  display: flex;
  gap: 6px;
}

.checklist {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.checklist li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
}

.checklist li:last-child { border-bottom: none; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.metric-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

.metric-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.metric-value {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
  color: var(--text);
}

.live-status-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child { border-bottom: none; padding-bottom: 0; }

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: #334155;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.log-list {
  max-height: 230px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-item {
  font-size: 0.78rem;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.log-time { color: var(--primary-light); font-family: monospace; flex-shrink: 0; }

.timer-display {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.4rem;
  color: var(--accent);
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px;
  font-size: 0.92rem;
  font-family: inherit;
}

.input-with-btn {
  display: flex;
  gap: 6px;
}

.appointments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.appt-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.appt-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.appt-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

.cap-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.cap-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px;
}

.cap-result {
  display: block;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--primary-light);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.compare-table th, .compare-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.compare-table th { color: var(--primary-light); }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(23, 26, 35, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}

.nav-btn {
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: 10px;
  cursor: pointer;
}

.nav-btn.active {
  color: var(--primary-light);
  background: rgba(124, 58, 237, 0.16);
}

.nav-icon { font-size: 1.15rem; }

.toast {
  position: fixed;
  bottom: calc(78px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--primary-light);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.84rem;
  z-index: 40;
  max-width: 90vw;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}
