/* Phinergy Admin Dashboard - Login Page Styles */
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;800&display=swap");

* {
  transition: all 0.3s ease;
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Montserrat", sans-serif;
  line-height: 1.3;
  min-height: 100vh;
  overflow-x: hidden;
  background: #f7f7f7;
}

#root {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Language/Theme Selector */
.header-bar {
  background: #ffffff;
  padding: 15px 50px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 20px;
}

.language-selector {
  display: flex;
  gap: 15px;
  align-items: center;
}

.language-item {
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 4px;
  transition: all 0.3s ease;
  font-size: 12px;
  font-weight: 500;
  color: #666;
}

.language-item:hover {
  background: #f0f0f0;
}

.language-item.active {
  border: 2px solid #666;
  color: #333;
}

/* Login Page Container */
.login-page {
  background: #f7f7f7;
  padding: 50px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-area {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.login-box {
  margin: 0;
  text-align: center;
  background: white;
  padding: 50px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  min-width: 400px;
}

.login-box .logo {
  width: 180px;
  margin: 0 auto 20px;
  display: block;
}

.login-box h2 {
  margin: 20px 0 40px;
  font-size: 30px;
  color: #333;
  font-weight: 600;
}

/* Form Box */
.form-box {
  display: flex;
  flex-direction: column;
  position: relative;
  gap: 20px;
}

.form-field {
  text-align: left;
  display: flex;
  flex-direction: column;
}

.form-field label {
  font-size: 12px;
  font-weight: 500;
  color: #666;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-field input {
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: "Montserrat", sans-serif;
  transition: all 0.3s ease;
}

.form-field input:focus {
  outline: none;
  border-color: #2b3a67;
  box-shadow: 0 0 5px rgba(43, 58, 103, 0.2);
}

.form-field input::placeholder {
  color: #999;
}

/* Button */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: "Montserrat", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-fill {
  background: #2b3a67;
  color: white;
  margin-top: 20px;
  align-self: flex-end;
}

.btn-fill:hover {
  background: #1f2847;
  box-shadow: 0 4px 12px rgba(43, 58, 103, 0.3);
}

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

/* Error Message */
.error-msg {
  text-align: left;
  background: #ffcdd2;
  color: #e53a35;
  overflow: hidden;
  padding: 0;
  margin: 0;
  height: 0;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.login-box.notValid {
  box-shadow: 0 0 5px #e53a35;
}

.login-box.notValid .error-msg {
  padding: 12px;
  margin-top: 30px;
  height: auto;
}

.login-box.success .form-box {
  opacity: 0.5;
  pointer-events: none;
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #2b3a67;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Dashboard (after login) */
.dashboard {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #f7f7f7;
}

.navbar {
  background: #2b3a67;
  color: white;
  padding: 15px 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.navbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.navbar .user-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.navbar .logout-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.navbar .logout-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.navbar .swiss-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  padding: 3px 6px;
}

.navbar .tabs {
  display: flex;
  gap: 4px;
  align-items: center;
}
.navbar .tab-btn {
  background: transparent;
  color: rgba(255,255,255,0.75);
  border: none;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
}
.navbar .tab-btn:hover { color: #fff; }
.navbar .tab-btn.active {
  color: #fff;
  border-bottom-color: #FFD600;
}

#tab-body { flex: 1; display: flex; min-height: 0; }
#tab-body > * { flex: 1; }

/* Events List page */
.events-page {
  padding: 24px 32px;
  overflow: auto;
  background: #f5f7fa;
  width: 100%;
}
.events-section {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 18px 22px;
}
.events-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.events-toolbar h2 {
  margin: 0;
  font-size: 18px;
  color: #2b3a67;
}
.events-filters {
  display: flex;
  align-items: center;
  gap: 14px;
}
.events-filters select {
  padding: 6px 10px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font-size: 13px;
}
.ev-filter-select,
.ev-filter-date {
  padding: 6px 10px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  color: #2b3a67;
}
.events-filters .btn {
  background: #2b3a67;
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.events-filters .btn:hover { background: #3a4d85; }

.events-table { overflow-x: auto; }
.events-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.events-table th, .events-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #eef0f3;
}
.events-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6a7280;
  background: #f9fafb;
  position: sticky;
  top: 0;
}
.events-table tbody tr:hover { background: #fafbfc; }
.ev-type-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #fff;
}
.ev-type-chip.state-active        { background: #0D47A1; }
.ev-type-chip.state-standby       { background: #2E7D32; }
.ev-type-chip.state-service       { background: #C62828; }
.ev-type-chip.state-off           { background: #9E9E9E; }
.ev-type-chip.state-energy_reload { background: #7B1FA2; }

/* ── Settings page ─────────────────────────────────────── */
.settings-page {
  flex: 1;
  overflow: auto;
  background: #f5f7fa;
  padding: 28px 32px;
}
.settings-inner {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
}

/* Sub-tab navigation */
.settings-tabs {
  display: flex;
  gap: 0;
  background: #2b3a67;
  padding: 0 20px;
}
.stab-btn {
  background: transparent;
  color: rgba(255,255,255,0.65);
  border: none;
  border-bottom: 3px solid transparent;
  padding: 14px 22px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.stab-btn:hover { color: #fff; }
.stab-btn.active { color: #fff; border-bottom-color: #FFD600; }

/* Content area */
.settings-body {
  padding: 24px 28px 32px;
  min-height: 300px;
}

/* Shared table */
.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.settings-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6a7280;
  background: #f9fafb;
  border-bottom: 1px solid #eef0f3;
  position: sticky;
  top: 0;
}
.settings-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #eef0f3;
  color: #2b3a67;
  vertical-align: middle;
}
.settings-table tbody tr:hover { background: #fafbfc; }
.settings-table .id-cell { color: #9aa0ac; font-size: 12px; }
.settings-table .mono { font-family: monospace; font-size: 12px; color: #555; }

/* Role chips */
.role-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}
.role-admin  { background: #2b3a67; }
.role-client { background: #66BB6A; }

/* Active badges */
.badge-active   { color: #2e7d32; font-weight: 600; font-size: 12px; }
.badge-inactive { color: #9aa0ac; font-size: 12px; }

/* Global settings form */
.gs-form { max-width: 900px; }
.gs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 32px;
  margin-bottom: 28px;
}
@media (max-width: 700px) { .gs-grid { grid-template-columns: 1fr; } }

.gs-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gs-field label {
  font-size: 13px;
  font-weight: 600;
  color: #2b3a67;
}
.gs-input {
  padding: 9px 12px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font-size: 14px;
  color: #2b3a67;
  background: #fafbfc;
  transition: border-color 0.2s;
}
.gs-input:focus {
  outline: none;
  border-color: #00b4d6;
  background: #fff;
}

.gs-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 4px;
}
.gs-save-btn {
  background: #2b3a67;
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.2s;
}
.gs-save-btn:hover { background: #3a4d85; }
.gs-save-msg { font-size: 13px; font-weight: 600; }
.gs-save-msg.ok  { color: #2e7d32; }
.gs-save-msg.err { color: #E53A35; }
.ev-type-chip.state-unknown  { background: #bbbbbb; }
.ev-ongoing { color: #E53A35; font-weight: 600; }

/* Events Statistics section */
.events-page-title {
  margin-bottom: 12px;
}
.events-page-title h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #2b3a67;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.events-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .events-stats-grid { grid-template-columns: 1fr; }
}

.ev-stat-card {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 28px 32px 24px;
}
.ev-stat-card h3 {
  margin: 0 0 20px;
  font-size: 17px;
  font-weight: 500;
  color: #2b3a67;
}

/* Horizontal bar chart (duration stats) */
.ev-hbar { display: flex; flex-direction: column; gap: 18px; }
.ev-hbar-total {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid #eef0f3;
  padding-bottom: 16px;
}
.ev-hbar-total label { font-size: 16px; color: #6a7280; width: 120px; }
.ev-hbar-total strong { font-size: 30px; font-weight: 700; color: #2b3a67; }

.ev-hbar-row { display: flex; align-items: center; gap: 14px; }
.ev-hbar-row label {
  font-size: 15px;
  color: #6a7280;
  width: 120px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 12px;
  border-right: 2px solid #d0d7de;
}
.ev-hbar-track {
  flex: 1;
  background: #e8edf2;
  border-radius: 4px;
  height: 40px;
  overflow: hidden;
}
.ev-hbar-fill {
  background: #00b4d6;
  border-radius: 0 4px 4px 0;
  height: 100%;
  min-width: 4px;
  transition: width 0.4s ease;
}
.ev-hbar-value {
  width: 90px;
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 700;
  color: #2b3a67;
  text-align: left;
  padding-left: 4px;
}

/* Vertical distribution bar chart
   Layout per column (flex column, top→bottom):
     [count label 22px] [bar-area flex:1] [bucket label 28px]
   bar-area uses justify-content:flex-end so fill grows up from its bottom.
   fill height % is relative to bar-area, not the full column — no overflow. */
.ev-dist {
  display: flex;
  flex-direction: column;
  height: 340px;
  padding-left: 44px;
  position: relative;
  box-sizing: border-box;
}
.ev-dist-ylabel {
  position: absolute;
  left: -8px;
  top: 45%;
  transform: rotate(-90deg) translateX(50%);
  transform-origin: left center;
  font-size: 12px;
  color: #6a7280;
  white-space: nowrap;
  width: 0;
}
.ev-dist-bars {
  display: flex;
  align-items: stretch;   /* columns stretch full height */
  flex: 1;
  gap: 6px;
}
.ev-dist-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
}
.ev-dist-count {
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #2b3a67;
  flex-shrink: 0;
}
.ev-dist-bar-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-bottom: 2px solid #d0d7de;
  overflow: hidden;
}
.ev-dist-fill {
  background: #00b4d6;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
}
.ev-dist-col b {
  height: 30px;
  line-height: 30px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: #6a7280;
  white-space: nowrap;
  flex-shrink: 0;
}
.ev-dist-xlabel {
  text-align: center;
  font-size: 13px;
  color: #6a7280;
  margin-top: 4px;
}

.main-content {
  flex: 1;
  padding: 50px;
  overflow-y: auto;
}

/* Map page (post-login dynamic map) */
.map-page {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 500px;
  gap: 0;
  min-height: 0;
}

.map-container {
  position: relative;
  background: #e6e9ef;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;  /* creates stacking context — keeps Leaflet's panes (z-index 200–600) inside */
}

.station-sidebar {
  background: white;
  border-left: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section {
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.sidebar-section h2 {
  margin: 0 0 15px;
  color: #2b3a67;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* View-mode toggle (Map / List) */
.sidebar-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}
.sidebar-view-header h2 { margin: 0; }

.view-mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}
.vmt-btn {
  background: #fff;
  color: #6a7280;
  border: none;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.vmt-btn + .vmt-btn { border-left: 1px solid #d0d7de; }
.vmt-btn:hover { background: #f5f7fa; color: #2b3a67; }
.vmt-btn.active { background: #2b3a67; color: #fff; }

/* Full-page stations list view */
.station-list-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #f5f7fa;
}

.slp-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 0 24px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.slp-top .view-mode-toggle {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}

/* Summary strip — full-width centered single row */
.slp-summary {
  display: flex;
  justify-content: center;
  flex: 1;
}
.slp-summary .station-status-info {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}
.slp-summary .station-status-info h4 { display: none; }
.slp-summary .status-chart {
  height: auto;
  align-items: stretch;
  justify-content: center;
  gap: 20px;
  flex-wrap: nowrap;
}
.slp-summary .status-chart li {
  justify-content: center;
  min-width: 56px;
  padding: 6px 18px;
  white-space: nowrap;
}
.slp-summary .status-chart li small {
  font-size: 10px;
}
.slp-summary .status-chart .sc-bar { display: none; }

.slp-body {
  flex: 1;
  overflow: auto;
  padding: 20px 24px;
}

/* Stations full table */
.stations-full-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stations-full-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6a7280;
  background: #f9fafb;
  border-bottom: 1px solid #eef0f3;
  position: sticky;
  top: 0;
}
.stations-full-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #eef0f3;
  color: #2b3a67;
  vertical-align: middle;
}
.sl-status-cell,
.sl-status-th {
  text-align: center;
}
.sl-status-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sl-status-btn:hover {
  filter: brightness(1.15);
  transform: scale(1.04);
}
.sl-status-btn:active {
  transform: scale(0.97);
}
.stations-full-table tbody tr:hover { background: #f5f7fa; cursor: pointer; }
.stations-full-table tbody tr.selected { background: #e8f4fd; }
.stations-full-table .sl-desc { color: #6a7280; }
.stations-full-table .sl-live { color: #b0b8c4; font-style: italic; }

.col-filter-row th {
  padding: 4px 8px 6px;
  background: #f1f3f6;
  position: sticky;
  top: 37px;
  text-align: center;
}
.sl-status-header-cell {
  text-align: center;
}
.sl-status-header-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  margin: 2px;
  opacity: 0.55;
  transition: opacity 0.15s, transform 0.1s;
}
.sl-status-header-btn:hover { opacity: 0.85; }
.sl-status-header-btn.sl-hdr-active { opacity: 1; box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor; }
/* "All" button style */
.sl-status-header-btn:not([class*="state-"]) {
  background: #6a7280;
  color: #fff;
}
.col-filter {
  width: 100%;
  padding: 4px 7px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #2b3a67;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}
.col-filter:focus { border-color: #0D47A1; box-shadow: 0 0 0 2px rgba(13,71,161,0.12); }
.col-filter::placeholder { color: #b0b8c4; }
.approx-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  color: #f0a020;
  font-style: italic;
}

.sidebar-section h3 {
  margin: 0 0 12px;
  color: #2b3a67;
  font-size: 15px;
}

.stations-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  margin-bottom: 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
}
.stations-search-input:focus {
  border-color: #0D47A1;
}

.stations-list {
  max-height: 50vh;
  overflow-y: auto;
}

.stations-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.station-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s ease;
}

.station-item:hover {
  background: #f5f7fb;
}

.station-item.selected {
  background: #eef1fb;
}

.station-item.wash-low {
  background: #fff5f5;
  border-left: 3px solid #C62828;
}

.station-item.wash-low:hover {
  background: #ffe8e8;
}

.wash-low-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 4px;
  background: #C62828;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: auto;
}

.reload-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: 4px;
}
.rb-wash   { background: #1565C0; }
.rb-al     { background: #7B1FA2; }
.rb-refuel { background: #E65100; }

tr.sl-row.wash-low td {
  background: #fff5f5;
}

tr.sl-row.wash-low td:first-child {
  border-left: 3px solid #C62828;
}

.station-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 1px solid transparent;
}

.station-status.state-active        { background: #0D47A1; }
.station-status.state-standby       { background: #2E7D32; }
.station-status.state-service       { background: #C62828; }
.station-status.state-off           { background: transparent; border-color: #9E9E9E; }
.station-status.state-unknown       { background: #bbbbbb; }
.station-status.state-energy_reload { background: #7B1FA2; }

/* Legacy fallback (used only when station.state is missing) */
.status-active   { background: #66BB6A; }
.status-inactive { background: transparent; border-color: #9E9E9E; }

.status-active-text {
  color: #54ad69;
}

.status-inactive-text {
  color: #9a9a9a;
}

.station-info {
  flex: 1;
  min-width: 0;
}

.station-info strong {
  display: block;
  font-size: 13px;
  color: #333;
}

.station-info p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #777;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-details .detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px dashed #f0f0f0;
}

.station-details .detail-row span {
  color: #888;
}

.station-details .detail-row strong {
  color: #333;
  text-align: right;
}

.empty-msg {
  color: #999;
  font-size: 13px;
  margin: 0;
}

.station-details .detail-row.approx-note {
  display: block;
  color: #a06000;
  border-bottom: none;
  font-size: 12px;
  font-style: italic;
}

.station-status-info {
  margin: 0;
  padding: 12px 14px 4px;
}
.station-status-info h4 {
  margin: 0 0 2px;
  font-size: 14px;
  color: #333;
  text-transform: capitalize;
}
.station-status-info .num-of-stations-label {
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
}
.station-status-info ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
/* Single unified chart: number + label + bar per column */
.station-status-info ul.status-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 90px;        /* total height: bar area + label area */
}
.station-status-info ul.status-chart li {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  cursor: pointer;
}
.station-status-info ul.status-chart li b {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.station-status-info ul.status-chart li small {
  font-size: 9px;
  color: #888;
  white-space: nowrap;
  margin-bottom: 4px;
}
.station-status-info ul.status-chart .sc-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
}
/* Colors — number matches bar */
.station-status-info ul.status-chart .total b          { color: #00b4d6; }
.station-status-info ul.status-chart .standby b        { color: #2E7D32; }
.station-status-info ul.status-chart .active b         { color: #0D47A1; }
.station-status-info ul.status-chart .service b        { color: #C62828; }
.station-status-info ul.status-chart .off b            { color: #9E9E9E; }
.station-status-info ul.status-chart .energy_reload b  { color: #7B1FA2; }
.station-status-info ul.status-chart .total .sc-bar          { background: #00b4d6; }
.station-status-info ul.status-chart .standby .sc-bar        { background: #2E7D32; }
.station-status-info ul.status-chart .active .sc-bar         { background: #0D47A1; }
.station-status-info ul.status-chart .service .sc-bar        { background: #C62828; }
.station-status-info ul.status-chart .off .sc-bar            { background: #9E9E9E; }
.station-status-info ul.status-chart .energy_reload .sc-bar  { background: #7B1FA2; }
/* Separator after Total */
.station-status-info ul.status-chart .total {
  border-right: 1px solid #e0e0e0;
  padding-right: 4px;
  margin-right: 2px;
}

.card {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.card h2 {
  margin-top: 0;
  margin-bottom: 20px;
  color: #2b3a67;
  font-size: 20px;
}

/* Responsive */
@media (max-width: 768px) {
  .login-box {
    min-width: auto;
    width: 100%;
    padding: 30px;
  }

  .header-bar,
  .login-page {
    padding: 20px;
  }

  .navbar {
    flex-direction: column;
    gap: 15px;
    padding: 20px;
  }

  .navbar .user-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .map-page {
    grid-template-columns: 1fr;
    grid-template-rows: 50vh auto;
  }

  .station-sidebar {
    border-left: none;
    border-top: 1px solid #e0e0e0;
  }
}

.region-select {
  width: 100%;
  margin-bottom: 10px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font-size: 14px;
}

/* Make station summary tiles look clickable and indicate the active filter. */
.station-status-info ul.status-chart li[data-filter] {
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: background-color 0.15s, transform 0.05s;
}
.station-status-info ul.status-chart li[data-filter]:hover {
  background: rgba(0, 0, 0, 0.04);
}
.station-status-info ul.status-chart li[data-filter]:active {
  transform: scale(0.97);
}
.station-status-info ul.status-chart li.selected {
  background: rgba(0, 180, 214, 0.08);
}

/* ── Station Screen ─────────────────────────────────────── */
.station-screen {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.station-screen-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.back-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 14px;
  cursor: pointer;
  color: #333;
  white-space: nowrap;
  transition: background 0.15s;
}
.back-btn:hover { background: #f0f0f0; }

.station-screen-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.station-screen-title h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.station-screen-badge {
  display: inline-block;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
  letter-spacing: 0.3px;
}

.station-screen-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 600px) {
  .station-screen-body { grid-template-columns: 1fr; }
}

.station-screen-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.sc-card-title {
  margin: 0 0 14px 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #555;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}

.sc-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 14px;
}
.sc-row:last-child { border-bottom: none; }
.sc-row span { color: #777; }
.sc-row strong { color: #222; font-weight: 600; text-align: right; max-width: 60%; word-break: break-word; }

/* ── Map Tooltip ────────────────────────────────────────── */
.st-tooltip {
  font-size: 13px;
  min-width: 190px;
}
.st-tooltip-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid #ddd;
}
.st-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
}
.st-tooltip-row span:first-child { color: #777; }
.st-tooltip-row span:last-child  { font-weight: 500; text-align: right; }

/* ── Station Details Screen v2 (matches mockup) ────────────────────── */
.station-screen-v2 {
  flex: 1;
  padding: 28px 36px;
  background: #f5f7fa;
  overflow: auto;
}

.ssv2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.ssv2-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #2b3a67;
  letter-spacing: 0.3px;
}

.back-to-map-btn {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #2b3a67;
  font-family: "Montserrat", sans-serif;
  transition: background 0.15s, box-shadow 0.15s;
}
.back-to-map-btn:hover { background: #f0f4f8; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

.ssv2-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) { .ssv2-body { grid-template-columns: 1fr; } }

.ssv2-info-card,
.ssv2-stats-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 24px 26px;
}

.ssv2-card-title {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #2b3a67;
  border-bottom: 1px solid #eef0f3;
  padding-bottom: 12px;
}

.ssv2-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.ssv2-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ssv2-status-label {
  font-size: 13px;
  font-weight: 600;
}

.ssv2-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 13px;
}
.ssv2-row:last-child { border-bottom: none; }
.ssv2-row span  { color: #9aa0ac; font-size: 12px; flex-shrink: 0; }
.ssv2-row strong { color: #2b3a67; font-weight: 600; text-align: right; word-break: break-word; }

/* KPI row */
.ssv2-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.ssv2-kpi {
  background: #f5f7fa;
  border-radius: 8px;
  padding: 16px 10px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.ssv2-kpi-val {
  font-size: 26px;
  font-weight: 700;
  color: #2b3a67;
  line-height: 1;
  white-space: nowrap;
}

.ssv2-kpi-label {
  font-size: 10px;
  color: #9aa0ac;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.3;
  text-align: center;
}

/* Monthly bar chart */
.ssv2-chart-section { margin-top: 4px; }

.ssv2-chart-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.ssv2-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 150px;
}

.ssv2-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.ssv2-bar-count {
  height: 18px;
  line-height: 18px;
  font-size: 10px;
  font-weight: 700;
  color: #2b3a67;
  flex-shrink: 0;
  text-align: center;
}

.ssv2-bar-area {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  border-bottom: 2px solid #e0e4ea;
}

.ssv2-bar-fill {
  background: #00b4d6;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.35s ease;
  width: 100%;
}

.ssv2-bar-label {
  font-size: 9px;
  color: #9aa0ac;
  text-align: center;
  margin-top: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Change-password button in navbar */
.chpw-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  opacity: 0.7;
  line-height: 1;
}
.chpw-btn:hover { opacity: 1; }

/* Change-password dropdown */
.chpw-modal {
  position: absolute;
  top: 56px;
  right: 120px;
  background: #fff;
  border: 1px solid #ccd0d9;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 9999;
  padding: 16px;
  width: 280px;
}
.chpw-inner h3 { margin: 0 0 12px; font-size: 15px; }

/* Capacity unit toggle button */
.cap-unit-toggle {
  font-size: 10px;
  padding: 1px 6px;
  border: 1px solid #00b4d6;
  border-radius: 4px;
  background: #e8f8fc;
  color: #00b4d6;
  cursor: pointer;
  font-weight: 600;
  vertical-align: middle;
  margin-left: 4px;
  line-height: 1.4;
}
.cap-unit-toggle:hover { background: #00b4d6; color: #fff; }

/* Add Station modal overlay */
.add-station-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.add-station-modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px 28px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}
.add-station-modal h3 { margin: 0 0 18px; font-size: 16px; }
.add-station-modal .form-row { margin-bottom: 13px; }
.add-station-modal .form-row label { display: block; font-size: 0.82em; color: #555; margin-bottom: 4px; }
.add-station-modal .modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 18px; }

/* Danger button variant */
.btn-danger {
  background: #c62828;
  color: #fff;
  border: none;
}
.btn-danger:hover { background: #b71c1c; }

/* Users admin tab */
.su-tab { }
.sg-tab { }

/* ── Bottom timeline scrubber ────────────────────────────────────────── */
#events-bar-wrap {
  position: absolute;
  bottom: 0;
  left: 30px;
  right: 30px;
  z-index: 10;  /* above #map (z-index:1); Leaflet internals stay inside #map's stacking context */
  pointer-events: none;
}

.events-bar {
  background: #fff;
  box-shadow: 0 0 10px #e0e0e0;
  border-radius: 10px 10px 0 0;
  padding: 10px 30px 0;
  text-align: center;
  pointer-events: all;
  transition: max-height 0.3s ease, padding 0.3s ease;
  max-height: 120px;
  overflow: hidden;
  position: relative;
}

.events-bar.events-bar-closed {
  max-height: 36px;
  padding-bottom: 0;
}

/* Toggle chevron button */
.eb-toggle-btn {
  position: absolute;
  top: -14px;
  left: 0;
  right: 0;
  margin: auto;
  width: 28px;
  height: 28px;
  background: #fff;
  border: none;
  box-shadow: 0 0 8px #e0e0e0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 1;
}
.eb-toggle-btn svg {
  width: 12px;
  height: 12px;
  fill: #555;
  transition: transform 0.3s;
}
.events-bar-closed .eb-toggle-btn svg {
  transform: rotate(180deg);
}

/* Title row */
.eb-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 8px;
  margin: 0;
}
.eb-title-bar h5 {
  margin: 0;
  font-size: 12px;
  color: #333;
  font-weight: 600;
}
.eb-all-link {
  font-size: 11px;
  color: #00b4d6;
  cursor: pointer;
  border: 1px solid #00b4d6;
  border-radius: 4px;
  padding: 1px 7px;
  text-decoration: none;
}
.eb-all-link:hover { background: #00b4d6; color: #fff; }

/* History strip */
.eb-history {
  display: flex;
  align-items: center;
  position: relative;
  margin: 0;
}

/* Prev / next nav buttons */
.eb-nav-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eb-nav-btn svg {
  width: 12px;
  height: 12px;
  fill: #555;
}
.eb-nav-btn:hover svg { fill: #00b4d6; }
.eb-nav-placeholder { width: 24px; flex-shrink: 0; }

/* Slot columns */
.eb-slots {
  display: flex;
  align-items: flex-end;
  flex: 1;
  margin: 0;
  overflow: hidden;
}
.eb-slot {
  flex: 1;
  min-width: 50px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.eb-slot-inner {
  height: 40px;
  position: relative;
}

/* Tick + date label */
.eb-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  color: #00b4d6;
  border-top: 1px solid #e0e0e0;
  padding-top: 3px;
  position: relative;
  font-weight: 600;
}
.eb-tick::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 1px;
  background: #00b4d6;
  top: -14px;
  left: 0;
  right: 0;
  margin: auto;
}
.eb-date {
  display: none;
}
.eb-slot:first-child .eb-date {
  display: inline;
}
.eb-tick small {
  font-size: 9px;
  color: #888;
  font-weight: 400;
}

/* Event bubbles — centered above the tick line */
.eb-bubble {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.eb-bubble button {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #00b4d6;
  color: #fff;
  font-size: 9px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.eb-bubble:hover button { background: #0090b0; }

/* Bubble tooltip */
.eb-bubble-tip {
  display: none;
  position: fixed;
  bottom: 105px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 0 10px #e0e0e0;
  border: 1px solid #00b4d6;
  border-radius: 6px;
  padding: 8px 12px;
  white-space: nowrap;
  z-index: 20;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}
.eb-bubble-tip strong {
  color: #00b4d6;
  font-size: 12px;
}
.eb-bubble-tip span {
  font-size: 11px;
  color: #555;
}
.eb-bubble:hover .eb-bubble-tip { display: flex; }
