/* GoElectric CMS — design system (light/dark) */

:root,
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f6f8fa;
  --bg-subtle: #eef1f5;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --brand: #10b981;
  --brand-dark: #059669;
  --brand-contrast: #ffffff;
  --brand-soft: #ecfdf5;
  --brand-soft-border: #a7f3d0;

  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-soft-border: #fecaca;

  --success: #16a34a;
  --success-soft: #f0fdf4;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.14);

  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-text-muted: #64748b;
  --sidebar-active: rgba(16, 185, 129, 0.16);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b1220;
  --bg-subtle: #0f172a;
  --surface: #131c2e;
  --surface-raised: #17223a;
  --border: #253045;
  --border-strong: #324158;

  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --brand: #34d399;
  --brand-dark: #10b981;
  --brand-contrast: #06281d;
  --brand-soft: rgba(52, 211, 153, 0.12);
  --brand-soft-border: rgba(52, 211, 153, 0.32);

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --danger-soft-border: rgba(248, 113, 113, 0.32);

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);

  --sidebar-bg: #070c17;
  --sidebar-text: #cbd5e1;
  --sidebar-text-muted: #4b5872;
  --sidebar-active: rgba(52, 211, 153, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

button {
  font-family: inherit;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.theme-toggle:active {
  transform: scale(0.94);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}
[data-theme="light"] .theme-toggle .icon-sun,
[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ---------- Login page ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

.login-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  width: 100%;
  min-height: 100vh;
}

.login-branding {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: #ecfdf5;
  background: radial-gradient(circle at 15% 15%, #16a34a 0%, #0f172a 55%), linear-gradient(160deg, #059669 0%, #0f172a 60%);
  overflow: hidden;
}

.login-branding::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.5;
  pointer-events: none;
}

.brand-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.brand-mark .bolt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(4px);
}
.brand-mark .bolt svg {
  width: 18px;
  height: 18px;
}

.login-branding-content {
  position: relative;
  max-width: 420px;
}
.login-branding-content h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}
.login-branding-content p {
  color: rgba(236, 253, 245, 0.78);
  font-size: 1rem;
  margin: 0;
}

.login-branding-footer {
  position: relative;
  font-size: 13px;
  color: rgba(236, 253, 245, 0.55);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card h2 {
  font-size: 1.5rem;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.login-card .subtitle {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 14px;
}

.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.input-wrap {
  position: relative;
}
.field input[type="email"],
.field input[type="password"],
.field input[type="text"],
.field input[type="number"] {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input-wrap .toggle-visibility {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
}
.input-wrap .toggle-visibility svg {
  width: 18px;
  height: 18px;
}
.input-wrap input {
  padding-right: 42px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  border-radius: 10px;
  border: none;
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn:hover {
  background: var(--brand-dark);
}
.btn:active {
  transform: scale(0.99);
}
.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-soft-border);
}
.btn-danger:hover {
  background: var(--danger);
  color: var(--brand-contrast);
}

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 20px;
}
.alert svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}
.alert-error {
  background: var(--danger-soft);
  border: 1px solid var(--danger-soft-border);
  color: var(--danger);
}
.alert-success {
  background: var(--success-soft);
  border: 1px solid var(--brand-soft-border);
  color: var(--success);
}
.alert-info {
  background: var(--brand-soft);
  border: 1px solid var(--brand-soft-border);
  color: var(--brand-dark);
}

.login-foot-note {
  margin-top: 24px;
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: center;
}

@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-branding {
    display: none;
  }
}

/* ---------- App shell (dashboard) ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar .brand-mark {
  color: #f8fafc;
  padding: 0 6px;
  margin-bottom: 28px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-muted);
  padding: 16px 10px 8px;
}
.nav-section-label:first-child {
  padding-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer;
}
.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}
.nav-item.disabled {
  cursor: default;
  color: var(--sidebar-text-muted);
  opacity: 0.8;
}
.nav-item.disabled:hover {
  background: none;
}
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text-muted);
  padding: 2px 7px;
  border-radius: 999px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--sidebar-text-muted);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar .theme-toggle {
  position: static;
  box-shadow: none;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  margin-right: auto;
}
.menu-toggle svg {
  width: 20px;
  height: 20px;
}

.sidebar-backdrop {
  display: none;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-contrast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-menu .who {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.user-menu .who .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.user-menu .who .role {
  font-size: 11.5px;
  color: var(--text-muted);
}
.user-menu .logout {
  color: var(--text-faint);
  display: inline-flex;
  padding: 4px;
  border-radius: 6px;
}
.user-menu .logout:hover {
  color: var(--danger);
  text-decoration: none;
  background: var(--danger-soft);
}
.user-menu .logout svg {
  width: 16px;
  height: 16px;
}

.content {
  padding: 28px;
  flex: 1;
}

.page-header {
  margin-bottom: 22px;
}
.page-header h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.page-header h1 svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--brand);
}
.page-header p {
  color: var(--text-muted);
  margin: 0;
  font-size: 14px;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.page-header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.page-header-actions .btn {
  width: auto;
  padding-left: 18px;
  padding-right: 18px;
}
.page-header-row .btn-back {
  width: auto;
  padding-left: 18px;
  padding-right: 18px;
  flex-shrink: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}
.stat-card .label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.stat-card .label svg {
  width: 15px;
  height: 15px;
}
.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.stat-card .value.muted {
  color: var(--text-faint);
}

.narrow-form {
  max-width: 420px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 24px;
}
@media (max-width: 960px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 18px;
}
.field-grid .field-span-2 {
  grid-column: 1 / -1;
}
@media (max-width: 620px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.form-actions .btn {
  width: auto;
  padding-left: 20px;
  padding-right: 20px;
}

.coord-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.map-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.map-search-row input {
  flex: 1;
}
.map-search-row .btn {
  width: auto;
  padding-left: 16px;
  padding-right: 16px;
  flex-shrink: 0;
}

.map-search-status {
  font-size: 12.5px;
  color: var(--text-muted);
  min-height: 16px;
  margin: -4px 0 10px;
}

.map-container {
  height: 320px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.map-container--large {
  height: 70vh;
  min-height: 420px;
}

.card--flush-map {
  padding: 0;
  overflow: hidden;
}
.card--flush-map .map-container {
  border: none;
  border-radius: 0;
  margin-bottom: 0;
}
.card--flush-map .map-legend {
  padding: 16px 22px;
  margin: 0;
  border-top: 1px solid var(--border);
}

.cp-marker-dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25), 0 1px 3px rgba(15, 23, 42, 0.35);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 14px 0 0;
}
.map-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface);
  color: var(--text);
}
.leaflet-popup-content a {
  color: var(--brand-dark);
}
.leaflet-container {
  background: var(--bg-subtle);
  font-family: inherit;
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px;
    z-index: 2001;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .menu-toggle {
    display: inline-flex;
  }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 2000;
  }

  .btn-back-label,
  .btn-delete-label {
    display: none;
  }
  .page-header-row .btn-back,
  .page-header-actions .btn-delete-station {
    width: 36px;
    height: 36px;
    padding: 0;
    gap: 0;
    flex-shrink: 0;
  }

  .page-header-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
  }
}
