﻿:root {
  --bg: #081018;
  --panel: rgba(11, 20, 31, 0.92);
  --panel-2: rgba(16, 28, 42, 0.96);
  --line: rgba(145, 168, 194, 0.18);
  --text: #e9f2ff;
  --muted: #9db0c6;
  --normal: #19c37d;
  --warning: #f5b83d;
  --alarm: #ff8a3d;
  --critical: #ff4d4d;
  --accent: #66b3ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(102, 179, 255, 0.14), transparent 25%),
    radial-gradient(circle at right, rgba(25, 195, 125, 0.08), transparent 22%),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px 10px;
}

.topbar h1, .panel h2, .panel h3 {
  margin: 0;
  letter-spacing: 0.3px;
}

.topbar p, .panel p, .panel span, .label, .muted {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-link {
  text-decoration: none;
  color: var(--text);
}

.status-pill {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  padding: 10px 14px;
  border-radius: 999px;
}

.layout {
  display: grid;
  gap: 18px;
  padding: 20px 28px 30px;
}

.dashboard-layout {
  grid-template-columns: 1fr 1fr;
}

.reports-layout {
  grid-template-columns: 1fr;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.22);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-panel, .alert-panel, .card-panel, .map-panel { grid-column: 1 / -1; }
.chart-panel { min-height: 280px; }
.ai-panel { grid-column: 1 / -1; }

.ai-layout {
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
}

.ai-panel-wide {
  grid-column: 1 / -1;
}

.chat-panel {
  display: grid;
  gap: 12px;
}

.chat-window {
  min-height: 420px;
  max-height: 520px;
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.chat-message {
  display: grid;
  gap: 6px;
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.chat-message.user {
  margin-left: auto;
  background: rgba(102,179,255,0.12);
}

.chat-message.assistant {
  margin-right: auto;
}

.chat-message-meta {
  font-size: 12px;
  color: var(--muted);
}

.chat-message-body {
  white-space: pre-wrap;
  line-height: 1.5;
}

.chat-form {
  display: grid;
  gap: 10px;
}

.chat-input-wrap {
  display: grid;
  gap: 8px;
}

.chat-input-wrap textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  font: inherit;
}

.chat-input-wrap textarea:focus {
  border-color: rgba(102, 179, 255, 0.7);
}

.chat-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

html[data-theme='light'] .chat-window,
html[data-theme='light'] .chat-message,
html[data-theme='light'] .chat-input-wrap textarea {
  background: rgba(255,255,255,0.92);
  border-color: rgba(15, 23, 42, 0.08);
}

.ai-insight-panel {
  display: grid;
  gap: 12px;
}

.ai-summary-card,
.ai-finding-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.ai-summary-top,
.ai-finding-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.ai-summary-text {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.55;
}

.ai-meta,
.ai-actions,
.ai-evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ai-findings {
  display: grid;
  gap: 10px;
}

.ai-finding-body {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.ai-actions .pill,
.ai-evidence .pill {
  background: rgba(255,255,255,0.04);
}

.severity-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

.severity-chip.info { background: rgba(102,179,255,0.15); }
.severity-chip.watch { background: rgba(245,184,61,0.16); }
.severity-chip.warning { background: rgba(255,138,61,0.18); }
.severity-chip.critical { background: rgba(255,77,77,0.2); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card, .worker-card, .alert-item, .detail-card, .device-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.kpi-card .value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 8px;
}

.kpi-card .label {
  font-size: 13px;
}

.chart-box {
  width: 100%;
  min-height: 210px;
  border-radius: 18px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  overflow: hidden;
  padding: 10px;
}

.map-shell {
  width: 100%;
  height: 460px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.report-map {
  height: 320px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.worker-card .title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  border-radius: 999px;
  padding: 6px 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.normal { background: var(--normal); }
.warning { background: var(--warning); }
.alarm { background: var(--alarm); }
.critical { background: var(--critical); }
.passive { background: #64748b; }

.stats, .metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.stat, .metric-card {
  padding: 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.04);
}

.stat strong, .metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.worker-card.outside-geofence {
  border-color: rgba(255, 95, 122, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255, 95, 122, 0.25);
}

.worker-card.passive-worker {
  opacity: 0.72;
  border-style: dashed;
}

.device-card.passive-device {
  opacity: 0.72;
}

.worker-marker-shell { background: transparent; border: 0; }
.worker-marker {
  width: 18px;
  height: 18px;
  border-radius: 50% 50% 50% 0;
  background: var(--marker-color, #66b3ff);
  transform: rotate(-45deg);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  position: relative;
}
.worker-marker::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
}

.alert-log, .risk-list, .timeline {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.alert-item, .risk-row, .timeline-item {
  display: grid;
  gap: 8px;
}

.alert-top, .report-row-top, .detail-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.alert-meta, .report-row-meta, .risk-meta, .pill-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.risk-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.risk-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.risk-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #66b3ff, #ff8a3d, #ff4d4d);
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab, .primary-button {
  border: 0;
  border-radius: 14px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
}

.tab {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}

.tab.active {
  background: linear-gradient(135deg, #66b3ff, #19c37d);
  color: #081018;
}

.primary-button {
  color: #081018;
  background: linear-gradient(135deg, #66b3ff, #19c37d);
}

.report-section.hidden { display: none; }

.filters {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.filters label {
  display: grid;
  gap: 8px;
}

.filters input,
.filters select,
.operator-panel input,
.operator-panel select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

.filters input:focus,
.filters select:focus,
.operator-panel input:focus,
.operator-panel select:focus {
  border-color: rgba(102, 179, 255, 0.7);
}

.filter-actions {
  display: flex;
  align-items: end;
}

.report-grid.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255,255,255,0.02);
}

.data-table th, .data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  text-align: left;
  white-space: nowrap;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: rgba(102,179,255,0.08);
}

.detail-panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.detail-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.timeline-item {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.04);
}

.operator-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.operator-panel label {
  display: grid;
  gap: 8px;
}

.report-summary { margin: 8px 0 12px; }
.report-meta { margin: 0 0 10px; }

@media (max-width: 1180px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-5, .grid-3, .operator-panel, .report-grid.two-col { grid-template-columns: 1fr; }
}


body.dashboard-page, body.reports-page, body.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#dashboardRoot, #reportsRoot, body.login-page > main.login-shell {
  flex: 1 0 auto;
}

.page-footer {
  margin-top: auto;
  padding: 16px 28px 24px;
  text-align: center;
}

.build-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.2px;
}


.theme-toggle {
  font: inherit;
  cursor: pointer;
}

.login-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

html[data-theme='light'] {
  color-scheme: light;
  --bg: #eef3f9;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-2: rgba(255, 255, 255, 0.98);
  --line: rgba(15, 23, 42, 0.09);
  --text: #0f172a;
  --muted: #52607a;
  --accent: #2563eb;
}

html[data-theme='light'] body {
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 24%),
    radial-gradient(circle at right, rgba(16, 185, 129, 0.08), transparent 22%),
    linear-gradient(180deg, #f8fbff 0%, #edf2f7 100%);
}

html[data-theme='light'] .status-pill,
html[data-theme='light'] .tab,
html[data-theme='light'] .chart-box,
html[data-theme='light'] .map-shell,
html[data-theme='light'] .stat,
html[data-theme='light'] .metric-card,
html[data-theme='light'] .timeline-item,
html[data-theme='light'] .detail-card,
html[data-theme='light'] .device-card,
html[data-theme='light'] .risk-item,
html[data-theme='light'] .alert-item,
html[data-theme='light'] .panel,
html[data-theme='light'] .detail-panel,
html[data-theme='light'] .data-table,
html[data-theme='light'] .table-wrap,
html[data-theme='light'] .build-info {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

html[data-theme='light'] .tab {
  color: var(--text);
}

html[data-theme='light'] .tab.active,
html[data-theme='light'] .primary-button {
  color: #ffffff;
}

html[data-theme='light'] .filters input,
html[data-theme='light'] .filters select,
html[data-theme='light'] .operator-panel input,
html[data-theme='light'] .operator-panel select {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--text);
}

html[data-theme='light'] .filters input::placeholder {
  color: #7a8699;
}

html[data-theme='light'] .data-table th,
html[data-theme='light'] .data-table td {
  border-bottom-color: rgba(15, 23, 42, 0.06);
}

html[data-theme='light'] .data-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.05);
}

html[data-theme='light'] .worker-marker {
  border-color: rgba(15, 23, 42, 0.9);
}

html[data-theme='light'] .worker-marker::after {
  background: rgba(15, 23, 42, 0.9);
}


html[data-theme='light'] .topbar {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

html[data-theme='light'] .panel,
html[data-theme='light'] .detail-panel,
html[data-theme='light'] .worker-card,
html[data-theme='light'] .alert-item,
html[data-theme='light'] .device-card,
html[data-theme='light'] .detail-card,
html[data-theme='light'] .risk-item,
html[data-theme='light'] .timeline-item,
html[data-theme='light'] .metric-card,
html[data-theme='light'] .stat,
html[data-theme='light'] .chart-box,
html[data-theme='light'] .map-shell,
html[data-theme='light'] .table-wrap,
html[data-theme='light'] .build-info,
html[data-theme='light'] .status-pill,
html[data-theme='light'] .tab {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

html[data-theme='light'] .panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.96));
}

html[data-theme='light'] .kpi-card,
html[data-theme='light'] .worker-card,
html[data-theme='light'] .alert-item,
html[data-theme='light'] .detail-card,
html[data-theme='light'] .device-card {
  background: rgba(255, 255, 255, 0.94);
}

html[data-theme='light'] .tab.active,
html[data-theme='light'] .primary-button {
  background: linear-gradient(135deg, #0f4c81, #1d72d8);
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(29, 114, 216, 0.18);
}

html[data-theme='light'] .status-pill.topbar-link {
  color: #1f2a37;
}

html[data-theme='light'] .theme-toggle {
  border-color: rgba(29, 78, 216, 0.18);
  color: #0f172a;
}

html[data-theme='light'] .topbar h1,
html[data-theme='light'] .panel h2,
html[data-theme='light'] .panel h3,
html[data-theme='light'] .worker-card .title strong,
html[data-theme='light'] .detail-top strong {
  color: #0f172a;
}

html[data-theme='light'] .label,
html[data-theme='light'] .muted,
html[data-theme='light'] .topbar p,
html[data-theme='light'] .panel p,
html[data-theme='light'] .panel span {
  color: #5b6474;
}

html[data-theme='light'] .filters input,
html[data-theme='light'] .filters select,
html[data-theme='light'] .operator-panel input,
html[data-theme='light'] .operator-panel select {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

html[data-theme='light'] .filters input:focus,
html[data-theme='light'] .filters select:focus,
html[data-theme='light'] .operator-panel input:focus,
html[data-theme='light'] .operator-panel select:focus {
  border-color: rgba(29, 114, 216, 0.45);
  box-shadow: 0 0 0 3px rgba(29, 114, 216, 0.12);
}

html[data-theme='light'] .data-table thead th {
  background: rgba(244, 248, 252, 0.96);
  color: #334155;
}

html[data-theme='light'] .data-table tbody tr:hover {
  background: rgba(29, 114, 216, 0.04);
}

html[data-theme='light'] .page-footer {
  background: transparent;
}

html[data-theme='light'] .build-info {
  color: #5b6474;
}


.alert-trigger,
.worker-alert-code {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.alert-trigger-sos,
.worker-alert-code-sos {
  color: #ff6666;
  border-color: rgba(255, 90, 90, 0.55);
  background: rgba(255, 90, 90, 0.12);
}

.alert-item-sos {
  box-shadow: 0 0 0 1px rgba(255, 90, 90, 0.18) inset;
}


.wifi-layout {
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
}

.wifi-full-width {
  grid-column: 1 / -1;
}

.wifi-form {
  display: grid;
  gap: 14px;
}

.wifi-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wifi-form-grid label,
.wifi-notes {
  display: grid;
  gap: 8px;
}

.wifi-form-grid input,
.wifi-form-grid select,
.wifi-form-grid textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  font: inherit;
}

.wifi-notes {
  grid-column: 1 / -1;
}

.wifi-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.wifi-map {
  height: 520px;
}

.wifi-list {
  display: grid;
  gap: 12px;
}

.wifi-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  display: grid;
  gap: 10px;
}

.wifi-card .wifi-actions .tab.danger {
  color: #ff8f8f;
  border-color: rgba(255, 77, 77, 0.35);
}

html[data-theme='light'] .wifi-form-grid input,
html[data-theme='light'] .wifi-form-grid select,
html[data-theme='light'] .wifi-form-grid textarea {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--text);
}

html[data-theme='light'] .wifi-card {
  background: rgba(255, 255, 255, 0.94);
}
