:root {
  --bg: #ffffff;
  --bg2: #f7f8fa;
  --bg3: #eef0f4;
  --border: #e2e5eb;
  --border2: #d0d4dc;
  --text: #1a1d23;
  --text2: #4a5060;
  --text3: #8892a0;
  --green: #00b87a;
  --green-bg: #e8faf3;
  --green-border: #b3edd6;
  --red: #e8394a;
  --red-bg: #fef0f1;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --teal: #0891b2;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.1);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(37, 99, 235, 0.04) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(37, 99, 235, 0.03) 0%, transparent 50%),
    linear-gradient(180deg, #f4f5f8 0%, #eef0f4 100%);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(26, 29, 35, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 29, 35, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── TOPBAR ── */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(20px, 3vw, 40px);
  min-height: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-center.client-branding {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 20px 6px 10px;
  background: linear-gradient(135deg, #f3fbf6 0%, #e6f4ea 45%, #fff8e8 100%);
  border: 1px solid #a8d4b4;
  border-radius: 12px;
  box-shadow:
    0 2px 10px rgba(10, 92, 50, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  pointer-events: none;
  max-width: min(520px, calc(100vw - 420px));
}
.client-branding-logo {
  height: 46px;
  width: auto;
  max-width: 52px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
}
.client-branding-text {
  text-align: left;
  min-width: 0;
}
.client-branding-title {
  font-size: 18px;
  font-weight: 700;
  color: #0a5c32;
  line-height: 1.15;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.client-branding-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: #3d6b4a;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 3px;
  white-space: nowrap;
}
.client-branding-title::after {
  content: '';
  display: block;
  width: 36px;
  height: 2px;
  margin-top: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #c9a227 0%, #e8c84a 50%, #c9a227 100%);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}
.logo-menu {
  position: relative;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.logo-mark-button {
  border: none;
  cursor: pointer;
  padding: 0;
  background: transparent;
  transition: box-shadow .15s, transform .15s;
}

.logo-mark-button img {
  width: 32px;
  height: 32px;
  display: block;
  object-fit: contain;
  border-radius: 8px;
}

.logo-mark-button:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  transform: translateY(-1px);
}

.logo-mark-button[aria-expanded="true"] {
  box-shadow: 0 0 0 2px var(--border2);
}

.user-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: transparent;
  cursor: default;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  animation: dropdown-in .15s ease;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.user-dropdown-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.user-dropdown-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.user-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  background: #fff;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}

.user-dropdown-item:hover {
  background: var(--bg2);
}

.user-dropdown-item.logout {
  color: var(--red);
  cursor: pointer;
}

.user-dropdown-item.logout:hover {
  background: var(--red-bg);
  cursor: pointer;
}

.user-dropdown-icon {
  font-size: 14px;
  line-height: 1;
}
.logo-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.2px;
}
.logo-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}
.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13px;
  font-family: 'IBM Plex Sans', sans-serif;
  cursor: pointer;
  background: #fff;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: .15s;
  font-weight: 500;
}
.btn:hover { background: var(--bg2); border-color: var(--border2); }
.btn-primary { background: var(--text); color: #fff; border-color: var(--text); }
.btn-primary:hover { background: #2d3240; }
.btn-red { background: var(--red); color: #fff; border-color: var(--red); }
.btn-green { background: var(--green); color: #fff; border-color: var(--green); }
.timestamp {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
}

/* ── LAYOUT ── */
.page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 24px clamp(20px, 3vw, 40px) 32px;
  position: relative;
  z-index: 1;
}

/* ── ALERT BANNER ── */
.alert-banner {
  background: var(--amber-bg);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #92400e;
  font-weight: 500;
}
.alert-banner .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); flex-shrink: 0; animation: pulse 1.5s infinite; }

/* ── OFFGRID BANNER ── */
.offgrid-banner {
  background: var(--red-bg);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  display: none;
}
.offgrid-banner.active { display: flex; }
.offgrid-left { display: flex; align-items: center; gap: 10px; }
.offgrid-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: .06em;
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.5} }
.offgrid-title { font-size: 13px; font-weight: 600; color: var(--red); }
.offgrid-sub { font-size: 12px; color: #b91c1c; margin-top: 1px; }
.offgrid-timer {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--red);
}
.soc-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.soc-track { width: 120px; height: 6px; background: #fecaca; border-radius: 3px; overflow: hidden; }
.soc-fill { height: 100%; background: var(--red); border-radius: 3px; transition: width .5s; }
.soc-label { font-size: 12px; font-weight: 600; color: var(--red); }

/* ── STAT CARDS ── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(12px, 1.5vw, 20px);
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  margin-bottom: 10px;
}
.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; font-weight: 500; }
.stat-val { font-size: 26px; font-weight: 700; color: var(--text); font-family: 'IBM Plex Mono', monospace; letter-spacing: -.5px; }
.stat-sub { font-size: 12px; color: var(--text3); margin-top: 3px; }

/* ── SECTION HEADER ── */
.sec-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.sec-title { font-size: 13px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .08em; }
.sec-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-red { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }
.badge-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid #fcd34d; }

/* ── MAIN TABLE ── */
.table-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.table-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.table-title { font-size: 13px; font-weight: 600; color: var(--text); }
.table-meta { font-size: 11px; color: var(--text3); font-family: 'IBM Plex Mono', monospace; }

table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg2);
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th:first-child { width: 40px; text-align: center; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg2); }
tbody td {
  padding: 14px;
  vertical-align: middle;
}
tbody td:first-child { text-align: center; width: 40px; }

.row-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  color: var(--text2);
  margin: auto;
}
.location-name { font-size: 13px; font-weight: 600; color: var(--text); }
.location-sub { font-size: 11px; color: var(--text3); margin-top: 1px; }
.status-dot {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
}
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 0 2px var(--green-bg); }
.dot-red { background: var(--red); box-shadow: 0 0 0 2px var(--red-bg); animation: pulse 1.5s infinite; }
.dot-amber { background: var(--amber); box-shadow: 0 0 0 2px var(--amber-bg); }
.dot-blue { background: var(--blue); box-shadow: 0 0 0 2px var(--blue-bg); }
.dot-gray { background: var(--text3); box-shadow: 0 0 0 2px var(--bg3); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.data-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.data-unit {
  font-size: 10px;
  color: var(--text3);
  display: block;
  margin-top: 1px;
  font-family: 'IBM Plex Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.load-cell { display: flex; align-items: center; gap: 8px; }
.load-bar-wrap { width: 50px; height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.load-bar { height: 100%; border-radius: 2px; }
.load-pct { font-family: 'IBM Plex Mono', monospace; font-size: 15px; font-weight: 700; }
.load-low { color: var(--green); }
.load-med { color: var(--amber); }
.load-high { color: var(--red); }
.load-bar-low { background: var(--green); }
.load-bar-med { background: var(--amber); }
.load-bar-high { background: var(--red); }

.offgrid-indicator {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
  background: var(--red-bg); color: var(--red);
  border: 1px solid #fca5a5;
  display: none;
}
.offgrid-indicator.show { display: inline-flex; animation: blink 1s infinite; }

.inv-name { font-size: 12px; font-weight: 600; color: var(--text); }
.inv-sub { font-size: 10px; color: var(--text3); margin-top: 1px; }

/* ── TABLE FOOTER ── */
.table-footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  display: flex; align-items: center; gap: 20px;
  font-size: 12px; color: var(--text3);
}
.table-footer strong { color: var(--text); }
.notif-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
}
.notif-footer strong { color: var(--text); }

/* ── DASHBOARD LOADER ── */
.dashboard-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  gap: 16px;
  color: var(--text3);
}
.dashboard-loader-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
}
.dashboard-loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: dashboard-spin 0.8s linear infinite;
}
.dashboard-body {
  position: relative;
}
.dashboard-loader-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
  border-radius: var(--radius-lg);
}
.dashboard-progress-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--blue-bg);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  color: var(--blue);
}
.dashboard-progress-spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
  flex-shrink: 0;
}
.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: dashboard-spin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes dashboard-spin {
  to { transform: rotate(360deg); }
}

/* ── BOTTOM GRID ── */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(16px, 2vw, 24px);
  margin-bottom: 24px;
}

/* ── OFFGRID LOG ── */
.log-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.log-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.log-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.log-search-wrap {
  position: relative;
}
.log-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text3);
  pointer-events: none;
}
.log-search {
  padding: 5px 10px 5px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  font-family: 'IBM Plex Sans', sans-serif;
  width: 150px;
  outline: none;
  background: #fff;
  color: var(--text);
}
.log-search:focus { border-color: var(--border2); }
.log-title { font-size: 12px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .06em; }
.log-export-btn {
  font-size: 11px;
  padding: 5px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.log-export-error {
  padding: 8px 16px;
  font-size: 11px;
  color: #b91c1c;
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
}
.log-body { padding: 0; }
.log-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  gap: 12px;
  align-items: center;
}
.log-row:last-child { border: none; }
.log-row:hover { background: var(--bg2); }
.log-loc { font-weight: 600; color: var(--text); }
.log-date { color: var(--text3); font-family: 'IBM Plex Mono', monospace; font-size: 11px; }
.log-dur { font-family: 'IBM Plex Mono', monospace; font-weight: 600; color: var(--red); font-size: 12px; }
.log-soc { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 600; }

/* ── NOTIFICATION CARD ── */
.notif-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.notif-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.notif-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text); }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.notif-item:last-child { border: none; }
.notif-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.ni-warn { background: var(--amber-bg); }
.ni-info { background: var(--blue-bg); }
.ni-ok { background: var(--green-bg); }
.notif-text { color: var(--text2); line-height: 1.5; }
.notif-text strong { color: var(--text); display: block; margin-bottom: 1px; }
.notif-time { font-size: 10px; color: var(--text3); margin-top: 3px; font-family: 'IBM Plex Mono', monospace; }

/* ── FLOWCHART MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  display: none;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 700px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text3);
}
.modal-close:hover { background: var(--bg2); }
.modal-body { padding: 20px; }

/* ── FLOWCHART ── */
.flowchart { display: flex; flex-direction: column; align-items: center; gap: 0; }
.fc-node {
  border: 2px solid var(--border2);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  min-width: 180px;
  background: #fff;
  position: relative;
}
.fc-node.start { background: var(--text); color: #fff; border-radius: 50px; border-color: var(--text); }
.fc-node.decision { background: var(--amber-bg); border-color: #fcd34d; transform: none; border-radius: 4px; }
.fc-node.action { background: var(--blue-bg); border-color: #93c5fd; }
.fc-node.alert { background: var(--red-bg); border-color: #fca5a5; color: var(--red); }
.fc-node.ok { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.fc-arrow {
  width: 2px; height: 24px;
  background: var(--border2);
  position: relative;
}
.fc-arrow::after {
  content: '▼';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: var(--border2);
}
.fc-row { display: flex; gap: 12px; align-items: center; }
.fc-branch-line {
  height: 2px; flex: 1;
  background: var(--border2);
}
.fc-label { font-size: 10px; color: var(--text3); font-weight: 600; margin-bottom: 4px; }

/* ── REPORT MODAL ── */
.report-section { margin-bottom: 20px; }
.report-section h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.report-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.report-table th { text-align: left; padding: 6px 8px; background: var(--bg2); font-weight: 600; font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; border: 1px solid var(--border); }
.report-table td { padding: 8px; border: 1px solid var(--border); color: var(--text2); font-family: 'IBM Plex Mono', monospace; font-size: 11px; }
.report-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 16px; }
.rs-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; text-align: center; }
.rs-val { font-size: 20px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; color: var(--text); }
.rs-lbl { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

/* ── LIMIT CARD ── */
.limit-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.limit-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.limit-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text); }
.limit-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.limit-item { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.limit-loc { font-size: 11px; color: var(--text3); margin-bottom: 6px; font-weight: 500; }
.limit-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.limit-bar { height: 100%; border-radius: 3px; transition: width .5s; }
.limit-vals { display: flex; justify-content: space-between; font-size: 10px; color: var(--text3); font-family: 'IBM Plex Mono', monospace; }
.limit-current { font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 700; margin-bottom: 2px; }

/* ── TABS ── */
.tabs { display: flex; gap: 2px; background: var(--bg2); padding: 3px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 16px; width: fit-content; }
.tab { padding: 6px 16px; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; color: var(--text3); transition: .15s; border: none; background: none; font-family: 'IBM Plex Sans', sans-serif; }
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); font-weight: 600; }

/* ── SEARCH INPUT ── */
.location-search {
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: 'IBM Plex Sans', sans-serif;
  width: 220px;
  outline: none;
  background: #fff;
  color: var(--text);
}
.location-search:focus { border-color: var(--border2); }

@media (max-width: 1100px) {
  .topbar-center.client-branding {
    max-width: min(440px, calc(100vw - 380px));
    padding: 5px 14px 5px 8px;
    gap: 10px;
  }

  .client-branding-logo {
    height: 40px;
    max-width: 46px;
  }

  .client-branding-title {
    font-size: 16px;
  }
}

/* ── MOBILE (portal layout unchanged above 768px) ── */
@media (max-width: 768px) {
  .page {
    padding: 16px 14px 24px;
  }

  .topbar {
    height: auto;
    min-height: 56px;
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .topbar-center.client-branding {
    position: static;
    transform: none;
    order: 3;
    width: 100%;
    max-width: none;
    justify-content: center;
    padding: 8px 14px;
  }

  .client-branding-logo {
    height: 40px;
    max-width: 46px;
  }

  .client-branding-title {
    font-size: 16px;
  }

  .client-branding-subtitle {
    font-size: 10px;
    letter-spacing: 0.08em;
  }

  .logo-name {
    font-size: 13px;
  }

  .logo-sub {
    display: none;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .timestamp {
    display: none;
  }

  .btn {
    padding: 7px 12px;
    font-size: 12px;
  }

  .offgrid-banner.active {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .offgrid-timer {
    font-size: 18px;
    align-self: flex-start;
  }

  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-val {
    font-size: 22px;
  }

  .sec-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .sec-header > div:last-child {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px;
    width: 100%;
  }

  .location-search {
    width: 100%;
    max-width: none;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 16px;
  }

  .table-wrap table {
    min-width: 720px;
  }

  .table-footer {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
    padding: 12px 16px;
  }

  .bottom-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .log-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .log-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .log-search {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .log-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 16px;
  }

  .log-date,
  .log-dur {
    text-align: left;
  }

  .notif-footer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 16px;
  }
}

@media (max-width: 480px) {
  .stat-row {
    grid-template-columns: 1fr;
  }
}

/* ── PRINT/PDF STYLES ── */
@media print {
  .topbar, .btn, .tabs, .notif-card, .modal-overlay { display: none !important; }
  .page { padding: 0; }
  body { background: #fff; }
}
