/*
 * Componentes de GUIA_ESTILOS_TURKANA.md para las páginas de v26 que siguen la guía.
 *
 * El armazón (barra superior, menú lateral y desplegables del menú) lo pone base_turkana.html.twig y aquí no se
 * repite. Las páginas sueltas (login y su recorrido) llevan body.tk-standalone y su propia barra, al final.
 * Iconos de Font Awesome 5: la guía usa los nombres de la 7.
 */

:root {
    --tk-bg: #0f172a;
    --tk-surface: #111827;
    --tk-surface-2: #1f2937;
    --tk-surface-3: #374151;
    --tk-surface-slate: #1e293b;
    --tk-border: rgba(148,163,184,.12);
    --tk-border-strong: rgba(148,163,184,.25);
    --tk-text: #f1f5f9;
    --tk-text-2: #cbd5e1;
    --tk-text-3: #94a3b8;
    --tk-text-4: #64748b;
    --tk-text-5: #475569;
    --tk-brand: #f49336;
    --tk-brand-soft: rgba(244,147,54,.15);
    --tk-brand-border: rgba(244,147,54,.60);
    --tk-green: #22c55e;
    --tk-green-l: #4ade80;
    --tk-lime: #84cc16;
    --tk-amber: #fbbf24;
    --tk-amber-l: #fcd34d;
    --tk-red: #ef4444;
    --tk-red-l: #f87171;
    --tk-blue: #3b82f6;
    --tk-blue-l: #60a5fa;
    --tk-purple: #8b5cf6;
    --tk-purple-l: #c084fc;
    --tk-emerald: #10b981;
    color-scheme: dark;
}

/* Con Tailwind delante, una regla display de un componente ganaría a [hidden]. */
[hidden] { display: none !important; }

/* Subnavegación, contenido y cabecera de página. */
.tk-subnav { background: var(--tk-surface); border-bottom: 1px solid var(--tk-surface-2); }
.tk-subnav-inner { display: flex; align-items: center; gap: .5rem; flex-wrap: nowrap; overflow-x: auto; padding: .5rem 1.5rem; max-width: 1900px; margin-inline: auto; }
.tk-tab { font-size: .875rem; white-space: nowrap; color: #9ca3af; padding: .35rem .5rem; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; }
.tk-tab i { font-size: .75rem; }
.tk-tab:hover { color: #fff; }
.tk-tab-active { color: #fff; font-weight: 600; border-bottom-color: var(--tk-brand); }
.tk-subnav-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.tk-content { padding: 1rem; max-width: 1536px; margin-inline: auto; }
.tk-content-wide { padding: 1.25rem 1.5rem 2rem; max-width: 1900px; margin-inline: auto; }
.tk-page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tk-page-head h1 { font-size: 1.25rem; font-weight: 600; color: #f3f4f6; margin: 0; }
.tk-page-meta { font-size: .75rem; color: var(--tk-text-4); }
.tk-toggle { display: inline-flex; align-items: center; gap: .35rem; font-size: .7rem; color: var(--tk-text-3); }
.tk-toggle input { accent-color: var(--tk-brand); }
.tk-notice { font-size: .75rem; border-bottom: 1px solid; }
.tk-notice-soft { background: #030712; border-color: var(--tk-surface-2); color: #6b7280; }
.tk-notice-hard { background: rgba(120,53,15,.3); border-color: rgba(180,83,9,.4); color: #fde68a; }
.tk-notice > div { padding: .5rem .75rem; max-width: 1536px; margin-inline: auto; }

/* Superficies. */
.section-box { background: var(--tk-surface); border: 1px solid var(--tk-surface-2); border-radius: .75rem; overflow: hidden; }
.section-hdr { padding: .75rem 1rem; background: rgba(31,41,55,.7); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-hdr h2 { font-size: .875rem; font-weight: 600; color: #e5e7eb; margin: 0; }
.tk-section-meta { font-size: .75rem; color: var(--tk-text-4); }
.tk-legend-dash { display: inline-block; width: 12px; height: 3px; margin: 0 .25rem 0 .75rem; vertical-align: middle; border-radius: 1px; }
.metric-card { background: var(--tk-surface); border: 1px solid var(--tk-surface-2); border-radius: .5rem; padding: 1rem; display: block; }
a.metric-card:hover, button.metric-card:hover { border-color: var(--tk-brand); transition: border-color .15s; }
.metric-card-compact { padding: .5rem .75rem; }
.detail-card { background: transparent; border: 1px solid rgba(148,163,184,.12); border-radius: 12px; transition: border-color .2s; }
.detail-card:hover { border-color: rgba(148,163,184,.22); }
.mini-stat { background: rgba(15,23,42,.5); border: 1px solid rgba(148,163,184,.1); border-radius: 6px; padding: .75rem; min-width: 0; }
.card-critical { background: linear-gradient(135deg, rgba(239,68,68,.14), transparent 55%), rgba(30,41,59,.6); border: 1px solid rgba(148,163,184,.14); }
.card-warning { background: linear-gradient(135deg, rgba(251,191,36,.12), transparent 55%), rgba(30,41,59,.6); border: 1px solid rgba(148,163,184,.14); }

/* Indicadores. */
.tk-metric-label { font-size: .75rem; color: #9ca3af; text-transform: uppercase; letter-spacing: .05em; margin: 0 0 .25rem; }
.tk-metric-value { font-size: 1.5rem; font-weight: 700; color: #fff; margin: 0; font-variant-numeric: tabular-nums; }
.tk-metric-unit { font-size: 1rem; font-weight: 400; color: var(--tk-text-3); }
.tk-metric-sub { font-size: .75rem; color: #6b7280; margin: .125rem 0 0; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; height: 1.375rem; padding: 0 .5rem; border-radius: .25rem; font-size: .72rem; font-weight: 600; line-height: 1; white-space: nowrap; }
.pill i { font-size: .7rem; }
.pill-neutral { background: var(--tk-surface-2); color: #e5e7eb; }
.pill-ok { background: rgba(20,83,45,.5); color: #86efac; }
.pill-warn { background: rgba(120,53,15,.6); color: var(--tk-amber-l); }
.pill-bad { background: rgba(127,29,29,.5); color: #fca5a5; }
.pill-info { background: rgba(30,58,138,.5); color: var(--tk-blue-l); }
.tk-num { display: inline-block; min-width: 1.6rem; text-align: center; font-variant-numeric: tabular-nums; }

/* Filtros, fechas y paginación. */
.filter-row-label { font-size: .70rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #475569; white-space: nowrap; min-width: 72px; }
.filter-sep { width: 1px; height: 20px; background: rgba(100,116,139,.25); flex-shrink: 0; align-self: center; }
.filter-btn { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .6rem; border-radius: 6px; font-size: .75rem; font-weight: 500; cursor: pointer; user-select: none; border: 1px solid rgba(100,116,139,.5); background: rgba(30,41,59,.8); color: #94a3b8; white-space: nowrap; transition: all .15s ease; font-family: inherit; }
.filter-btn i { font-size: .7rem; }
.filter-btn:hover { border-color: rgba(148,163,184,.6); color: #cbd5e1; background: rgba(51,65,85,.8); }
.filter-btn.active { background: var(--tk-brand-soft); border-color: var(--tk-brand-border); color: var(--tk-brand); }
.filter-dropdown { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; max-width: 320px; background: var(--tk-surface-slate); border: 1px solid rgba(148,163,184,.2); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); z-index: 200; flex-direction: column; overflow: hidden; }
.filter-dropdown.open { display: flex; }
.dd-search { padding: .4rem .5rem; border-bottom: 1px solid rgba(100,116,139,.2); flex-shrink: 0; }
.dd-search input { width: 100%; background: rgba(15,23,42,.7); border: 1px solid rgba(100,116,139,.3); border-radius: 4px; color: #cbd5e1; padding: .25rem .5rem; font-size: .75rem; outline: none; font-family: inherit; }
.dd-search input:focus { border-color: rgba(244,147,54,.5); }
.dd-list { flex: 1; overflow-y: auto; padding: .25rem; max-height: 320px; }
.dd-option { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .375rem .5rem; border: none; background: none; border-radius: 6px; font-size: .8rem; color: #94a3b8; cursor: pointer; text-align: left; font-family: inherit; }
.dd-option:hover, .dd-option.is-active { background: rgba(51,65,85,.6); color: #cbd5e1; }
.dd-option.is-selected { color: var(--tk-brand); }
.dd-group-header { padding: .375rem .5rem .2rem; font-size: .7rem; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .04em; }
.tk-input { font-size: .75rem; background: rgba(15,23,42,.8); border: 1px solid rgba(100,116,139,.4); color: #d1d5db; border-radius: 5px; height: 28px; padding: 0 .6rem; outline: none; font-family: inherit; }
.tk-input:focus { border-color: var(--tk-brand); box-shadow: 0 0 0 2px rgba(244,147,54,.15); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .85; cursor: pointer; }
.page-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 .4rem; border-radius: 6px; font-size: .8125rem; font-weight: 500; cursor: pointer; user-select: none; border: 1px solid rgba(100,116,139,.3); background: rgba(30,41,59,.8); color: #64748b; transition: all .12s; font-family: inherit; }
.page-btn:hover { border-color: rgba(148,163,184,.5); color: #94a3b8; }
.page-btn.active { background: var(--tk-brand-soft); border-color: var(--tk-brand-border); color: var(--tk-brand); font-weight: 700; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Tablas. La de pantalla completa pega su cabecera bajo la barra superior, que mide 56 px. */
.tk-table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.tk-table thead { background: rgba(31,41,55,.5); }
.tk-table th { padding: .45rem .75rem; text-align: left; font-size: .7rem; color: #9ca3af; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; white-space: nowrap; }
.tk-table td { padding: .4rem .75rem; border-top: 1px solid var(--tk-surface-2); color: #cbd5e1; vertical-align: top; }
.tk-table tbody tr:hover { background: rgba(31,41,55,.4); }
.tk-datatable { width: 100%; border-collapse: collapse; }
.tk-datatable thead th { padding: .6rem .5rem; text-align: left; font-size: .7rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; border-bottom: 1px solid rgba(148,163,184,.18); position: sticky; top: 56px; z-index: 20; background: rgba(15,23,42,.92); backdrop-filter: blur(8px); }
.tk-datatable thead th.sortable { cursor: pointer; user-select: none; }
.tk-datatable thead th.sortable:hover { color: #94a3b8; }
.tk-datatable thead th.sort-asc, .tk-datatable thead th.sort-desc { color: var(--tk-brand); }
.tk-datatable tbody tr { height: 36px; background: transparent; border-bottom: 1px solid rgba(148,163,184,.1); transition: background .2s ease; scroll-margin-top: 110px; scroll-margin-bottom: 20px; }
.tk-datatable tbody tr:hover { background: rgba(51,65,85,.3); }
.tk-datatable tbody tr.is-clickable { cursor: pointer; }
.tk-datatable tbody tr.row-active { background: rgba(71,85,105,.55); }
.tk-datatable tbody tr.row-active:hover { background: rgba(71,85,105,.65); }
.tk-datatable tbody td { padding: 0 .5rem; font-size: .75rem; color: #cbd5e1; vertical-align: middle; white-space: nowrap; }
.tk-right { text-align: right; }
.tk-center { text-align: center; }
.tk-datatable thead th.tk-right, .tk-table th.tk-right { text-align: right; }
.tk-datatable thead th.tk-center, .tk-table th.tk-center { text-align: center; }
.tk-strong { font-weight: 600; }
.tk-muted { color: var(--tk-text-4); }
.tk-empty { padding: 1.5rem 1rem; text-align: center; color: #6b7280; font-size: .75rem; }
.cell-truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes tk-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-row td { padding: .4rem .5rem; }
.skeleton-cell { height: 14px; border-radius: 4px; background: linear-gradient(90deg, rgba(51,65,85,.5) 25%, rgba(71,85,105,.5) 50%, rgba(51,65,85,.5) 75%); background-size: 200% 100%; animation: tk-shimmer 1.4s infinite; }
.state-panel { padding: 3rem 2rem; text-align: center; color: #64748b; font-size: .8125rem; white-space: normal; }
.state-panel i { font-size: 2.5rem; margin-bottom: 1rem; display: block; color: #475569; }
.state-panel .btn { margin-top: .9rem; }
.state-panel-error i { color: var(--tk-red); }

/* Modal, panel lateral y visor de imágenes. */
.tk-modal { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); padding: 1rem; overflow-y: auto; justify-content: center; align-items: flex-start; }
.tk-modal.open { display: flex; }
.tk-modal-panel { background: var(--tk-surface); border: 1px solid var(--tk-surface-2); border-radius: .75rem; width: 100%; max-width: 64rem; margin: 1.5rem 0; box-shadow: 0 25px 50px -12px rgba(0,0,0,.6); }
.tk-modal-panel-sm { max-width: 32rem; }
.tk-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--tk-surface-2); position: sticky; top: 0; background: var(--tk-surface); border-radius: .75rem .75rem 0 0; z-index: 10; }
.tk-modal-title { font-size: 1rem; font-weight: 600; color: #f3f4f6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.tk-modal-icon-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: none; background: transparent; border-radius: 4px; color: #9ca3af; cursor: pointer; flex-shrink: 0; }
.tk-modal-icon-btn:hover { color: #fff; background: var(--tk-surface-2); }
.tk-modal-body { padding: 1rem 1.25rem 1.25rem; }
.tk-modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.25rem; border-top: 1px solid var(--tk-surface-2); }
/* Sin display:none: un panel que pasa de none a visible en el mismo fotograma sale ya abierto, sin animar. */
.drawer { position: fixed; inset: 0; z-index: 2100; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); opacity: 0; visibility: hidden; transition: opacity .22s ease, visibility .22s ease; }
.drawer.open { opacity: 1; visibility: visible; }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: 460px; max-width: 92vw; display: flex; flex-direction: column; background: var(--tk-surface); border-left: 1px solid var(--tk-surface-2); box-shadow: -24px 0 50px rgba(0,0,0,.6); transform: translateX(100%); transition: transform .22s ease; }
.drawer-panel-wide { width: 760px; }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border-bottom: 1px solid var(--tk-surface-2); flex-shrink: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1rem; }
.drawer-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--tk-surface-2); flex-shrink: 0; }
.tk-lightbox { display: none; position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.88); align-items: center; justify-content: center; cursor: zoom-out; }
.tk-lightbox.open { display: flex; }
.tk-lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 8px; box-shadow: 0 25px 60px rgba(0,0,0,.8); }
.tk-lb-close { position: absolute; top: 1.5rem; right: 1.5rem; width: 40px; height: 40px; background: rgba(30,41,59,.9); border: 1px solid rgba(100,116,139,.4); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #94a3b8; cursor: pointer; font-size: 1.1rem; transition: all .15s; }
.tk-lb-close:hover { color: #fff; border-color: rgba(148,163,184,.7); }
.tk-lb-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; background: rgba(30,41,59,.8); border: 1px solid rgba(100,116,139,.4); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #cbd5e1; cursor: pointer; transition: all .15s; z-index: 1; }
.tk-lb-arrow.prev { left: 1.5rem; }
.tk-lb-arrow.next { right: 1.5rem; }
.tk-lb-arrow:hover:not(.disabled) { color: var(--tk-brand); border-color: rgba(244,147,54,.6); }
.tk-lb-arrow.disabled { opacity: .25; cursor: not-allowed; pointer-events: none; }

/* Ayuda (i) y tooltip único, en position: fixed para que no lo recorte ningún overflow. */
.tk-info { display: inline-flex; align-items: center; vertical-align: middle; cursor: help; }
.tk-info > i { color: #6b7280; margin-left: .25rem; font-size: 11px; }
.tk-info:hover > i { color: #d1d5db; }
.tk-tip { position: fixed; display: none; background: var(--tk-bg); border: 1px solid var(--tk-border-strong); border-radius: 8px; padding: 10px 12px; min-width: 180px; max-width: 320px; z-index: 9000; pointer-events: none; box-shadow: 0 12px 28px rgba(0,0,0,.7); font-size: 12px; line-height: 1.45; color: #cbd5e1; white-space: pre-line; }
.tk-tip.open { display: block; }

/* Gráficas: Chart.js necesita un contenedor de altura fija. */
.chart-container { position: relative; height: 200px; width: 100%; }
.chart-container-sm { position: relative; height: 140px; width: 100%; }
.chart-container-lg { position: relative; height: 260px; width: 100%; }

/* Botones. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; height: 30px; padding: 0 .75rem; border-radius: 6px; font-size: .75rem; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; user-select: none; border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s; text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .4; cursor: not-allowed; }
.btn-xs { height: 24px; padding: 0 .5rem; font-size: .6875rem; border-radius: 5px; }
.btn-md { height: 36px; padding: 0 .9rem; font-size: .8125rem; }
.btn-block { width: 100%; }
.btn > i { font-size: .9em; }
.btn-primary { background: var(--tk-brand); border-color: var(--tk-brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #e07f1f; border-color: #e07f1f; }
.btn-secondary { background: rgba(30,41,59,.8); border-color: rgba(100,116,139,.5); color: #cbd5e1; }
.btn-secondary:hover:not(:disabled) { background: rgba(51,65,85,.8); border-color: rgba(148,163,184,.6); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--tk-text-3); }
.btn-ghost:hover:not(:disabled) { background: rgba(51,65,85,.6); color: #fff; }
.btn-danger { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.5); color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.28); color: #fff; }
.btn-icon { width: 30px; padding: 0; }
.btn-icon.btn-md { width: 36px; }
.btn-icon.btn-xs { width: 24px; }
.btn.is-loading { pointer-events: none; }
@keyframes tk-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.btn-spinner { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 999px; animation: tk-spin .7s linear infinite; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: rgba(15,23,42,.7); border: 1px solid rgba(100,116,139,.35); }
.seg-btn { height: 26px; padding: 0 .8rem; border: none; background: transparent; border-radius: 6px; font-size: .75rem; font-weight: 600; color: var(--tk-text-3); cursor: pointer; transition: all .15s; font-family: inherit; }
.seg-btn:hover { color: #fff; }
.seg-btn.is-active { background: rgba(244,147,54,.18); color: var(--tk-brand); }

/* Formularios. */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.field-label { font-size: .75rem; font-weight: 600; color: var(--tk-text-2); }
.field-req { color: var(--tk-brand); }
.field-hint { font-size: .6875rem; color: var(--tk-text-4); margin: 0; }
.field-error { font-size: .6875rem; color: #fca5a5; margin: 0; display: flex; align-items: center; gap: .3rem; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 200px; }
.input, select.input, textarea.input { width: 100%; height: 36px; padding: 0 .7rem; border-radius: 6px; font-size: .8125rem; font-family: inherit; color: var(--tk-text-2); background: rgba(15,23,42,.8); border: 1px solid rgba(100,116,139,.4); outline: none; transition: border-color .15s, background .15s; }
textarea.input { height: auto; min-height: 88px; padding: .5rem .7rem; line-height: 1.45; resize: vertical; }
select.input { appearance: none; padding-right: 1.9rem; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.input::placeholder { color: var(--tk-text-5); }
.input:hover:not(:disabled):not([readonly]) { border-color: rgba(148,163,184,.5); }
.input:focus { border-color: var(--tk-brand); box-shadow: 0 0 0 3px rgba(244,147,54,.12); }
.input[readonly]:focus { border-color: rgba(100,116,139,.25); box-shadow: none; }
.input:disabled { opacity: .4; cursor: not-allowed; }
.input[readonly] { background: rgba(2,6,23,.6); border-color: rgba(100,116,139,.25); }
.has-error .input { border-color: rgba(239,68,68,.6); background: rgba(239,68,68,.06); }
.has-error .field-label { color: #fca5a5; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0; }
.input-group > :first-child { border-radius: 6px 0 0 6px; }
.input-group > :last-child { border-radius: 0 6px 6px 0; }
.input-affix { display: inline-flex; align-items: center; padding: 0 .6rem; font-size: .75rem; color: var(--tk-text-4); background: rgba(30,41,59,.8); border: 1px solid rgba(100,116,139,.4); }
.input-group .input + .input-affix, .input-group .input-affix + .input { border-left: none; }
.input-group:focus-within { border-radius: 6px; box-shadow: 0 0 0 3px rgba(244,147,54,.12); }
.input-group .input:focus { box-shadow: none; }
.input-group:focus-within .input-affix { border-color: var(--tk-brand); }
.fieldset { border: 1px solid var(--tk-surface-2); border-radius: 8px; padding: 1rem; margin: 0 0 1rem; }
.fieldset-legend { padding: 0 .4rem; font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--tk-text-4); }
.check { display: inline-flex; align-items: center; gap: .5rem; font-size: .8125rem; color: var(--tk-text-2); cursor: pointer; }
.check input { accent-color: var(--tk-brand); width: 15px; height: 15px; }
.switch { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 34px; height: 18px; border-radius: 999px; background: rgba(100,116,139,.45); position: relative; transition: background .18s; flex-shrink: 0; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 999px; background: #e2e8f0; transition: transform .18s; }
.switch input:checked + .switch-track { background: var(--tk-brand); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); }
.switch input:disabled + .switch-track { opacity: .4; }
/* El input real está oculto: sin esto el interruptor no enseña el foco de teclado. */
.switch input:focus-visible + .switch-track { outline: 2px solid var(--tk-brand); outline-offset: 2px; }
.switch-label { font-size: .8125rem; color: var(--tk-text-2); }

/* Avisos en línea y notificaciones flotantes. */
.alert { display: flex; align-items: flex-start; gap: .6rem; padding: .7rem .9rem; border-radius: 8px; font-size: .8125rem; line-height: 1.45; border: 1px solid; border-left-width: 3px; margin-bottom: 1rem; }
.alert > i { margin-top: .15rem; }
.alert-info { background: rgba(30,58,138,.15); border-color: rgba(59,130,246,.3); border-left-color: var(--tk-blue); color: #bfdbfe; }
.alert-ok { background: rgba(20,83,45,.15); border-color: rgba(34,197,94,.3); border-left-color: var(--tk-green); color: #bbf7d0; }
.alert-warn { background: rgba(120,53,15,.18); border-color: rgba(251,191,36,.3); border-left-color: var(--tk-amber); color: #fde68a; }
.alert-error { background: rgba(127,29,29,.18); border-color: rgba(239,68,68,.35); border-left-color: var(--tk-red); color: #fecaca; }
.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 4000; display: flex; flex-direction: column; gap: .5rem; max-width: 380px; }
@keyframes tk-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast { display: flex; align-items: flex-start; gap: .6rem; padding: .7rem .8rem; border-radius: 10px; background: var(--tk-surface-slate); border: 1px solid rgba(148,163,184,.2); box-shadow: 0 20px 40px rgba(0,0,0,.6); font-size: .8125rem; color: var(--tk-text-2); animation: tk-toast-in .2s ease-out; }
.toast.is-out { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast > i { margin-top: .15rem; }
.toast-ok > i { color: var(--tk-green); }
.toast-error > i { color: var(--tk-red); }
.toast-warn > i { color: var(--tk-amber); }
.toast-info > i { color: var(--tk-blue); }
.toast-close { margin-left: auto; background: none; border: none; color: var(--tk-text-4); cursor: pointer; padding: 0 .1rem; }
.toast-close:hover { color: #fff; }

/* Migas, menú contextual y línea de tiempo. */
.crumbs { display: flex; align-items: center; gap: .45rem; font-size: .75rem; color: var(--tk-text-4); margin-bottom: .75rem; flex-wrap: wrap; }
.crumbs a { color: var(--tk-text-3); }
.crumbs a:hover { color: #fff; }
.crumbs i { font-size: .55rem; color: var(--tk-text-5); }
.crumbs [aria-current="page"] { color: var(--tk-text); font-weight: 600; }
.menu { min-width: 180px; padding: .3rem; border-radius: 10px; background: var(--tk-surface-slate); border: 1px solid rgba(148,163,184,.2); box-shadow: 0 20px 40px rgba(0,0,0,.6); }
.menu-item { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .45rem .55rem; border: none; background: none; border-radius: 6px; font-size: .8125rem; color: var(--tk-text-2); cursor: pointer; text-align: left; font-family: inherit; }
.menu-item > i { width: 14px; text-align: center; color: var(--tk-text-4); font-size: .8em; }
.menu-item:hover { background: rgba(51,65,85,.8); color: #fff; }
.menu-item:hover > i { color: var(--tk-brand); }
.menu-sep { height: 1px; background: rgba(148,163,184,.12); margin: .25rem .3rem; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 .25rem; }
.tl-item { position: relative; display: flex; gap: .75rem; padding: 0 0 1rem 1.1rem; border-left: 1px solid rgba(100,116,139,.3); }
.tl-item:last-child { border-left-color: transparent; }
.tl-dot { position: absolute; left: -5px; top: 3px; width: 9px; height: 9px; border-radius: 999px; background: var(--tk-text-4); box-shadow: 0 0 0 3px var(--tk-bg); }
.tl-time { font-size: .6875rem; color: var(--tk-text-4); font-variant-numeric: tabular-nums; min-width: 62px; }
.tl-body { font-size: .8125rem; color: var(--tk-text-2); }

/* Estados de página completa: vacío en gris, error en rojo, sin permiso en ámbar. */
.page-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 4rem 2rem; text-align: center; }
.page-state > i { font-size: 2.75rem; color: var(--tk-text-5); margin-bottom: .4rem; }
.page-state h1, .page-state h2 { font-size: 1rem; font-weight: 600; color: var(--tk-text-2); margin: 0; }
.page-state p { font-size: .8125rem; color: var(--tk-text-4); max-width: 420px; margin: 0; }
.page-state-error > i { color: var(--tk-red); }
.page-state-denied > i { color: var(--tk-amber); }

/* Foco de teclado: contorno naranja solo cuando el foco llega por teclado. Los campos de texto se quedan con su borde
   y su halo: el navegador les da :focus-visible también cuando se pulsan con el ratón. */
:where(a, button, input, select, textarea, [tabindex]):where(:not(.input, .tk-input)):focus-visible { outline: 2px solid var(--tk-brand); outline-offset: 2px; border-radius: 4px; }
.input:focus-visible, .tk-input:focus-visible { outline: none; }
:where(a, button, input, select, textarea, [tabindex]):focus:not(:focus-visible) { outline: none; }
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 10000; padding: .6rem 1rem; background: var(--tk-brand); color: #fff; font-weight: 700; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }
.custom-scrollbar { scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.3) rgba(15,23,42,.5); }
.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: rgba(15,23,42,.5); border-radius: 3px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(148,163,184,.3); border-radius: 3px; }

@media (prefers-reduced-motion: reduce) {
    .skeleton-cell, .btn-spinner { animation: none; }
    .drawer, .drawer-panel, .toast { transition: none; animation: none; }
}

/* Páginas sueltas: el login y su recorrido. Van sin menú lateral, con la barra superior sola. */
body.tk-standalone { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--tk-bg); color: var(--tk-text-2); font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body.tk-standalone *, body.tk-standalone *::before, body.tk-standalone *::after { box-sizing: border-box; }
.tk-standalone .tk-topbar { background: rgba(15,23,42,.95); border-bottom: 1px solid var(--tk-border); }
.tk-standalone .tk-topbar-inner { display: flex; align-items: center; min-height: 58px; padding: .6rem 1.25rem; }
.tk-standalone .tk-brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.tk-standalone .tk-brand img { height: 34px; width: auto; }
.tk-standalone .tk-brand-title { font-weight: 700; color: #fff; font-size: 1rem; line-height: 1.2; letter-spacing: -.01em; }
.tk-standalone-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.tk-standalone-foot { padding: 1rem; text-align: center; font-size: .6875rem; color: var(--tk-text-5); }
