:root {
  --navy: #161933; --navy-2: #232850; --orange: #ef9623; --orange-d: #b86a00;
  --paper: #f7f7fa; --card: #fff; --ink: #1b1d2e; --muted: #5d6178; --line: #dcdde6;
  --ok: #1f7a4d; --ok-bg: #e2f4ea; --warn: #8a5300; --warn-bg: #fff0d6; --info: #1d4f91; --info-bg: #e3edfb; --err: #b3261e; --err-bg: #fde7e5;
  --r: 14px; --tab-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #11132a; --card: #1b1e3b; --ink: #eceef8; --muted: #a2a6c0; --line: #33375c;
    --ok: #6fd6a2; --ok-bg: #153a2a; --warn: #f6c36b; --warn-bg: #3b2c0e; --info: #9cc3f7; --info-bg: #172c4d; --err: #ff9c94; --err-bg: #4a1b19; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
h1 { font-size: 1.5rem; margin: 0; } h2 { font-size: 1.1rem; margin: 0; } h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: 0; } a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
[hidden] { display: none !important; }

.stack { display: flex; flex-direction: column; gap: .9rem; } .stack.small { gap: .5rem; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: .88rem; } .pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { color: var(--muted); text-align: center; padding: 1rem .5rem; }
.label { display: block; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .2rem; }
ul.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.group { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; margin-top: .4rem; }
.back { text-decoration: none; font-size: .95rem; }

/* Estructura */
.shell { min-height: 100dvh; display: block; }
.side { display: none; }
.content { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 1rem); }
.top { display: flex; justify-content: space-between; align-items: center; background: var(--navy); color: #fff; padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem; position: sticky; top: 0; z-index: 5; }
.top .icon-btn { color: #fff; }
#view { padding: 1rem; max-width: 820px; margin: 0 auto; outline: none; }
.statusbar { background: var(--warn-bg); color: var(--warn); padding: .4rem 1rem; font-size: .9rem; display: flex; gap: .4rem; align-items: center; justify-content: center; }
.tabs { position: fixed; inset: auto 0 0 0; display: flex; background: var(--navy); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
.tabs a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tab-h); color: #b9bcd8; text-decoration: none; font-size: .68rem; }
.tabs a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs a.active { color: var(--orange); }
.brand { display: flex; align-items: center; gap: .6rem; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--orange); color: var(--navy); font-weight: 800; }

@media (min-width: 860px) {
  .shell { display: grid; grid-template-columns: 250px 1fr; }
  .side { display: flex; flex-direction: column; gap: 1.2rem; background: var(--navy); color: #fff; padding: 1.2rem 1rem; position: sticky; top: 0; height: 100dvh; }
  .side-nav { display: flex; flex-direction: column; gap: .2rem; }
  .side-nav a { display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem; border-radius: 10px; color: #d5d7ea; text-decoration: none; }
  .side-nav a:hover { background: var(--navy-2); }
  .side-nav a.active { background: var(--orange); color: var(--navy); font-weight: 600; }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; } .side-foot .hint { color: #b9bcd8; }
  .top, .tabs { display: none; }
  .content { padding-bottom: 2rem; }
  #view { padding: 2rem; }
}

/* Componentes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; }
a.card, button.card { display: block; width: 100%; text-align: left; color: inherit; text-decoration: none; cursor: pointer; }
a.card:hover, button.card:hover { border-color: var(--orange); }
.card.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--navy); color: #fff; border: 0; }
.hero p { color: #cfd1e6; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.report > * + * { margin-top: .35rem; } .report-top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.hours { color: var(--orange-d); font-weight: 700; } @media (prefers-color-scheme: dark) { .hours { color: var(--orange); } }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-block; font-size: .78rem; padding: .12rem .55rem; border-radius: 99px; background: var(--line); color: var(--ink); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.info { background: var(--info-bg); color: var(--info); }
.job-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .7rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.job-row:first-of-type { border-top: 0; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem; display: flex; flex-direction: column; }
.tile b { font-size: 1.6rem; color: var(--navy); } @media (prefers-color-scheme: dark) { .tile b { color: var(--orange); } } .tile span { color: var(--muted); font-size: .85rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 44px; padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600; }
.side .btn { background: var(--navy-2); border-color: transparent; color: #fff; }
.btn.small { min-height: 38px; padding: .3rem .8rem; font-size: .9rem; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: var(--navy); }
.btn.danger { color: var(--err); border-color: var(--err); background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; color: inherit; }
.icon-btn:hover { background: rgba(127, 127, 160, .18); }

input:not([type=checkbox]):not([type=file]), select, textarea { width: 100%; min-height: 44px; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: .25rem; } .field label { font-weight: 600; font-size: .92rem; }
.form-error { color: var(--err); background: var(--err-bg); padding: .5rem .7rem; border-radius: 10px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; align-items: end; }
.checks { display: flex; flex-direction: column; } .check { display: flex; align-items: center; gap: .5rem; min-height: 40px; }
.check input { width: 20px; height: 20px; }

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: var(--navy); }
.auth .card { width: min(420px, 100%); }

/* Ventanas y avisos */
dialog.modal { border: 0; padding: 0; border-radius: var(--r); width: min(560px, calc(100% - 1rem)); max-height: calc(100dvh - 1rem); background: var(--card); color: var(--ink); }
dialog.modal::backdrop { background: rgba(10, 12, 30, .6); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .6rem .6rem .6rem 1rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.modal-body { padding: 1rem; } .modal-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 1rem + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: .7rem 1.1rem; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100% - 2rem); }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.error { background: var(--err); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
@media (min-width: 860px) { .toast { bottom: 1.5rem; } }
@media (prefers-color-scheme: dark) { .toast.ok { color: #08240f; } .toast.error { color: #3a0a07; } }

/* Fotos y archivos */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; }
.file { display: flex; flex-direction: column; gap: .2rem; font-size: .75rem; color: var(--muted); text-decoration: none; position: relative; overflow-wrap: anywhere; }
.file img, .file .pdf { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--line); display: grid; place-items: center; font-weight: 700; }

/* Agenda */
.cal-nav { display: flex; justify-content: space-between; align-items: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { text-align: center; font-size: .8rem; color: var(--muted); font-weight: 600; }
.cal-cell { aspect-ratio: 1; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 4px 2px; cursor: pointer; }
.cal-cell.blank { border: 0; background: transparent; cursor: default; }
.cal-cell.today { border-color: var(--orange); border-width: 2px; } .cal-cell.selected { background: var(--navy); color: #fff; }
.dots { display: flex; gap: 3px; min-height: 8px; } .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.warn { background: var(--orange); } .dot.ok { background: var(--ok); } .dot.info { background: var(--info); }
.legend { color: var(--muted); font-size: .85rem; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; } .actions .btn { flex: 1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.quick { display: flex; gap: .4rem; flex-wrap: wrap; }
.job-sel { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.job-sel select { width: auto; min-width: 140px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
