/* Layout: barra superior de marca + una columna de trabajo; el calendario es la pieza central
   y es una rejilla horas × días (o horas × aviones) con scroll propio. */
:root {
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --ink: #14171D;
  --ink-2: #4A5160;
  --ink-3: #7A8293;
  --line: #DCE0E7;
  --brand: #F5A524;          /* naranja Falcon */
  --brand-ink: #8A5200;      /* naranja legible sobre claro */
  --brand-soft: #FFF1D6;
  --on-brand: #1A1204;
  --ok: #157A52; --ok-soft: #DDF3E9;
  --warn: #9A5B00; --warn-soft: #FFF0D1;
  --bad: #B3261E; --bad-soft: #FBE3E1;
  --busy: #E4E7EC; --busy-ink: #5A6273;
  --maint: repeating-linear-gradient(135deg, #E9E3D6 0 6px, #F4EFE5 6px 12px);
  --shadow: 0 1px 2px rgba(20, 23, 29, .06), 0 8px 24px rgba(20, 23, 29, .06);
  --focus: 0 0 0 3px rgba(245, 165, 36, .45);

  --f-display: "MuseoModerno", "Trebuchet MS", system-ui, sans-serif;
  --f-body: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r: 10px;
  --cell-h: 34px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1116; --surface: #161A21; --surface-2: #1B2029; --ink: #E9ECF1; --ink-2: #B3BAC7; --ink-3: #868E9C;
    --line: #2A303B; --brand: #F5A524; --brand-ink: #FFC062; --brand-soft: #3A2A0E; --on-brand: #1A1204;
    --ok: #4CC38A; --ok-soft: #12301F; --warn: #F0B040; --warn-soft: #33260C; --bad: #FF8A80; --bad-soft: #3A1614;
    --busy: #252B36; --busy-ink: #A5ADBB;
    --maint: repeating-linear-gradient(135deg, #2C2A24 0 6px, #24221D 6px 12px);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1116; --surface: #161A21; --surface-2: #1B2029; --ink: #E9ECF1; --ink-2: #B3BAC7; --ink-3: #868E9C;
  --line: #2A303B; --brand: #F5A524; --brand-ink: #FFC062; --brand-soft: #3A2A0E; --on-brand: #1A1204;
  --ok: #4CC38A; --ok-soft: #12301F; --warn: #F0B040; --warn-soft: #33260C; --bad: #FF8A80; --bad-soft: #3A1614;
  --busy: #252B36; --busy-ink: #A5ADBB;
  --maint: repeating-linear-gradient(135deg, #2C2A24 0 6px, #24221D 6px 12px);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--brand); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; font-family: var(--f-body); font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
a { color: var(--brand-ink); }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.reg { font-family: var(--f-mono); font-weight: 600; letter-spacing: .06em; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); font-weight: 600; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--brand); color: var(--on-brand);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar-in { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; padding-block: 6px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand img { display: block; height: 28px; width: auto; }
.brand b { font-family: var(--f-display); font-size: 1.3rem; letter-spacing: .04em; }
.brand span { font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; opacity: .75; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.nav a, .nav button {
  color: var(--on-brand); text-decoration: none; padding: 7px 11px; border-radius: 8px; font-weight: 500;
  background: none; border: 0; font: inherit; cursor: pointer;
}
.nav a:hover, .nav button:hover { background: rgba(0, 0, 0, .08); }
.nav a[aria-current="page"] { background: rgba(0, 0, 0, .14); }
.nav .count { display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: 4px; border-radius: 99px; background: var(--on-brand); color: var(--brand); font-size: .75rem; text-align: center; font-weight: 700; }
.lang { display: inline-flex; border: 1.5px solid rgba(0, 0, 0, .35); border-radius: 8px; overflow: hidden; }
.lang button { background: none; border: 0; padding: 4px 9px; font: 600 .8rem var(--f-body); color: var(--on-brand); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--on-brand); color: var(--brand); }

/* ---------- Demo ---------- */
.demo {
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.demo-in { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding-block: 8px; font-size: .85rem; }
.demo-in .tag { background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; padding: 2px 8px; border-radius: 6px; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.demo-in .chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Página ---------- */
main {
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 56px;
}
.wrap { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.narrow { max-width: 460px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

/* ---------- Formularios ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: .9rem; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
label.check input { margin-top: 3px; accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px;
  padding: 9px 11px; min-width: 0; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--brand); }
input[type="color"] { padding: 2px; height: 40px; }
.req::after { content: " *"; color: var(--bad); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 .95rem var(--f-body); padding: 10px 16px; border-radius: 9px; border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover { filter: brightness(1.15); }
.btn-brand { background: var(--brand); color: var(--on-brand); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-bad { background: transparent; color: var(--bad); border-color: currentColor; }
.btn-sm { padding: 6px 11px; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: progress; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-ink); font: inherit; text-decoration: underline; cursor: pointer; }

.msg { padding: 10px 12px; border-radius: 8px; font-size: .9rem; }
.msg-bad { background: var(--bad-soft); color: var(--bad); }
.msg-ok { background: var(--ok-soft); color: var(--ok); }
.msg-info { background: var(--brand-soft); color: var(--brand-ink); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-pending { background: var(--warn-soft); color: var(--warn); }
.pill-approved { background: var(--ok-soft); color: var(--ok); }
.pill-rejected, .pill-suspended { background: var(--bad-soft); color: var(--bad); }
.pill-admin { background: var(--brand-soft); color: var(--brand-ink); }
.pill-admin::before { display: none; }

/* ---------- Bienvenida ---------- */
.welcome { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: stretch; }
.welcome-hero { background: var(--ink); color: var(--bg); border-radius: 14px; padding: clamp(22px, 4vw, 40px); display: flex; flex-direction: column; gap: 16px; position: relative; overflow: hidden; min-width: 0; }
.welcome-hero h1 { color: var(--bg); max-width: 18ch; }
.welcome-hero p { color: var(--bg); opacity: .8; max-width: 52ch; }
.welcome-hero .strip { display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; }
.placard { font-weight: 600; letter-spacing: .04em; border: 1.5px solid var(--brand); color: var(--brand); padding: 4px 10px; border-radius: 6px; font-size: .9rem; }
.welcome-lang { display: flex; flex-direction: column; gap: 12px; justify-content: center; }
.langcard { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; font: inherit; color: var(--ink); text-align: left; }
.langcard:hover { border-color: var(--brand); }
.langcard b { font-family: var(--f-display); font-size: 1.4rem; font-weight: 600; }
.langcard span { color: var(--ink-2); font-size: .9rem; }
.langcard .arrow { font-size: 1.4rem; color: var(--brand-ink); }

/* ---------- Calendario ---------- */
.cal-tools { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.seg { display: inline-flex; background: var(--surface); border: 1.5px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 7px; font: 500 .88rem var(--f-body); color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.acpick { display: flex; gap: 6px; flex-wrap: wrap; }
.acpick button { display: inline-flex; gap: 8px; align-items: center; border: 1.5px solid var(--line); background: var(--surface); border-radius: 9px; padding: 6px 11px; cursor: pointer; font: inherit; color: var(--ink); }
.acpick .acb { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.acpick .acb small { font-size: .7rem; color: var(--ink-2); font-weight: 500; }
.acpick button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.datenav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.datenav .label { font-weight: 600; min-width: 11ch; text-align: center; text-transform: capitalize; }
.iconbtn { width: 36px; height: 36px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1.05rem; display: inline-flex; align-items: center; justify-content: center; }

.cal-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.cal { display: grid; min-width: 100%; }
.cal .head { position: sticky; top: 0; background: var(--surface); z-index: 2; border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: center; font-size: .82rem; line-height: 1.25; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.cal .head > span { max-width: 100%; overflow-wrap: anywhere; }
.cal .head b { display: block; font-size: .95rem; text-transform: capitalize; }
.cal .head.today b { color: var(--brand-ink); }
.cal .head .reg { font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; }
.cal .hour { font: 500 .75rem var(--f-mono); color: var(--ink-3); text-align: right; padding: 0 8px; height: var(--cell-h); line-height: var(--cell-h); border-right: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.cal .hour.night { color: var(--ink-3); background: var(--surface-2); }
.cell { height: var(--cell-h); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); position: relative; padding: 0; background: var(--surface); }
.cell.free { cursor: pointer; }
.cell.free:hover { background: var(--brand-soft); }
.cell.free:hover::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--brand-ink); font-weight: 700; }
.cell.past { background: var(--surface-2); cursor: default; }
.cell.off { background: var(--surface-2); }
.cell.busy { background: var(--busy); }
.cell.mine { background: var(--ac, var(--brand)); }
.cell.maint { background: var(--maint); }
.cell .tag { position: absolute; left: 6px; right: 4px; top: 4px; font-size: .72rem; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--busy-ink); z-index: 1; }
.cell.mine .tag { color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.cell.busy.start, .cell.mine.start, .cell.maint.start { border-top: 2px solid var(--surface); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: .85rem; color: var(--ink-2); }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; border: 1px solid var(--line); }

/* ---------- Listas ---------- */
.list { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .when { font-variant-numeric: tabular-nums; }
.item .when b { display: block; }
.item.past { opacity: .6; }
.item.cancelled .when, .item.cancelled .what { text-decoration: line-through; }
.badge-ac { display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px; border-radius: 7px; border: 1.5px solid var(--line); background: var(--surface-2); }
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat b { font-family: var(--f-display); font-size: 1.8rem; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 2.5px solid transparent; padding: 9px 12px; font: 600 .95rem var(--f-body); color: var(--ink-2); cursor: pointer; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }

.pilot { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 12px 18px; padding: 16px 0; border-top: 1px solid var(--line); align-items: start; }
.pilot:first-child { border-top: 0; }
.pilot dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; font-size: .88rem; }
.pilot dt { color: var(--ink-3); }
.pilot dd { margin: 0; overflow-wrap: anywhere; }
.pilot .actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.pilot textarea { min-height: 40px; font-size: .88rem; }

.actable { width: 100%; border-collapse: collapse; }
.actable th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 6px 8px; }
.actable td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.actable input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--brand); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 12, 16, .5); z-index: 50; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal { background: var(--surface); border-radius: 14px; width: min(480px, 100%); max-height: 100%; overflow: auto; box-shadow: var(--shadow); }
.modal header { padding: 18px 20px 0; display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.modal .body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.summary { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.summary .big { font-family: var(--f-display); font-size: 1.5rem; font-variant-numeric: tabular-nums; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; z-index: 60; font-weight: 500; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }

@media (max-width: 760px) {
  .cal .hour { padding: 0 6px; font-size: .7rem; }
  .cal .head .muted { font-size: .72rem; }
  .welcome { grid-template-columns: minmax(0, 1fr); }
  .nav { margin-left: 0; width: 100%; }
  .nav { order: 2; }
  .nav.nav-out { display: none; }
  .lang { margin-left: auto; order: 1; }
  .topbar-in { gap: 8px 12px; }
  .brand { gap: 8px; }
  .brand span { letter-spacing: .06em; font-size: .7rem; }
  .datenav { margin-left: 0; }
  .pilot { grid-template-columns: minmax(0, 1fr); }
  .pilot .actions { flex-direction: row; flex-wrap: wrap; }
  .item { grid-template-columns: minmax(0, 1fr) auto; }
  .item .badge-ac { grid-column: 1 / -1; justify-self: start; }
}
@media (max-width: 374px) {
  .brand span { display: none; }
}

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