:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-tint: #e6f2f0;
  --signal: #c9791a;
  --signal-tint: #fbf0e2;
  --bg: #eef2f0;
  --card-bg: #ffffff;
  --border: #dbe3e0;
  --ink: #16241f;
  --text: #23322d;
  --text-muted: #5f6d67;
  --error: #b91c1c;
  --font-display: "Bahnschrift", "Segoe UI Semibold", "Segoe UI", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Consolas", "SFMono-Regular", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(15, 118, 110, 0.16) 1px, transparent 1.6px);
  background-size: 24px 24px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 48px 16px;
}

.wizard {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 760px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 32px 32px;
  box-shadow: 0 1px 2px rgba(16, 34, 31, 0.05), 0 20px 45px rgba(16, 34, 31, 0.10);
}

.wizard::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--primary);
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.45) 0 2px, transparent 2px 16px);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal);
  margin: 0 0 6px;
}

.wizard-header h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 22px;
}

.steps-indicator {
  position: relative;
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.steps-indicator::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--border);
  transform: translateY(-50%);
}

.step-dot {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.step-dot.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px var(--primary-tint);
}

.wizard-step { display: none; }
.wizard-step.active { display: block; }

.wizard-step h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.wizard-step h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--signal);
  flex-shrink: 0;
}

.field {
  margin-bottom: 18px;
}

.field label, .field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
  color: var(--text);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="number"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--text);
  background: white;
}

.input-mono {
  font-family: var(--font-mono) !important;
  letter-spacing: 0.03em;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

.radio-group {
  display: flex;
  gap: 20px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 0.9rem;
  cursor: pointer;
}

.field-group {
  border-top: 1px dashed var(--border);
  padding-top: 16px;
  margin-bottom: 18px;
}

.field-group h3 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 12px;
  color: var(--primary-dark);
}

.hidden { display: none !important; }

.welcome-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

@media (max-width: 560px) {
  .welcome-cards {
    grid-template-columns: 1fr;
  }
}

.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(16, 34, 31, 0.03);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.welcome-card:hover {
  border-color: var(--primary);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.14);
  transform: translateY(-3px);
}

.welcome-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.welcome-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary-tint);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.welcome-card h3 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 1rem;
  color: var(--ink);
}

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

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.success-message {
  background: #f0fdf6;
  border: 1px solid #b8e6cc;
  color: var(--primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.resumen-cuentas-botones {
  display: flex;
  gap: 10px;
}

.resumen-datos {
  display: grid;
  grid-template-columns: 160px 1fr;
  row-gap: 6px;
  column-gap: 12px;
  margin: 0;
}

.resumen-datos dt {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.resumen-datos dd {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
}

.wizard-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

.wizard-actions-split {
  justify-content: space-between;
}

.wizard-actions-start {
  justify-content: flex-start;
}

.btn-back {
  background: var(--card-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-back:hover {
  background: var(--primary-tint);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.3), 0 6px 14px rgba(15, 118, 110, 0.18);
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.35), 0 8px 18px rgba(15, 118, 110, 0.22);
  transform: translateY(-1px);
}

.step-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  margin-top: 0;
  margin-bottom: 20px;
}

.btn-secondary {
  background: var(--primary-tint);
  color: var(--primary-dark);
  border: 1px dashed var(--primary);
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: #d9ece9;
}

.btn-danger-link {
  background: none;
  border: none;
  color: var(--error);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
}

.nodo-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  background: #fafcfb;
}

.nodo-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.nodo-card-header h4 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.nodo-card-header .badge-gateway {
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.nodo-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.nodo-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 4px;
}

.expansiones-box {
  border-top: 1px dashed var(--border);
  margin-top: 14px;
  padding-top: 12px;
}

.expansiones-box h5 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.port-banner {
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
  padding: 7px 4px;
  letter-spacing: 0.02em;
}

.port-banner.green {
  background: #3fa579;
  border-radius: 6px 6px 0 0;
}

.port-banner.blue {
  background: #3b9eeb;
  border-radius: 6px;
}

.port-banner.pink {
  background: #ec5fa0;
  border-radius: 6px;
}

.port-label-row {
  display: grid;
}

.port-label {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--signal);
  padding-bottom: 4px;
}

.port-grid {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.port-grid.port-grid-banner {
  border-top: none;
  border-radius: 0 0 6px 6px;
}

.port-cell {
  border-right: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.port-cell:last-child {
  border-right: none;
}

.port-cell.blocked {
  background: #eceef0;
  color: #94a0a6;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  padding: 11px 4px;
}

.port-cell.blocked-latch {
  background: #e6d3e1;
  color: #6b4a63;
}

.port-select {
  width: 100%;
  height: 100%;
  position: relative;
}

.port-select-value {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: none;
  padding: 9px 2px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-align: center;
  background: transparent;
  cursor: pointer;
}

.port-select-value:hover {
  filter: brightness(0.97);
}

.port-select-list {
  position: fixed;
  z-index: 1000;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  max-height: 260px;
  overflow-y: auto;
}

.port-select-option {
  padding: 7px 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  background: #ffffff;
  cursor: pointer;
  white-space: nowrap;
}

.port-select-option:hover {
  background: var(--primary-tint);
}

.equipo-card, .sector-card, .valvula-card, .bomba-card, .estanque-card, .valvula-fip-card, .usuario-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  background: #fafcfb;
}

.equipo-card-header, .sector-card-header, .valvula-card-header, .bomba-card-header, .estanque-card-header, .valvula-fip-card-header, .usuario-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.equipo-card-header h4, .sector-card-header h4, .valvula-card-header h4, .bomba-card-header h4, .estanque-card-header h4, .valvula-fip-card-header h4, .usuario-card-header h4 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 36, 31, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

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

.modal-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modal-box h3 {
  font-family: var(--font-display);
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 1.1rem;
}

.modal-box p {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.info-modal-box {
  max-width: 560px;
  max-height: 82vh;
  overflow-y: auto;
}

.info-perfil-section {
  margin-bottom: 18px;
}

.info-perfil-section:last-child {
  margin-bottom: 0;
}

.info-perfil-section h4 {
  font-family: var(--font-display);
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.95rem;
}

.info-perfil-section ul {
  margin: 0;
  padding-left: 18px;
}

.info-perfil-section li {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 2px;
}

.label-with-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.btn-info-icon:hover {
  background: var(--primary);
  color: #ffffff;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 400;
  cursor: pointer;
}
