:root {
  color-scheme: light;
  --bg: #d9d9d9;
  --panel: #ffffff;
  --panel-strong: #e9e9e9;
  --ink: #000000;
  --muted: #404040;
  --line: #101010;
  --accent: #004397;
  --accent-2: #0aaee0;
  --wincc-blue: #21a9df;
  --wincc-green: #08c50d;
  --warn: #ffd400;
  --danger: #ff1d12;
  --ok: #08c50d;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 14px 12px;
  background: #cfcfcf;
  color: #000000;
  border-right: 2px solid #9a9a9a;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 0;
  background: #ffffff;
  color: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--accent);
  font-size: 0.86rem;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 2px;
  color: #000000;
  background: linear-gradient(#ffffff, #c7c7c7);
  border: 1px solid #a0a0a0;
  text-decoration: none;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 0;
  background: #efefef;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: linear-gradient(#ffffff, #d6d6d6);
  color: var(--accent);
}

.security-note {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #cce6de;
  font-size: 0.9rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.safe {
  background: #6fe0a0;
  box-shadow: 0 0 0 5px rgba(111, 224, 160, 0.12);
}

.main {
  padding: 0 0 18px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding: 10px 18px 0;
  background: #ffffff;
  border-bottom: 40px solid #454545;
  position: relative;
}

.topbar::after {
  content: "Principal";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -35px;
  color: #ffffff;
  text-align: center;
  font-size: 1.45rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  color: #6b89bd;
  text-align: center;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.18rem;
}

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

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: linear-gradient(#ffffff, #d2d2d2);
  color: var(--accent);
  cursor: pointer;
}

.icon-button:hover {
  border-color: #adc2ca;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: linear-gradient(#ffffff, #d2d2d2);
  color: var(--accent);
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #dbe9ef;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0 10px 18px;
}

.status-strip article,
.room-card,
.detail-card,
.table-card,
.process-map,
.system-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow);
}

.status-strip article {
  padding: 12px 14px;
  background: var(--wincc-green);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 1.18rem;
  color: #0017ba;
}

.status-strip small,
.room-card small,
.map-node small {
  color: var(--muted);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin: 0 10px 14px;
}

.section-heading p {
  color: var(--muted);
  margin-bottom: 0;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.85fr) 1.15fr;
  gap: 16px;
}

.process-map {
  min-height: 340px;
  padding: 22px;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background:
    linear-gradient(90deg, rgba(47, 127, 116, 0.08), transparent),
    var(--panel);
}

.map-node {
  min-height: 150px;
  padding: 18px;
  border: 1px solid #c7d7dd;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
}

.map-node span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 32px;
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.map-node.source span {
  background: #e7effa;
  color: #2a5d8f;
}

.map-node.app span {
  background: #e8f4ed;
  color: var(--ok);
}

.map-line {
  width: 36px;
  height: 2px;
  background: #9db7c0;
}

.room-list,
.detail-grid,
.wincc-grid,
.system-grid,
.system-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wincc-grid {
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 36px 10px;
  padding: 0 10px;
}

.area-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.system-strip {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  padding: 22px 10px 0;
}

.system-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  padding: 0 10px;
}

.wincc-card {
  border: 1px solid #000000;
  background: var(--wincc-green);
  color: #000000;
  min-height: 176px;
  display: grid;
  grid-template-rows: 58px 48px 48px 48px 30px;
}

.wincc-card header {
  display: grid;
  place-items: center;
  min-height: 58px;
  padding: 7px;
  background: var(--wincc-blue);
  border-bottom: 1px solid #000000;
  color: #ffffff;
  text-align: center;
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
}

.wincc-row {
  display: grid;
  grid-template-columns: 0.9fr 1fr;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.55);
  padding: 0 8px;
}

.wincc-row span,
.wincc-card footer {
  font-weight: 900;
  text-transform: uppercase;
}

.wincc-row strong {
  color: #0017ba;
  text-align: right;
  font-size: 1.65rem;
  line-height: 1;
}

.state-row {
  grid-template-columns: 1fr;
  text-align: center;
}

.state-row strong {
  color: #000000;
  text-align: center;
  font-size: 1rem;
}

.wincc-card footer {
  display: grid;
  place-items: center;
  min-height: 30px;
}

.wincc-card.is-warning footer,
.wincc-card.is-warning .state-row {
  background: var(--warn);
}

.wincc-card.is-alarm footer,
.wincc-card.is-alarm .state-row {
  background: var(--danger);
}

.wincc-card.is-inactive {
  filter: grayscale(0.75);
  opacity: 0.75;
}

.system-compact {
  min-height: 74px;
  border: 1px solid #000000;
  background: var(--wincc-green);
  display: grid;
  place-content: center;
  text-align: center;
  padding: 10px;
}

.system-compact span {
  font-weight: 900;
  text-transform: uppercase;
}

.system-compact strong {
  color: #0017ba;
}

.system-card {
  padding: 18px;
}

.system-card.is-warning,
.system-compact.is-warning {
  background: #ffe55c;
}

.system-card.is-alarm,
.system-compact.is-alarm {
  background: #ff3b30;
}

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

.kv-item {
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid #000000;
  padding: 9px;
}

.kv-item span,
.kv-item strong {
  display: block;
}

.kv-item span {
  font-weight: 900;
}

.kv-item strong {
  color: #0017ba;
  font-size: 1.15rem;
}

.mini-trend {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.35);
}

.mini-trend-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-weight: 900;
}

.mini-trend-title small {
  color: var(--muted);
  font-weight: 700;
}

.mini-trend canvas {
  width: 100%;
  height: 150px;
  border: 1px solid #000000;
  background: #fbfdfe;
}

.room-card,
.detail-card {
  padding: 18px;
}

.room-card {
  min-height: 160px;
}

.card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e9f5ee;
  color: var(--ok);
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.muted {
  background: #e5e5e5;
  color: #444444;
}

.badge.warn {
  background: #fbf1df;
  color: var(--warn);
}

.badge.danger {
  background: #f8e4e6;
  color: var(--danger);
}

.readings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.reading {
  padding: 12px;
  border-radius: 8px;
  background: #f6fafb;
  border: 1px solid #e0eaee;
}

.reading strong {
  display: block;
  margin-top: 4px;
  font-size: 1.18rem;
}

.detail-card canvas {
  width: 100%;
  height: 180px;
  margin-top: 12px;
  border: 1px solid #e0eaee;
  border-radius: 8px;
  background: #fbfdfe;
}

.area-trend-grid {
  padding: 0 10px 14px;
}

.table-card {
  overflow: auto;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.92rem;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
}

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

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

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

  .nav-item {
    justify-content: center;
    font-size: 0.82rem;
  }

  .overview-grid,
  .status-strip,
  .room-list,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .process-map {
    grid-template-columns: 1fr;
  }

  .map-line {
    width: 2px;
    height: 26px;
    justify-self: center;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .readings {
    grid-template-columns: 1fr;
  }
}
