* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  background: #00538d;
  color: #0f172a;
}

.brand-topbar {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 18px 0;
  display: flex;
  align-items: center;
}

.brand-logo {
  height: 56px;
  width: auto;
  object-fit: contain;
  mix-blend-mode: screen;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.login-overlay.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.login-card {
  width: min(420px, 92vw);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #dbe3ee;
  padding: 18px;
  display: grid;
  gap: 10px;
}

.login-card h2 {
  margin: 0;
}

.login-card p {
  color: #64748b;
  margin-bottom: 6px;
}

.login-card label {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.login-card input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
}

.login-card small {
  min-height: 18px;
  color: #dc2626;
}

.layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 18px;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(320px, 1fr);
  gap: 18px;
}

.main-panel,
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
}

h2,
h3 {
  margin: 0 0 8px;
}

p {
  margin: 0;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.app-header p {
  color: #475569;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.toolbar-spacer {
  margin-left: auto;
}

.machine-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #334155;
}

.machine-select-wrap select {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 180px;
  background: #fff;
}

.language-flags {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.flag-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #111827;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 22px 22px;
}

.flag-btn.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.flag-es {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Crect width='24' height='24' fill='%23c60b1e'/%3E%3Crect y='6' width='24' height='12' fill='%23ffc400'/%3E%3C/svg%3E");
}

.flag-en {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Crect width='24' height='24' fill='%23012169'/%3E%3Cpath d='M0 0 24 24M24 0 0 24' stroke='%23fff' stroke-width='5'/%3E%3Cpath d='M0 0 24 24M24 0 0 24' stroke='%23c8102e' stroke-width='2.5'/%3E%3Cpath d='M12 0v24M0 12h24' stroke='%23fff' stroke-width='7'/%3E%3Cpath d='M12 0v24M0 12h24' stroke='%23c8102e' stroke-width='3.5'/%3E%3C/svg%3E");
}

button {
  border: none;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  transition: 0.18s ease;
}

button:hover {
  filter: brightness(0.96);
}

.secondary {
  background: #6b7280;
}

.ghost {
  background: #e2e8f0;
  color: #0f172a;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 600;
  padding: 9px 14px;
  text-decoration: none;
  font-size: 14px;
}

.danger {
  background: #dc2626;
}

.danger.active {
  background: #991b1b;
}

.status-pill {
  background: #e2e8f0;
  color: #334155;
  font-size: 13px;
  border-radius: 999px;
  padding: 6px 11px;
}

.state-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

.state-card h2 {
  font-size: 36px;
  margin-bottom: 4px;
}

.state-card p {
  color: #475569;
}

.mode-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mode-headline {
  font-size: 30px;
  font-weight: 700;
  color: #16a34a;
  margin: 2px 0 8px;
}

.badges {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: #2563eb;
  color: #fff;
}

.badge-dark {
  background: #111827;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.section-title-row small {
  color: #64748b;
}

.history-controls {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.history-controls input[type="datetime-local"] {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}

.history-bar {
  display: flex;
  height: 56px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid #dbe3ee;
  background: #f8fafc;
  margin-top: 10px;
}

.history-x-axis {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #64748b;
  font-size: 11px;
  padding: 0 2px;
}

.history-block {
  flex: 1 1 auto;
  min-width: 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.35);
}

.legend {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: #334155;
  font-size: 12px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  display: inline-block;
}

.hint {
  color: #64748b;
  padding: 10px 12px;
}

.split-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 14px;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.history-pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
}

.side-panel .controls small {
  color: #64748b;
}

.side-panel .controls {
  background: #ffffff;
  border-color: #ffffff;
}

.buttons-column {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.remote-control-grid {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.remote-action {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.remote-label {
  font-size: 30px;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
}

.remote-icon-btn {
  width: 76px;
  height: 76px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  line-height: 1;
  padding: 0;
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.22);
}

.remote-power-btn {
  background: radial-gradient(circle at 35% 35%, #ff6b6b 0%, #e10600 68%);
}

.remote-power-btn.active {
  background: radial-gradient(circle at 35% 35%, #4ade80 0%, #15803d 68%);
}

.remote-restart-btn {
  background: radial-gradient(circle at 35% 35%, #f7f08e 0%, #d3cc21 68%);
  color: #ffffff;
  font-size: 46px;
  font-weight: 700;
}

.info-list {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.info-list dt {
  font-size: 12px;
  color: #64748b;
}

.info-list dd {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #1e293b;
}

.admin-subtitle {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 10px;
}

.admin-form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-form label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: #334155;
}

.admin-form input,
.admin-form select {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px;
}

.admin-users-wrap h4 {
  margin: 4px 0 8px;
}

.chart-wrap {
  width: 100%;
  height: 320px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #ffffff;
}

.chart-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

#s7Chart {
  width: 100%;
  height: 100%;
}

#s7AnalogRows tr {
  cursor: pointer;
}

#s7AnalogRows tr.selected {
  background: #e0ecff;
}

.synoptic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.synoptic-item {
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
}

.synoptic-item strong {
  display: block;
  margin-bottom: 4px;
}

.synoptic-hmi {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #eef2f7;
}

.syn-status-strip {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 10px;
}

.syn-header-mode {
  background: #14b8a6;
  color: #0b1220;
  border-radius: 8px;
  text-align: center;
  font-weight: 800;
  padding: 8px 6px;
}

.syn-header-state {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  text-align: center;
  font-weight: 700;
  padding: 8px 6px;
}

.syn-canvas {
  position: relative;
  width: 100%;
  max-width: 980px;
  aspect-ratio: 1004 / 527;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  margin: 0 auto;
  background: #f8fafc;
}

.syn-base-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.syn-custom-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.syn-custom-point {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  pointer-events: auto;
}

.syn-custom-dot {
  border-radius: 999px;
  border: 2px solid #0f172a;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.syn-custom-label {
  display: none;
}

.syn-editor-canvas {
  position: relative;
  width: 100%;
  max-width: 1500px;
  aspect-ratio: 1004 / 527;
  margin: 0 auto;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.syn-custom-point-editor {
  cursor: grab;
}

.syn-custom-point-text {
  transform: translate(0, -50%);
}

.syn-custom-text {
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border: 2px solid #94a3b8;
  border-radius: 8px;
  padding: 3px 8px;
  white-space: nowrap;
}

.editor-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
}

.editor-threshold-row {
  display: grid;
  grid-template-columns: 1fr 1fr 120px auto;
  gap: 8px;
  margin-bottom: 6px;
}

.editor-point-list {
  max-height: 380px;
  overflow: auto;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
}

.editor-point-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  position: relative;
  width: 50px;
  height: 28px;
  display: inline-block;
}

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

.switch-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: 0.2s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  transition: 0.2s ease;
}

.switch input:checked + .switch-slider {
  background: #22c55e;
}

.switch input:checked + .switch-slider::before {
  transform: translateX(22px);
}

.syn-node,
.syn-custom-point {
  position: relative;
}

.syn-node:hover::after,
.syn-custom-point:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #94a3b8;
  border-radius: 8px;
  padding: 4px 8px;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
  pointer-events: none;
}

.syn-value {
  position: absolute;
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #94a3b8;
  border-radius: 999px;
  padding: 2px 7px;
}

.syn-value-redox {
  left: 29%;
  top: 13%;
}

.syn-value-desinc {
  left: 40%;
  top: 13%;
}

.syn-value-ph {
  left: 49%;
  top: 13%;
}

.syn-node {
  position: absolute;
  z-index: 2;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #1e293b;
  background: rgba(148, 163, 184, 0.7);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
  opacity: 0;
}

.syn-node.active {
  border-color: #166534;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), 0 0 0 8px rgba(34, 197, 94, 0.25);
  opacity: 1;
}

.syn-node.alert {
  border-color: #991b1b;
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), 0 0 0 8px rgba(239, 68, 68, 0.25);
  opacity: 1;
}

.syn-pret {
  left: 20%;
  top: 35%;
}
.syn-vme {
  left: 9.5%;
  top: 28%;
}
.syn-filtro {
  left: 20.2%;
  top: 29%;
}
.syn-drx {
  left: 29%;
  top: 26%;
}
.syn-dds {
  left: 39%;
  top: 26%;
}
.syn-dph {
  left: 47.5%;
  top: 26%;
}
.syn-balta {
  left: 14.8%;
  top: 56%;
}
.syn-ro1 {
  left: 31%;
  top: 57%;
}
.syn-balta2 {
  left: 50.5%;
  top: 57%;
}
.syn-ro2 {
  left: 61.5%;
  top: 57%;
}
.syn-vmf2 {
  left: 66%;
  top: 34.5%;
}
.syn-vmf1 {
  left: 76.5%;
  top: 34.5%;
}
.syn-vmd {
  left: 73.5%;
  top: 51.5%;
}
.syn-dep-perm {
  left: 79.5%;
  top: 52%;
}
.syn-dep-flush {
  left: 89%;
  top: 62.5%;
}
.syn-bflush {
  left: 54%;
  top: 74%;
}

.syn-legend {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #334155;
}

.syn-legend span {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 4px 8px;
}

@media (max-width: 1000px) {
  .syn-status-strip {
    grid-template-columns: 1fr;
  }

  .syn-canvas {
    max-width: 100%;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

th,
td {
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  padding: 10px;
  font-size: 13px;
}

th {
  background: #f8fafc;
  color: #334155;
}

dialog {
  border: 1px solid #d1d5db;
  border-radius: 12px;
  width: min(450px, 90%);
}

.plant-form {
  display: grid;
  gap: 10px;
}

.plant-form label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: #334155;
}

.plant-form input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

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

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

  .state-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }
}

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

.simulator-signals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.simulator-signals label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: #334155;
}

.simulator-signals input {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px;
}

.simulator-console {
  margin: 0;
  min-height: 180px;
  max-height: 380px;
  overflow: auto;
  background: #0f172a;
  color: #a7f3d0;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
}
