:root,
[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #1e2a3c;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 8px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --border: #d5dde8;
  --text: #152033;
  --muted: #5b6b82;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --ok: #059669;
  --warn: #b45309;
  --danger: #dc2626;
  color-scheme: light;
}

:root {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

h1 .icon,
h1 svg {
  width: 1.1rem;
  height: 1.1rem;
  color: var(--accent);
}

h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.subtitle {
  color: var(--muted);
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
}

.header-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.65rem;
}

.table-card {
  padding: 0.5rem 0.55rem 0.65rem;
}

.warn-card {
  padding: 0.55rem 0.75rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
  padding: 0 0.2rem;
}

.muted,
.optional {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.empty {
  color: var(--muted);
  padding: 0.75rem 0.35rem;
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
}

.routes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.routes-table th,
.routes-table td {
  padding: 0.4rem 0.45rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.routes-table th {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 650;
}

.routes-table tbody tr:hover {
  background: var(--surface-2);
}

.route-name {
  font-weight: 650;
  white-space: normal;
  max-width: 200px;
}

.route-path,
.email-cell {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 650;
  border: 1px solid var(--border);
}

.badge.on {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

.badge.off {
  color: var(--muted);
}

.badge.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

.badge.alert {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

.pct-ok {
  color: var(--ok);
  font-weight: 650;
}

.pct-bad {
  color: var(--danger);
  font-weight: 650;
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
}

label {
  display: block;
  margin-bottom: 0.7rem;
  font-size: 0.82rem;
  font-weight: 500;
}

label.inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
  align-items: end;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"] {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

button svg {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

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

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

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover:not(:disabled) {
  border-color: var(--muted);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
}

button.tiny {
  padding: 0.22rem 0.35rem;
  font-size: 0.72rem;
}

button.tiny svg {
  width: 0.85rem;
  height: 0.85rem;
}

button.icon-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
}

[data-theme="dark"] .icon-sun {
  display: none;
}

[data-theme="light"] .icon-moon {
  display: none;
}

[data-theme="dark"] .icon-moon,
[data-theme="light"] .icon-sun {
  display: block;
}

.message {
  min-height: 1rem;
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
}

.message.ok {
  color: var(--ok);
}

.message.err {
  color: var(--danger);
}

.warn {
  margin: 0;
  color: var(--warn);
  font-size: 0.8rem;
}

dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(520px, calc(100vw - 1.5rem));
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

dialog form {
  padding: 0.9rem 1rem 1rem;
}

.dialog-map {
  width: 100%;
  height: 160px;
  border-radius: 6px;
  background: var(--bg);
  margin-bottom: 0.75rem;
}

gmp-place-autocomplete {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  color-scheme: light;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.login-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.login-card h1 {
  margin: 0;
}

.login-card .muted {
  margin: 0 0 1rem;
}

@media (max-width: 720px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .route-path,
  .email-cell {
    max-width: 140px;
  }
}
