/* ============================================================
   SAT — Sistemas de Apoyo Técnico al Transporte
   Paleta: azul marino / blanco / naranja
   Tipografía: Barlow (señalización vial) + IBM Plex Mono (datos)
   ============================================================ */

:root {
  --navy: #1b4570;
  --navy-deep: #123356;
  --navy-soft: #1d406422;
  --orange: #f5720d;
  --orange-dark: #d95f04;
  --white: #ffffff;
  --surface: #f2f5f9;
  --line: #dde5ee;
  --ink: #16212e;
  --muted: #64748b;
  --error: #c62828;

  --font-body: "Barlow", system-ui, sans-serif;
  --font-display: "Barlow Condensed", "Barlow", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 10px;
  --shadow: 0 8px 24px rgba(14, 42, 71, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Motivo firma: franja de código de barras ---------- */
.barcode-strip {
  display: block;
  height: 22px;
  width: 180px;
  background: repeating-linear-gradient(
    90deg,
    currentColor 0 2px, transparent 2px 5px,
    currentColor 5px 9px, transparent 9px 11px,
    currentColor 11px 12px, transparent 12px 17px,
    currentColor 17px 20px, transparent 20px 22px,
    currentColor 22px 23px, transparent 23px 28px
  );
  color: var(--orange);
}
.barcode-strip-sm { height: 12px; width: 110px; }
.barcode-strip-muted { color: var(--line); margin: 0 auto 14px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-dark); }

.btn-outline { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: var(--white); }

.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--navy); border-color: var(--navy); }

.btn-block { width: 100%; }

/* ---------- Vistas ---------- */
.view { min-height: 100vh; }

/* ===== Bienvenida ===== */
.view-split { display: grid; grid-template-columns: 1.15fr 1fr; }

.split-brand {
  background: var(--white);
  color: var(--navy);
  padding: 64px 56px 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
}
.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.brand-logo { width: min(320px, 70%); height: auto; display: block; margin-bottom: 30px; }

.brand-name {
  font-family: var(--font-display);
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.08;
  color: var(--navy);
}
.brand-tag { margin-top: 14px; font-size: 18px; color: var(--muted); }

.brand-modules {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 22px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 15px;
  color: var(--muted);
  margin-top: 32px;
}
.brand-modules li::before { content: "▪ "; color: var(--orange); }

.split-action {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%);
}
.action-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; }
.action-title {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--white);
}
.action-sub { color: #b8c7d9; margin-bottom: 12px; }
.split-action .btn-outline { color: var(--white); border-color: var(--white); }
.split-action .btn-outline:hover { background: var(--white); color: var(--navy); }

/* ===== Autenticación ===== */
.view-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(0deg, rgba(14, 42, 71, 0.04), rgba(14, 42, 71, 0.04)),
    var(--white);
  padding: 32px;
}
.auth-card {
  width: min(440px, 100%);
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 6px solid var(--orange);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 36px 28px;
}
.link-back {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 18px;
}
.link-back:hover { color: var(--navy); }

.auth-eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 14px;
  color: var(--orange);
}
.auth-head h2 {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--navy);
  margin: 4px 0 22px;
}
.auth-alt { margin-top: 18px; font-size: 14px; color: var(--muted); }
.link-inline {
  background: none;
  border: none;
  color: var(--orange);
  font-weight: 600;
  font-size: 14px;
  text-decoration: underline;
}

/* ---------- Campos ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy);
}
.field input {
  font-family: var(--font-body);
  font-size: 15.5px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  transition: border-color 0.15s ease;
}
.field input::placeholder { color: #9fb0c2; }
.field input:focus { outline: none; border-color: var(--orange); }
.field select, .field textarea {
  font-family: var(--font-body);
  font-size: 15.5px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  transition: border-color 0.15s ease;
}
.field select:focus, .field textarea:focus { outline: none; border-color: var(--orange); }
.input-mono { font-family: var(--font-mono) !important; letter-spacing: 0.06em; text-transform: uppercase; }

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 12px 2px;
  font-size: 15px;
}
.radio-row label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.radio-row input { accent-color: var(--orange); width: 17px; height: 17px; }

.form-section {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--navy);
  border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
  margin: 18px 0 16px;
}
.form-section-first { margin-top: 0; }
.form-hint { color: #1f7a34; font-size: 14px; margin: 4px 0 12px; }

.form-error {
  color: var(--error);
  font-size: 14px;
  margin: -6px 0 12px;
}

/* ===== Shell de la app ===== */
.view-app { display: grid; grid-template-columns: 264px 1fr; }

.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 28px 18px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { display: flex; flex-direction: column; gap: 10px; padding: 0 10px 26px; }
.sidebar-plate {
  display: inline-flex;
  background: var(--white);
  border-radius: 12px;
  padding: 10px 14px;
  width: fit-content;
}
.sidebar-logo { width: 120px; height: auto; display: block; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-label {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11.5px;
  font-weight: 600;
  color: #7d9ab8;
  padding: 14px 12px 4px;
}
.nav-item {
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: #a9bcd0;
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 11px 12px;
  border-radius: 0 8px 8px 0;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-item:hover { color: var(--white); background: rgba(255, 255, 255, 0.06); }
.nav-item.is-active { color: var(--white); border-left-color: var(--orange); background: rgba(255, 255, 255, 0.08); }
.nav-item:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }

.sidebar-foot { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--orange);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mail { font-size: 12.5px; color: #8fa3b900; color: #8aa0b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .btn-ghost { color: #a9bcd0; border-color: rgba(255, 255, 255, 0.2); font-size: 14px; padding: 9px 14px; }
.sidebar .btn-ghost:hover { color: var(--white); border-color: var(--white); }

/* ---------- Contenido ---------- */
.content { background: var(--surface); padding: 44px 48px 64px; min-height: 100vh; }

.module-head { margin-bottom: 30px; }
.module-eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 14px;
  color: var(--orange);
  font-weight: 600;
}
.module-title {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--navy);
  line-height: 1.05;
  margin: 4px 0 8px;
}
.module-sub { color: var(--muted); max-width: 60ch; }

/* ---------- Tarjetas de módulos ---------- */
.group-title {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  margin: 28px 0 12px;
}
.group-title:first-of-type { margin-top: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}
.module-card {
  text-align: left;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.module-card:hover { border-color: var(--navy); box-shadow: var(--shadow); transform: translateY(-2px); }
.module-card:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.card-key {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--orange);
  border: 1.5px solid currentColor;
  border-radius: 6px;
  padding: 3px 8px;
  width: fit-content;
  letter-spacing: 0.1em;
}
.card-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--navy);
  line-height: 1.1;
}
.card-desc { font-size: 14.5px; color: var(--muted); line-height: 1.45; flex: 1; }
.card-cta {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--orange);
}
.card-accent { border-top: 4px solid var(--orange); }

/* ---------- Toolbars y tablas ---------- */
.toolbar { margin-bottom: 16px; }
.toolbar-catalogo { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.toolbar-catalogo .input-search { flex: 1; min-width: 240px; }

.toolbar-consulta {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 260px)) auto;
  gap: 14px;
  align-items: end;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.toolbar-consulta .field { margin-bottom: 0; }
.toolbar-actions { display: flex; gap: 10px; padding-bottom: 2px; }

.form-catalogo { margin-bottom: 18px; }
.td-acciones { white-space: nowrap; }

.pill {
  display: inline-block;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.pill-orden { background: #e8eef6; color: var(--navy); }
.pill-dictamen { background: #fdeadd; color: var(--orange-dark); }
.input-search {
  width: min(420px, 100%);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
}
.input-search:focus { outline: none; border-color: var(--orange); }

.table-wrap {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.data-table th {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13.5px;
  text-align: left;
  color: var(--white);
  background: var(--navy);
  padding: 12px 16px;
  white-space: nowrap;
}
.data-table td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .mono { font-family: var(--font-mono); font-size: 13.5px; letter-spacing: 0.04em; }
.btn-mini {
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}
.btn-mini:hover { border-color: var(--orange); color: var(--orange); }

.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--white);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.empty-state strong { color: var(--navy); }
.empty-state .btn { margin-top: 12px; }
.empty-state code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
}
.table-wrap .empty-state { border: none; }

/* ---------- Órdenes de trabajo ---------- */
.ot-layout {
  display: grid;
  grid-template-columns: minmax(340px, 480px) minmax(340px, 1fr);
  gap: 26px;
  align-items: start;
}
.ot-form {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.span-2 { grid-column: span 2; }
.form-wide { max-width: 1000px; }
.form-wide .form-grid.grid-4 { grid-template-columns: repeat(4, 1fr); }
.form-wide .form-grid.grid-4 .span-2 { grid-column: span 2; }
.dictamen-doc { max-width: 760px; margin-top: 26px; }
.dictamen-doc .ticket-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
.dictamen-doc .t-span2 { grid-column: span 2; }
.form-actions { display: flex; gap: 12px; margin-top: 6px; }

.ot-preview { position: sticky; top: 32px; }
.ot-preview-empty {
  padding: 64px 32px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

/* Tarjetón de orden (imprimible) */
.orden-ticket {
  background: var(--white);
  border: 2px solid var(--navy);
  border-radius: var(--radius);
  overflow: hidden;
}
.ticket-head {
  background: var(--navy);
  color: var(--white);
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.ticket-brand {
  display: block;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 14px;
  color: #b8c7d9;
}
.ticket-folio {
  display: block;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--white);
  margin-top: 2px;
}
.ticket-fecha { font-size: 13.5px; color: #b8c7d9; white-space: nowrap; }

.ticket-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 8px 0;
}
.t-item { padding: 10px 22px; border-bottom: 1px solid var(--line); }
.t-span2 { grid-column: span 2; }
.t-item span {
  display: block;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  color: var(--muted);
}
.t-item strong { font-size: 16px; font-weight: 600; color: var(--ink); }
.t-item.mono strong { font-family: var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase; }

.ticket-barcode { padding: 18px 22px 8px; text-align: center; }
.ticket-barcode svg { max-width: 100%; }
.ticket-actions { display: flex; gap: 12px; padding: 14px 22px 22px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  padding: 12px 22px;
  border-radius: 8px;
  border-left: 4px solid var(--orange);
  box-shadow: var(--shadow);
  font-size: 15px;
  z-index: 100;
}

/* ---------- Impresión: solo el documento activo ---------- */
@media print {
  body * { visibility: hidden; }
  .print-target, .print-target * { visibility: visible; }
  .print-target {
    position: fixed;
    inset: 0 auto auto 0;
    width: 100%;
    max-width: none;
    border-radius: 0;
    border-width: 1px;
  }
  .no-print { display: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .ot-layout { grid-template-columns: 1fr; }
  .ot-preview { position: static; }
}

@media (max-width: 900px) {
  .view-split { grid-template-columns: 1fr; }
  .split-brand { padding: 44px 32px; gap: 32px; }
  .view-app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 16px; }
  .sidebar-brand { padding: 0 12px 0 0; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { border-left: none; border-bottom: 3px solid transparent; border-radius: 8px 8px 0 0; padding: 8px 10px; font-size: 14.5px; }
  .nav-item.is-active { border-bottom-color: var(--orange); }
  .sidebar-foot { flex-direction: row; align-items: center; border-top: none; padding-top: 0; margin-left: auto; }
  .content { padding: 28px 20px 48px; }
  .module-title { font-size: 32px; }
}

@media (max-width: 1000px) {
  .form-wide .form-grid.grid-4 { grid-template-columns: 1fr 1fr; }
  .toolbar-consulta { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .form-grid, .form-wide .form-grid.grid-4, .toolbar-consulta { grid-template-columns: 1fr; }
  .span-2, .form-wide .form-grid.grid-4 .span-2 { grid-column: span 1; }
  .dictamen-doc .ticket-grid { grid-template-columns: 1fr; }
  .dictamen-doc .t-span2 { grid-column: span 1; }
  .ticket-grid { grid-template-columns: 1fr; }
  .t-span2 { grid-column: span 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
