@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Barlow:ital,wght@0,300;0,400;0,500;0,600;1,300&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:          #111420;
  --surface:     #171b2e;
  --card:        #1d2235;
  --border:      #2a3050;
  --border-hi:   #3d4870;
  --accent:      #00e5a0;
  --accent-dim:  rgba(0, 229, 160, 0.12);
  --accent-glow: rgba(0, 229, 160, 0.28);
  --blue:        #3b82f6;
  --text:        #d0dcee;
  --text-dim:    #6878a0;
  --text-mid:    #9aabc8;
  --danger:      #f43f5e;
  --warning:     #fbbf24;
  --success:     #00e5a0;
  --sidebar-w:   240px;
  --radius:      6px;
  --font-display: 'Chakra Petch', monospace;
  --font-mono:    'JetBrains Mono', monospace;
  --font-body:    'Barlow', sans-serif;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: #33ffb8; }
img { display: block; max-width: 100%; }

/* ── Sidebar layout ─────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-mid);
  transition: color 0.12s, background 0.12s;
  margin-bottom: 1px;
}
.nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}
.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
}
.nav-link svg {
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-size: 0.8rem;
  color: var(--text-mid);
}

.sidebar-user-email {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.775rem;
}

/* ── Main wrapper ───────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  flex: 1;
}

.page-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.page-content {
  padding: 28px 32px;
  flex: 1;
}

/* ── Auth layout ────────────────────────────────────────── */
.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-text {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

.auth-logo-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 24px;
}

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-mid);
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mid);
}

/* ── Metric cards ───────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 100%);
  opacity: 0.6;
}

.metric-label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.metric-unit {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-left: 4px;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

/* .table is an alias for table.data-table (used in admin/catalog templates) */
table.data-table,
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data-table th,
table.table th {
  text-align: left;
  padding: 9px 14px;
  font-family: var(--font-display);
  font-size: 0.67rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table td,
table.table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(42,48,80,0.55);
  color: var(--text);
  vertical-align: middle;
}

table.data-table tr:last-child td,
table.table tr:last-child td {
  border-bottom: none;
}

table.data-table tbody tr:hover td,
table.table tbody tr:hover td {
  background: rgba(255,255,255,0.035);
}

table.data-table .mono,
table.table .mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
}

table.data-table .text-dim,
table.table .text-dim {
  color: var(--text-dim);
  font-size: 0.82rem;
}

/* .text-muted alias (used in admin templates) */
.text-muted { color: var(--text-dim); }

.table-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ── Forms ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}

.form-grid .form-group.full {
  grid-column: 1 / -1;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mid);
  margin-bottom: 7px;
}

.form-label .req {
  color: var(--accent);
  margin-left: 2px;
}

.form-control {
  display: block;
  width: 100%;
  background: rgba(17,20,40,0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 13px;
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-control.is-error {
  border-color: var(--danger);
}

.form-control.is-error:focus {
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.15);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M6 8L0 0h12z' fill='%236878a0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Aliases used in admin/catalog templates */
.form-input  { display: block; width: 100%; background: rgba(17,20,40,0.85); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 13px; color: var(--text); font-size: 0.875rem; font-family: var(--font-body); transition: border-color 0.15s, box-shadow 0.15s; appearance: none; }
.form-input:focus  { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-select { display: block; width: 100%; background: rgba(17,20,40,0.85) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M6 8L0 0h12z' fill='%236878a0'/%3E%3C/svg%3E") no-repeat right 12px center; border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 32px 9px 13px; color: var(--text); font-size: 0.875rem; font-family: var(--font-body); transition: border-color 0.15s, box-shadow 0.15s; appearance: none; }
.form-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

input[type="date"],
input[type="month"],
input[type="time"],
input[type="datetime-local"] {
  color-scheme: dark;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.input-with-action {
  position: relative;
}

.input-with-action .form-control {
  padding-right: 40px;
}

.input-action-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  line-height: 1;
}

.input-action-btn:hover {
  color: var(--accent);
}

.input-action-btn.is-loading svg {
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 5px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 5px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.14s;
  text-decoration: none;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #0d1020;
  font-weight: 600;
}
.btn-primary:hover {
  background: #1fffa8;
  color: #0d1020;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--text-mid);
}
.btn-secondary:hover {
  border-color: var(--text-mid);
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

.btn-ghost {
  background: transparent;
  color: var(--text-mid);
  padding: 6px 10px;
}
.btn-ghost:hover {
  color: var(--text);
  background: rgba(255,255,255,0.08);
}

.btn-danger {
  background: transparent;
  border: 1px solid rgba(244,63,94,0.25);
  color: var(--danger);
}
.btn-danger:hover {
  background: rgba(244,63,94,0.10);
  border-color: var(--danger);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 6px;
  line-height: 1;
}

/* ── Badges / status ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

.badge-active {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0,229,160,0.2);
}

.badge-inactive {
  background: rgba(78,90,120,0.2);
  color: var(--text-dim);
  border: 1px solid rgba(78,90,120,0.3);
}

.badge-scheduled {
  background: rgba(59,130,246,0.12);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.25);
}

.badge-expired {
  background: rgba(251,191,36,0.1);
  color: #fbbf24;
  border: 1px solid rgba(251,191,36,0.25);
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-neutral {
  background: rgba(78,90,120,0.18);
  color: var(--text-mid);
  border: 1px solid rgba(78,90,120,0.28);
}

.badge-warning {
  background: rgba(251,191,36,0.12);
  color: #fbbf24;
  border: 1px solid rgba(251,191,36,0.28);
}

.badge-danger {
  background: rgba(244,63,94,0.12);
  color: var(--danger);
  border: 1px solid rgba(244,63,94,0.25);
}

.badge-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0,229,160,0.2);
}

/* ── Direction radio group ──────────────────────────────── */
.radio-group {
  display: flex;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}

.radio-option input[type="radio"] { display: none; }

.radio-option:has(input:checked).radio-danger {
  border-color: var(--danger);
  background: rgba(244,63,94,0.1);
  color: var(--danger);
}

.radio-option:has(input:checked).radio-accent {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.radio-option:hover { border-color: var(--text-dim); }


.filters-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 20px;
}

.filters-bar .form-group {
  margin-bottom: 0;
  min-width: 140px;
}

/* ── Alert/Flash ────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 20px;
}

.alert-success {
  background: rgba(0,229,160,0.08);
  border: 1px solid rgba(0,229,160,0.25);
  color: var(--accent);
}

.alert-error {
  background: rgba(244,63,94,0.08);
  border: 1px solid rgba(244,63,94,0.25);
  color: var(--danger);
}

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}

.empty-state-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  opacity: 0.35;
  color: var(--text-mid);
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* ── Utilities ──────────────────────────────────────────── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 6px; }
.mt-4 { margin-top: 20px; }
.mb-4 { margin-bottom: 20px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 0.82rem; }
.text-mono { font-family: var(--font-mono); }
.font-600 { font-weight: 600; }
.w-full { width: 100%; }

/* ── Mobile topbar ──────────────────────────────────────── */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  z-index: 200;
}

.topbar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
  color: var(--text-mid);
  transition: color 0.15s;
}
.topbar-toggle:hover { color: var(--text); }

.topbar-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.22s ease;
  transform-origin: center;
}

body.nav-open .topbar-toggle span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
body.nav-open .topbar-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0); }
body.nav-open .topbar-toggle span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.topbar-brand svg { flex-shrink: 0; }

/* ── Sidebar overlay ────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 52px; left: 0; right: 0; bottom: 0;
  background: rgba(8, 10, 20, 0.78);
  z-index: 120;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.sidebar-overlay.active { display: block; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .page-header  { padding: 16px 24px; }
  .page-content { padding: 22px 24px; }
}

@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

@media (max-width: 768px) {
  /* Show mobile topbar */
  .topbar { display: flex; }

  /* Sidebar: hidden, slides in from left below topbar */
  .sidebar {
    top: 52px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.26s ease;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.5);
  }

  /* Main content: full width, offset for topbar */
  .main-wrapper {
    margin-left: 0;
    padding-top: 52px;
  }

  /* Page header */
  .page-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Page content */
  .page-content { padding: 14px 16px; }

  /* Metrics: 2 columns */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .metric-card { padding: 16px 18px; }

  /* Forms: single column */
  .form-grid { grid-template-columns: 1fr; gap: 0; }

  /* Filters bar */
  .filters-bar {
    padding: 12px;
    gap: 8px;
  }
  .filters-bar .form-group {
    min-width: 0;
    flex: 1 1 calc(50% - 4px);
  }

  /* Cards */
  .card { padding: 16px; }

  /* Auth */
  .auth-box { padding: 24px 20px; }
}

@media (max-width: 480px) {
  .metrics-grid { gap: 8px; }

  .metric-card { padding: 14px 14px; }

  .metric-value { font-size: 1.5rem; }

  .metric-unit { font-size: 0.8rem; }

  .page-title { font-size: 0.95rem; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 14px;
  }

  .page-content { padding: 12px 14px; }

  .filters-bar { padding: 10px; }

  .filters-bar .form-group { flex: 1 1 100%; }

  .card { padding: 14px; }

  .table-actions { gap: 4px; }

  .table-actions .btn-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .btn-sm { padding: 5px 10px; }
}

/* ── Grid utilities ─────────────────────────────────────── */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.grid-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* ── Responsive visibility ───────────────────────────────── */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }

  /* 3-col grids collapse to 1 col on mobile */
  .grid-3col { grid-template-columns: 1fr; gap: 10px; }
  .grid-2col { grid-template-columns: 1fr; }

  /* Last metric card spans full width when there's an odd count */
  .metrics-grid > *:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Free kWh row: allow text to wrap on narrow screens */
  .freekwh-header { flex-wrap: wrap; gap: 4px 0; align-items: flex-start !important; }
  .freekwh-header .freekwh-info { font-size: 0.77rem !important; }
}

@media (max-width: 480px) {
  .hide-xs { display: none !important; }
}

/* ── Delete confirm dialog ──────────────────────────────── */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17,20,32,0.88);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.active { display: flex; }
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
}
.confirm-box h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 10px;
}
.confirm-box p {
  color: var(--text-mid);
  font-size: 0.875rem;
  margin-bottom: 22px;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── Mobile table → card transformation ─────────────────── */
/*
 * Usage: add data-label="Label" to each visible <td>.
 * Add data-primary to the leading/date cell.
 * Add class="td-actions" to the actions <td>.
 * hide-mobile / hide-xs classes still suppress cells on mobile.
 */
@media (max-width: 768px) {
  .table-wrap { overflow-x: hidden; }

  table.data-table,
  table.table {
    display: block;
  }

  table.data-table thead,
  table.table thead {
    display: none;
  }

  table.data-table tfoot,
  table.table tfoot {
    display: none;
  }

  table.data-table tbody,
  table.table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  table.data-table tr,
  table.table tr {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
  }

  table.data-table tr:hover,
  table.table tr:hover {
    border-color: var(--border-hi);
  }

  /* All cells: label + value row */
  table.data-table td,
  table.table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(42,48,80,0.4);
    font-size: 0.875rem;
    min-height: 40px;
  }

  table.data-table tr td:last-child,
  table.table tr td:last-child {
    border-bottom: none;
  }

  /* Label column via ::before pseudo */
  table.data-table td[data-label]::before,
  table.table td[data-label]::before {
    content: attr(data-label);
    font-family: var(--font-display);
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    flex-shrink: 0;
    min-width: 58px;
    padding-right: 12px;
    line-height: 1.3;
  }

  /* Primary / lead cell — slightly accented */
  table.data-table td[data-primary],
  table.table td[data-primary] {
    background: rgba(0, 229, 160, 0.045);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 11px 14px;
  }

  table.data-table td[data-primary]::before,
  table.table td[data-primary]::before {
    color: rgba(0, 229, 160, 0.55);
  }

  /* Actions footer cell */
  table.data-table td.td-actions,
  table.table td.td-actions {
    justify-content: flex-end;
    padding: 7px 10px;
    background: rgba(0, 0, 0, 0.18);
    border-top: 1px solid var(--border);
    border-bottom: none;
    gap: 6px;
    min-height: unset;
  }

  table.data-table td.td-actions .table-actions,
  table.table td.td-actions .table-actions {
    margin: 0;
  }

  /* Suppress hide-mobile / hide-xs columns inside cards */
  table.data-table td.hide-mobile,
  table.table td.hide-mobile,
  table.data-table td.hide-xs,
  table.table td.hide-xs {
    display: none !important;
  }

  /* Reset hover row background (handled by tr border now) */
  table.data-table tbody tr:hover td,
  table.table tbody tr:hover td {
    background: transparent;
  }

  table.data-table tbody tr:hover td[data-primary],
  table.table tbody tr:hover td[data-primary] {
    background: rgba(0, 229, 160, 0.06);
  }

  table.data-table tbody tr:hover td.td-actions,
  table.table tbody tr:hover td.td-actions {
    background: rgba(0, 0, 0, 0.2);
  }
}

/* ── Touch-friendly form controls ───────────────────────── */
@media (max-width: 768px) {
  .form-control,
  .form-input,
  .form-select,
  select.form-control {
    min-height: 44px;
    font-size: 1rem; /* prevents iOS auto-zoom */
    padding: 10px 13px;
  }

  select.form-control,
  .form-select {
    padding-right: 36px;
  }

  textarea.form-control {
    min-height: 80px;
    font-size: 1rem;
  }

  /* Bigger tap targets for buttons */
  .btn {
    min-height: 42px;
  }

  .btn-sm {
    min-height: 36px;
  }

  /* Input-with-action (GPS button) */
  .input-action-btn {
    width: 40px;
    height: 40px;
    right: 4px;
  }
}

/* ── Form actions — stack on very small screens ─────────── */
@media (max-width: 480px) {
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn {
    justify-content: center;
  }

  /* Filters bar — full-width fields on XS */
  .filters-bar .form-group {
    flex: 1 1 100%;
    min-width: 0;
  }

  /* Confirm dialog */
  .confirm-box {
    padding: 22px 18px;
  }

  .confirm-actions {
    flex-direction: column;
  }

  .confirm-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── Mobile utility classes ─────────────────────────────── */
.show-mobile { display: none !important; }
@media (max-width: 768px) {
  .show-mobile { display: block !important; }
  .show-mobile-flex { display: flex !important; }
}

/* ── Page header — sticky on scroll ─────────────────────── */
@media (max-width: 768px) {
  .page-header {
    position: sticky;
    top: 52px;
    z-index: 90;
    background: var(--surface);
  }
}

/* ── Password strength rules ─────────────────────────────── */
.pwd-rules {
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pwd-rule {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .82rem;
  color: var(--text-dim);
  transition: color .15s;
}
.pwd-rule-icon {
  font-size: .75rem;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}
.pwd-rule.pass {
  color: #34d399;
}
.pwd-rule.fail {
  color: #f87171;
}

/* ── Analytics responsive grid ───────────────────────────── */
@media (max-width: 768px) {
  .analytics-2col {
    grid-template-columns: 1fr !important;
  }
  .soc-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
}

/* ─── Session form: SOC pills + kWh suggestion ─────────────────────────── */
.soc-pill {
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-alt, #1e2530);
  color: var(--text-dim);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.soc-pill:hover {
  background: var(--accent, #00e5a0);
  color: #0a0f1a;
  border-color: var(--accent, #00e5a0);
}
.kwh-use-link {
  color: var(--text-accent, #00e5a0);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
}
.kwh-use-link:hover {
  text-decoration: underline;
}
