/* Comunicados — estilos. Colores, tipografía y formas tomados de TURIFY Nexus.
   Pensado primero para móvil. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Tema oscuro: el de Nexus por defecto (variables --control-*) */
:root {
  --bg: #12151a;
  --card: #191d24;
  --row: #1f242c;
  --hover: #21262e;
  --border: #262c35;
  --field-border: #4b5563;
  --text: #e6e8eb;
  --text-2: #9ba1a9;
  --muted: #6b7280;
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-text: #fb923c;
  --on-accent: #ffffff;
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning-bg: rgba(245, 158, 11, 0.12);
  --error-bg: rgba(239, 68, 68, 0.12);
  --accent-bg: rgba(249, 115, 22, 0.12);
  --paper: #ffffff;
  --ink: #16233b;
  color-scheme: dark;
}

/* Tema claro de Nexus (COMUNICADOS_THEME=light) */
[data-theme="light"] {
  --bg: #f8fafc;
  --card: #ffffff;
  --row: #f8fafc;
  --hover: #f1f5f9;
  --border: #e2e8f0;
  --field-border: #94a3b8;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --accent-text: #c2410c;
  --success: #047857;
  --warning: #b45309;
  --error: #b91c1c;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning-bg: rgba(245, 158, 11, 0.1);
  --error-bg: rgba(239, 68, 68, 0.1);
  --accent-bg: rgba(249, 115, 22, 0.1);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, p { margin: 0; }
a { color: var(--accent-text); }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell { max-width: 480px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; }
.shell--wide { max-width: 960px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack--tight { gap: 8px; }
.pad { padding: 20px 16px; }
.grow { flex: 1 1 auto; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }

/* Marca */
.brand { display: flex; align-items: center; gap: 12px; }
.brand__logo { width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0; }
.brand__name { font-size: 20px; line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; color: var(--text); }
.brand__sub { font-size: 13px; line-height: 1.3; color: var(--accent-text); }
.brand--center { flex-direction: row; justify-content: center; }
.brand--center .brand__logo { width: 50px; height: 50px; }
.brand--center .brand__name { font-size: 24px; }
.brand--center .brand__sub { font-size: 14px; }

/* Barras */
.bar { min-height: 56px; background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 4px; padding: 0 8px; }
.bar__back { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--text); border-radius: 8px; }
.bar__back:hover { background: var(--hover); color: var(--text); }
.bar__title { font-size: 17px; font-weight: 600; }
.head { background: var(--card); border-bottom: 1px solid var(--border); padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 12px; }
.head__title { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 14px; }
.nav a { font-weight: 500; text-decoration: none; padding: 8px 12px; border-radius: 8px; color: var(--text-2); }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-bg); color: var(--accent-text); }
.nav form { margin: 0 0 0 auto; }
.linkbtn { border: 0; background: none; padding: 8px 4px; font: inherit; font-size: 13px; color: var(--text-2); cursor: pointer; text-decoration: underline; }
.linkbtn:hover { color: var(--text); }

/* Tarjetas y listas */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.card--tight { padding: 4px 18px; }
.card--link { text-decoration: none; color: inherit; }
.card--link:hover { color: inherit; border-color: var(--accent); }
.section__head { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.section__title { font-size: 15px; font-weight: 600; }
.count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.count--pending { background: var(--warning-bg); color: var(--warning); }
.count--done { background: var(--success-bg); color: var(--success); }
.item__title { font-size: 18px; line-height: 1.3; font-weight: 600; }
.item__sub { font-size: 14px; color: var(--text-2); }
.row { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 8px 10px 16px; display: flex; align-items: center; gap: 12px; }
.row:hover { background: var(--row); }
.row__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: var(--text); text-decoration: none; }
.row__main:hover { color: var(--text); }
.row__title { font-size: 16px; font-weight: 600; }
.row__icon { width: 32px; height: 32px; border-radius: 16px; background: var(--success-bg); color: var(--success); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.iconbtn { width: 44px; height: 44px; border-radius: 8px; color: var(--text-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.iconbtn:hover { background: var(--hover); color: var(--text); }
.empty { font-size: 15px; color: var(--text-2); padding: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 26px; padding: 3px 10px; border-radius: 13px; background: var(--hover); color: var(--text-2); font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip--pending { background: var(--warning-bg); color: var(--warning); }
.chip--done { background: var(--success-bg); color: var(--success); }
.chip--late { background: var(--error-bg); color: var(--error); }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; font-size: 14px; border-top: 1px solid var(--border); }
.kv:first-child { border-top: 0; }
.kv__k { color: var(--text-2); flex-shrink: 0; }
.kv__v { font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.kv__v--code { white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* Botones y formularios */
.btn { min-height: 48px; padding: 12px 20px; border: 0; border-radius: 8px; background: var(--accent); color: var(--on-accent); font: inherit; font-size: 16px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; text-align: center; transition: background-color 0.15s; }
.btn:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn:disabled { background: var(--hover); color: var(--text-2); cursor: not-allowed; }
.btn--secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn--secondary:hover { background: var(--hover); color: var(--text); }
.btn--small { min-height: 44px; font-size: 15px; padding: 10px 16px; }
.btn--inline { display: inline-flex; }
.textbtn { min-height: 44px; padding: 0 12px; margin-right: -12px; border: 0; background: none; font: inherit; font-size: 15px; font-weight: 500; color: var(--accent-text); cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.field { display: flex; flex-direction: column; gap: 8px; }
.fieldset { border: 0; padding: 0; margin: 0; }
.field__label { font-size: 14px; font-weight: 500; padding: 0; }
.field__hint { font-size: 13px; color: var(--text-2); }
.input, .textarea, .select { width: 100%; min-height: 48px; padding: 12px 16px; border: 1px solid var(--field-border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 16px; transition: border-color 0.15s; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
.input--code { font-size: 26px; font-weight: 600; letter-spacing: 0.3em; text-align: center; }
.radio, .check { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); cursor: pointer; }
.radio:hover, .check:hover { background: var(--hover); }
.radio input, .check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.radio__title { font-weight: 500; }
.checklist { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; padding: 2px; }
.checklist__group { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 8px 2px 2px; }
[hidden] { display: none !important; }

.note { background: var(--hover); border-radius: 8px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; color: var(--text); }
.note svg { flex-shrink: 0; margin-top: 2px; color: var(--text-2); }
.note--ok { background: var(--success-bg); color: var(--success); }
.alert { background: var(--error-bg); color: var(--error); border-radius: 8px; padding: 12px 14px; font-size: 15px; font-weight: 500; }
.alert ul { margin: 8px 0 0; padding-left: 18px; font-weight: 400; font-size: 14px; }

/* Documento: las páginas son papel blanco, también en el tema oscuro */
.doc-meta { padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.doc-meta__title { font-size: 20px; line-height: 1.3; font-weight: 600; }
.pages { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.page { display: block; width: 100%; height: auto; background: var(--paper); border: 1px solid var(--border); border-radius: 4px; }
.actionbar { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--border); padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }

/* Firma: el recuadro es papel blanco con tinta oscura, porque así queda en el PDF */
.sign-head__title { font-size: 22px; line-height: 1.3; font-weight: 600; }
.pad-row { display: flex; align-items: center; justify-content: space-between; }
.sigpad { position: relative; width: 100%; height: 180px; background: var(--paper); border: 1px solid var(--field-border); border-radius: 8px; overflow: hidden; }
.sigpad__canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.sigpad__line { position: absolute; left: 20px; right: 20px; top: 138px; border-top: 1.5px dashed #8a93a6; pointer-events: none; }
.sigpad__hint { position: absolute; left: 0; right: 0; top: 70px; text-align: center; font-size: 15px; color: #4b5870; pointer-events: none; }

/* Confirmación */
.done-icon { width: 64px; height: 64px; border-radius: 32px; background: var(--success-bg); color: var(--success); display: flex; align-items: center; justify-content: center; }
.done-title { font-size: 26px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; }
.sigline { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.sigline svg { color: var(--success); flex-shrink: 0; }
.filehead { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.filehead svg { color: var(--text-2); flex-shrink: 0; }

/* Acceso: como la pantalla de entrada de Nexus */
.auth { justify-content: center; padding: 24px 16px; max-width: 448px; }
.auth__card { background: var(--bg); border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px; display: flex; flex-direction: column; gap: 16px; }
.auth__title { font-size: 18px; line-height: 1.3; font-weight: 600; }
.auth__foot { font-size: 13px; color: var(--muted); text-align: center; }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 14px; text-align: left; vertical-align: top; border-top: 1px solid var(--border); }
.table th { border-top: 0; font-size: 12px; font-weight: 500; color: var(--text-2); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.04em; }
.table tbody tr:hover { background: var(--row); }
.table tr.is-off td { color: var(--muted); }
.table form { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { padding: 12px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.events li:first-child { border-top: 0; }
.events__label { font-weight: 500; }
