:root {
  --bg: #071018;
  --panel: #0c1824;
  --panel2: #102333;
  --line: #21445a;
  --text: #ecf7ff;
  --muted: #90a7bc;
  --cyan: #2dd4ff;
  --green: #20d99a;
  --yellow: #ffd36a;
  --red: #ff3158;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #16364a 0, #071018 420px);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}
button, input, select {
  font: inherit;
}
button {
  border: 1px solid #2b6684;
  background: #132a3d;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 13px;
  font-weight: 800;
  cursor: pointer;
}
button:hover { border-color: var(--cyan); }
button.primary { background: linear-gradient(135deg, #167da4, #20a175); }
button:disabled { opacity: .55; cursor: wait; }
input, select {
  width: 100%;
  color: var(--text);
  background: #07111b;
  border: 1px solid #2a5068;
  border-radius: 8px;
  padding: 9px 10px;
}
label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.appHeader {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(5, 12, 18, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.appHeader b { display: block; font-size: 24px; letter-spacing: .5px; }
.appHeader span { color: var(--muted); }
.appHeader nav { display: flex; gap: 14px; align-items: center; }
.appHeader a, .appFooter a { color: #a9ecff; }
.brandHeader {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brandHeader img {
  width: 148px;
  height: 52px;
  object-fit: contain;
  background: rgba(255,255,255,.96);
  border-radius: 8px;
  padding: 5px 8px;
}
.brandHeader div { min-width: 0; }
.toolbar, .compareBox {
  display: grid;
  grid-template-columns: repeat(8, minmax(120px, 1fr));
  gap: 10px;
  padding: 12px 18px;
  background: rgba(9, 21, 32, .78);
  border-bottom: 1px solid #18344a;
}
.toolbar.secondary { grid-template-columns: 2fr 1fr 1fr .7fr auto auto; }
.field { min-width: 0; }
.field label { display: block; margin-bottom: 5px; }
.field.small { max-width: 120px; }
.field.wide { min-width: 260px; }
.cameraChecks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid #18344a;
}
.cameraChecks label, .compareBox .check {
  background: #0b1722;
  border: 1px solid #24485e;
  border-radius: 8px;
  padding: 8px 10px;
  color: #d6e9f4;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cameraChecks input, .compareBox input[type="checkbox"] {
  width: auto;
  margin-right: 6px;
}
.compareBox {
  grid-template-columns: 170px 180px 160px 160px auto 1fr;
  align-items: end;
}
.content {
  padding: 16px 18px 34px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
}
.card, .panel, .loginCard {
  background: linear-gradient(180deg, rgba(16,35,51,.98), rgba(8,18,27,.98));
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,.24);
}
.card {
  padding: 13px;
  min-height: 88px;
}
.card small {
  display: block;
  color: #88d8ff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.card b {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}
.formula {
  margin: 12px 0;
  padding: 12px;
  background: #06111b;
  border: 1px solid #2b5d78;
  border-radius: 8px;
  color: #c7f4ff;
  font-weight: 900;
}
.chartGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}
.widePanel {
  grid-column: span 2;
}
.panel {
  padding: 14px;
  min-width: 0;
}
.panel h2 {
  margin: 0 0 12px;
  color: #b7efff;
  font-size: 15px;
}
.barChart {
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
}
.lineChart {
  position: relative;
  min-height: 270px;
  overflow: hidden;
  background: #07111b;
  border: 1px solid #193448;
  border-radius: 8px;
  padding: 10px;
}
.lineChart svg {
  width: 100%;
  height: 214px;
  display: block;
}
#hourChart { min-height: 330px; }
#hourChart svg { height: 260px; }
.axisLabels {
  position: relative;
  height: 28px;
  color: var(--muted);
  font-size: 10px;
}
.axisLabels span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.barRow {
  display: grid;
  grid-template-columns: minmax(130px, 230px) 1fr;
  gap: 9px;
  align-items: center;
  margin: 8px 0;
}
.barRow span {
  color: #d9e8f2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.barRow b {
  display: block;
  min-width: 28px;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  color: #041018;
  font-size: 12px;
}
.donutText {
  min-height: 220px;
  display: grid;
  align-content: center;
  gap: 10px;
}
.donutNumber {
  width: 124px;
  height: 124px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 20px solid var(--cyan);
  box-shadow: inset 0 0 0 8px #07111b;
  font-size: 26px;
  font-weight: 900;
}
.legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #d9e8f2;
}
.heatmap {
  min-height: 280px;
  overflow: auto;
}
.heatGrid {
  display: grid;
  gap: 3px;
  min-width: 980px;
  align-items: stretch;
}
.heatGrid b, .heatGrid strong, .heatGrid i {
  min-height: 26px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  font-style: normal;
  font-size: 11px;
}
.heatGrid b {
  color: #88d8ff;
  background: #0b1722;
}
.heatGrid strong {
  justify-content: start;
  padding-left: 8px;
  color: #d9e8f2;
  background: #0b1722;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.heatGrid i {
  color: #ffffff;
  border: 1px solid rgba(255,255,255,.04);
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 10px;
}
.tabs button.active {
  background: #1d7ea9;
  border-color: #7de9ff;
}
.tablePanel {
  overflow: hidden;
}
#tableWrap {
  max-height: 560px;
  overflow: auto;
  border: 1px solid #1f3a4e;
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 850px;
}
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid #18344a;
  text-align: left;
  font-size: 13px;
}
th {
  position: sticky;
  top: 0;
  background: #102333;
  color: #b7efff;
  z-index: 2;
}
tr:nth-child(even) td { background: rgba(255,255,255,.025); }
.loading {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #102333;
  border: 1px solid var(--yellow);
  border-radius: 10px;
  box-shadow: 0 12px 34px rgba(0,0,0,.35);
  font-weight: 900;
}
.loading.hidden { display: none; }
.loading div {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #28465b;
  border-top-color: var(--yellow);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty {
  color: var(--muted);
  padding: 20px;
  border: 1px dashed #2a5068;
  border-radius: 8px;
  text-align: center;
}
.appFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  color: var(--muted);
  border-top: 1px solid #18344a;
}
.footerBrand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.footerBrand img {
  width: 136px;
  height: 46px;
  object-fit: contain;
  background: rgba(255,255,255,.96);
  border-radius: 7px;
  padding: 5px 7px;
}
.loginBody {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}
.loginCard {
  width: min(460px, 100%);
  padding: 28px;
}
.loginBrand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.loginBrand img {
  width: 180px;
  height: 64px;
  object-fit: contain;
  background: rgba(255,255,255,.98);
  border-radius: 10px;
  padding: 7px 10px;
}
.loginBrand span {
  color: #b7efff;
  font-size: 24px;
  font-weight: 1000;
}
.loginCard h1 { margin: 0; font-size: 30px; }
.loginCard p, .loginCard footer { color: var(--muted); }
.loginFooter {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #18344a;
}
.loginFooter span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.loginFooter img {
  width: 128px;
  height: 42px;
  object-fit: contain;
  background: rgba(255,255,255,.96);
  border-radius: 7px;
  padding: 5px 7px;
}
.loginForm {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}
.loginForm label { display: grid; gap: 6px; }
.loginForm button { margin-top: 4px; background: linear-gradient(135deg, #167da4, #20a175); }
.error { min-height: 20px; color: #ff8ca0; font-weight: 900; }
@media (max-width: 1100px) {
  .toolbar, .toolbar.secondary, .compareBox { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .chartGrid { grid-template-columns: 1fr; }
  .widePanel { grid-column: span 1; }
  .appFooter { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 620px) {
  .appHeader { align-items: flex-start; flex-direction: column; }
  .toolbar, .toolbar.secondary, .compareBox { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .card b { font-size: 24px; }
  .field.small, .field.wide { max-width: none; min-width: 0; }
}
