:root {
  --bg: #f3f7fa;
  --sidebar: #071c2e;
  --panel: #ffffff;
  --ink: #102033;
  --muted: #64748b;
  --line: #dbe5ec;
  --soft: #edf3f7;
  --accent: #0b7b75;
  --accent-2: #1aa6df;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #e11d48;
  --blue: #2563eb;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

button {
  background: var(--ink);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

.commercial-shell {
  min-height: 100vh;
}

.login-view {
  align-items: center;
  display: grid;
  min-height: 100vh;
  overflow: hidden;
  padding: 24px;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin: 0 auto;
  max-width: 380px;
  padding: 24px;
  width: 100%;
}

.login-panel h1,
.topbar h1,
.panel h2,
.section-head h2 {
  margin: 0;
}

.login-panel p,
.topbar p,
.panel p,
.section-head p {
  color: var(--muted);
  margin: 4px 0 0;
}

.login-panel input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 11px;
}

#loginStatus {
  color: var(--bad);
  font-size: 13px;
  min-height: 18px;
}

.dashboard-view {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: #d8e6f1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  padding: 30px 18px 22px;
  position: sticky;
  top: 0;
}

.brand {
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: .02em;
  margin: 10px 12px 34px;
}

.commercial-tabs {
  display: grid;
  gap: 10px;
  align-content: start;
}

.tab {
  align-items: center;
  background: transparent;
  border-radius: 8px;
  color: #d8e6f1;
  display: flex;
  gap: 12px;
  justify-content: flex-start;
  min-height: 44px;
  padding: 0 14px;
  text-align: left;
}

.tab.active {
  background: #1d67a3;
  color: #fff;
  font-weight: 800;
}

.tab-icon {
  display: inline-grid;
  font-size: 14px;
  width: 18px;
}

.sidebar-user {
  align-items: center;
  display: flex;
  gap: 10px;
}

.sidebar-user > span {
  align-items: center;
  background: #bfe3dd;
  border-radius: 999px;
  color: var(--sidebar);
  display: grid;
  font-size: 12px;
  font-weight: 900;
  height: 40px;
  justify-items: center;
  width: 40px;
}

.sidebar-user strong,
.sidebar-user small {
  display: block;
}

.sidebar-user small {
  color: #9db2c3;
  margin-top: 2px;
}

.content-shell {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: 30px 28px;
}

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

.top-actions,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.top-actions button:last-child,
.ghost-button {
  background: #e5edf2;
  color: var(--ink);
}

.commercial-view {
  display: none;
}

.commercial-view.active {
  display: grid;
  gap: 18px;
}

.visual-section.commercial-view.active {
  display: block;
}

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

.metrics article,
.panel,
.visual-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 30px rgba(15, 35, 54, .04);
}

.metrics article {
  min-height: 108px;
  padding: 20px;
}

.metrics span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.metrics strong {
  display: block;
  font-size: 32px;
  line-height: 1.05;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

#onlineDevices,
#healthyDevices {
  color: var(--good);
}

#attentionDevices {
  color: var(--bad);
}

#visualCoverage {
  color: var(--blue);
}

#mainApp {
  color: #0f6f86;
  font-size: 18px;
  line-height: 1.2;
}

.summary-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) minmax(280px, 1fr);
}

.panel {
  padding: 22px;
}

.panel-head {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: 20px;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.donut-layout {
  align-items: center;
  display: grid;
  gap: 24px;
  grid-template-columns: 190px minmax(0, 1fr);
}

.donut {
  align-items: center;
  aspect-ratio: 1;
  background: conic-gradient(var(--good) 0deg, var(--good) var(--good-angle, 0deg), var(--bad) var(--good-angle, 0deg), var(--bad) 360deg);
  border-radius: 50%;
  display: grid;
  justify-items: center;
  position: relative;
}

.donut::after {
  background: var(--panel);
  border-radius: 50%;
  content: "";
  inset: 38px;
  position: absolute;
}

.donut strong,
.donut span {
  position: relative;
  z-index: 1;
}

.donut strong {
  font-size: 30px;
}

.donut span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: -42px;
}

.legend-list,
.coverage-list,
.attention-list,
.app-breakdown {
  display: grid;
  gap: 12px;
}

.legend-row,
.attention-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.swatch {
  border-radius: 4px;
  height: 12px;
  width: 12px;
}

.count,
.percent {
  font-weight: 800;
}

.percent {
  color: var(--muted);
  font-size: 13px;
}

.break-row,
.coverage-row {
  display: grid;
  gap: 7px;
}

.break-top,
.coverage-top {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.break-line,
.coverage-line {
  background: #e7eef2;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.break-line span,
.coverage-line span {
  background: var(--accent);
  display: block;
  height: 100%;
}

.break-label {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.break-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lifecycle-panel {
  grid-column: span 2;
}

.lifecycle-steps {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.life-step {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 128px;
  padding: 20px 12px;
}

.life-step strong {
  color: #0f6f86;
  font-size: 30px;
}

.life-step span {
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.life-step small {
  color: var(--muted);
}

.attention-row {
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 54px;
  padding: 10px 12px;
}

.attention-dot {
  background: #ffe0e3;
  border-radius: 999px;
  height: 14px;
  width: 14px;
}

.tag {
  background: #eaf1f5;
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.tag.bad {
  background: #ffe0e3;
  color: var(--bad);
}

.tag.warn {
  background: #fff1d6;
  color: #9a5b00;
}

.tag.good {
  background: #dcfce7;
  color: #15803d;
}

.visual-strip-panel {
  overflow: hidden;
  padding-bottom: 18px;
}

.visual-strip {
  display: grid;
  gap: 16px;
  grid-auto-columns: 174px;
  grid-auto-flow: column;
  overflow-x: auto;
  padding-bottom: 4px;
}

.mini-shot {
  display: grid;
  gap: 8px;
}

.mini-frame {
  align-items: center;
  aspect-ratio: 16 / 11;
  background: #0f1d2d;
  border-radius: 8px;
  display: grid;
  justify-items: center;
  overflow: hidden;
}

.mini-frame img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.mini-shot strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visual-section {
  padding: 22px;
}

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

.filter {
  background: #e5edf2;
  color: var(--ink);
}

.filter.active {
  background: var(--accent);
  color: #fff;
}

.snapshot-gallery {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin-top: 18px;
}

.shot-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.shot-frame {
  align-items: center;
  aspect-ratio: 9 / 16;
  background: #dfe8ed;
  display: grid;
  justify-items: center;
}

.shot-frame img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.shot-missing {
  color: var(--muted);
  font-weight: 700;
}

.shot-meta {
  display: grid;
  gap: 3px;
  padding: 10px;
}

.shot-meta strong {
  font-size: 14px;
}

.shot-meta span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  border-radius: 50%;
  display: inline-block;
  height: 8px;
  margin-right: 6px;
  width: 8px;
}

.dot.ok {
  background: var(--good);
}

.dot.bad {
  background: var(--bad);
}

@media (max-width: 1180px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .lifecycle-panel {
    grid-column: auto;
  }
}

@media (max-width: 820px) {
  .dashboard-view {
    grid-template-columns: 1fr;
  }

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

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

  .sidebar-user {
    display: none;
  }

  .content-shell {
    padding: 18px;
  }

  .topbar,
  .section-head,
  .panel-head,
  .donut-layout {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .metrics,
  .lifecycle-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
