/* Pivara Design System - DVN SCADA */

/* ===== Design Tokens ===== */
:root {
  /* Primary Colors */
  --color-sky: #00A3E0;
  --color-azure: #0066B3;
  --color-navy: #1A1F71;
  --color-deep: #0D1147;

  /* Neutrals */
  --color-background: #FAFBFC;
  --color-surface: #FFFFFF;
  --color-border: #E2E8F0;
  --color-muted: #64748B;
  --color-text: #1E293B;

  /* Status Colors */
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-error: #EF4444;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(26, 31, 113, 0.08), 0 1px 2px rgba(26, 31, 113, 0.06);
  --shadow-elevated: 0 4px 6px rgba(26, 31, 113, 0.1), 0 2px 4px rgba(26, 31, 113, 0.06);

  /* Spacing */
  --sidebar-width: 240px;
  --header-height: 64px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* ===== Base Reset ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--color-background);
  color: var(--color-text);
  line-height: 1.5;
}

/* ===== Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-deep);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 24px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== Sidebar site picker (multi-site) ===== */
.sidebar-site-picker {
  padding: 14px 18px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-site-picker .picker-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 6px;
}
.sidebar-site-picker .picker-select {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.6) 50%),
                    linear-gradient(135deg, rgba(255,255,255,0.6) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
.sidebar-site-picker .picker-select:hover {
  border-color: var(--color-sky);
  background-color: rgba(255, 255, 255, 0.12);
}
.sidebar-site-picker .picker-select:focus {
  outline: none;
  border-color: var(--color-sky);
  box-shadow: 0 0 0 2px rgba(0, 163, 224, 0.25);
}
.sidebar-site-picker .picker-select option {
  background: #0d1147;
  color: white;
}

.sidebar-site-details {
  padding: 8px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-site-details .site-name {
  font-size: 14px;
  font-weight: 700;
  color: white;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-site-details .site-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  gap: 5px;
  align-items: center;
  margin-bottom: 6px;
}
.sidebar-site-details .site-meta .meta-sep {
  opacity: 0.4;
}
.sidebar-site-details .site-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
}
.sidebar-site-details .site-status .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.sidebar-site-details .site-status.status-online {
  color: #34D399;
}
.sidebar-site-details .site-status.status-online .status-dot {
  background: #34D399;
  box-shadow: 0 0 6px #34D399;
}
.sidebar-site-details .site-status.status-offline {
  color: #F59E0B;
}
.sidebar-site-details .site-status.status-offline .status-dot {
  background: #F59E0B;
}
.sidebar-site-details .site-status.status-unknown {
  color: rgba(255, 255, 255, 0.4);
}
.sidebar-site-details .site-status.status-unknown .status-dot {
  background: rgba(255, 255, 255, 0.4);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
}

.nav-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
  color: white;
  background: var(--color-sky);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-sky);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
}

.user-role {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  color: rgba(255, 255, 255, 0.7);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.1);
}

/* ===== Header ===== */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-navy);
}

.page-subtitle {
  font-size: 14px;
  color: var(--color-muted);
  margin-top: 4px;
}

/* ===== Cards ===== */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-navy);
}

.card-body {
  padding: 20px;
}

/* ===== KPI Cards ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon svg {
  width: 24px;
  height: 24px;
}

.kpi-icon.sky {
  background: rgba(0, 163, 224, 0.1);
  color: var(--color-sky);
}

.kpi-icon.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.kpi-icon.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.kpi-icon.navy {
  background: rgba(26, 31, 113, 0.1);
  color: var(--color-navy);
}

.kpi-content {
  flex: 1;
  min-width: 0;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.2;
}

.kpi-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted);
  margin-left: 4px;
}

.kpi-label {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 4px;
}

/* ===== Data Tables ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--color-background);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--color-border);
}

.data-table th.text-right {
  text-align: right;
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--color-border);
}

.data-table td.text-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover {
  background: var(--color-background);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ===== Compact Comparison Table ===== */
.compact-table td,
.compact-table th {
  padding: 10px 16px;
}

.compact-table .param-label {
  font-weight: 500;
  color: var(--color-navy);
}

.compact-table .param-label .unit {
  font-weight: 400;
  color: var(--color-muted);
  font-size: 12px;
}

/* Color-coded values */
.value-power {
  color: #2563eb;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.value-voltage {
  color: #7c3aed;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.value-current {
  color: #0891b2;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.value-freq {
  color: #4f46e5;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.value-efficiency {
  color: var(--color-success);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.value-energy {
  color: #059669;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.value-neutral {
  color: var(--color-navy);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ===== Status Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.badge-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background: var(--color-azure);
  color: white;
}

.btn-primary:hover {
  background: var(--color-navy);
}

.btn-secondary {
  background: var(--color-background);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-icon {
  padding: 8px;
}

/* ===== Grid Layouts ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }
}

/* ===== Chart Container ===== */
.chart-container {
  width: 100%;
  height: 300px;
}

.chart-container.tall {
  height: 400px;
}

/* ===== Weather Cards ===== */
.weather-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.weather-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 16px;
  text-align: center;
}

.weather-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 8px;
  color: var(--color-sky);
}

.weather-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-navy);
}

.weather-label {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 4px;
}

/* ===== String Matrix (AJB) ===== */
.string-matrix {
  width: 100%;
  border-collapse: collapse;
}

.string-matrix th,
.string-matrix td {
  padding: 8px 12px;
  text-align: center;
  border: 1px solid var(--color-border);
  font-size: 13px;
}

.string-matrix th {
  background: var(--color-navy);
  color: white;
  font-weight: 600;
}

.string-matrix td.cell-ok {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.string-matrix td.cell-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.string-matrix td.cell-error {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-error);
  font-weight: 600;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
}

.tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s ease;
}

.tab:hover {
  color: var(--color-navy);
}

.tab.active {
  color: var(--color-sky);
  border-bottom-color: var(--color-sky);
}

/* ===== Loading & Error States ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--color-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-sky);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.refresh-btn:hover {
  opacity: 0.9;
}

.refresh-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error-message {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
}

/* ===== Skeleton Loaders ===== */
.skeleton {
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-background) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Size variants */
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text:last-child { margin-bottom: 0; }
.skeleton-text.sm { height: 12px; }
.skeleton-text.lg { height: 18px; }
.skeleton-text.xl { height: 24px; }
.skeleton-heading { height: 28px; width: 60%; margin-bottom: 12px; }

/* Width modifiers */
.skeleton-w-25 { width: 25%; }
.skeleton-w-50 { width: 50%; }
.skeleton-w-75 { width: 75%; }
.skeleton-w-100 { width: 100%; }

/* KPI Card Skeleton */
.skeleton-kpi { display: flex; align-items: flex-start; gap: 16px; padding: 16px; }
.skeleton-kpi-content { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-kpi-value { height: 24px; width: 70%; }
.skeleton-kpi-label { height: 12px; width: 50%; }
.skeleton-icon { width: 36px; height: 36px; border-radius: var(--radius-md); flex-shrink: 0; }
.skeleton-icon.sm { width: 32px; height: 32px; }
.skeleton-icon.lg { width: 48px; height: 48px; }

/* Weather Card Skeleton */
.skeleton-weather { padding: 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.skeleton-weather-icon { width: 32px; height: 32px; border-radius: 50%; }
.skeleton-weather-value { height: 20px; width: 50px; }
.skeleton-weather-label { height: 11px; width: 70px; }

/* Table Skeleton */
.skeleton-table { width: 100%; }
.skeleton-table-row { display: flex; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.skeleton-table-row:last-child { border-bottom: none; }
.skeleton-table-cell { flex: 1; height: 14px; }
.skeleton-table-cell.sm { flex: 0.5; }
.skeleton-table-cell.lg { flex: 1.5; }

/* Chart Skeletons */
.skeleton-chart { width: 100%; display: flex; align-items: flex-end; justify-content: space-around; padding: 20px; gap: 8px; }
.skeleton-chart-bar { flex: 1; max-width: 40px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.skeleton-chart-bar:nth-child(1) { height: 60%; }
.skeleton-chart-bar:nth-child(2) { height: 80%; }
.skeleton-chart-bar:nth-child(3) { height: 45%; }
.skeleton-chart-bar:nth-child(4) { height: 90%; }
.skeleton-chart-bar:nth-child(5) { height: 70%; }
.skeleton-chart-bar:nth-child(6) { height: 55%; }
.skeleton-chart-bar:nth-child(7) { height: 75%; }

.skeleton-chart-line {
  width: 100%;
  position: relative;
  background: var(--color-background);
  border-radius: var(--radius-sm);
}

/* Gauge Skeleton */
.skeleton-gauge { width: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.skeleton-gauge-circle {
  width: 140px;
  height: 70px;
  border: 12px solid var(--color-border);
  border-bottom: 12px solid transparent;
  border-radius: 140px 140px 0 0;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-background) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* Matrix Skeleton */
.skeleton-matrix { width: 100%; overflow-x: auto; }
.skeleton-matrix-row { display: flex; }
.skeleton-matrix-cell { flex: 1; height: 32px; border: 1px solid var(--color-border); min-width: 45px; }
.skeleton-matrix-header { background: rgba(26, 31, 113, 0.1); }

/* Profile/Stats Row */
.skeleton-stat-row { display: flex; justify-content: space-between; padding: 10px 12px; background: var(--color-background); border-radius: var(--radius-sm); margin-bottom: 6px; }
.skeleton-stat-row:last-child { margin-bottom: 0; }
.skeleton-stat-label { width: 45%; height: 12px; }
.skeleton-stat-value { width: 35%; height: 14px; }

/* Filter Controls Skeleton */
.skeleton-filter { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.skeleton-filter-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 150px; }
.skeleton-filter-label { height: 12px; width: 60%; }
.skeleton-filter-input { height: 40px; border-radius: var(--radius-md); }
.skeleton-filter-button { height: 40px; width: 100px; border-radius: var(--radius-md); }

/* Inverter Stats Card Skeleton */
.skeleton-inverter-stat { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.skeleton-inverter-value { height: 28px; width: 60%; }
.skeleton-inverter-label { height: 11px; width: 80%; }
.skeleton-inverter-sub { height: 10px; width: 50%; }

/* ===== Last Updated ===== */
.last-updated {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-muted);
}

.last-updated .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== Login Page ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-deep) 0%, var(--color-navy) 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  width: 100%;
  max-width: 400px;
  padding: 40px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-navy);
}

.login-logo p {
  font-size: 14px;
  color: var(--color-muted);
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-sky);
  box-shadow: 0 0 0 3px rgba(0, 163, 224, 0.1);
}

.form-error {
  margin-top: 8px;
  font-size: 13px;
  color: var(--color-error);
}

/* ===== Utility Classes ===== */
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

.text-sky { color: var(--color-sky); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }
.text-muted { color: var(--color-muted); }
.text-navy { color: var(--color-navy); }

.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

.text-center { text-align: center; }
.text-right { text-align: right; }

/* ===== Staleness Indicators ===== */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  display: inline-block;
  animation: pulse 2s infinite;
}

.dot.stale-warning {
  background: var(--color-warning);
  animation: pulse-warning 1.5s infinite;
}

.dot.stale-critical {
  background: var(--color-error);
  animation: pulse-critical 0.8s infinite;
}

@keyframes pulse-warning {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50% { opacity: 0.6; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
}

@keyframes pulse-critical {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { opacity: 0.5; box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.stale-dimmed {
  opacity: 0.55;
}

.stale-border-warning {
  border-color: var(--color-warning) !important;
  border-width: 2px;
}

.stale-border-critical {
  border-color: var(--color-error) !important;
  border-width: 2px;
}

/* ===== Alarm Banner ===== */
.alarm-banner {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideDown 0.3s ease-out;
  font-size: 14px;
  font-weight: 500;
}

.alarm-banner.alarm-critical {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-error);
}

.alarm-banner.alarm-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--color-warning);
}

.alarm-banner .alarm-dismiss {
  background: none;
  border: 1px solid currentColor;
  color: inherit;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.8;
}

.alarm-banner .alarm-dismiss:hover {
  opacity: 1;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Alarm Row Highlights ===== */
.alarm-row-critical {
  background: rgba(239, 68, 68, 0.08) !important;
}

.alarm-row-warning {
  background: rgba(245, 158, 11, 0.08) !important;
}

/* ===== SMB Page ===== */
.smb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.smb-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  position: relative;
}
.smb-card:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(26,31,113,0.08); }
.smb-card.has-alarm { border-color: var(--color-error); }
.smb-card.is-stale  { opacity: 0.55; }
.smb-card.zero-power { border-left: 3px solid var(--color-warning); }

.smb-strings {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
  margin-top: 10px;
}
.smb-strings .cell {
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  background: rgba(100,116,139,0.15);
}
.smb-strings .cell.ok    { background: rgba(16,185,129,0.65); }
.smb-strings .cell.warn  { background: rgba(245,158,11,0.65); }
.smb-strings .cell.fault { background: rgba(239,68,68,0.8); }
.smb-strings .cell.zero  { background: rgba(100,116,139,0.25); }
.smb-strings .cell.nully {
  background: repeating-linear-gradient(45deg,
    rgba(100,116,139,0.15) 0 3px,
    transparent 3px 6px);
}

.smb-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  font-size: 11px;
  margin-top: 8px;
}
.smb-kpi-row > div > div:first-child { color: var(--color-muted); font-size: 10px; }
.smb-kpi-row > div > div:last-child  { font-weight: 600; color: var(--color-navy); font-size: 13px; }

/* String matrix cell colouring */
.string-matrix td.band-ok    { background: rgba(16,185,129,0.18); color: #065f46; font-weight: 600; }
.string-matrix td.band-warn  { background: rgba(245,158,11,0.20); color: #92400e; font-weight: 600; }
.string-matrix td.band-fault { background: rgba(239,68,68,0.22); color: #991b1b; font-weight: 700; }
.string-matrix td.band-zero  { background: rgba(100,116,139,0.10); color: var(--color-muted); }
.string-matrix td.band-nully { background: transparent; color: var(--color-muted); }
.string-matrix th, .string-matrix td { border-bottom: 1px solid var(--color-border); }

/* ===== User management page ===== */

.user-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}
.user-form .form-group { display: flex; flex-direction: column; }
.user-form label { font-size: 11px; font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.user-form input, .user-form select {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  background: white;
}
.user-form input:focus, .user-form select:focus {
  outline: none;
  border-color: var(--color-sky);
  box-shadow: 0 0 0 2px rgba(0, 163, 224, 0.15);
}
.user-form input:disabled, .user-form select:disabled {
  background: #f3f4f6;
  color: var(--color-muted);
  cursor: not-allowed;
}
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

.badge-super   { background: rgba(26, 31, 113, 0.15); color: var(--color-navy); }
.badge-admin   { background: rgba(0, 163, 224, 0.15); color: var(--color-sky); }
.badge-user    { background: rgba(100, 116, 139, 0.15); color: var(--color-muted); }
.badge-muted   { background: rgba(148, 163, 184, 0.15); color: var(--color-muted); }

.row-deactivated { opacity: 0.5; }
.row-deactivated td { text-decoration: line-through; }

.btn { padding: 8px 14px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent; font-family: inherit; }
.btn-primary { background: var(--color-sky); color: white; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--color-muted); }
.btn-ghost:hover { background: rgba(100, 116, 139, 0.1); color: var(--color-navy); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }
.btn-danger { color: #dc2626; }
.btn-danger:hover { background: rgba(220, 38, 38, 0.1); color: #991b1b; }

.alert { padding: 10px 14px; border-radius: var(--radius-md); font-size: 13px; }
.alert-error { background: rgba(239, 68, 68, 0.1); color: #991b1b; border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-success { background: rgba(16, 185, 129, 0.1); color: #065f46; border: 1px solid rgba(16, 185, 129, 0.2); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(13, 17, 71, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: white;
  padding: 24px;
  border-radius: var(--radius-lg);
  min-width: 360px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(13, 17, 71, 0.25);
}
.modal h3 { margin: 0 0 16px 0; color: var(--color-navy); }
.modal .form-group { display: flex; flex-direction: column; margin-bottom: 12px; }
.modal .form-group label { font-size: 11px; font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.modal input, .modal select {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
}

