:root {
  --bg: #f6f7fb;
  --bg-soft: #eef3f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #162033;
  --muted: #667085;
  --line: #d9e1ec;
  --primary: #1f6feb;
  --primary-strong: #1557c0;
  --success: #138a55;
  --warning: #b7791f;
  --danger: #c2413b;
  --shadow: 0 16px 40px rgba(22, 32, 51, 0.08);
  --radius: 8px;
}

* {
  letter-spacing: 0;
}

html {
  background: var(--bg);
}

body {
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(31, 111, 235, 0.08), rgba(31, 111, 235, 0) 280px),
    var(--bg) !important;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  background: rgba(255, 255, 255, 0.88) !important;
  border-bottom: 1px solid rgba(217, 225, 236, 0.82);
  box-shadow: none !important;
  backdrop-filter: blur(14px);
}

.header h1 {
  color: var(--text) !important;
  font-size: 21px !important;
  font-weight: 750;
}

.header-actions {
  flex-wrap: wrap;
}

.container {
  max-width: 1240px !important;
  padding: 28px 24px 48px !important;
}

.btn,
a.btn {
  min-height: 40px;
  border: 1px solid transparent !important;
  border-radius: var(--radius) !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  box-shadow: none !important;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.22) !important;
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary) !important;
  color: #fff !important;
}

.btn-primary:hover {
  background: var(--primary-strong) !important;
}

.btn-secondary {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

.btn-success {
  background: var(--success) !important;
  color: #fff !important;
}

.btn-danger {
  background: var(--danger) !important;
  color: #fff !important;
}

.btn-small {
  min-height: 34px;
  padding: 7px 10px !important;
}

.card,
.stat-card,
.login-container {
  border: 1px solid rgba(217, 225, 236, 0.9);
  border-radius: var(--radius) !important;
  background: rgba(255, 255, 255, 0.96) !important;
  box-shadow: var(--shadow) !important;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 16px !important;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 22px !important;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.stat-card h3,
.card-header h2,
.card h2 {
  color: var(--text) !important;
}

.stat-card h3 {
  margin-bottom: 10px !important;
  color: var(--muted) !important;
  font-size: 13px !important;
}

.stat-card .value {
  color: var(--text) !important;
  font-size: 34px !important;
  font-variant-numeric: tabular-nums;
}

#activeStations {
  color: var(--success) !important;
}

#lowBalanceStations {
  color: var(--danger) !important;
}

.card {
  padding: 22px !important;
}

.card-header {
  gap: 16px;
  flex-wrap: wrap;
}

.table {
  min-width: 860px;
}

.table thead {
  background: var(--surface-muted) !important;
}

.table th {
  color: #475467 !important;
  border-bottom: 1px solid var(--line) !important;
  text-transform: none;
}

.table td {
  border-bottom: 1px solid #edf1f6 !important;
  color: var(--text) !important;
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #f8fbff;
}

#stationsTable {
  overflow-x: auto;
}

.badge {
  border-radius: 999px !important;
  padding: 5px 10px !important;
  border: 1px solid transparent;
  font-weight: 700 !important;
}

.badge-success {
  background: #e7f7ef !important;
  color: #0f6b43 !important;
  border-color: #bce8d0;
}

.badge-warning {
  background: #fff5dc !important;
  color: #8a5a14 !important;
  border-color: #f4d58a;
}

.badge-danger {
  background: #fff0ee !important;
  color: #a33934 !important;
  border-color: #f1b8b3;
}

.badge-secondary {
  background: #eef2f7 !important;
  color: #526070 !important;
  border-color: #dde5ef;
}

.form-group input,
.form-group select {
  min-height: 44px;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  background: #fff;
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.form-group label {
  color: #344054 !important;
  font-weight: 650 !important;
}

.form-group small {
  color: var(--muted) !important;
}

.modal {
  background: rgba(15, 23, 42, 0.45) !important;
  backdrop-filter: blur(10px);
}

.modal-content {
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius) !important;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.26) !important;
}

.alert {
  border-radius: var(--radius) !important;
  border-width: 1px !important;
}

.alert-success {
  background: #e7f7ef !important;
  color: #0f6b43 !important;
  border-color: #bce8d0 !important;
}

.alert-error {
  background: #fff0ee !important;
  color: #a33934 !important;
  border-color: #f1b8b3 !important;
}

.alert-info {
  background: #eaf2ff !important;
  color: #1557c0 !important;
  border-color: #bcd4ff !important;
}

.login-page {
  min-height: 100vh;
  display: grid !important;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 22% 14%, rgba(31, 111, 235, 0.18), transparent 28%),
    linear-gradient(180deg, #f7f9fc 0%, #edf3f9 100%) !important;
}

.login-container {
  max-width: 430px !important;
  padding: 34px !important;
}

.login-header {
  text-align: left !important;
}

.login-header h1 {
  color: var(--text) !important;
  font-size: 28px !important;
}

.login-header p {
  color: var(--muted) !important;
  font-size: 15px !important;
}

.login-container .btn {
  width: 100%;
  min-height: 46px;
}

.actions {
  flex-wrap: wrap;
}

.empty,
.loading {
  color: var(--muted) !important;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  min-width: 260px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.16);
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: #bce8d0;
}

.toast.error {
  border-color: #f1b8b3;
}

.settings-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid rgba(217, 225, 236, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 46px rgba(22, 32, 51, 0.06);
}

.settings-overview .eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.settings-overview h2 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.25;
}

.settings-overview p {
  max-width: 720px;
  color: var(--muted);
  font-size: 14px;
}

.settings-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(112px, 1fr));
  gap: 10px;
}

.status-tile {
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.status-tile span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.status-tile strong {
  color: var(--text);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.settings-card {
  min-height: 100%;
}

.card-description {
  max-width: 680px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 14px;
}

.interval-control,
.form-row.two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(128px, 0.34fr);
  gap: 12px;
}

.form-row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 820px) {
  .header {
    align-items: flex-start !important;
    flex-direction: column;
    gap: 12px;
  }

  .container {
    padding: 20px 14px 36px !important;
  }

  .stats-grid,
  .settings-grid {
    grid-template-columns: 1fr !important;
  }

  .settings-overview {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .settings-status,
  .form-row.two {
    grid-template-columns: 1fr;
  }

  .interval-control {
    grid-template-columns: minmax(0, 1fr) 112px;
  }

  .card,
  .stat-card,
  .login-container {
    padding: 18px !important;
  }

  .form-actions,
  .card-header > div {
    width: 100%;
    justify-content: stretch !important;
  }

  .form-actions .btn,
  .card-header .btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
