:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --surface-3: #e6e9ef;
  --border: #d8dee6;
  --text: #1a2330;
  --text-dim: #5b6b7c;
  --accent: #1f7ae0;
  --accent-dim: #1a5fa8;
  --success: #1c9d63;
  --danger: #c8362f;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 8px 24px rgba(20, 30, 45, 0.12);
}

:root[data-theme="dark"] {
  --bg: #0f1620;
  --surface: #141d29;
  --surface-2: #1b2634;
  --surface-3: #23303f;
  --border: #2a3a4c;
  --text: #e7edf5;
  --text-dim: #9db0c4;
  --accent: #3aa0ff;
  --accent-dim: #1f6fb8;
  --success: #33c481;
  --danger: #e2564f;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { background: var(--surface-2); border-color: var(--accent-dim); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--accent-dim); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
.btn-primary:hover { background: #57b0ff; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(226, 86, 79, 0.12); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58, 160, 255, 0.15);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-admin { background: rgba(51, 196, 129, 0.15); color: var(--success); }
.badge-viewer { background: rgba(58, 160, 255, 0.15); color: var(--accent); }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-error { background: rgba(200, 54, 47, 0.1); border-color: var(--danger); color: var(--danger); }
.alert-success { background: rgba(51, 196, 129, 0.12); border-color: var(--success); color: var(--success); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 22, 32, 0.5);
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.modal-close:hover { color: var(--text); }
