:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #1c1f24;
  --muted: #646b76;
  --border: #dde1e6;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --mine: #2f5bd3;
  --mine-text: #ffffff;
  --ok: #1d7a46;
  --ok-bg: #e3f4ea;
  --warn: #9a5b00;
  --warn-bg: #fdf0d9;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1b1e24;
    --surface-2: #252932;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2f343e;
    --accent: #6d8ff0;
    --accent-text: #0d1220;
    --mine: #3b5fc9;
    --mine-text: #ffffff;
    --ok: #6fd39b;
    --ok-bg: #173826;
    --warn: #f2bd63;
    --warn-bg: #3a2c12;
    --bad: #f28b82;
    --bad-bg: #42201e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 14px;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button:disabled { opacity: .55; cursor: default; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--bad); }
.hidden { display: none !important; }

/* ---------- Encabezado ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; }
.topbar .who { color: var(--muted); font-size: 14px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 24px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; }
.login-card label { display: block; font-size: 14px; margin: 12px 0 4px; color: var(--muted); }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 20px; padding: 10px; }

/* ---------- Chat ---------- */
.chat-page { display: flex; flex-direction: column; height: 100%; max-width: 720px; margin: 0 auto; background: var(--bg); }
.period {
  margin: 12px 16px 0; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px;
}
.period strong { font-size: 16px; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); overflow-wrap: anywhere; }
.msg.bot { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--mine); color: var(--mine-text); border-color: var(--mine); border-bottom-right-radius: 4px; }
.msg.me img { display: block; max-width: 220px; max-height: 260px; border-radius: 10px; }
.msg .time { display: block; font-size: 12px; opacity: .75; margin-top: 4px; }
.msg.typing { color: var(--muted); }
.composer {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.composer .preview { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--muted); font-size: 14px; }
.composer .preview img { height: 48px; width: 48px; object-fit: cover; border-radius: 8px; }
.composer .preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Panel ---------- */
.admin-main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 14px; white-space: nowrap; color: var(--muted); }
.tabs button.active { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 600; text-align: center; margin-left: 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; cursor: zoom-in; display: block; background: var(--surface-2); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 13px; white-space: nowrap; }
.pill.pendiente { background: var(--surface-2); color: var(--muted); }
.pill.aprobado { background: var(--ok-bg); color: var(--ok); }
.pill.rechazado { background: var(--bad-bg); color: var(--bad); }
.pill.sospechoso { background: var(--warn-bg); color: var(--warn); }
.reasons { margin: 4px 0 0; padding-left: 18px; color: var(--warn); font-size: 14px; }
.amount-input { width: 90px; text-align: right; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.new-user { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.notice { background: var(--ok-bg); color: var(--ok); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.notice code { font-size: 16px; font-weight: 700; user-select: all; }

/* ---------- Visor de imagen ---------- */
dialog.viewer { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; }
dialog.viewer::backdrop { background: rgba(0, 0, 0, .8); }
dialog.viewer img { max-width: 96vw; max-height: 88vh; display: block; border-radius: 8px; }
dialog.viewer .viewer-bar { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }

@media (max-width: 640px) {
  .msg { max-width: 90%; }
  .card .value { font-size: 20px; }
  .hide-sm { display: none; }
}

/* ---------- Tema vidrio (chat, login y panel): fondo negro + superficies difuminadas ---------- */
body.glass {
  --g-text: #f2efe8;
  --g-muted: rgba(242, 239, 232, .6);
  --g-surface: rgba(255, 255, 255, .06);
  --g-surface-hover: rgba(255, 255, 255, .1);
  --g-border: rgba(255, 255, 255, .12);
  --g-blur: blur(22px) saturate(150%);
  /* Los colores base también pasan a vidrio, así todos los componentes se adaptan. */
  --bg: #000;
  --surface: var(--g-surface);
  --surface-2: rgba(255, 255, 255, .04);
  --text: var(--g-text);
  --muted: var(--g-muted);
  --border: var(--g-border);
  --accent: #f2efe8;
  --accent-text: #111;
  --ok: #7fd6a4;
  --ok-bg: rgba(127, 214, 164, .14);
  --warn: #f0c27a;
  --warn-bg: rgba(240, 194, 122, .14);
  --bad: #f19a92;
  --bad-bg: rgba(241, 154, 146, .14);
  background: #000;
  color: var(--g-text);
  color-scheme: dark;
}
/* Luces tenues detrás: sin algo detrás, el difuminado sobre negro puro no se notaría. */
body.glass::before {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 30% at 25% 30%, rgba(214, 170, 92, .16), transparent 70%),
    radial-gradient(35% 28% at 78% 62%, rgba(70, 120, 140, .18), transparent 70%),
    radial-gradient(30% 22% at 50% 95%, rgba(214, 170, 92, .10), transparent 70%);
  filter: blur(40px);
}
.glass .chat-page, .glass .login-wrap { background: transparent; }

.glass .topbar,
.glass .period,
.glass .msg.bot,
.glass .composer,
.glass .login-card {
  background: var(--g-surface);
  -webkit-backdrop-filter: var(--g-blur);
  backdrop-filter: var(--g-blur);
  border: 1px solid var(--g-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 8px 30px rgba(0, 0, 0, .35);
  color: var(--g-text);
}
.glass .topbar { border-width: 0 0 1px; box-shadow: none; }
.glass .topbar a, .glass button.link { color: var(--g-text); opacity: .85; }
.glass .muted, .glass .topbar .who, .glass .msg.typing { color: var(--g-muted); }
.glass .period { border-radius: 18px; }

.glass .msg.bot { border-radius: 20px 20px 20px 6px; }
.glass .msg.me {
  background: rgba(242, 239, 232, .14);
  -webkit-backdrop-filter: var(--g-blur);
  backdrop-filter: var(--g-blur);
  border: 1px solid rgba(242, 239, 232, .22);
  color: var(--g-text);
  border-radius: 20px 20px 6px 20px;
}

/* La barra de envío flota como una cápsula, igual que el campo de la referencia. */
.glass .composer {
  margin: 0 12px calc(12px + env(safe-area-inset-bottom));
  padding: 8px 8px 8px 10px;
  border-radius: 999px;
}
.glass .composer .preview { color: var(--g-muted); }
.glass button, .glass input {
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  color: var(--g-text);
  border-radius: 999px;
}
.glass button:hover { background: var(--g-surface-hover); }
.glass button.primary {
  background: rgba(242, 239, 232, .9);
  border-color: transparent;
  color: #111;
}
.glass button.primary:disabled { background: rgba(255, 255, 255, .18); color: rgba(255, 255, 255, .55); opacity: 1; }
.glass button.link { background: none; border: 0; }
.glass input::placeholder { color: var(--g-muted); }
.glass .login-card { border-radius: 24px; }
.glass .login-card input { border-radius: 12px; padding: 10px 14px; }
/* La cápsula flota sobre los mensajes para que se vea el difuminado al desplazarse. */
.glass .chat-page { position: relative; }
.glass .messages { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.glass .composer { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; }
/* Vidrio oscuro: legible aunque pase una foto blanca por detrás. */
.glass .composer { background: rgba(24, 26, 30, .62); }

/* Botones redondos con ícono (+ para agregar foto, flecha para enviar). */
.icon-btn {
  flex: none;
  width: 44px; height: 44px;
  padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
}
.glass .composer .icon-btn {
  background: rgba(255, 255, 255, .14);
  border: 0;
  color: var(--g-text);
}
.glass .composer .icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.glass .composer .icon-btn.send:not(:disabled) { background: rgba(242, 239, 232, .9); color: #111; }
.glass .composer .icon-btn:disabled { opacity: .45; }
.glass .composer { padding: 6px; gap: 10px; }

/* ---------- Panel con tema vidrio ---------- */
.glass .card,
.glass .table-wrap,
.glass .notice {
  background: var(--g-surface);
  -webkit-backdrop-filter: var(--g-blur);
  backdrop-filter: var(--g-blur);
  border: 1px solid var(--g-border);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 8px 30px rgba(0, 0, 0, .35);
}
.glass .topbar { position: sticky; top: 0; z-index: 5; }
.glass th { background: rgba(255, 255, 255, .04); }
.glass .tabs { border-bottom-color: var(--g-border); }
.glass .tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; }
.glass .tabs button.active { border-bottom-color: var(--g-text); }
.glass .tabs button:hover { background: none; color: var(--g-text); }
.glass select, .glass input[type="date"], .glass input[type="number"] {
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--g-text);
}
.glass .amount-input { border-radius: 10px; padding: 6px 10px; }
.glass select option { background: #1a1c20; color: var(--g-text); }
.glass .admin-main button:not(.link) { border-radius: 999px; }
.glass .badge { background: #e5675c; }
.glass dialog.viewer .viewer-bar a { color: var(--g-text); }
.glass .admin-main h3 { font-weight: 600; }
.glass .admin-main .tabs button { border-radius: 0; }

/* Logo en el inicio de sesión */
.login-card .login-logo { margin: 4px 0 18px; line-height: 0; }
.login-card .login-logo img { display: block; width: 100%; height: auto; }
.login-card .login-logo + p { text-align: center; }

/* Pie de página */
.site-footer { text-align: center; font-size: 13px; color: var(--muted); padding: 24px 16px calc(16px + env(safe-area-inset-bottom)); letter-spacing: .02em; }
.site-footer.fixed { position: fixed; left: 0; right: 0; bottom: 0; padding-top: 0; }

/* Logo en la barra del chat */
.topbar .topbar-logo { line-height: 0; }
.topbar .topbar-logo img { height: 24px; width: auto; display: block; }

/* Interruptor de recepción (panel) */
.recepcion { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.recepcion-title { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.recepcion .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 4px var(--bad-bg); flex: none; }
.recepcion.abierta .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }

/* Chat bloqueado */
.composer .locked-note { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 0 6px; min-width: 0; }
.composer .locked-note svg { flex: none; }
.composer.locked .icon-btn, .composer.locked .preview { display: none; }
.composer:not(.locked) .locked-note { display: none; }
.glass .composer.locked { padding: 12px 18px; }

/* Confirmación dentro de la página y avisos */
.confirm-inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
button.danger { background: var(--bad); border-color: var(--bad); color: #111; }
button.danger:hover { background: var(--bad); filter: brightness(1.1); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: rgba(30, 32, 36, .9); color: #f2efe8; border: 1px solid rgba(255, 255, 255, .14);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); font-size: 14px;
}
.toast.error { border-color: rgba(241, 154, 146, .5); }

/* ---------- Carrusel de marcas (inicio de sesión) ---------- */
.glass .login-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px; padding-bottom: 64px; }
.brands { width: 100vw; display: grid; gap: 22px; }
.marquee {
  overflow: hidden;
  /* Desvanecido en los bordes, como en la referencia. */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent);
}
.marquee .track { display: flex; width: max-content; animation: marquee-left 30s linear infinite; }
.marquee .track[data-dir="right"] { animation-name: marquee-right; }
.marquee .group { display: flex; flex: none; }
@keyframes marquee-left { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes marquee-right { from { transform: translateX(-50%); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .marquee .track { animation: none; } }

.brand {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 44px; height: 30px;
  color: #c9b48f; /* dorado tenue */
  font-size: 18px; font-weight: 500; white-space: nowrap;
  opacity: .85;
}
.brand-abr { font-weight: 700; letter-spacing: .14em; }
.brand-abr small { font-size: 11px; font-weight: 600; letter-spacing: .2em; opacity: .8; }
.brand-claude svg { flex: none; }
body.glass { overflow-x: hidden; }

/* Ajustes: marcas más pequeñas y pasando por detrás de la tarjeta de inicio de sesión. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.login-card .lead { text-align: center; margin: 4px 0 8px; }
.glass .login-wrap { position: relative; padding-bottom: 16px; }
.glass .login-card { position: relative; z-index: 1; }
.brands {
  position: fixed; left: 0; top: 50%; z-index: 0;
  transform: translateY(-50%);
  gap: 18px;
  pointer-events: none;
}
.brand { font-size: 15px; height: 24px; padding: 0 34px; gap: 6px; }
.brand-abr small { font-size: 9px; }
.brands .marquee { -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent); mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent); }
.login-card .login-logo.small-logo { margin: 2px auto 14px; max-width: 190px; }
.topbar .panel-brand { display: flex; align-items: center; gap: 12px; line-height: 1; }
.topbar .panel-brand span { font-size: 14px; font-weight: 500; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--border); }

/* Selectores: flecha propia con espacio a la derecha para que no toque el borde redondeado. */
.glass select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23f2efe8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 12px;
  cursor: pointer;
}

/* Pregunta con botones dentro del chat */
.msg .choices { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.msg .choice { border-radius: 999px; padding: 7px 14px; font-size: 14px; }
.glass .msg .choice { background: rgba(255, 255, 255, .1); border: 1px solid var(--g-border); color: var(--g-text); }
.glass .msg .choice.primary { background: rgba(242, 239, 232, .9); color: #111; border-color: transparent; }
.msg .choice:disabled { opacity: .45; cursor: default; }
.pill.confirmado { background: rgba(140, 170, 255, .16); color: #a9bcff; }
.toast.ok { border-color: rgba(127, 214, 164, .5); }

/* Fechas del periodo junto al botón de abrir recepción */
.rec-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rec-fechas { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-fechas input[type="date"] { padding: 7px 12px; }
.glass optgroup { background: #1a1c20; color: var(--g-muted); font-style: normal; }

/* Alertas: el texto alineado con el resto de la columna y el punto colgando por fuera. */
.reasons { padding-left: 0; margin-left: 0; list-style-position: outside; }
.reasons li { margin-left: 0; }

/* Aprobar y Rechazar del mismo tamaño */
.row-actions button[data-act="aprobado"], .row-actions button[data-act="rechazado"] { width: 108px; text-align: center; padding-left: 0; padding-right: 0; }

/* Panel: ocupa casi todo el ancho de la ventana, con un margen pequeño y parejo a ambos lados. */
.admin-main { max-width: none; padding: 20px clamp(16px, 2.5vw, 40px); }

/* Botón destructivo con borde */
.glass .admin-main button.danger-outline { border-color: rgba(241, 154, 146, .45); color: var(--bad); }
.glass .admin-main button.danger-outline:hover { background: var(--bad-bg); }
.confirm-inline > span { max-width: 360px; }

/* Detalle de reservas leídas por la IA (panel) */
.cobros { list-style: none; margin: 6px 0 4px; padding: 0; display: grid; gap: 4px; }
.cobros li { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, .04); font-size: 13px; }
.cobros li .muted { grid-column: 1; font-size: 12px; }
.cobros li strong { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-variant-numeric: tabular-nums; }

/* Instrucción fija arriba del chat del empleado */
.instruccion {
  margin: 10px 16px 0; padding: 10px 14px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13.5px; line-height: 1.45; color: var(--g-muted, var(--muted));
  background: rgba(255, 255, 255, .04); border: 1px solid var(--border); border-radius: 14px;
}
.instruccion svg { flex: none; margin-top: 2px; color: #c9b48f; }
.instruccion strong { color: var(--g-text, var(--text)); font-weight: 600; }

/* Resumen por empleado: líneas divisorias entre todas las columnas. */
[data-panel="resumen"] table th:not(:last-child),
[data-panel="resumen"] table td:not(:last-child) {
  border-right: 1px solid var(--border);
}

/* ==========================================================================
   Mejoras de accesibilidad y CSS moderno (revisión con modern-web-guidance)
   ========================================================================== */

/* --- Pestañas: estado desde aria-selected; subrayado con borde en un pseudo-elemento
       (no box-shadow/fondo, que desaparecen en modo de alto contraste) y sin cambiar tamaños. --- */
.tabs button { position: relative; font-weight: 500; }
.glass .tabs button, .glass .tabs button.active { border-bottom: 0; font-weight: 500; }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; inset-inline: 8px; inset-block-end: -1px;
  border-block-end: 2px solid currentColor; border-radius: 2px;
}
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }
[role="tabpanel"][hidden] { display: none !important; }

/* --- Diálogos modales nativos --- */
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { overflow: hidden; overscroll-behavior: contain; }
dialog.confirm {
  max-width: min(440px, calc(100vw - 32px)); padding: 22px 22px 18px;
  border: 1px solid var(--border); border-radius: 18px;
  background: #16181c; color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
dialog.confirm::backdrop { background: rgba(0, 0, 0, .6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog.confirm h2 { margin: 0 0 8px; font-size: 18px; }
dialog.confirm p { margin: 0 0 18px; color: var(--muted); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.confirm-actions button { border-radius: 999px; padding: 9px 18px; }
.glass .confirm-actions button { background: rgba(255, 255, 255, .08); border: 1px solid var(--border); color: var(--text); }
.glass .confirm-actions button.danger { background: var(--bad); border-color: var(--bad); color: #111; }
dialog.viewer .viewer-bar a { color: var(--g-text, #fff); }
dialog.viewer .viewer-bar button { border-radius: 999px; }

/* --- Avisos: un contenedor fijo (popover manual en la capa superior) que apila los avisos. --- */
.toast-region {
  position: fixed; inset: auto 16px 16px auto; margin: 0; padding: 0;
  border: 0; background: transparent; overflow: visible;
  width: min(420px, calc(100vw - 32px));
  display: none; flex-direction: column; gap: 8px;
}
.toast-region:popover-open { display: flex; }
.toast-region .toast {
  position: static; transform: none; max-width: none;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 10px 10px 14px; font-size: 14px; line-height: 1.4;
  opacity: 1; translate: 0 0;
  transition: opacity .2s, translate .2s;
}
@starting-style { .toast-region .toast { opacity: 0; translate: 0 8px; } }
@media (prefers-reduced-motion: reduce) { .toast-region .toast { transition: none; } }
.toast-region .toast p { margin: 0; flex: 1; overflow-wrap: anywhere; }
.toast-close {
  flex: none; width: 28px; height: 28px; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .1); border: 0; color: inherit; font-size: 18px; line-height: 1;
}

/* --- Tablas: contenedor desplazable con teclado y vista de tarjetas en espacios angostos. --- */
.table-wrap { container-type: inline-size; }
.table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@container (width < 600px) {
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; }
  .table-wrap thead { display: none; } /* los nombres de columna van en cada celda */
  .table-wrap tr { padding: 10px 4px; border-bottom: 1px solid var(--border); }
  .table-wrap tr:last-child { border-bottom: 0; }
  .table-wrap td { border: 0 !important; padding: 4px 12px; text-align: left !important; }
  .table-wrap td[data-label]:not(:first-child)::before {
    content: attr(data-label);
    display: block; font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted);
  }
  .table-wrap td.hide-sm { display: block; }
  .table-wrap .empty { text-align: center !important; }
}

/* --- Logo del carrusel: máscara CSS con el color exacto (antes, cadena de filtros aproximada). --- */
.brand-logo {
  display: inline-block; height: 17px; aspect-ratio: 1018 / 198;
  background-color: currentColor;
  -webkit-mask: url("/static/logo-stargate.png") no-repeat center / contain;
  mask: url("/static/logo-stargate.png") no-repeat center / contain;
}

/* --- Carrusel: se puede pausar (WCAG 2.2.2) y se detiene al escribir en el formulario. --- */
.brands.pausado .marquee .track,
.login-wrap:has(.login-card:focus-within) .marquee .track { animation-play-state: paused; }
.marquee-toggle {
  position: fixed; right: 16px; bottom: 14px; z-index: 2;
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
}
@media (prefers-reduced-motion: reduce) { .marquee-toggle { display: none; } }

/* Panel: en pantallas medianas y grandes ocupa ~81% del ancho, centrado. En pantallas angostas usa casi todo el ancho. */
@media (min-width: 900px) {
  .admin-main { width: 81%; max-width: 1600px; margin-inline: auto; padding-inline: 0; }
}

/* Columna Monto: encabezado y valor centrados; campo compacto con el símbolo $ dentro. */
th.monto, td.monto { text-align: center; white-space: nowrap; }
.amount-field {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px 8px; border-radius: 8px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--border);
  font-variant-numeric: tabular-nums; cursor: text;
}
.amount-field:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.amount-field span { color: var(--muted); font-size: 14px; }
.glass .amount-field .amount-input,
.amount-field .amount-input {
  width: 5.5ch; padding: 0; border: 0; border-radius: 0; background: transparent;
  text-align: left; font-size: 14px; outline: none;
  -moz-appearance: textfield; appearance: textfield;
}
.amount-field .amount-input::-webkit-inner-spin-button,
.amount-field .amount-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
td.monto .muted { display: block; margin-top: 4px; }

/* Monto: alineado a la izquierda como los demás encabezados. */
th.monto, td.monto { text-align: left; }

/* Estado: encabezado, etiquetas y botones centrados sobre una misma línea vertical. */
th.estado, td.estado { text-align: center; }
td.estado .estado-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
td.estado .row-actions { flex-direction: column; align-items: center; margin-top: 8px; }
@container (width < 600px) {
  .table-wrap td.estado { text-align: left !important; }
  td.estado .estado-pills { justify-content: flex-start; }
  td.estado .row-actions { flex-direction: row; align-items: flex-start; }
}

/* Monto: centrado sobre su campo, igual que Estado (Empleado y Enviado quedan a la izquierda). */
th.monto, td.monto { text-align: center; }
@container (width < 600px) { .table-wrap td.monto { text-align: left !important; } }
