:root {
  --primary: #146c94;
  --primary-dark: #0f5878;
  --accent: #01696f;
  --accent-soft: #e6f3f4;
  --ink: #0f1d28;
  --muted: #526572;
  --border: #d5e0ea;
  --panel-bg: #ffffff;
  /* Acentos para tarjetas de métricas del admin */
  --stat-blue: #2563eb;
  --stat-teal: #0d9488;
  --stat-violet: #7c3aed;
  --stat-slate: #475569;
  --stat-red: #dc2626;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at 1px 1px, rgba(20, 108, 148, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #f7f9ff 0%, #eef4fb 100%);
  background-size: 18px 18px, auto;
  color: #0f1d28;
  overflow-x: hidden;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

img,
svg {
  max-width: 100%;
}

.page {
  display: flex;
  justify-content: center;
  padding: 28px 16px 48px;
}

.panel {
  width: min(1024px, 100%);
  background: #ffffff;
  border: 1px solid #d5e0ea;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(26, 52, 77, 0.08);
  padding: 28px;
}

.page-wide {
  padding: 26px 0 48px;
}

.creation-panel {
  width: min(1500px, calc(100% - 32px));
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.creation-form {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.creation-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.creation-form .form-section {
  min-width: 0;
  padding: 0;
  overflow: visible;
  border-color: #d5e0ea;
  background: rgba(247, 249, 255, 0.88);
  box-shadow: 0 8px 22px rgba(26, 52, 77, 0.05);
}

.creation-form .form-section > h2 {
  margin: 0;
  padding: 13px 16px;
  border-bottom: 1px solid #d5e0ea;
  color: #142633;
  font-size: 1rem;
  font-weight: 600;
}

.section-icon {
  display: inline-grid;
  width: 22px;
  margin-right: 4px;
  place-items: center;
  color: #005374;
}

.destination-card > .field-grid,
.destination-card > .helper-text,
.connectivity-card > .field-grid {
  margin: 16px;
}

.field-grid {
  display: grid;
  gap: 14px 18px;
}

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

.field-grid label {
  min-width: 0;
  margin: 0;
}

.full-field {
  grid-column: 1 / -1;
}

.autofill-box {
  margin: 18px 16px 14px;
  padding: 18px 16px 14px;
  border: 1px solid #d5e0ea;
  border-radius: 10px;
  background: rgba(237, 244, 255, 0.72);
}

.autofill-box legend {
  padding: 0 8px;
  color: #0f1d28;
  font-weight: 700;
}

.creation-form label {
  font-size: 0.88rem;
}

.creation-form input,
.creation-form select,
.creation-form textarea,
.creation-form .search-select-trigger {
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 3px;
}

.creation-form input,
.creation-form select,
.creation-form .search-select-trigger {
  min-height: 44px;
}

.info-callout,
.tip-callout {
  display: flex;
  margin: 16px 0 0;
  padding: 14px 16px;
  align-items: flex-start;
  gap: 12px;
  border-top: 1px solid #d5e0ea;
  background: #edf4ff;
  color: #263d4c;
  line-height: 1.45;
}

.info-callout span,
.tip-callout span {
  flex: 0 0 auto;
  color: #005374;
  font-size: 1.1rem;
}

.equipment-card {
  grid-column: 1 / -1;
}

.equipment-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(460px, 1.2fr);
  gap: 26px;
  padding: 20px;
}

.equipment-description label,
.terminal-textarea-label {
  min-width: 0;
  margin: 0;
}

.equipment-description textarea,
.terminal-description textarea {
  min-height: 250px;
  background: #fff;
  line-height: 1.55;
}

.equipment-description,
.terminal-description,
.devices-panel {
  min-width: 0;
}

.devices-heading {
  display: flex;
  min-height: 47px;
  margin-bottom: 12px;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.devices-heading p {
  margin: 5px 0 0;
  color: #526572;
  font-size: 0.82rem;
  font-style: italic;
  overflow-wrap: anywhere;
}

.add-row-button {
  display: inline-flex;
  padding: 9px 14px;
  align-items: center;
  gap: 8px;
  border: 1px solid #9ec3d9;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #edf5fb 100%);
  color: #005374;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 83, 116, 0.1);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.add-row-button:hover {
  background: linear-gradient(180deg, #ffffff 0%, #e3f0f8 100%);
  box-shadow: 0 4px 12px rgba(0, 83, 116, 0.16);
  transform: translateY(-1px);
}

.add-row-button:active {
  transform: translateY(0);
}

.add-row-emoji {
  font-size: 1rem;
  line-height: 1;
}

.device-columns {
  display: grid;
  grid-template-columns: 0.95fr 1.35fr 0.55fr 0.8fr 34px;
  gap: 12px;
  margin: 0 10px 7px;
  color: #344b5a;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.device-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-row {
  display: grid;
  grid-template-columns: 0.95fr 1.35fr 0.55fr 0.8fr 34px;
  gap: 10px;
  padding: 10px;
  align-items: center;
  border: 1px solid #d5e0ea;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 3px 9px rgba(26, 52, 77, 0.04);
}

.device-model-field {
  min-width: 0;
}

.device-model-field input,
.device-model-field select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: 9px 10px;
}

.device-row input,
.device-row select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: 9px 10px;
}

.remove-device,
.remove-terminal {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid #e8c8c8;
  border-radius: 50%;
  background: #fff5f5;
  color: #b42318;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.remove-device:hover,
.remove-terminal:hover {
  background: #fde8e8;
  border-color: #d9a3a3;
}

.tip-callout {
  margin-top: 12px;
  border-top: 0;
  border-left: 4px solid #bccbda;
  border-radius: 7px;
}

.terminal-heading {
  display: flex;
  min-height: 47px;
  margin-bottom: 12px;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.terminal-heading p {
  margin: 5px 0 0;
  color: #526572;
  font-size: 0.82rem;
  font-style: italic;
  overflow-wrap: anywhere;
}

.terminal-columns {
  display: grid;
  grid-template-columns: 1fr 0.9fr 0.6fr 0.9fr 0.9fr 0.75fr 0.65fr 34px;
  gap: 10px;
  margin: 0 10px 7px;
  color: #344b5a;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.terminal-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.terminal-row {
  display: grid;
  grid-template-columns: 1fr 0.9fr 0.6fr 0.9fr 0.9fr 0.75fr 0.65fr 34px;
  gap: 10px;
  padding: 10px;
  align-items: center;
  border: 1px solid #d5e0ea;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 3px 9px rgba(26, 52, 77, 0.04);
}

.terminal-row input,
.terminal-row select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: 9px 10px;
}

.dect-base-field.is-hidden {
  opacity: 0.35;
  pointer-events: none;
}

.advanced-fields {
  min-width: 0;
  padding: 13px 16px;
  border: 1px solid #d5e0ea;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
}

.advanced-fields summary {
  color: #315268;
  font-weight: 700;
  cursor: pointer;
}

.advanced-fields-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr;
  gap: 18px;
  margin-top: 16px;
}

.import-offer-card {
  border: 2px solid #b8d4e8;
  background: linear-gradient(180deg, #f7fbff 0%, #ffffff 100%);
}

.paste-bar-wrap {
  margin-bottom: 18px;
  padding: 12px;
  border: 2px solid #146c94;
  border-radius: 12px;
  background: #eef7ff;
}

.paste-bar {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.paste-bar textarea {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  max-height: 120px;
  margin: 0;
  padding: 10px 14px;
  border: 2px solid #7eb8dc;
  border-radius: 10px;
  background: #fff;
  font: inherit;
  line-height: 1.35;
  resize: none;
  overflow-y: auto;
  box-sizing: border-box;
}

.paste-bar textarea:focus {
  outline: none;
  border-color: #146c94;
  box-shadow: 0 0 0 3px rgba(20, 108, 148, 0.15);
}

.paste-bar-button {
  flex: 0 0 auto;
  min-width: 120px;
  padding: 0 24px;
  border: none;
  border-radius: 10px;
  background: #146c94;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.paste-bar-button:hover {
  background: #0f5878;
}

.paste-bar-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.paste-bar-status {
  margin: 6px 0 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: #1f5f3f;
}

.paste-bar-status:empty {
  display: none;
}

.paste-bar-status.is-warn {
  color: #9a3412;
}

.glpi-suggestions {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #f0c987;
  border-radius: 10px;
  background: #fffaf0;
}

.glpi-suggestions-title {
  margin: 0 0 10px;
  color: #9a3412;
  font-size: 0.88rem;
  font-weight: 700;
}

.glpi-suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.glpi-suggestion-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e8c88a;
  border-radius: 10px;
  background: #fff;
  color: #0f1d28;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.glpi-suggestion-card:hover {
  border-color: #146c94;
  background: #f7fbff;
  box-shadow: 0 4px 12px rgba(20, 108, 148, 0.12);
}

.glpi-suggestion-card strong {
  font-size: 0.92rem;
  color: #0f5878;
}

.glpi-suggestion-meta {
  color: #526572;
  font-size: 0.78rem;
  line-height: 1.35;
}

.glpi-suggestion-address {
  color: #526572;
  font-size: 0.8rem;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .glpi-suggestion-card {
    min-height: 44px;
  }
}

.paste-offer-top {
  margin-bottom: 20px;
  padding: 18px 20px 16px;
  border: 2px solid #7eb8dc;
  border-radius: 12px;
  background: linear-gradient(180deg, #eef7ff 0%, #ffffff 100%);
}

.paste-offer-top-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin-bottom: 10px;
}

.paste-offer-top-head h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #1a4a6e;
}

.paste-offer-top textarea {
  width: 100%;
  min-height: 140px;
  margin: 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.45;
  border-radius: 8px;
  border: 1px solid #b8d0e2;
  padding: 12px;
  box-sizing: border-box;
}

.paste-offer-top-actions {
  margin-top: 12px;
}

.paste-fill-button {
  min-width: 140px;
  font-size: 1.05rem;
  font-weight: 700;
}

.import-offer-card textarea {
  min-height: 220px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.45;
}

.import-offer-card kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid #c5d5e2;
  border-radius: 4px;
  background: #fff;
  font-size: 0.85em;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.import-hint {
  margin-top: 4px;
}

.import-status:not(:empty) {
  margin-top: 10px;
  font-weight: 600;
  color: #1f5f3f;
}

.import-advanced {
  margin-top: 12px;
}

.import-warnings {
  margin: 8px 0 0;
  padding-left: 1.2rem;
  color: #8a5a00;
}

.creation-actions {
  display: flex;
  padding: 14px 0 0;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.button.quiet {
  background: transparent;
  color: #0f1d28;
}

.creation-actions .button.primary {
  padding-inline: 28px;
  box-shadow: 0 7px 18px rgba(20, 108, 148, 0.2);
}

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

.panel-header {
  margin-bottom: 22px;
}

.panel-header h1 {
  margin-bottom: 6px;
  font-size: clamp(1.55rem, 3vw, 2rem);
  letter-spacing: -0.025em;
}

.panel-header p {
  margin: 0;
  color: #526572;
}

.panel-header h1,
.form-section h2,
.message h2,
.warnings h3 {
  margin-top: 0;
}

.app-brand {
  margin-bottom: 18px;
}

.app-brand img {
  display: block;
  width: 180px;
  max-width: 60%;
  height: auto;
}

.topbar {
  position: sticky;
  z-index: 100;
  top: 0;
  width: 100%;
  border-bottom: 1px solid #d5e0ea;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 28px rgba(26, 52, 77, 0.09);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  display: flex;
  width: min(1180px, calc(100% - 32px));
  min-height: 66px;
  margin: 0 auto;
  align-items: center;
  gap: 24px;
}

.topbar-brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}

.topbar-brand img {
  display: block;
  width: 132px;
  height: auto;
}

.topbar-nav {
  display: flex;
  min-width: 0;
  align-self: stretch;
  align-items: stretch;
  gap: 4px;
  scrollbar-width: thin;
}

.topbar-link {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 3px solid transparent;
  color: #405563;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.topbar-link:hover {
  background: #e8f0f6;
  color: #005374;
}

.topbar-link.active {
  border-bottom-color: #005374;
  color: #005374;
}

.topbar-actions {
  display: flex;
  min-width: 0;
  margin-left: auto;
  align-items: center;
  gap: 8px;
}

.topbar-actions form {
  margin: 0;
}

.topbar-search {
  position: relative;
  display: flex;
  width: min(220px, 22vw);
  margin: 0;
  align-items: center;
}

.topbar-search span {
  position: absolute;
  z-index: 1;
  left: 12px;
  color: #6e7e89;
  font-size: 0.85rem;
}

.topbar-search input {
  height: 36px;
  margin: 0;
  padding: 7px 14px 7px 34px;
  border-radius: 999px;
  background: #f7f9ff;
  font-size: 0.82rem;
}

.technician-pill {
  max-width: 145px;
  overflow: hidden;
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf4ff;
  color: #315268;
  font-size: 0.78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #405563;
  font-size: 1.05rem;
  cursor: pointer;
}

.icon-button:hover {
  background: #e8f0f6;
  color: #005374;
}

.login-brand {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 26px;
  color: #446176;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-brand img {
  width: min(330px, 90%);
  height: auto;
}

.technician-bar,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #e8f0f6;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #0d5f7e;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.app-tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0 20px;
  border-bottom: 1px solid #ccd8e2;
}

.app-tab {
  padding: 10px 16px;
  color: #315268;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  font-weight: 700;
}

.app-tab.active {
  color: #0d5f7e;
  border-bottom-color: #0d789e;
}

.upload-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.diagram-table-wrap {
  overflow-x: auto;
  border: 1px solid #d5e0ea;
  border-radius: 10px;
  background: #fff;
}

.diagram-table {
  width: 100%;
  border-collapse: collapse;
}

.diagram-table th,
.diagram-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #d5e0ea;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.diagram-table th {
  background: #edf4ff;
  color: #405563;
  font-size: 0.72rem;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.diagram-table tbody tr {
  transition: background 140ms ease;
}

.diagram-table tbody tr:hover {
  background: #f7faff;
}

.diagram-table tbody tr:last-child td {
  border-bottom: 0;
}

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

.form-section {
  background: #ffffff;
  border: 1px solid #d5e0ea;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 5px 16px rgba(26, 52, 77, 0.04);
}

.form-section h2 {
  padding-bottom: 10px;
  border-bottom: 1px solid #d5e0ea;
  color: #005374;
  font-size: 1.15rem;
}

.form-section.full,
.actions {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 14px;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid #bccbda;
  border-radius: 7px;
  font: inherit;
  box-sizing: border-box;
  background: #fff;
  max-width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #01658d;
  outline: 2px solid rgba(1, 101, 141, 0.12);
}

textarea {
  resize: vertical;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

.search-select {
  position: relative;
  margin-top: 8px;
  font-weight: 400;
}

.search-select-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid #bccbda;
  border-radius: 10px;
  background: #fff;
  color: #111;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.search-select.disabled .search-select-trigger {
  background: #f4f6f8;
  color: #7b8791;
  cursor: not-allowed;
}

.search-select-arrow {
  margin-left: 12px;
}

.search-select-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  display: none;
  width: 100%;
  overflow: hidden;
  border: 1px solid #bccbda;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(25, 48, 68, 0.2);
}

.search-select.open .search-select-menu {
  display: block;
}

.search-select-filter {
  width: calc(100% - 16px);
  margin: 8px;
  padding: 9px 10px;
  border-radius: 6px;
}

.search-select-options {
  max-height: 230px;
  overflow-y: auto;
  border-top: 1px solid #e0e7ed;
}

.search-select-option {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.search-select-option:hover,
.search-select-option:focus {
  background: #e8f0fb;
}

.search-select-empty {
  padding: 12px 14px;
  color: #6b7780;
}

.actions {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.button {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 999px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-weight: 700;
}

.button.primary {
  background: #146c94;
  color: #fff;
}

.button.secondary {
  background: #dcecf6;
  color: #10384f;
}

.button.glpi {
  margin-left: 8px;
  background: #a7c942;
  color: #183000;
}

.message {
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 18px;
}

.message,
.helper-text,
.info-callout,
.tip-callout {
  overflow-wrap: anywhere;
}

.message.error {
  background: #fff0f0;
  border: 1px solid #efb0b0;
}

.message.success {
  background: #eef9f1;
  border: 1px solid #afd8bb;
}

.message.warning {
  background: #fff8df;
  border: 1px solid #e6c85d;
}

.preview-page {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.preview-toolbar {
  border-radius: 0;
  background: #203e52;
  color: #fff;
}

.preview-logo {
  width: 125px;
  height: auto;
}

.drawio-preview {
  width: 100%;
  height: 100%;
  border: 0;
}

.login-panel {
  max-width: 430px;
  text-align: center;
}

.login-panel form,
.login-panel .helper-text {
  text-align: left;
}

@media (max-width: 640px) {
  .app-brand img {
    width: 145px;
    max-width: 75%;
  }

  .app-tabs {
    overflow-x: auto;
  }
}

@media (max-width: 900px) {
  .topbar-inner {
    width: calc(100% - 20px);
    min-height: 0;
    padding: 8px 0;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .topbar-brand img {
    width: 108px;
  }

  .topbar-nav {
    display: none;
  }

  .topbar-search {
    display: none;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .technician-pill {
    display: none;
  }

  .creation-top-grid,
  .equipment-grid {
    grid-template-columns: 1fr;
  }

  .equipment-grid {
    padding: 16px;
  }

  .advanced-fields-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1250px) {
  .creation-panel {
    width: calc(100% - 24px);
  }

  .equipment-grid {
    grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
    gap: 18px;
    padding: 16px;
  }

  .terminal-columns,
  .terminal-row {
    grid-template-columns: 1fr 0.85fr 0.6fr 0.85fr 0.85fr 0.7fr 0.65fr 32px;
    gap: 7px;
  }

  .device-columns,
  .device-row {
    grid-template-columns: 0.95fr 1.35fr 0.55fr 0.8fr 34px;
    gap: 7px;
  }

  .terminal-row,
  .device-row {
    padding: 8px;
  }

  .terminal-row input,
  .terminal-row select,
  .device-row input,
  .device-row select {
    padding-inline: 7px;
    font-size: 0.82rem;
  }

  .topbar-inner {
    width: calc(100% - 24px);
    gap: 14px;
  }

  .topbar-link {
    padding-inline: 9px;
    font-size: 0.77rem;
  }

  .topbar-brand img {
    width: 116px;
  }
}

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

  .equipment-description textarea {
    min-height: 180px;
  }

  .terminal-row {
    grid-template-columns: minmax(140px, 1fr) minmax(80px, 0.85fr) minmax(70px, 0.6fr) minmax(110px, 0.85fr) minmax(110px, 0.85fr) minmax(90px, 0.7fr) minmax(80px, 0.65fr) 32px;
    overflow-x: auto;
  }

  .device-row {
    grid-template-columns: minmax(120px, 0.95fr) minmax(160px, 1.35fr) minmax(70px, 0.55fr) minmax(100px, 0.8fr) 32px;
    overflow-x: auto;
  }

  .terminal-columns,
  .device-columns {
    display: none;
  }
}

@media (max-width: 640px) {
  .app-brand img {
    width: 145px;
    max-width: 75%;
  }

  .app-tabs {
    overflow-x: auto;
  }

  .field-grid.two-columns {
    grid-template-columns: 1fr;
  }

  .full-field {
    grid-column: auto;
  }
}

@media (min-width: 1800px) {
  .creation-panel {
    width: min(1680px, calc(100% - 64px));
  }

  .topbar-inner {
    width: min(1480px, calc(100% - 64px));
  }

  .creation-form {
    gap: 22px;
  }

  .creation-top-grid {
    gap: 22px;
  }
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 14px;
  margin: 12px 0;
}

.warnings {
  margin-top: 12px;
}

.helper-text {
  margin-top: 8px;
  color: #446176;
  font-size: 0.95rem;
}

.generation-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.generation-result-actions .button {
  margin-left: 0;
}

.generation-scroll-hint {
  display: none;
}

.upload-error {
  padding: 10px 12px;
  border-left: 4px solid #c97322;
  background: #fff5e8;
}

ul {
  margin-bottom: 0;
}

/* ── Admin panel ── */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-stat-card {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  grid-template-areas: "icon body";
  gap: 0.85rem;
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 0.75rem;
  padding: 1rem 1.15rem;
  box-shadow: 0 5px 14px rgba(26, 52, 77, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.admin-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(26, 52, 77, 0.09);
}

.admin-stat-card .stat-icon {
  grid-area: icon;
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border-radius: 0.6rem;
  background: var(--accent-soft);
  color: var(--accent);
}

.admin-stat-card .stat-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}

.admin-stat-card .stat-body {
  grid-area: body;
  min-width: 0;
}

.admin-stat-card .stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.admin-stat-card strong {
  display: block;
  font-size: 1.85rem;
  line-height: 1.15;
  margin-top: 0.1rem;
  color: var(--ink);
}

.admin-stat-card small {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  margin-top: 0.1rem;
}

/* Acentos por tipo de métrica */
.admin-stat-card.stat-hoy { border-top-color: var(--stat-blue); }
.admin-stat-card.stat-hoy .stat-icon { background: #e0ecff; color: var(--stat-blue); }

.admin-stat-card.stat-semana { border-top-color: var(--stat-teal); }
.admin-stat-card.stat-semana .stat-icon { background: var(--accent-soft); color: var(--stat-teal); }

.admin-stat-card.stat-mes { border-top-color: var(--stat-violet); }
.admin-stat-card.stat-mes .stat-icon { background: #f1e9ff; color: var(--stat-violet); }

.admin-stat-card.stat-total { border-top-color: var(--stat-slate); }
.admin-stat-card.stat-total .stat-icon { background: #e8edf2; color: var(--stat-slate); }

.admin-stat-card.stat-warn {
  border-top-color: var(--stat-red);
  background: rgba(220, 38, 38, 0.04);
}
.admin-stat-card.stat-warn .stat-icon { background: #fee2e2; color: var(--stat-red); }
.admin-stat-card.stat-warn strong { color: var(--stat-red); }

/* Cabecera de contexto del admin */
.admin-context {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.admin-context .ctx-dot {
  color: var(--border);
}

/* Rejilla gráfico + top técnicos */
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.admin-grid .admin-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 5px 14px rgba(26, 52, 77, 0.05);
}

/* Barras de proporción del top de técnicos */
.top-tech-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.top-tech-row {
  display: grid;
  grid-template-columns: minmax(0, 8rem) 1fr auto;
  gap: 0.6rem;
  align-items: center;
}

.top-tech-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-tech-bar-wrap {
  height: 0.6rem;
  border-radius: 9999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.top-tech-bar {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transition: width 0.35s ease;
}

.top-tech-count {
  min-width: 1.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-dark);
}

/* Filas de filtros / toolbar unificadas */
.admin-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0 0.75rem;
}

.admin-toolbar h2 {
  margin: 0;
}

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

.admin-toolbar input[type="search"] {
  width: auto;
  min-width: 200px;
  max-width: 240px;
  margin: 0;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

.admin-toolbar .csv-button {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  cursor: pointer;
  background: none;
  transition: background 0.15s, color 0.15s;
}

.admin-toolbar .csv-button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.sec-table-wrap {
  max-height: 420px;
  overflow-y: auto;
}

.row-warn { background: rgba(220, 38, 38, 0.05); }
.row-warn td { color: #7f1d1d; }

.sec-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.sec-badge-info    { background: #dcfce7; color: #166534; }
.sec-badge-warning { background: #fef9c3; color: #854d0e; }
.sec-badge-error   { background: #fee2e2; color: #991b1b; }
.sec-badge-critical{ background: #fce7f3; color: #9d174d; }

.sec-filter,
.period-filter {
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.8rem;
  cursor: pointer;
  background: none;
  transition: background 0.15s, color 0.15s;
}
.sec-filter.active,
.sec-filter:hover,
.period-filter.active,
.period-filter:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.3rem;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 0.3rem;
  vertical-align: middle;
  line-height: 1;
}

/* Cobertura de diagramas */
.coverage-details summary::-webkit-details-marker {
  display: none;
}

.coverage-details[open] {
  padding: 1rem 1.25rem;
}

.coverage-details[open] summary {
  margin-bottom: 0.4rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

/* ── Bottom-nav fija (móvil/tablet) ── */
.bottom-nav {
  display: none;
}

.field-mobile-label {
  display: none;
}

.row-field {
  display: contents;
  margin: 0;
  font-weight: 400;
}

.row-field input,
.row-field select {
  margin-top: 0;
}

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

  .coverage-details[open] {
    padding: 0.8rem 1rem;
  }

  /* Evita el zoom-auto de iOS al enfocar inputs */
  input,
  select,
  textarea {
    font-size: 16px;
  }

  /* Reserva espacio para la bottom-nav */
  .page,
  .page-wide {
    padding: 14px 12px calc(88px + env(safe-area-inset-bottom, 0px));
  }

  body.has-generation-result .page-wide {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }

  .page-wide .creation-panel {
    width: 100%;
  }

  .creation-panel {
    width: 100%;
  }

  .panel {
    width: 100%;
    min-width: 0;
    padding: 16px 12px;
    border-radius: 10px;
  }

  .panel-header h1 {
    font-size: 1.35rem;
  }

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

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

  /* Bottom-nav visible y fija */
  .bottom-nav {
    position: fixed;
    z-index: 1000;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    min-height: 58px;
    padding: 4px 0 env(safe-area-inset-bottom, 6px);
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 18px rgba(26, 52, 77, 0.1);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
  }

  .bottom-nav-item {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 50px;
    padding: 2px 1px;
    color: var(--muted);
    font-size: 0.64rem;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    line-height: 1.1;
    transition: color 0.15s ease;
  }

  .bottom-nav-icon {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
  }

  .bottom-nav-icon svg {
    width: 20px;
    height: 20px;
    display: block;
  }

  .bottom-nav-label {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bottom-nav-item.active {
    color: var(--primary);
  }

  .bottom-nav-item:hover {
    color: var(--primary);
  }

  .bottom-nav .admin-badge {
    position: relative;
    top: -1px;
    min-width: 0.95rem;
    height: 0.95rem;
    font-size: 0.58rem;
  }

  /* Tablas → tarjetas */
  .diagram-table-wrap.is-cards {
    background: transparent;
    border: 0;
  }

  .diagram-table.is-cards,
  .diagram-table.is-cards thead,
  .diagram-table.is-cards tbody,
  .diagram-table.is-cards tr,
  .diagram-table.is-cards td {
    display: block;
    width: 100%;
  }

  .diagram-table.is-cards {
    border-collapse: separate;
  }

  .diagram-table.is-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .diagram-table.is-cards tbody tr {
    display: grid;
    gap: 2px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(26, 52, 77, 0.06);
  }

  .diagram-table.is-cards tbody tr:last-child {
    margin-bottom: 0;
  }

  .diagram-table.is-cards tbody tr:hover {
    background: #fff;
  }

  .diagram-table.is-cards td {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    border: 0;
    font-size: 0.9rem;
    min-width: 0;
  }

  .diagram-table.is-cards td::before {
    content: attr(data-label);
    flex: 0 0 5.5rem;
    margin-right: 4px;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .diagram-table.is-cards td[data-label="Mensaje"] {
    flex-direction: column;
    gap: 4px;
  }

  .diagram-table.is-cards td[data-label="Mensaje"]::before {
    flex: none;
    margin-right: 0;
  }

  .diagram-table.is-cards td[data-label=""] {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  .diagram-table.is-cards td[data-label=""]::before {
    display: none;
  }

  .diagram-table.is-cards td .button {
    width: 100%;
    text-align: center;
    min-height: 44px;
  }

  .diagram-table.is-cards .sec-badge {
    align-self: flex-start;
  }

  /* Selectores GLPI: menú tipo hoja sobre la bottom-nav */
  .search-select.open {
    z-index: 1100;
  }

  .search-select.open .search-select-menu {
    position: fixed;
    top: auto;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    width: auto;
    max-height: min(55vh, 360px);
    z-index: 1101;
    box-shadow: 0 -10px 32px rgba(26, 52, 77, 0.18);
  }

  /* Creador */
  .paste-bar-wrap {
    padding: 10px;
  }

  .paste-bar {
    flex-direction: column;
    gap: 8px;
  }

  .paste-bar textarea {
    max-height: 100px;
  }

  .paste-bar-button {
    width: 100%;
    min-height: 48px;
  }

  .creation-top-grid,
  .equipment-grid,
  .advanced-fields-grid,
  .field-grid.two-columns {
    grid-template-columns: 1fr;
  }

  .full-field {
    grid-column: auto;
  }

  .devices-heading,
  .terminal-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .add-row-button {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .field-mobile-label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .row-field {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    min-width: 0;
  }

  .device-row,
  .terminal-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    overflow: visible;
  }

  .device-model-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .device-row input,
  .device-row select,
  .terminal-row input,
  .terminal-row select {
    min-height: 44px;
    padding: 10px;
  }

  .remove-device,
  .remove-terminal {
    align-self: flex-end;
    width: 44px;
    height: 44px;
  }

  .creation-actions {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 10px;
  }

  .creation-actions .button {
    width: 100%;
    min-height: 48px;
  }

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

  .generation-result-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .generation-result-actions .button {
    width: 100%;
    min-height: 48px;
    text-align: center;
  }

  .message.success {
    margin-bottom: 0.5rem;
  }

  .generation-scroll-hint {
    display: block;
    margin-bottom: 0.25rem;
    padding-bottom: 0.25rem;
    font-weight: 600;
  }

  /* Admin móvil */
  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .admin-stat-card {
    padding: 0.7rem 0.75rem;
    gap: 0.55rem;
  }

  .admin-stat-card strong {
    font-size: 1.35rem;
  }

  .admin-stat-card .stat-icon {
    width: 2rem;
    height: 2rem;
  }

  .admin-context {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .admin-context .ctx-dot {
    display: none;
  }

  .admin-card {
    padding: 0.9rem 1rem;
    min-width: 0;
  }

  .admin-card canvas {
    width: 100% !important;
    max-width: 100%;
  }

  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    margin-top: 1.25rem;
  }

  .admin-toolbar h2 {
    width: 100%;
    font-size: 1.05rem;
  }

  .admin-toolbar .toolbar-spacer,
  .admin-toolbar .filter-row {
    margin-left: 0;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .admin-toolbar .period-filter,
  .admin-toolbar .sec-filter {
    flex: 1 1 calc(33% - 0.5rem);
    min-height: 40px;
    padding: 0.35rem 0.5rem;
    text-align: center;
  }

  .admin-toolbar input[type="search"] {
    width: 100%;
    max-width: none;
    min-height: 44px;
    order: 10;
  }

  .admin-toolbar .csv-button {
    width: 100%;
    min-height: 44px;
    order: 11;
  }

  .top-tech-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 0.35rem 0.6rem;
  }

  .top-tech-name {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .top-tech-bar-wrap {
    grid-column: 1;
  }

  .top-tech-count {
    grid-column: 2;
    align-self: center;
  }

  .sec-table-wrap {
    max-height: none;
  }

  .coverage-details summary {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .coverage-details summary .sec-badge {
    margin-left: 0 !important;
    margin-top: 4px;
  }

  /* Login */
  .login-panel {
    max-width: none;
  }

  .login-panel .button.primary {
    width: 100%;
    min-height: 48px;
  }
}

@media (max-width: 768px) {
  .coverage-details[open] {
    padding: 0.8rem 1rem;
  }
}

@media (max-width: 420px) {
  .admin-stats {
    grid-template-columns: 1fr;
  }

  .bottom-nav-label {
    font-size: 0.62rem;
  }
}
