:root {
  --bg: #071923;
  --surface: #102a36;
  --surface-2: #143543;
  --surface-3: #041017;
  --line: rgba(40, 75, 88, 0.78);
  --line-strong: rgba(40, 75, 88, 0.95);
  --text: #e6f2f5;
  --muted: #91a8b0;
  --cyan: #32d5e8;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, #041017 0%, #071923 48%, #0b202a 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(40, 75, 88, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(40, 75, 88, 0.18) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}

button,
input,
table {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

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

.shell {
  width: min(1520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 38px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 24px 26px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(16, 42, 54, 0.96), rgba(4, 16, 23, 0.96));
  box-shadow: var(--shadow);
}

.eyebrow,
.status-caption,
.status-meta,
.data-source,
.process-meta,
.trend-analysis,
th,
td {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 920px;
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.35rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.operations-status {
  display: grid;
  gap: 12px;
  min-width: 320px;
}

.plant-status,
.status-meta,
.process-section,
.alarms-section,
.history-section,
.alarm-admin-section,
.panel,
.mobile-24h {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 42, 54, 0.94);
  box-shadow: var(--shadow);
}

.plant-status {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}

.status-dot {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 20px currentColor;
}

.status-dot.alerta {
  background: var(--amber);
}

.status-dot.advertencia,
.status-dot.warning {
  background: var(--amber);
}

.status-dot.critico {
  background: var(--red);
}

.status-caption {
  display: block;
  margin-bottom: 4px;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-label {
  display: block;
  font-size: 1.5rem;
  line-height: 1;
}

.status-meta {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  font-size: 0.86rem;
}

.admin-access-button,
.primary-action,
.secondary-action,
.icon-close-button {
  min-height: 38px;
  border: 1px solid rgba(147, 185, 197, 0.22);
  border-radius: 8px;
  background: rgba(20, 53, 67, 0.72);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 850;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.admin-access-button {
  justify-self: end;
  padding: 0 13px;
  color: var(--muted);
}

.admin-access-button:hover,
.secondary-action:hover,
.icon-close-button:hover {
  border-color: rgba(50, 213, 232, 0.5);
  color: var(--text);
}

.primary-action {
  padding: 0 16px;
  border-color: rgba(50, 213, 232, 0.5);
  background: linear-gradient(180deg, rgba(50, 213, 232, 0.24), rgba(20, 53, 67, 0.88));
  color: #d9f7ff;
}

.secondary-action {
  padding: 0 14px;
  color: var(--muted);
}

.icon-close-button {
  width: 38px;
  padding: 0;
  color: var(--muted);
}

.mobile-controls {
  display: grid;
  gap: 10px;
  margin: 8px 0;
}

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

.segmented button {
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid rgba(40, 75, 88, 0.82);
  border-radius: 8px;
  background: #102a36;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.segmented button.is-active {
  border-color: #284b58;
  color: var(--text);
  background: #143543;
  box-shadow: inset 0 0 0 1px rgba(50, 213, 232, 0.16);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.process-section,
.alarms-section,
.history-section,
.alarm-admin-section,
.mobile-24h {
  padding: 18px;
  margin-bottom: 18px;
}

.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.alarm-admin-section {
  background: linear-gradient(180deg, rgba(16, 42, 54, 0.96), rgba(4, 16, 23, 0.94));
}

.admin-subsection {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 13, 18, 0.28);
}

.admin-subsection > h3 {
  margin-bottom: 14px;
  color: var(--cyan);
}

.profile-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.profile-card-heading h3 {
  color: var(--cyan);
}

.profile-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.profile-status-badge .status-dot {
  width: 12px;
  height: 12px;
  flex-basis: 12px;
}

.profile-facts,
.compact-facts {
  margin-bottom: 0;
}

.operation-target {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid rgba(147, 185, 197, 0.12);
  border-radius: 8px;
  background: rgba(3, 13, 18, 0.24);
}

.operation-target p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.system-facts {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
}

.system-facts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(147, 185, 197, 0.12);
}

.system-facts dt { color: var(--muted); }
.system-facts dd { margin: 0; font-weight: 800; text-align: right; }

.danger-action {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(239, 68, 68, 0.55);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  font-weight: 850;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

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

.future-options button {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.future-options span { display: block; margin-top: 4px; font-size: .7rem; color: var(--cyan); }

.admin-note {
  max-width: 920px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.import-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.file-picker {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 850;
}

.file-picker input {
  min-height: 42px;
  padding: 7px;
  border: 1px solid rgba(147, 185, 197, .22);
  border-radius: 8px;
  background: rgba(3, 13, 18, .44);
  color: var(--text);
}

.file-picker input::file-selector-button {
  margin-right: 10px;
  padding: 7px 11px;
  border: 1px solid rgba(50, 213, 232, .4);
  border-radius: 6px;
  background: rgba(50, 213, 232, .12);
  color: var(--text);
  cursor: pointer;
}

.import-progress-panel {
  margin-top: 16px;
}

.import-progress-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .84rem;
}

.import-progress-panel progress {
  width: 100%;
  height: 15px;
  accent-color: var(--cyan);
}

.legacy-cleanup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 10px;
}

.implementation-identity {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.78rem;
}

.implementation-identity strong {
  color: var(--text);
}

.legacy-cleanup-facts {
  margin-top: 14px;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
}

.import-summary div {
  padding: 12px;
  border: 1px solid rgba(147, 185, 197, .14);
  border-radius: 8px;
  background: rgba(3, 13, 18, .32);
}

.import-summary dt {
  color: var(--muted);
  font-size: .76rem;
}

.import-summary dd {
  margin: 5px 0 0;
  font-size: 1.15rem;
  font-weight: 850;
}

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

.import-preview div {
  min-width: 0;
}

.import-preview h4 {
  margin: 0 0 10px;
  color: var(--text);
}

.import-preview pre {
  max-height: 360px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid rgba(147, 185, 197, .14);
  border-radius: 8px;
  background: rgba(3, 13, 18, .38);
  color: #dbeafe;
  font-size: .74rem;
  line-height: 1.45;
}

.import-errors {
  margin-top: 18px;
}

.import-errors h4 {
  margin: 0 0 10px;
  color: var(--red);
}

.import-errors-table {
  min-width: 620px;
}

.import-errors-table td:last-child {
  color: #fca5a5;
}

.alarm-config-table-wrap {
  overflow-x: auto;
}

.alarm-config-table {
  min-width: 980px;
}

.alarm-config-table td:first-child {
  min-width: 190px;
}

.limit-input {
  width: 112px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(147, 185, 197, 0.18);
  border-radius: 8px;
  background: rgba(3, 13, 18, 0.44);
  color: var(--text);
  outline: none;
}

.limit-input:focus {
  border-color: rgba(50, 213, 232, 0.68);
  box-shadow: 0 0 0 2px rgba(50, 213, 232, 0.12);
}

.alarm-config-table tr.has-error td {
  background: rgba(239, 68, 68, 0.08);
}

.alarm-config-table tr.has-error .limit-input {
  border-color: rgba(239, 68, 68, 0.72);
}

.normal-range {
  display: inline-flex;
  min-width: 104px;
  padding: 8px 10px;
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 8px;
  color: var(--green);
  background: rgba(34, 197, 94, 0.08);
  font-size: 0.82rem;
  font-weight: 850;
}

.alarm-admin-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.admin-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 16, 23, 0.78);
  backdrop-filter: blur(8px);
}

.admin-password-panel {
  width: min(430px, 100%);
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(16, 42, 54, 0.98), rgba(4, 16, 23, 0.98));
  box-shadow: var(--shadow);
}

.admin-password-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.admin-password-field input {
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid rgba(147, 185, 197, 0.22);
  border-radius: 8px;
  background: rgba(3, 13, 18, 0.44);
  color: var(--text);
  outline: none;
}

.admin-password-field input:focus {
  border-color: rgba(50, 213, 232, 0.68);
  box-shadow: 0 0 0 2px rgba(50, 213, 232, 0.12);
}

.process-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(145px, 1fr));
  gap: 12px;
}

.process-node {
  position: relative;
  z-index: 0;
  min-height: 154px;
  padding: 17px;
  border: 1px solid rgba(40, 75, 88, 0.82);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(20, 53, 67, 0.94), rgba(7, 25, 35, 0.94));
  text-align: left;
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease, outline-color 200ms ease;
}

.process-node::after {
  position: absolute;
  top: 50%;
  right: -13px;
  width: 13px;
  height: 2px;
  content: "";
  background: rgba(50, 213, 232, 0.34);
}

.process-node:last-child::after {
  display: none;
}

.process-node.normal {
  border-color: rgba(34, 197, 94, 0.32);
}

.process-node.alerta {
  border-color: rgba(245, 158, 11, 0.42);
}

.process-node.advertencia,
.process-node.warning {
  border-color: rgba(245, 158, 11, 0.42);
}

.process-node.critico {
  border-color: rgba(239, 68, 68, 0.48);
}

.process-node.is-selected {
  z-index: 1;
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  transform: scale(1.04);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.34), 0 0 18px rgba(50, 213, 232, 0.12);
}

.process-name {
  display: block;
  margin-bottom: 11px;
  color: var(--text);
  font-size: 1.04rem;
  font-weight: 850;
}

.process-state,
.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.process-state {
  gap: 7px;
  margin-bottom: 14px;
  padding: 6px 9px;
}

.process-state::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  content: "";
  background: currentColor;
}

.normal {
  color: var(--green);
}

.alerta {
  color: var(--amber);
}

.advertencia,
.warning {
  color: var(--amber);
}

.critico {
  color: var(--red);
}

.process-meta,
.process-value {
  display: block;
}

.process-alarm-summary {
  display: block;
  min-height: 30px;
  margin-top: 8px;
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.35;
}

.process-meta {
  font-size: 0.78rem;
}

.process-value {
  margin-top: 5px;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
}

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

.trend-group-title {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding: 8px 2px 0;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel {
  min-width: 0;
  padding: 17px;
  background: rgba(16, 42, 54, 0.94);
}

.wide-panel {
  grid-column: 1 / -1;
}

.chart-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-heading span {
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 850;
}

.chart-box {
  position: relative;
  height: 270px;
}

.trend-analysis {
  min-height: 22px;
  margin: 12px 0 0;
  font-size: 0.9rem;
  font-weight: 800;
}

.trend-analysis.up {
  color: var(--cyan);
}

.trend-analysis.down {
  color: var(--amber);
}

.trend-analysis.stable {
  color: var(--green);
}

.trend-analysis.alarm-status.warning {
  color: var(--amber);
}

.trend-analysis.alarm-status.alarm {
  color: #ef4444;
}

.trend-analysis.alarm-status.normal {
  color: var(--green);
}

.data-source {
  padding: 7px 10px;
  border: 1px solid rgba(147, 185, 197, 0.22);
  border-radius: 999px;
  background: rgba(20, 53, 67, 0.72);
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.alarms-list {
  display: grid;
  gap: 9px;
}

.alarm-row {
  display: grid;
  grid-template-columns: 72px 130px minmax(160px, 1fr) 92px minmax(220px, 1.5fr);
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid rgba(147, 185, 197, 0.12);
  border-radius: 8px;
  background: rgba(3, 13, 18, 0.34);
}

.alarm-row time,
.alarm-row span,
.alarm-row p {
  color: var(--muted);
  font-size: 0.84rem;
}

.alarm-row strong {
  color: var(--text);
  font-size: 0.88rem;
}

.alarm-row p {
  margin-bottom: 0;
}

.empty-state {
  margin-bottom: 0;
  color: var(--muted);
}

.mobile-24h {
  display: none;
}

.mobile-counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mobile-counts span {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid rgba(147, 185, 197, 0.16);
  border-radius: 8px;
  color: var(--muted);
}

.mobile-counts strong {
  color: var(--text);
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(147, 185, 197, 0.12);
  text-align: left;
  font-size: 0.84rem;
}

th {
  color: #d9f7ff;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: #e8f8fc;
}

.state-pill {
  min-width: 80px;
  padding: 5px 8px;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .operations-status {
    min-width: 0;
  }

  .process-map {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .process-node::after {
    display: none;
  }

  .alarm-row {
    grid-template-columns: 68px 120px minmax(140px, 1fr) 90px;
  }

  .alarm-row p {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  body::before {
    display: none;
  }

  .shell {
    width: min(100% - 24px, 1520px);
    padding-top: 8px;
    padding-bottom: 14px;
  }

  .topbar {
    gap: 8px;
    padding: 10px 12px;
  }

  .brand-block .eyebrow {
    margin-bottom: 3px;
    font-size: 0.64rem;
  }

  h1 {
    font-size: 1.08rem;
    line-height: 1.08;
  }

  .operations-status {
    gap: 6px;
  }

  .admin-access-button {
    justify-self: stretch;
    min-height: 34px;
    font-size: 0.72rem;
  }

  .plant-status {
    gap: 9px;
    padding: 9px 10px;
  }

  .status-dot {
    width: 12px;
    height: 12px;
    flex-basis: 12px;
  }

  .status-caption {
    margin-bottom: 2px;
    font-size: 0.62rem;
  }

  .status-label {
    font-size: 1rem;
  }

  .status-meta {
    gap: 2px;
    padding: 8px 10px;
    font-size: 0.68rem;
  }

  .desktop-only,
  .desktop-heading {
    display: none;
  }

  .process-section {
    padding: 14px 12px;
  }

  .alarm-admin-section {
    padding: 14px;
  }

  .admin-grid,
  .future-options,
  .import-summary,
  .import-preview {
    grid-template-columns: 1fr;
  }

  .import-controls {
    grid-template-columns: 1fr;
  }

  .alarm-admin-section .section-heading,
  .admin-password-panel .section-heading {
    align-items: flex-start;
  }

  .alarm-admin-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .admin-note {
    font-size: 0.82rem;
  }

  .limit-input {
    width: 96px;
  }

  .process-section .section-heading {
    margin-bottom: 12px;
  }

  .process-map {
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 100%;
    gap: 10px;
    margin: 0;
    padding: 6px 4px 14px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 4px;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: rgba(50, 213, 232, 0.42) rgba(3, 13, 18, 0.28);
    -webkit-overflow-scrolling: touch;
  }

  .process-node {
    width: 100%;
    min-width: 0;
    min-height: 142px;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .process-node.is-selected {
    transform: none;
  }

  .process-alarm-summary,
  .process-value,
  .process-name {
    overflow-wrap: anywhere;
  }

  .charts-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .trend-group-title {
    margin-top: 2px;
    padding-top: 4px;
    font-size: 0.7rem;
  }

  .panel {
    padding: 13px;
  }

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

  .chart-box {
    height: 230px;
  }

  .chart-heading h3 {
    font-size: 0.96rem;
  }

  .mobile-24h {
    display: block;
    padding: 14px;
  }

  .alarms-section {
    padding: 14px;
  }

  .alarm-row {
    grid-template-columns: 58px minmax(0, 1fr) 82px;
    gap: 8px;
  }

  .alarm-row span:not(.state-pill) {
    grid-column: 1 / -1;
  }

  .alarm-row p {
    grid-column: 1 / -1;
    font-size: 0.8rem;
  }
}
