:root {
  color-scheme: light;
  --navy: #12344d;
  --navy-deep: #0c263a;
  --blue: #176b87;
  --cyan: #21a4b7;
  --ink: #172b3a;
  --muted: #617484;
  --line: #dce5eb;
  --surface: #ffffff;
  --canvas: #f3f7fa;
  --soft-blue: #eaf4f8;
  --success: #18794e;
  --success-bg: #e8f6ef;
  --warning: #946200;
  --warning-bg: #fff5dc;
  --danger: #b42332;
  --danger-bg: #fff0f0;
  --shadow: 0 8px 24px rgba(18, 52, 77, .07);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; transition: background .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(33, 164, 183, .28);
  outline-offset: 2px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; color: var(--navy); font-size: clamp(22px, 2vw, 28px); line-height: 1.2; letter-spacing: -.035em; }
h2 { margin-bottom: 3px; color: var(--navy); font-size: 17px; letter-spacing: -.015em; }
h3 { color: var(--navy); }

.hidden { display: none !important; }
.muted { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.eyebrow { margin-bottom: 6px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .14em; }

/* Acceso */
.login-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px 18px;
  background: radial-gradient(circle at 18% 16%, rgba(33, 164, 183, .12), transparent 32%),
              radial-gradient(circle at 82% 86%, rgba(23, 107, 135, .10), transparent 30%), var(--canvas);
}
.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(18, 52, 77, .12);
}
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 8px; color: var(--navy); font-size: 22px; font-weight: 800; letter-spacing: -.04em; }
.brand-icon { display: grid; width: 39px; height: 39px; place-items: center; border-radius: 12px; background: var(--soft-blue); color: var(--blue); font-size: 12px; font-weight: 900; letter-spacing: -.07em; }
.login-card h1 { margin: 24px 0 18px; font-size: 25px; }
.login-card label { margin-top: 14px; }
.login-note { display: block; margin-top: 18px; color: var(--muted); font-size: 11px; line-height: 1.5; }

/* Campos y botones */
label { display: block; margin: 11px 0 5px; color: #314b5d; font-size: 12px; font-weight: 700; }
input, select, textarea {
  display: block;
  width: 100%;
  min-height: 40px;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid #cbd8e1;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 1px 1px rgba(18, 52, 77, .025);
}
input::placeholder, textarea::placeholder { color: #91a1ad; }
textarea { min-height: 94px; resize: vertical; }
button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 750;
}
.primary { border-color: var(--navy); background: var(--navy); color: #fff; box-shadow: 0 3px 9px rgba(18, 52, 77, .13); }
.primary:hover { border-color: var(--blue); background: var(--blue); }
.secondary { border-color: var(--line); background: #fff; color: var(--navy); }
.secondary:hover { border-color: #a9c6d4; background: #f4fafc; }
.full { width: 100%; margin-top: 18px; min-height: 44px; }
.icon-btn { min-width: 34px; min-height: 34px; padding: 0 7px; border: 0; background: transparent; color: var(--muted); font-size: 25px; }
.icon-btn:hover { background: var(--canvas); }

/* Navegación y área de trabajo */
.sidebar {
  position: fixed;
  z-index: 10;
  inset: 0 auto 0 0;
  display: flex;
  width: 252px;
  flex-direction: column;
  padding: 24px 16px 18px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  box-shadow: 6px 0 24px rgba(12, 38, 58, .08);
}
.sidebar .brand { margin: 0 5px 27px; color: #fff; }
.sidebar .brand-icon { background: rgba(255,255,255,.13); color: #aeeaf0; }
.side-label { margin: 0 9px 10px; color: #a9c4d1; font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.module-nav { display: flex; max-height: calc(100vh - 180px); flex-direction: column; gap: 5px; overflow: auto; padding-right: 2px; }
.module-nav .nav {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #dceaf0;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
}
.module-nav .nav:hover { background: rgba(255,255,255,.09); color: #fff; }
.module-nav .nav.active { border-color: rgba(174,234,240,.2); background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 #69d1dc; }
.side-foot { margin-top: auto; padding: 16px 7px 0; border-top: 1px solid rgba(255,255,255,.17); color: #d7e6ec; font-size: 11px; }
.logout { width: 100%; margin-top: 12px; border-color: rgba(255,255,255,.34); background: transparent; color: #fff; }
.logout:hover { background: rgba(255,255,255,.10); }
.main { max-width: 1700px; min-height: 100vh; margin-left: 252px; padding: 30px clamp(18px, 3vw, 42px); }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.role-badge { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 12px; border: 1px solid #cce3ed; border-radius: 999px; background: var(--soft-blue); color: var(--blue); font-size: 11px; font-weight: 800; white-space: nowrap; }

/* Indicadores y paneles */
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metrics article {
  position: relative;
  overflow: hidden;
  min-height: 100px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.metrics article::after { position: absolute; top: 0; right: 0; width: 4px; height: 100%; background: #b8dce5; content: ""; }
.metrics span { display: block; color: var(--muted); font-size: 11px; font-weight: 650; }
.metrics strong { display: block; margin-top: 6px; color: var(--navy); font-size: 27px; line-height: 1.1; letter-spacing: -.04em; }
.panel { margin-bottom: 18px; padding: 21px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel-head .muted { margin-top: 3px; }
.filters { display: grid; grid-template-columns: minmax(190px, 1.3fr) minmax(160px, 1fr) minmax(160px, 1fr) auto; gap: 9px; margin: 18px 0 16px; }
.filters input, .filters select { margin: 0; min-height: 40px; }

/* Tablas */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
table { width: 100%; min-width: 780px; border-collapse: separate; border-spacing: 0; text-align: left; }
th, td { padding: 12px 13px; border-bottom: 1px solid #eaf0f4; vertical-align: middle; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; background: #f5f9fb; color: #526a7a; font-size: 10px; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; }
td { color: #324b5c; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfd; }
td strong { display: block; color: var(--navy); font-size: 12px; font-weight: 750; }
.sub { display: block; margin-top: 2px; color: #718493; font-size: 10px; }
.table-state { padding: 28px 16px; color: var(--muted); text-align: center; }
.status { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 99px; background: #eef4f7; color: #425d6e; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status.activo, .status.resuelto, .status.cerrado, .status.reconocido, .status.activa { background: var(--success-bg); color: var(--success); }
.status.inactivo, .status.descartado, .status.inactiva, .status.dado_de_baja { background: #eef1f4; color: #526170; }
.status.en_mantenimiento, .status.asignado, .status.nuevo, .status.en_reparacion { background: var(--warning-bg); color: var(--warning); }
.status.abierto { background: #fff0e6; color: #a34b13; }
.status.baja { background: #eef4f7; color: #526a7a; }
.status.media { background: #edf3ff; color: #315a9b; }
.status.alta { background: #fff1df; color: #98510a; }
.status.critica { background: var(--danger-bg); color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 5px; }
.actions button { min-height: 30px; padding: 5px 9px; font-size: 10px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 15px; color: var(--muted); font-size: 11px; }
.pagination div { display: flex; gap: 7px; }

/* Mensajes */
.message { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }
.message.ok { color: var(--success); }
.hint { margin: 13px 0; color: var(--muted); font-size: 11px; }

/* Ventanas y formularios */
dialog { max-height: min(88vh, 900px); overflow: auto; border: 1px solid rgba(220,229,235,.9); border-radius: 16px; padding: 0; background: #fff; box-shadow: 0 24px 80px rgba(12, 38, 58, .25); }
dialog::backdrop { background: rgba(12, 31, 46, .58); backdrop-filter: blur(2px); }
#equipmentDialog { width: min(790px, calc(100% - 28px)); }
#equipmentForm { padding: 25px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; padding-top: 14px; border-top: 1px solid #edf1f4; }
.catalog-dialog { width: min(590px, calc(100% - 28px)); }
.catalog-form { display: grid; gap: 9px; padding: 24px; color: var(--ink); }
.catalog-form h3 { margin: 0 0 5px; font-size: 17px; letter-spacing: -.02em; }
.catalog-form label { display: grid; gap: 4px; }
.catalog-form input, .catalog-form select, .catalog-form textarea { min-height: 42px; margin-top: 2px; }
.catalog-form .actions { justify-content: flex-end; gap: 8px; margin-top: 9px; padding-top: 13px; border-top: 1px solid #edf1f4; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: 58vh; overflow: auto; padding: 3px 1px 7px; }
.detail-grid > div { display: flex; min-width: 0; flex-direction: column; gap: 4px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfdfe; }
.detail-grid strong { color: #617889; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.detail-grid span { overflow-wrap: anywhere; color: var(--ink); font-size: 12px; }
.module-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 15px 0; }
.module-actions select { width: auto; min-width: 190px; margin: 0; }
.report-picker { display: grid; min-width: 210px; gap: 3px; margin: 0; color: var(--muted); font-size: 10px; }
.module-actions button { min-height: 38px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.dashboard-card { padding: 15px 16px; border: 1px solid var(--line); border-radius: 11px; background: #fbfdfe; }
.dashboard-card span { display: block; color: var(--muted); font-size: 11px; }
.dashboard-card strong { display: block; margin-top: 4px; color: var(--navy); font-size: 23px; }
.dashboard-section-title { margin: 8px 0 10px; font-size: 14px; }

@media (max-width: 1100px) {
  .sidebar { width: 220px; }
  .main { margin-left: 220px; padding: 25px 20px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sidebar { position: relative; width: 100%; min-height: auto; padding: 13px 14px 10px; }
  .sidebar .brand { margin: 0 4px 12px; font-size: 19px; }
  .sidebar .brand-icon { width: 34px; height: 34px; }
  .side-label { margin-bottom: 6px; }
  .module-nav { max-height: none; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 5px; }
  .module-nav .nav { width: auto; min-width: max-content; min-height: 36px; padding: 7px 10px; }
  .side-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; padding-top: 9px; }
  .logout { width: auto; min-height: 32px; margin: 0; }
  .main { margin: 0; padding: 20px 14px; }
  .metrics { gap: 9px; }
  .metrics article { min-height: 85px; padding: 13px; }
  .panel { padding: 15px; }
}
@media (max-width: 560px) {
  .login-card { padding: 25px 21px; }
  .topbar { display: block; }
  .role-badge { margin-top: 10px; }
  .metrics, .dashboard-grid { grid-template-columns: 1fr; }
  .filters, .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .dialog-actions { flex-wrap: wrap; }
}
