:root {
  --bg: #080b12;
  --surface: #121720;
  --surface-2: #171d28;
  --line: #252d3a;
  --muted: #8e98aa;
  --text: #f3f7ff;
  --cyan: #18d3e8;
  --blue: #2f6cf0;
  --green: #32d179;
  --amber: #ffbd4a;
  --red: #ff5b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(24, 211, 232, .14), transparent 32%),
    linear-gradient(145deg, #080b12, #111827);
}

.login-panel {
  width: min(420px, 100%);
  padding: 34px;
  background: rgba(18, 23, 32, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .34);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--cyan);
  color: #071018;
  font-weight: 900;
}

.login-panel h1 {
  margin: 18px 0 8px;
  font-size: 34px;
}

.login-panel p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.5;
}

.login-form,
.settings-form,
.device-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: #aab3c4;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

input,
select {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090d15;
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(24, 211, 232, .12);
}

.login-form button,
.settings-form button,
.device-form button,
.filter-panel button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-weight: 900;
}

small {
  color: var(--red);
  min-height: 16px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #141922;
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  height: 80px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 8px;
  padding: 22px 12px;
}

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9ba5b6;
  padding: 0 16px;
  font-weight: 800;
  text-align: left;
}

.nav-item span {
  width: 18px;
  color: #a9b2c2;
}

.nav-item.active {
  color: var(--text);
  background: rgba(24, 211, 232, .12);
  box-shadow: inset 3px 0 0 var(--cyan);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.logout-btn {
  border: 0;
  background: transparent;
  color: #ff7a83;
  text-align: left;
  font-weight: 800;
}

.health-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.health-card strong {
  color: #dfe6f3;
}

.health-card i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 8px;
}

.content {
  padding: 28px 32px 44px;
  min-width: 0;
}

.topbar,
.section-head,
.panel-head,
.table-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 0;
}

h2 {
  font-size: 32px;
}

h3 {
  font-size: 25px;
}

h4 {
  margin: 0;
  font-size: 14px;
  color: #dbe4f2;
}

.operator-pill {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

#clockText {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.page {
  display: none;
  margin-top: 28px;
}

.page.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-card,
.panel,
.filter-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card {
  padding: 20px;
  display: grid;
  gap: 8px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .16);
}

.metric-card span,
.metric-card small,
.section-head p,
.panel-head p {
  color: var(--muted);
}

.metric-card strong {
  font-size: 32px;
}

.metric-card.cyan {
  border-color: rgba(24, 211, 232, .35);
}

.metric-card.green {
  border-color: rgba(50, 209, 121, .35);
}

.metric-card.amber {
  border-color: rgba(255, 189, 74, .35);
}

.metric-card.red {
  border-color: rgba(255, 91, 107, .35);
}

.dashboard-grid,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  padding: 24px;
}

.panel.wide {
  min-width: 0;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.chart-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid #202938;
  border-radius: 8px;
  background: #0b1018;
}

canvas {
  width: 100%;
  max-width: 100%;
  margin-top: 10px;
  background: #0b1018;
  border: 0;
  border-radius: 8px;
}

.field-summary {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.summary-row span {
  color: var(--muted);
}

.section-head {
  margin-bottom: 18px;
}

.section-head input {
  width: min(330px, 100%);
}

.filter-row {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.chip,
.table-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: #d9e2f1;
  padding: 0 14px;
  font-weight: 800;
}

.chip.active {
  border-color: var(--cyan);
  color: white;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 22px;
  margin-top: 22px;
}

.add-device-panel {
  margin-bottom: 4px;
}

.device-form {
  grid-template-columns: 1fr 1fr 1.4fr auto;
  align-items: end;
  margin-top: 18px;
}

.device-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
  display: grid;
  gap: 18px;
}

.device-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.device-title p {
  margin: 6px 0 0;
  color: var(--muted);
}

.badge {
  align-self: start;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.badge.online,
.badge.normal {
  color: var(--green);
  background: rgba(50, 209, 121, .12);
}

.badge.maintenance {
  color: var(--amber);
  background: rgba(255, 189, 74, .12);
}

.badge.low {
  color: var(--red);
  background: rgba(255, 91, 107, .12);
}

.device-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.stat strong {
  display: block;
  margin: 8px 0;
  font-size: 22px;
}

.bar {
  height: 7px;
  border-radius: 999px;
  background: #283142;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--cyan);
}

.stat:nth-child(2) .bar i {
  background: var(--green);
}

.bar.warn i {
  background: var(--amber);
}

.bar.danger i {
  background: var(--red);
}

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

.delete-device {
  min-height: 36px;
  border: 1px solid rgba(255, 91, 107, .35);
  border-radius: 8px;
  background: rgba(255, 91, 107, .08);
  color: #ff8a94;
  padding: 0 14px;
  font-weight: 900;
}

.delete-device:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.filter-panel {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 20px;
  align-items: end;
  padding: 24px;
  margin-bottom: 24px;
}

.table-panel {
  padding: 20px;
}

.table-actions {
  margin-bottom: 18px;
}

.table-actions > div {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1320px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid #202837;
  text-align: left;
  white-space: nowrap;
}

th {
  color: #a9b3c3;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

td {
  color: #dfe6f3;
}

.entry-info {
  color: var(--muted);
  margin: 16px 0 0;
}

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

.user-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #0c1119;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.spec-panel dl {
  display: grid;
  gap: 12px;
  margin-bottom: 0;
}

.spec-panel dt {
  color: var(--muted);
  font-weight: 800;
}

.spec-panel dd {
  margin: -8px 0 0;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(4, 1fr);
  }

  .sidebar-footer {
    display: none;
  }

  .metric-grid,
  .dashboard-grid,
  .settings-grid,
  .filter-panel,
  .device-form,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head,
  .panel-head,
  .table-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  .sidebar,
  .topbar,
  .filter-panel,
  .table-actions {
    display: none;
  }

  .app-shell {
    display: block;
  }

  body,
  .content,
  .panel {
    background: white;
    color: black;
  }

  table {
    color: black;
  }
}
