/* Mesa de operación VMA · demo
   Pizarra sobre gris frío; un solo acento, ámbar de chaleco reflectivo, para lo que espera una decisión humana.
   Barlow (rótulos de carretera) para texto; Barlow Condensed para cifras e IDs, como en un tablero de turnos. */

:root {
  --slate: #1C2733;      /* tinta y barra lateral */
  --slate-2: #2A3746;
  --steel: #5D6B7A;      /* texto secundario */
  --mist: #E9EDF1;       /* fondo */
  --line: #CFD7DF;       /* reglas */
  --white: #FFFFFF;
  --amber: #F5A800;      /* por aprobar: el único acento */
  --amber-wash: #FFF4D6;
  --red: #C8303A;
  --red-wash: #FBE7E8;
  --green: #22764A;
  --green-wash: #E2F2E9;
  --font: "Barlow", system-ui, sans-serif;
  --cond: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); color: var(--slate); background: var(--mist); line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Acceso */
.gate { min-height: 100vh; display: grid; place-items: center; background: var(--slate); padding: 24px; }
.gate-card { width: min(380px, 100%); background: var(--white); border-radius: var(--r-md); padding: 32px; display: grid; gap: 14px; }
.gate-logo { height: 44px; width: auto; justify-self: start; }
.gate h1 { font-size: 1.6rem; font-weight: 700; }
.gate p { color: var(--steel); }
.gate input { padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm); }
.gate-error { color: var(--red); min-height: 1.2em; font-weight: 600; }

/* Botones */
.btn { border: 0; border-radius: var(--r-sm); padding: 10px 16px; font-weight: 600; transition: transform .08s ease, background .15s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--amber); color: var(--slate); }
.btn-primary:hover { background: #FFB81C; }
.btn-ink { background: var(--slate); color: var(--white); }
.btn-ink:hover { background: var(--slate-2); }
.btn-quiet { background: transparent; color: var(--steel); border: 1.5px solid var(--line); }
.btn-quiet:hover { color: var(--slate); border-color: var(--steel); }
.btn[disabled] { opacity: .55; cursor: progress; }

/* Estructura */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--slate); color: #DCE3EA; display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh; }
.brand { display: grid; gap: 10px; padding: 0 8px 22px; border-bottom: 1px solid var(--slate-2); }
.brand img { height: 38px; width: auto; filter: invert(1) brightness(1.6); justify-self: start; }
.brand span { font-weight: 600; font-size: 1.05rem; color: var(--white); }
.nav { display: grid; gap: 2px; margin-top: 18px; }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px; border-radius: var(--r-sm); color: #C3CDD7; text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--slate-2); color: var(--white); }
.nav a.on { background: var(--white); color: var(--slate); font-weight: 700; }
.count { font-family: var(--cond); font-weight: 600; font-size: .95rem; min-width: 26px; text-align: center; padding: 1px 7px; border-radius: 99px; background: var(--slate-2); color: #DCE3EA; }
.nav a.on .count { background: var(--mist); color: var(--slate); }
.count-amber { background: var(--amber); color: var(--slate); }
.nav a.on .count-amber { background: var(--amber); }
.count-red { background: var(--red); color: var(--white); }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 16px 8px 0; border-top: 1px solid var(--slate-2); }
.side-link { background: none; border: 0; padding: 0; text-align: left; color: #AFBBC7; text-decoration: none; font-size: .93rem; }
.side-link:hover { color: var(--white); text-decoration: underline; }
.live { display: flex; align-items: center; gap: 8px; font-size: .93rem; color: var(--white); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6FD39C; box-shadow: 0 0 0 0 rgba(111, 211, 156, .6); animation: pulse 2s infinite; }
.live.stale .dot { background: var(--amber); animation: none; }
.live.down .dot { background: var(--red); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(111, 211, 156, 0); } 100% { box-shadow: 0 0 0 0 rgba(111, 211, 156, 0); } }
.demo-note { font-size: .8rem; color: #8695A4; }

.main { padding: 24px 32px 48px; min-width: 0; }

/* Tablero de cifras: una franja, no tarjetas sueltas */
.board { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.tile { padding: 14px 18px 16px; display: grid; gap: 2px; border-left: 1px solid var(--line); cursor: help; position: relative; }
.tile:first-child { border-left: 0; }
.tile b { font-family: var(--cond); font-weight: 700; font-size: 2.6rem; line-height: 1; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.tile span { color: var(--steel); font-size: .92rem; }
.tile-amber { background: var(--amber-wash); }
.tile-amber::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--amber); }
.tile-red b { color: var(--red); }
.tile-red.zero b, .tile-amber.zero b { color: var(--slate); }

.view { margin-top: 28px; }
.view-head { display: grid; gap: 4px; margin-bottom: 16px; max-width: 72ch; }
.view-head h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.01em; }
.view-head p { color: var(--steel); }

/* Por aprobar: la pieza central */
.queue { display: grid; gap: 16px; }
.approval { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); overflow: hidden; }
.approval.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--amber); } 100% { box-shadow: 0 0 0 0 transparent; } }
.ap-left { padding: 18px 20px; border-right: 1px solid var(--line); display: grid; gap: 12px; align-content: start; }
.ap-right { padding: 18px 20px; background: var(--amber-wash); display: grid; gap: 10px; align-content: start; }
.ap-id { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ap-id .id { font-family: var(--cond); font-weight: 700; font-size: 1.5rem; }
.ap-who { color: var(--steel); }
.ap-who strong { color: var(--slate); }
.bubble { background: #F1F4F7; border-radius: 12px 12px 12px 3px; padding: 9px 12px; max-width: 95%; white-space: pre-wrap; }
.bubble small { display: block; color: var(--steel); font-size: .8rem; margin-bottom: 2px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: .93rem; }
.facts dt { color: var(--steel); }
.ap-right label { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.ap-right textarea { width: 100%; min-height: 128px; resize: vertical; padding: 12px; border: 1.5px solid #E3C77A; border-radius: var(--r-sm); background: var(--white); line-height: 1.5; }
.ap-right textarea:focus { border-color: var(--amber); outline: none; box-shadow: 0 0 0 3px rgba(245, 168, 0, .25); }
.ap-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ap-hint { font-size: .85rem; color: #7A6320; }
.empty { background: var(--white); border: 1.5px dashed var(--line); border-radius: var(--r-md); padding: 36px; text-align: center; color: var(--steel); }
.empty strong { display: block; color: var(--slate); font-size: 1.15rem; margin-bottom: 4px; }

/* Chips de estado */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .85rem; font-weight: 600; white-space: nowrap; background: var(--mist); color: var(--slate); }
.chip.alta { background: var(--red-wash); color: var(--red); }
.chip.media { background: #EEF0F3; }
.chip.baja { background: #F4F6F8; color: var(--steel); }
.chip.pend { background: var(--amber); color: var(--slate); }
.chip.ok { background: var(--green-wash); color: var(--green); }
.chip.bad { background: var(--red-wash); color: var(--red); }
.chip.warn { background: var(--amber-wash); color: #7A5600; }
.chip.ia { background: #E7EAF6; color: #3A4A8C; }

/* Tablas */
.filters { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.search input { width: 320px; max-width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--white); }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--white); }
.seg button { border: 0; background: none; padding: 8px 14px; color: var(--steel); font-weight: 600; }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button.on { background: var(--slate); color: var(--white); }
.table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); overflow: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: .95rem; }
.grid th { text-align: left; font-weight: 600; color: var(--steel); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #F6F8FA; white-space: nowrap; position: sticky; top: 0; }
.grid td { padding: 11px 14px; border-bottom: 1px solid #E6EBF0; vertical-align: top; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: #F6F8FA; }
.grid tbody tr.flash { animation: rowflash 2s ease-out; }
@keyframes rowflash { 0% { background: var(--amber-wash); } 100% { background: transparent; } }
.grid .id { font-family: var(--cond); font-weight: 700; font-size: 1.1rem; }
.grid .sub { color: var(--steel); font-size: .88rem; }
#t-padron tbody tr { cursor: default; }

/* Presentismo */
.alerts { display: grid; gap: 10px; margin-bottom: 18px; }
.alert { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; background: var(--white); border: 1px solid var(--line); border-left: 5px solid var(--red); border-radius: var(--r-md); padding: 14px 18px; }
.alert h3 { font-size: 1.05rem; }
.alert p { color: var(--steel); font-size: .93rem; }
.cover-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cover-form input { padding: 9px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); width: 220px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.days button { border: 1.5px solid var(--line); background: var(--white); border-radius: var(--r-sm); padding: 7px 12px; text-align: left; display: grid; line-height: 1.15; }
.days button b { font-family: var(--cond); font-size: 1.05rem; }
.days button span { font-size: .8rem; color: var(--steel); }
.days button.on { background: var(--slate); color: var(--white); border-color: var(--slate); }
.days button.on span { color: #C3CDD7; }
.days button .alert-dot { display: inline-block; width: 7px; height: 7px; background: var(--red); border-radius: 50%; margin-left: 4px; vertical-align: middle; }
.shifts { display: grid; gap: 18px; }
.site h3 { font-size: 1.05rem; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; }
.site h3 small { font-weight: 500; color: var(--steel); }
.shift-row { display: grid; grid-template-columns: 110px 1fr 1fr auto; gap: 14px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 14px; margin-bottom: 6px; }
.shift-row.miss { border-left: 5px solid var(--red); }
.shift-row .hours { font-family: var(--cond); font-weight: 600; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.shift-row .note { grid-column: 2 / -1; font-size: .88rem; color: var(--steel); }

/* Conversaciones */
.chat { display: grid; grid-template-columns: 280px 1fr; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; height: calc(100vh - 290px); min-height: 460px; }
.contacts { list-style: none; border-right: 1px solid var(--line); overflow: auto; }
.contacts button { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid #E6EBF0; padding: 12px 16px; display: grid; gap: 2px; }
.contacts button:hover { background: #F6F8FA; }
.contacts button.on { background: var(--mist); box-shadow: inset 4px 0 0 var(--slate); }
.contacts strong { font-weight: 600; }
.contacts span { color: var(--steel); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-wrap { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.thread-head { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.thread-head strong { font-size: 1.1rem; }
.thread { list-style: none; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; background: #F3F5F7; }
.msg { max-width: 72%; padding: 8px 12px 6px; border-radius: 12px; white-space: pre-wrap; box-shadow: 0 1px 0 rgba(28, 39, 51, .06); }
.msg.in { align-self: flex-start; background: var(--white); border-bottom-left-radius: 3px; }
.msg.out { align-self: flex-end; background: #DDEBDF; border-bottom-right-radius: 3px; }
.msg.mesa { background: var(--amber-wash); border: 1px solid #EBD38E; }
.msg.sys { align-self: center; background: none; box-shadow: none; color: var(--steel); font-size: .85rem; padding: 2px; }
.msg.err { align-self: center; background: var(--red-wash); color: var(--red); font-size: .85rem; }
.msg .meta { display: flex; gap: 8px; justify-content: flex-end; font-size: .75rem; color: var(--steel); margin-top: 3px; }
.msg .who { font-weight: 700; }
.day-sep { align-self: center; font-size: .8rem; color: var(--steel); background: var(--white); border-radius: 99px; padding: 2px 10px; margin: 6px 0; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.composer textarea { resize: none; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); }
.thread-empty { margin: auto; color: var(--steel); text-align: center; }

/* Cajón de detalle */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(28, 39, 51, .35); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--white); overflow: auto; padding: 28px 28px 40px; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
.drawer-close { position: absolute; top: 14px; right: 16px; border: 0; background: none; font-size: 1.8rem; line-height: 1; color: var(--steel); }
.d-title { font-family: var(--cond); font-weight: 700; font-size: 2rem; }
.d-sec { margin-top: 22px; display: grid; gap: 8px; }
.d-sec h2 { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.d-sec select { padding: 9px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--white); max-width: 260px; }
.timeline { list-style: none; display: grid; gap: 10px; border-left: 2px solid var(--line); padding-left: 14px; }
.timeline li { font-size: .93rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--white); border: 2px solid var(--steel); }
.timeline li small { display: block; color: var(--steel); font-size: .8rem; }
.prose { white-space: pre-wrap; background: #F6F8FA; border-radius: var(--r-sm); padding: 10px 12px; }

/* Ayuda contextual */
.info { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--slate); color: var(--white); font-size: .72rem; font-weight: 700; cursor: help; flex: none; }
[data-tip] { cursor: help; }
th [data-tip] { border-bottom: 1px dotted var(--steel); }
.tip { position: fixed; z-index: 100; max-width: 300px; background: var(--slate); color: var(--white); font-size: .88rem; line-height: 1.4; padding: 9px 12px; border-radius: var(--r-sm); pointer-events: none; box-shadow: 0 6px 18px rgba(28, 39, 51, .25); }

/* Avisos */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--slate); color: var(--white); padding: 12px 16px; border-radius: var(--r-sm); box-shadow: 0 8px 22px rgba(28, 39, 51, .28); max-width: 360px; animation: slide .2s ease-out; }
.toast.amber { background: var(--amber); color: var(--slate); font-weight: 600; }
.toast.error { background: var(--red); }

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(3, 1fr); }
  .tile:nth-child(4) { border-left: 0; }
  .tile:nth-child(n+4) { border-top: 1px solid var(--line); }
  .approval { grid-template-columns: 1fr; }
  .ap-left { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .main { padding: 18px 14px 40px; }
  .board { grid-template-columns: 1fr 1fr; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .shift-row { grid-template-columns: 1fr auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Acciones de vista, fotos, toma de conversación */
.view-actions { display: flex; gap: 10px; margin: -4px 0 16px; flex-wrap: wrap; }
.alert.pending { border-left-color: var(--amber); }
.alert-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photo { width: 120px; height: 90px; border-radius: var(--r-sm); background: var(--mist) center/cover no-repeat; border: 1px solid var(--line); display: grid; place-items: end start; overflow: hidden; }
.photo span { background: rgba(28, 39, 51, .72); color: var(--white); font-size: .72rem; padding: 2px 6px; border-top-right-radius: 6px; max-width: 100%; }
.photo.big { width: 100%; height: 220px; }
.msg img { display: block; max-width: 240px; border-radius: 8px; margin-bottom: 4px; }
.msg .kind { font-weight: 700; }
.handoff { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.chip.mesa { background: var(--amber); color: var(--slate); }
.notify { display: flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--steel); }
.rating { font-family: var(--cond); font-weight: 700; font-size: 1.2rem; }
