:root {
  --bg: #08080d;
  --surface: #11111a;
  --surface-2: #181725;
  --surface-3: #211f2f;
  --line: #302c46;
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #f7f7fb;
  --muted: #a9a7b8;
  --muted-2: #777287;
  --primary: #ef3f62;
  --primary-2: #ff6b87;
  --ok: #00df7d;
  --warn: #ffb84d;
  --bad: #ff5c6b;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  background:
    linear-gradient(rgba(239, 63, 98, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(239, 63, 98, 0.14) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(239, 63, 98, 0.22), transparent 36rem),
    radial-gradient(circle at 85% 35%, rgba(0, 223, 125, 0.06), transparent 26rem),
    var(--bg);
  background-size: 40px 40px, 40px 40px, auto, auto, auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(8, 8, 13, 0.2), rgba(8, 8, 13, 0.82));
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button:hover,
a:hover {
  filter: brightness(1.05);
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0b12;
  color: var(--text);
  padding: 0.72rem 0.8rem;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(239, 63, 98, 0.75);
  box-shadow: 0 0 0 3px rgba(239, 63, 98, 0.16);
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 1.1rem 0 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  letter-spacing: 0.16em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #050507;
  box-shadow: 0 0 28px rgba(239, 63, 98, 0.24);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1;
}

.brand strong {
  font-size: 0.78rem;
}

.brand small {
  margin-top: 0.28rem;
  color: var(--primary);
  font-size: 0.62rem;
  font-weight: 800;
}

.language-picker {
  width: min(180px, 45vw);
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  align-items: center;
  gap: 4rem;
  min-height: calc(100vh - 90px);
  padding: 4rem 0;
}

.login-copy {
  max-width: 720px;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--primary-2);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-copy h1 {
  max-width: 760px;
  margin: 1rem 0 0;
  font-size: clamp(3rem, 7vw, 6.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.login-copy p:not(.eyebrow) {
  max-width: 620px;
  margin: 1.4rem 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.7vw, 1.34rem);
  line-height: 1.55;
}

.signal-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 2rem;
}

.signal-strip span,
.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 17, 26, 0.76);
  color: var(--muted);
  padding: 0.5rem 0.72rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.auth-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0)),
    rgba(17, 17, 26, 0.94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.auth-card {
  display: grid;
  gap: 1rem;
  padding: 1.35rem;
}

.auth-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 18px rgba(0, 223, 125, 0.85);
}

.advanced-login summary {
  color: var(--muted-2);
  cursor: pointer;
  font-size: 0.82rem;
}

.advanced-login input {
  margin-top: 0.6rem;
}

.primary-action {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 16px 36px rgba(239, 63, 98, 0.32);
}

.secondary-action,
.primary-mini {
  border: 1px solid rgba(239, 63, 98, 0.35);
  background: rgba(239, 63, 98, 0.14);
  color: var(--text);
  font-weight: 800;
}

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.banner {
  margin: 1rem 0;
  border-radius: 10px;
  padding: 0.78rem 0.9rem;
  font-size: 0.9rem;
}

.banner.ok {
  border: 1px solid rgba(0, 223, 125, 0.32);
  background: rgba(0, 223, 125, 0.1);
}

.banner.warn {
  border: 1px solid rgba(255, 184, 77, 0.36);
  background: rgba(255, 184, 77, 0.12);
}

.banner.bad {
  border: 1px solid rgba(255, 92, 107, 0.4);
  background: rgba(255, 92, 107, 0.12);
}

.hidden {
  display: none !important;
}

.portal-workspace {
  padding: 2rem 0 0;
}

.workspace-header,
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.workspace-header h1 {
  margin: 0.3rem 0 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

.workspace-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  white-space: nowrap;
}

.inline input {
  width: auto;
  min-height: auto;
}

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

.panel {
  min-width: 0;
  padding: 1rem;
}

.customer-panel {
  grid-column: span 1;
}

.customer-panel h2 {
  margin: 0.55rem 0 1rem;
  overflow-wrap: anywhere;
  font-size: 1.35rem;
}

.stat-panel {
  grid-column: span 1;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.stat-row div {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.026);
  padding: 0.75rem;
}

.stat-row strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.stat-row span {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.stat-row.compact strong {
  color: var(--ok);
  font-size: 1.35rem;
}

.stat-row.compact div:last-child strong {
  color: var(--bad);
}

.metric {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.62rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  color: var(--text);
  overflow-wrap: anywhere;
  text-align: right;
}

.bar {
  height: 9px;
  margin: 0.45rem 0 0.9rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #08080d;
}

.bar > div {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ok), #69ffb0);
  transition: width 0.25s ease;
}

#offlineRatioBar {
  background: linear-gradient(90deg, var(--warn), var(--bad));
}

.premium-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 0.9rem;
}

.mission-control {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 1fr);
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.mission-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.42fr);
  gap: 1rem;
  overflow: hidden;
  min-height: 270px;
  padding: 1.25rem;
}

.mission-hero::after {
  content: "";
  position: absolute;
  right: -110px;
  top: -110px;
  width: 290px;
  height: 290px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(0, 223, 125, 0.16), transparent 62%);
}

.mission-hero.state-critical::after {
  background: radial-gradient(circle, rgba(255, 92, 107, 0.2), transparent 62%);
}

.mission-hero.state-warning::after {
  background: radial-gradient(circle, rgba(255, 184, 77, 0.2), transparent 62%);
}

.mission-copy {
  position: relative;
  z-index: 1;
}

.mission-copy h2 {
  max-width: 760px;
  margin: 0.6rem 0;
  font-size: clamp(2.25rem, 5vw, 5.2rem);
  line-height: 0.92;
  letter-spacing: -0.055em;
}

.mission-summary {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.next-action {
  display: grid;
  gap: 0.35rem;
  margin-top: 1.2rem;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(8, 8, 13, 0.5);
  padding: 0.9rem;
}

.next-action span {
  color: var(--primary-2);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.next-action strong {
  font-size: 1rem;
  line-height: 1.42;
}

.mission-kpis {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.7rem;
}

.mission-kpis div {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(8, 8, 13, 0.62);
  padding: 0.9rem;
}

.mission-kpis strong {
  display: block;
  font-size: 2.15rem;
  line-height: 1;
}

.mission-kpis span {
  display: block;
  margin-top: 0.45rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.priority-panel {
  grid-row: span 2;
}

.tight {
  align-items: center;
  margin-bottom: 0.8rem;
}

.tight h2,
.machine-map-panel h2 {
  margin: 0.25rem 0 0;
  font-size: 1.4rem;
}

.priority-list,
.handover-list {
  display: grid;
  gap: 0.75rem;
}

.priority-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 0.8rem;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--ok);
  border-radius: 12px;
  background: rgba(8, 8, 13, 0.58);
  padding: 0.85rem;
}

.priority-card.critical {
  border-left-color: var(--bad);
}

.priority-card.warning {
  border-left-color: var(--warn);
}

.priority-rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: var(--mono);
  font-weight: 900;
}

.priority-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.priority-machine {
  margin: 0.25rem 0 0.55rem;
  color: var(--primary-2);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.priority-body p {
  margin: 0.4rem 0;
  color: var(--muted);
  line-height: 1.42;
}

.priority-advice {
  display: grid;
  gap: 0.25rem;
  margin: 0.65rem 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  padding: 0.65rem;
}

.priority-advice span,
.priority-meta {
  color: var(--muted-2);
  font-size: 0.76rem;
}

.priority-advice strong {
  line-height: 1.4;
}

.priority-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.priority-incident-btn {
  width: 100%;
  margin-top: 0.75rem;
}

.handover-panel,
.predictive-panel {
  min-height: 150px;
}

.handover-item {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.032);
  color: var(--muted);
  padding: 0.75rem;
  line-height: 1.42;
}

.machine-map-panel {
  margin-bottom: 0.9rem;
}

.machine-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.machine-card {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(8, 8, 13, 0.55);
  padding: 0.85rem;
}

.machine-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.machine-light {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 18px rgba(0, 223, 125, 0.8);
}

.machine-card.warning .machine-light {
  background: var(--warn);
  box-shadow: 0 0 18px rgba(255, 184, 77, 0.75);
}

.machine-card.critical .machine-light {
  background: var(--bad);
  box-shadow: 0 0 18px rgba(255, 92, 107, 0.75);
}

.machine-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.7rem 0;
}

.machine-stats span {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  padding: 0.28rem 0.5rem;
  font-size: 0.75rem;
}

.machine-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.capacity-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.small {
  font-size: 0.8rem;
  line-height: 1.4;
}

.muted {
  color: var(--muted);
}

.devices-panel,
.alerts-panel {
  margin-top: 0.9rem;
}

.sites-panel {
  margin-top: 0.9rem;
}

.devices {
  display: grid;
  gap: 0.9rem;
}

.device-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(8, 8, 13, 0.62);
  padding: 1rem;
}

.device-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.device-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.device-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 0.8rem 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.nodes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.nodes-table th,
.nodes-table td {
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.nodes-table th {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.chip.active,
.chip.online {
  border-color: rgba(0, 223, 125, 0.42);
  background: rgba(0, 223, 125, 0.12);
  color: #87ffc1;
}

.chip.offline,
.chip.suspended,
.chip.disabled,
.chip.critical {
  border-color: rgba(255, 92, 107, 0.42);
  background: rgba(255, 92, 107, 0.12);
  color: #ff98a3;
}

.chip.warning,
.chip.maintenance {
  border-color: rgba(255, 184, 77, 0.44);
  background: rgba(255, 184, 77, 0.12);
  color: #ffd08a;
}

.alerts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  user-select: none;
}

.alerts-header:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.alerts-header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.alerts-icon,
.toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(239, 63, 98, 0.14);
  color: var(--primary-2);
  font-family: var(--mono);
  font-weight: 900;
}

.alerts-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.alerts-subtitle,
.field-hint {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.alerts-chevron {
  color: var(--muted);
}

.alerts-body {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}

.alerts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.alerts-field,
.timeline-item {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(8, 8, 13, 0.5);
  padding: 0.85rem;
}

.threshold-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.threshold-row input {
  max-width: 92px;
  text-align: center;
}

.threshold-unit,
.alerts-updated {
  color: var(--muted);
  font-size: 0.82rem;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.toggle-label {
  flex: 1;
  flex-direction: row;
  align-items: flex-start;
  cursor: pointer;
}

.toggle-label div {
  display: flex;
  flex-direction: column;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex: none;
  cursor: pointer;
}

.switch input {
  width: 0;
  height: 0;
  opacity: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0b0b12;
}

.slider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--muted-2);
  transform: translateY(-50%);
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch input:checked + .slider {
  border-color: rgba(0, 223, 125, 0.5);
  background: rgba(0, 223, 125, 0.12);
}

.switch input:checked + .slider::before {
  background: var(--ok);
  transform: translate(18px, -50%);
}

.recipients-input {
  margin-top: 0.65rem;
}

.alerts-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}

#alertsSaveBtn {
  min-width: 180px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--text);
  font-weight: 900;
}

.sites-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.8fr) minmax(260px, 0.9fr);
  gap: 0.85rem;
  margin-top: 1rem;
}

.site-list,
.site-form {
  display: grid;
  gap: 0.65rem;
}

.site-list-wrap,
.site-form {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(8, 8, 13, 0.5);
  padding: 0.85rem;
}

.site-list-wrap h3,
.site-form h3 {
  margin: 0 0 0.25rem;
  font-size: 0.92rem;
}

.site-card {
  display: grid;
  gap: 0.15rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 0.65rem;
}

.site-card span,
.site-card small {
  color: var(--muted);
  font-size: 0.78rem;
}

.site-form input,
.site-form select {
  width: 100%;
}

.maintenance-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 230px;
  overflow: auto;
}

.timeline-item {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
}

.timeline-item strong {
  font-size: 0.86rem;
}

.timeline-item span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  white-space: nowrap;
}

body.authenticated #loginScreen {
  display: none;
}

body.authenticated #portalWorkspace {
  display: grid !important;
}

body.unauthenticated #portalWorkspace {
  display: none !important;
}

/* AAA dashboard pass: clearer hierarchy, fewer competing modules above the fold. */
.portal-workspace {
  gap: 1.25rem;
  padding-top: 1.5rem;
}

.workspace-header {
  align-items: center;
  margin-bottom: 0;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(17, 17, 26, 0.58);
}

.workspace-header h1 {
  max-width: 760px;
  font-size: clamp(2.2rem, 4.2vw, 4.6rem);
}

.workspace-actions {
  max-width: 520px;
}

.mission-control {
  grid-template-columns: minmax(0, 1.12fr) minmax(390px, 0.88fr);
  gap: 1.25rem;
  margin-bottom: 0;
}

.mission-hero {
  grid-template-columns: 1fr;
  min-height: 390px;
  padding: clamp(1.25rem, 2.6vw, 2rem);
}

.mission-copy h2 {
  max-width: 820px;
  font-size: clamp(3.1rem, 6vw, 6.4rem);
}

.mission-summary {
  max-width: 680px;
}

.next-action {
  max-width: 620px;
  margin-top: 2rem;
}

.priority-panel {
  grid-row: auto;
  min-height: 390px;
  padding: 1.2rem;
}

.priority-list {
  max-height: 295px;
  overflow: auto;
  padding-right: 0.25rem;
}

.executive-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.kpi-card {
  min-height: 128px;
  padding: 1.1rem;
}

.kpi-card span,
.kpi-card small {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.kpi-card strong {
  display: block;
  margin-top: 0.8rem;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
}

.kpi-card small {
  margin-top: 0.65rem;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.35;
  text-transform: none;
}

.machine-map-panel {
  margin-bottom: 0;
  padding: 1.25rem;
}

.machine-map {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.insight-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 1rem;
}

.handover-panel,
.predictive-panel {
  min-height: 180px;
}

.overview-grid,
.premium-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.premium-grid,
.devices-panel,
.sites-panel,
.alerts-panel {
  margin-top: 0;
}

@media (max-width: 1080px) {
  .login-screen {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .auth-card {
    max-width: 520px;
  }

  .grid,
  .premium-grid,
  .executive-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mission-control,
  .mission-hero,
  .insight-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .shell {
    width: min(100% - 24px, 1280px);
  }

  .topbar,
  .workspace-header,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .language-picker {
    width: 100%;
  }

  .login-screen {
    min-height: auto;
    padding: 2rem 0;
  }

  .login-copy h1 {
    font-size: 3rem;
  }

  .grid,
  .premium-grid,
  .executive-kpis,
  .insight-grid,
  .alerts-grid,
  .sites-grid,
  .machine-map {
    grid-template-columns: 1fr;
  }

  .mission-control {
    grid-template-columns: 1fr;
  }

  .mission-copy h2 {
    font-size: 2.4rem;
  }

  .priority-card {
    grid-template-columns: 1fr;
  }

  .workspace-actions {
    justify-content: stretch;
  }

  .workspace-actions button,
  .workspace-actions .inline {
    width: 100%;
  }

  .stat-row {
    grid-template-columns: 1fr;
  }

  .nodes-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
