:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --surface: #fff;
  --ink: #13233c;
  --muted: #56657a;
  --border: #d8dee8;
  --accent: #1c6fd1;
  --accent-dark: #1656a3;
  --accent-soft: #e7f0fc;
  --secondary: #161616;
  --secondary-ink: #fff;
  --warn: #b7511e;
  --warn-soft: #fbe9e0;
  --good: #2f6e49;
  --good-soft: #e5f2ea;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--accent); }

.admin-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--secondary); color: var(--secondary-ink); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.admin-header-left { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.admin-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-header nav a {
  text-decoration: none; color: rgba(255,255,255,0.75); font-weight: 600; font-size: 0.92rem;
  padding: 6px 10px; border-radius: 6px;
}
.admin-header nav a.active, .admin-header nav a:hover { background: var(--accent); color: #fff; }
.admin-header-right { display: flex; align-items: center; gap: 10px; }
.admin-header-right a { text-decoration: none; font-weight: 600; font-size: 0.9rem; color: rgba(255,255,255,0.85); }

.nav-toggle {
  display: none; background: none; border: none; color: #fff; cursor: pointer;
  padding: 6px; border-radius: 6px; flex: none;
}
.nav-toggle:hover { background: rgba(255,255,255,0.12); }

/* Con 7 secciones en el nav, en vertical en celular se saturaba el header; abajo de este
   ancho se oculta el nav y se muestra como menu hamburguesa desplegable. */
@media (max-width: 680px) {
  .admin-header-left strong { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-toggle { display: flex; align-items: center; justify-content: center; }
  .admin-header nav {
    display: none; flex-direction: column; gap: 2px; flex-wrap: nowrap;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--secondary); padding: 6px 16px 14px; box-shadow: 0 8px 16px rgba(0,0,0,0.3);
  }
  .admin-header nav.abierto { display: flex; }
  .admin-header nav a { padding: 12px 10px; }
  /* Una sola línea: nombre + menú a la izquierda; campana, rol y Salir juntos a la derecha */
  .admin-header { flex-wrap: nowrap; gap: 6px; padding: 10px 10px; }
  .admin-header-left { flex-wrap: nowrap; gap: 4px; min-width: 0; flex: 0 1 auto; }
  .admin-header-right { flex-wrap: nowrap; gap: 6px; flex: none; }
  .admin-header-right a { font-size: 0.85rem; white-space: nowrap; }
  .admin-header-right a svg.ico { margin-right: 3px; }
  .admin-header-right .badge { white-space: nowrap; }
}
.admin-header .nom-corto { display: none; }
@media (max-width: 680px) and (orientation: portrait) {
  .admin-header .nom-largo { display: none; }
  .admin-header .nom-corto { display: inline; }
}
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; background: var(--accent-soft); color: var(--accent);
  padding: 3px 9px; border-radius: 999px;
}

main.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.35rem; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; font-size: 0.95rem; font-weight: 700; border-radius: 8px; border: none;
  cursor: pointer; text-decoration: none; min-height: 44px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:active { background: var(--bg); }
.btn-disabled { background: var(--surface); color: var(--muted); border: 1px dashed var(--border); cursor: default; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; min-height: 36px; }

.card { background: var(--surface); border-radius: 12px; padding: 18px; box-shadow: 0 1px 2px rgba(19,35,60,0.06); margin-bottom: 14px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 2px rgba(19,35,60,0.06);
  text-decoration: none; color: inherit;
}
.list-item:hover { outline: 1px solid var(--accent); }
.list-item-main strong { display: block; font-size: 1rem; }
.list-item-main span { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.list-item-chevron { color: var(--muted); flex: none; }
.empty { color: var(--muted); font-size: 0.9rem; padding: 18px 0; text-align: center; }

.push-banner {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; max-width: 690px; margin: 0 auto;
  background: var(--secondary); color: #fff; border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.push-banner span { flex: 1 1 200px; font-size: 0.9rem; }

.nav-bell { position: relative; display: inline-flex; }
.nav-bell .bell-count {
  position: absolute; top: -4px; right: -6px; background: var(--warn); color: #fff;
  font-size: 0.65rem; font-weight: 700; line-height: 1; padding: 3px 5px; border-radius: 999px;
}

.search-box { display: flex; gap: 8px; margin-bottom: 16px; }
.search-box input {
  flex: 1; font-size: 1rem; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
}
.search-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.quickgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.quickcard {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  background: var(--surface); border-radius: 10px; padding: 14px; box-shadow: 0 1px 2px rgba(19,35,60,0.06);
  text-decoration: none; color: inherit; min-height: 76px; justify-content: center;
}
.quickcard svg.ico { color: var(--accent); margin-bottom: 2px; }
.quickcard strong { font-size: 0.95rem; }

/* Accesos directos a los servicios express (Inicio) */
.express-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.express-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  min-height: 124px; padding: 16px 8px; background: var(--surface); border-radius: 16px; text-decoration: none; color: inherit;
  box-shadow: 0 1px 3px rgba(19,35,60,0.1); transition: transform .12s, box-shadow .12s; -webkit-tap-highlight-color: transparent;
}
.express-tile .ico { display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; border-radius: 50%; background: var(--accent); color: #fff; }
.express-tile strong { font-size: 0.92rem; line-height: 1.2; }
.express-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(19,35,60,0.16); }
.express-tile:active { transform: scale(.96); }

/* Iconos del menú y de botones sin clase .btn */
.admin-header nav a svg.ico, .nav-more > summary svg.ico, .admin-header-right a svg.ico { vertical-align: -3px; margin-right: 6px; }
button > svg.ico:not(.btn svg) { width: 1.1em; height: 1.1em; flex: none; }
.quickcard span { font-size: 0.78rem; color: var(--muted); }
.quickcard.disabled { opacity: 0.55; }

.section-title { font-size: 1rem; font-weight: 700; margin: 22px 0 10px; }

form.stack { display: flex; flex-direction: column; gap: 4px; }
form.stack label { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-top: 12px; margin-bottom: 6px; }
form.stack input, form.stack select, form.stack textarea {
  width: 100%; font-size: 1.05rem; padding: 13px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font-family: inherit;
}
form.stack input:focus, form.stack select:focus, form.stack textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
form.stack .actions { margin-top: 22px; display: flex; gap: 10px; }

.form-row { display: flex; gap: 10px; align-items: flex-end; }
.form-row .form-col { flex: 1; min-width: 0; }
.form-row .form-col-country { flex: 0 0 108px; }
.form-row .form-col-year { flex: 0 0 84px; }
.form-row .form-col select { min-width: 0; }
.form-row .form-col select { padding-left: 8px; padding-right: 8px; }

.error { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 8px; font-size: 0.9rem; margin-bottom: 14px; }
.success { background: var(--good-soft); color: var(--good); padding: 10px 12px; border-radius: 8px; font-size: 0.9rem; margin-bottom: 14px; }

.linkbox {
  display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-size: 0.85rem; word-break: break-all;
}
.linkbox code { flex: 1; }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-item { display: block; text-decoration: none; color: inherit; background: var(--surface); border-radius: 10px; padding: 12px 14px; box-shadow: 0 1px 2px rgba(19,35,60,0.06); }
.timeline-item .meta { font-size: 0.8rem; color: var(--muted); }

.status-pill {
  display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}

.section { background: var(--surface); border-radius: 12px; padding: 4px 18px 18px; box-shadow: 0 1px 2px rgba(19,35,60,0.06); margin-bottom: 14px; }
.section > summary { cursor: pointer; list-style: none; padding: 14px 0; font-weight: 700; font-size: 1rem; }
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after { content: '▾'; float: right; color: var(--muted); }
.section[open] > summary::after { content: '▴'; }

.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 10px 0; }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 0.92rem; font-weight: 500; color: var(--ink); }
form.stack label.check input[type="checkbox"] { width: 20px; height: 20px; padding: 0; border: 1px solid var(--border); accent-color: var(--accent); flex: none; }
form.stack input[type="range"] { padding: 0; border: none; background: none; height: 32px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 20px; }
.media-item { position: relative; background: var(--surface); border-radius: 10px; overflow: hidden; box-shadow: 0 1px 2px rgba(19,35,60,0.06); }
.media-delete-form { position: absolute; top: 6px; right: 6px; z-index: 2; margin: 0; }
.media-delete-btn {
  width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(0,0,0,0.55); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.media-delete-btn:hover { background: rgba(224,38,63,0.85); }

.list-item-trash {
  flex: none; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.list-item-trash:hover { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.media-item img, .media-item video { width: 100%; height: 140px; object-fit: cover; display: block; background: #000; }
.media-item audio { display: block; margin: 10px; width: calc(100% - 20px); }
.media-item .meta { padding: 6px 8px; font-size: 0.72rem; color: var(--muted); }
.media-item.is-file { display: flex; align-items: center; gap: 10px; padding: 14px 12px; height: 140px; box-sizing: border-box; }
.media-item.is-file .file-icon { font-size: 1.8rem; flex: none; }
.media-item.is-file .file-name { font-size: 0.8rem; word-break: break-word; color: var(--ink); }

.hidden { display: none !important; }

.capture-overlay {
  position: fixed; inset: 0; background: #000; z-index: 1000;
  display: none; align-items: center; justify-content: center; overflow: hidden;
}
.capture-overlay.open { display: flex; }
.cam-preview { width: 100%; height: 100%; object-fit: cover; background: #000; }

.capture-topbar {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; z-index: 3;
}
.capture-topbar button {
  background: rgba(0,0,0,0.5); color: #fff; border: none; border-radius: 999px; width: 42px; height: 42px; font-size: 1.15rem;
}
.capture-timer {
  color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; background: rgba(0,0,0,0.5);
  padding: 5px 12px; border-radius: 999px; font-size: 0.85rem;
}
.capture-bottombar {
  position: absolute; bottom: 30px; left: 0; right: 0; display: flex; justify-content: center; align-items: center; z-index: 3;
}
.cam-shutter {
  width: 76px; height: 76px; border-radius: 50%; background: #fff; border: 5px solid rgba(255,255,255,0.5);
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.cam-shutter.recording { background: #e0263f; border-color: rgba(224,38,63,0.5); }

.mic-overlay-body { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.mic-button {
  width: 96px; height: 96px; border-radius: 50%; background: var(--accent); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.mic-button.recording { background: #e0263f; animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224,38,63,0.5); }
  50% { box-shadow: 0 0 0 18px rgba(224,38,63,0); }
}
@media (prefers-reduced-motion: reduce) { .mic-button.recording, .dictado-btn.listening { animation: none; } }

.dictado-wrap { position: relative; }
.dictado-wrap input, .dictado-wrap textarea { padding-right: 44px; }
.dictado-btn {
  position: absolute; right: 6px; width: 32px; height: 32px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; border: none; background: var(--accent-soft); color: var(--accent);
  font-size: 1rem; cursor: pointer;
}
.dictado-btn.listening { background: #e0263f; color: #fff; animation: micpulse 1.2s ease-in-out infinite; }

/* Regla universal: avisos/ayudas van en un popup detras de un icono "i", nunca como texto fijo debajo del campo. */
.field-info-row { display: flex; align-items: center; gap: 8px; }
.field-info-row > input, .field-info-row > select, .field-info-row > .form-row { flex: 1; min-width: 0; }
.info-icon {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--accent);
  background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.info-icon:hover, .info-icon:focus-visible { background: var(--accent); color: #fff; }
.section-title-row { display: flex; align-items: center; gap: 8px; }
.section-title-row .section-title { margin: 0; }

.info-popup-overlay {
  position: fixed; inset: 0; background: rgba(19,35,60,0.4); z-index: 2000;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.info-popup-overlay.open { display: flex; }
.info-popup {
  background: var(--surface); border-radius: 12px; padding: 22px 20px 20px; max-width: 340px; width: 100%;
  box-shadow: 0 10px 34px rgba(0,0,0,0.28); position: relative;
}
.info-popup p { margin: 0; padding-right: 18px; font-size: 0.9rem; line-height: 1.55; color: var(--ink); }
.info-popup-close {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--bg); color: var(--ink); font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.info-popup-close:hover { background: var(--border); }
.mic-hint { color: #fff; opacity: 0.75; font-size: 0.85rem; margin: 0; }

.capture-preview {
  display: none; flex-direction: column; align-items: center; gap: 22px;
  width: 100%; height: 100%; justify-content: center; background: #000; z-index: 2;
}
.capture-preview.open { display: flex; }
.capture-preview-media { max-width: 100%; max-height: 65vh; display: flex; justify-content: center; }
.capture-preview-media img, .capture-preview-media video { max-width: 100%; max-height: 65vh; }
.capture-preview-actions { display: flex; gap: 34px; }
.capture-preview-actions button {
  width: 58px; height: 58px; border-radius: 50%; border: none; font-size: 1.4rem; color: #fff;
}
.capture-discard { background: #4a4a4a; }
.capture-send { background: var(--good); }
.capture-send:disabled { opacity: 0.6; }

/* ---- Tracker de estatus de la orden (vertical, pensado para movil) ---- */
.tracker { list-style: none; margin: 0 0 16px; padding: 0; }
.tracker li { position: relative; }
.tracker-node { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--ink); position: relative; min-height: 56px; }
.tracker-node:active { background: var(--accent-soft); }
.tracker-dot { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 0.9rem; font-weight: 700; background: #e3e8ef; color: #7a8798; position: relative; z-index: 1; }
.tracker li:not(:last-child) .tracker-node::after { content: ""; position: absolute; left: 26px; top: 40px; bottom: -16px; width: 3px; background: #e3e8ef; z-index: 0; }
.tracker li.done:not(:last-child) .tracker-node::after { background: var(--accent); }
.tracker li.done .tracker-dot { background: var(--accent); color: #fff; }
.tracker li.current .tracker-dot { background: var(--accent); color: #fff; box-shadow: 0 0 0 5px var(--accent-soft); animation: trackerPulse 1.8s ease-in-out infinite; }
.tracker li.final.current .tracker-dot { animation: none; }
.tracker-text { flex: 1; min-width: 0; }
.tracker-text strong { display: block; font-size: 1rem; }
.tracker-text span { font-size: 0.8rem; color: var(--muted); }
.tracker li.pending .tracker-text strong { color: var(--muted); font-weight: 600; }
.tracker li.seleccionada .tracker-node { outline: 2px solid var(--accent); background: var(--accent-soft); }
.tracker-chevron { color: var(--muted); font-size: 1.3rem; }
@keyframes trackerPulse { 50% { box-shadow: 0 0 0 9px rgba(28, 111, 209, 0.12); } }
.etapa-panel { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.etapa-panel h2 { margin: 0 0 10px; font-size: 1.15rem; }
.etapa-panel .muted, .tracker .muted { color: var(--muted); }
.resumen-tabla { width: 100%; border-collapse: collapse; }
.resumen-tabla td { padding: 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.resumen-tabla td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; }
.resumen-tabla tfoot td { font-weight: 700; border-bottom: 0; font-size: 1.05rem; }
@media print { .no-print, .tracker, .portal-header { display: none !important; } }

/* Botones con el atributo hidden (display del .btn lo anulaba) */
.btn[hidden] { display: none !important; }

/* Iconos de los botones (assets/js/iconos_botones.js) */
.btn svg.ico { width: 1.15em; height: 1.15em; flex: none; }
.btn-sm svg.ico { width: 1.05em; height: 1.05em; }

/* Submenú "Más" del menú principal (Citas, Clasificados) */
.nav-more { position: relative; }
.nav-more > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 5px;
  color: rgba(255,255,255,0.75); font-weight: 600; font-size: 0.92rem; padding: 6px 10px; border-radius: 6px; position: relative;
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary:hover, .nav-more[open] > summary, .nav-more.active > summary { background: var(--accent); color: #fff; }
.nav-more .nav-more-count { position: static; margin-left: 2px; }
.nav-more-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 190px; z-index: 20;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--secondary); border-radius: 10px; box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}
@media (max-width: 680px) {
  .nav-more > summary { padding: 12px 10px; }
  .nav-more-menu { position: static; min-width: 0; box-shadow: none; padding: 0 0 0 14px; background: transparent; }
}

/* Botón verde de WhatsApp */
.btn-wa { background: #25d366; color: #fff; border: none; }
.btn-wa:active { background: #1ebe5b; }
