:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.1);
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
  --accent: #2a78d6;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 12px rgba(11, 11, 11, 0.06);
  --focus-ring: 0 0 0 3px rgba(42, 120, 214, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.1);
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-critical: #d03b3b;
    --accent: #3987e5;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.4);
    --focus-ring: 0 0 0 3px rgba(57, 135, 229, 0.4);
  }
}

* {
  box-sizing: border-box;
}

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

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.page-header {
  margin-bottom: 24px;
}

h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.page-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

h2 {
  font-size: 16px;
  margin: 0;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.settings-panel {
  padding: 0;
}

.settings-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 10px;
}

.settings-panel summary::-webkit-details-marker {
  display: none;
}

.settings-summary-title {
  flex: 1;
}

.settings-summary-value {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.settings-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}

.settings-panel[open] .settings-chevron {
  transform: rotate(45deg);
}

.settings-panel form.inline {
  padding: 0 16px 16px;
  margin-top: 0;
}

form.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

form.inline label {
  font-size: 13px;
  color: var(--text-secondary);
}

form.inline input,
form.inline select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--gridline);
  border-radius: 6px;
  background: var(--surface-1);
  color: var(--text-primary);
}

form.inline input[type="text"] {
  flex: 1;
  min-width: 120px;
}

button,
input,
select,
summary {
  transition: filter 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

button {
  font: inherit;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--gridline);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.error-banner {
  background: var(--surface-1);
  border: 1px solid var(--status-critical);
  color: var(--status-critical);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--gridline);
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 4px 4px 0 0;
  padding: 8px 4px;
  margin-bottom: -1px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tab:hover:not(:disabled) {
  filter: none;
  color: var(--text-primary);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.child-card {
  margin-bottom: 12px;
  animation: card-in 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
  .child-card {
    animation: none;
  }
}

.child-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.allowance-note {
  color: var(--text-muted);
  font-size: 13px;
}

.balance-display {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.balance-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  transition: color 0.4s ease;
}

.balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.control-label {
  display: block;
  margin-top: 14px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.balance-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.balance-adjust-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.adjust-btn,
.unlimited-btn {
  padding: 4px 10px;
  font-size: 13px;
}

.set-balance-form {
  margin-top: 0;
}

.set-balance-form input[type="number"] {
  width: 110px;
  flex: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.devices {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gridline);
}

.assign-device select {
  flex: 1;
  min-width: 160px;
}

.allowance-form input[type="number"] {
  width: 80px;
  flex: none;
}

.device-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.device-list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.device-list-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 0;
}

.device-assignment {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
}

.account-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.account-bar button {
  padding: 2px 8px;
  font-size: 12px;
}

.parents-section {
  padding: 0 16px 16px;
}

.hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 0;
}

#devices-list .device-list-item {
  flex-wrap: wrap;
}

.pair-btn {
  padding: 2px 8px;
  font-size: 12px;
}

.pairing-code {
  flex-basis: 100%;
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.pairing-code strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--text-primary);
}

.unassign-btn {
  margin-left: auto;
  padding: 2px 8px;
  font-size: 12px;
}

.platform-badge {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  border: 1px solid var(--gridline);
  border-radius: 4px;
  padding: 1px 6px;
}

.list-note {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 16px;
}

.list-note--empty {
  padding: 32px 16px;
  border: 1px dashed var(--gridline);
  border-radius: 10px;
}
