/* =====================================================================
   LexOffice · Hoja de estilos principal
   Minimalista · profesional · modo claro y oscuro
   ===================================================================== */

/* --- Tokens de diseño ------------------------------------------------ */
:root {
    --navy-900: #0f2440;
    --navy-800: #16304f;
    --navy-700: #1e3a5f;
    --navy-600: #2b4f7e;
    --navy-500: #3b6ba5;

    --gold-500: #c9a227;
    --gold-400: #d9b74a;
    --gold-100: #f6edd2;

    --green-600: #0f766e;
    --green-500: #16a34a;
    --green-100: #dcfce7;

    --red-600: #b91c1c;
    --red-500: #dc2626;
    --red-100: #fee2e2;

    --amber-500: #d97706;
    --amber-100: #fef3c7;

    --blue-500: #0ea5e9;
    --blue-100: #e0f2fe;

    /* Superficies (modo claro) */
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e3e8ef;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --sidebar-bg: #0f2440;
    --sidebar-text: #c7d5e8;
    --sidebar-active: #1e3a5f;

    --accent: var(--navy-700);
    --accent-contrast: #ffffff;

    --shadow-sm: 0 1px 2px rgba(15, 36, 64, .06);
    --shadow: 0 2px 8px rgba(15, 36, 64, .07), 0 1px 2px rgba(15, 36, 64, .04);
    --shadow-lg: 0 12px 32px rgba(15, 36, 64, .12);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;

    --sidebar-w: 258px;
    --sidebar-w-collapsed: 74px;
    --topbar-h: 62px;

    --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
    --bg: #0b111c;
    --surface: #141d2c;
    --surface-2: #182334;
    --surface-3: #1e2b3f;
    --border: #26344b;
    --border-strong: #35486a;
    --text: #e8eef8;
    --text-2: #c3cfe0;
    --muted: #8fa1bb;
    --sidebar-bg: #0a1220;
    --sidebar-text: #a9bbd4;
    --sidebar-active: #17263c;

    --gold-100: #3a3213;
    --green-100: #10291d;
    --red-100: #33161a;
    --amber-100: #33280f;
    --blue-100: #12283a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
}

/* --- Reset ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

h1, h2, h3, h4, h5 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.25; color: var(--text); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
h4 { font-size: .92rem; }
p  { margin: 0 0 .75rem; }

a { color: var(--navy-600); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--navy-500); }
[data-theme="dark"] a { color: #79a7e0; }

img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
small { font-size: .8rem; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

:focus-visible { outline: 2px solid var(--navy-500); outline-offset: 2px; border-radius: 4px; }

/* --- Estructura ------------------------------------------------------ */
.layout { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: width var(--transition), transform var(--transition);
    border-right: 1px solid rgba(255, 255, 255, .06);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    height: var(--topbar-h);
    padding: 0 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar__logo {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--gold-500), var(--gold-400));
    color: var(--navy-900);
    display: grid; place-items: center;
    font-weight: 700; font-size: .95rem;
    flex-shrink: 0;
    object-fit: cover;
}

.sidebar__name {
    font-weight: 600; font-size: .97rem; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__name small { display: block; font-size: .68rem; color: var(--sidebar-text); font-weight: 400; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: .8rem .65rem 1.5rem; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-color: transparent; }

.nav-section {
    font-size: .66rem; text-transform: uppercase; letter-spacing: .09em;
    color: rgba(255, 255, 255, .35); margin: 1.1rem .75rem .35rem; font-weight: 600;
    white-space: nowrap; overflow: hidden;
}

.nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .58rem .75rem; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: .885rem; font-weight: 500;
    white-space: nowrap; overflow: hidden;
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--gold-500); }
.nav-link .ico { flex-shrink: 0; width: 19px; height: 19px; opacity: .9; }
.nav-link .nav-badge {
    margin-left: auto; background: var(--gold-500); color: var(--navy-900);
    border-radius: 20px; font-size: .68rem; font-weight: 700; padding: 1px 7px;
}

.sidebar__footer { padding: .75rem; border-top: 1px solid rgba(255, 255, 255, .08); }

/* Sidebar plegado (escritorio) */
.app.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.app.is-collapsed .sidebar__name,
.app.is-collapsed .nav-link span,
.app.is-collapsed .nav-section,
.app.is-collapsed .nav-badge { opacity: 0; width: 0; visibility: hidden; }
.app.is-collapsed .nav-link { justify-content: center; padding-inline: 0; }
.app.is-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin var(--transition);
}

.topbar {
    position: sticky; top: 0; z-index: 40;
    height: var(--topbar-h);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: .6rem;
    padding: 0 1.15rem;
}

.topbar__title { font-weight: 600; font-size: 1.02rem; margin-right: auto; }
.topbar__title small { display: block; font-weight: 400; font-size: .74rem; color: var(--muted); }

.content { padding: 1.35rem; flex: 1; max-width: 1560px; width: 100%; }

/* --- Botones ---------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .52rem .95rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text-2);
    font: inherit; font-size: .865rem; font-weight: 550;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition);
    user-select: none;
}
.btn:hover { background: var(--border); color: var(--text); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--navy-700); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--navy-600); color: #fff; }

.btn-gold { background: var(--gold-500); color: var(--navy-900); }
.btn-gold:hover { background: var(--gold-400); color: var(--navy-900); }

.btn-success { background: var(--green-600); color: #fff; }
.btn-success:hover { background: var(--green-500); color: #fff; }

.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: var(--red-500); color: #fff; }

.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn-outline:hover { background: var(--surface-3); border-color: var(--muted); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-sm { padding: .34rem .65rem; font-size: .79rem; }
.btn-lg { padding: .72rem 1.35rem; font-size: .95rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .45rem; width: 34px; height: 34px; }

.btn .ico { width: 16px; height: 16px; }

/* --- Tarjetas --------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.1rem;
    overflow: hidden;
}

.card__header {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.card__header h2, .card__header h3 { margin: 0; font-size: .95rem; }
.card__header .spacer { margin-left: auto; }
.card__body { padding: 1.1rem; }
.card__body.tight { padding: .6rem; }
.card__footer { padding: .8rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface-2); }

/* Tarjetas estadísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
    gap: .85rem;
    margin-bottom: 1.1rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.05rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::after {
    content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
    background: var(--navy-700);
}
.stat.is-gold::after { background: var(--gold-500); }
.stat.is-green::after { background: var(--green-600); }
.stat.is-red::after { background: var(--red-500); }
.stat.is-amber::after { background: var(--amber-500); }
.stat.is-blue::after { background: var(--blue-500); }

.stat__label { font-size: .765rem; color: var(--muted); text-transform: uppercase; letter-spacing: .045em; font-weight: 600; }
.stat__value { font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; margin: .28rem 0 .1rem; }
.stat__value.sm { font-size: 1.22rem; }
.stat__meta { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: .3rem; }
.stat__icon {
    position: absolute; right: .9rem; top: .9rem;
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--surface-3); color: var(--navy-600);
}

/* --- Tablas ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
    text-align: left; font-weight: 600; font-size: .74rem;
    text-transform: uppercase; letter-spacing: .045em;
    color: var(--muted);
    padding: .7rem .8rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
}
.table td { padding: .68rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: .2rem; }
.table-sm td, .table-sm th { padding: .45rem .6rem; font-size: .82rem; }

.t-main { font-weight: 600; color: var(--text); display: block; }
.t-sub { font-size: .78rem; color: var(--muted); }

/* --- Insignias -------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .16rem .55rem;
    border-radius: 999px;
    font-size: .72rem; font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.badge--ok     { background: var(--green-100); color: var(--green-600); }
.badge--done   { background: var(--blue-100);  color: #0369a1; }
.badge--info   { background: var(--blue-100);  color: #0369a1; }
.badge--warn   { background: var(--amber-100); color: var(--amber-500); }
.badge--danger { background: var(--red-100);   color: var(--red-600); }
.badge--muted  { background: var(--surface-3); color: var(--muted); }
.badge--gold   { background: var(--gold-100);  color: #8a6d10; }
[data-theme="dark"] .badge--gold { color: var(--gold-400); }
[data-theme="dark"] .badge--warn { color: #fbbf24; }
[data-theme="dark"] .badge--danger { color: #f87171; }
[data-theme="dark"] .badge--ok { color: #4ade80; }
[data-theme="dark"] .badge--info, [data-theme="dark"] .badge--done { color: #7dd3fc; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* --- Barras de progreso ----------------------------------------------- */
.progress {
    height: 8px; border-radius: 99px;
    background: var(--surface-3);
    overflow: hidden;
    position: relative;
}
.progress__bar {
    height: 100%; border-radius: 99px;
    background: linear-gradient(90deg, var(--navy-600), var(--navy-500));
    transition: width .6s cubic-bezier(.4, 0, .2, 1);
}
.progress__bar.is-gold  { background: linear-gradient(90deg, var(--gold-500), var(--gold-400)); }
.progress__bar.is-green { background: linear-gradient(90deg, var(--green-600), var(--green-500)); }
.progress__bar.is-red   { background: linear-gradient(90deg, var(--red-600), var(--red-500)); }
.progress.lg { height: 12px; }
.progress.sm { height: 5px; }

.progress-label { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; }
.progress-label b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Barra financiera */
.finance-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; }
.finance-bar > div { padding: .55rem .3rem; }
.finance-bar .k { font-size: .73rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.finance-bar .v { font-size: 1.08rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.finance-bar .v.pos { color: var(--green-600); }
.finance-bar .v.neg { color: var(--red-600); }
[data-theme="dark"] .finance-bar .v.pos { color: #4ade80; }
[data-theme="dark"] .finance-bar .v.neg { color: #f87171; }

/* --- Formularios ------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: .9rem 1rem; }
.col-1 { grid-column: span 1; }  .col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }  .col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }  .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }  .col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }  .col-10 { grid-column: span 10; }
.col-12 { grid-column: span 12; }

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .label {
    font-size: .8rem; font-weight: 600; color: var(--text-2);
    display: flex; align-items: center; gap: .3rem;
}
.field label .req { color: var(--red-500); }
.field .hint { font-size: .74rem; color: var(--muted); }
.field .err { font-size: .76rem; color: var(--red-600); }
[data-theme="dark"] .field .err { color: #f87171; }

.input, .select, .textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit; font-size: .875rem;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--navy-500);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy-500) 18%, transparent);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--red-500); }
.textarea { resize: vertical; min-height: 82px; line-height: 1.5; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .65rem center;
    padding-right: 1.9rem;
}

.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.check { display: flex; align-items: flex-start; gap: .5rem; font-size: .85rem; cursor: pointer; user-select: none; }
.check input[type="checkbox"], .check input[type="radio"] {
    width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--navy-700); cursor: pointer; flex-shrink: 0;
}
.check span { color: var(--text-2); }
.check small { display: block; color: var(--muted); font-size: .74rem; }

.switch-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .5rem .9rem; }

.form-actions {
    display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap;
    padding-top: 1rem; margin-top: .4rem; border-top: 1px solid var(--border);
}

fieldset.group { border: 0; padding: 0; margin: 0 0 1.4rem; }
fieldset.group > legend {
    font-size: .76rem; text-transform: uppercase; letter-spacing: .06em;
    font-weight: 700; color: var(--navy-600); padding: 0 0 .55rem;
    width: 100%; border-bottom: 1px solid var(--border); margin-bottom: .9rem;
}
[data-theme="dark"] fieldset.group > legend { color: var(--gold-400); }

/* --- Filtros ---------------------------------------------------------- */
.filters {
    display: flex; flex-wrap: wrap; gap: .55rem; align-items: flex-end;
    padding: .85rem 1.05rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.filters .field { flex: 1 1 160px; max-width: 230px; }
.filters .field.wide { flex: 2 1 250px; max-width: 340px; }
.filters .actions { display: flex; gap: .4rem; margin-left: auto; }

.search-box { position: relative; flex: 1 1 240px; }
.search-box .ico { position: absolute; left: .62rem; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search-box .input { padding-left: 2.1rem; }

/* --- Alertas ---------------------------------------------------------- */
.alert {
    display: flex; align-items: flex-start; gap: .65rem;
    padding: .75rem .95rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    margin-bottom: 1rem;
    font-size: .865rem;
    animation: slide-down .28s ease;
}
.alert .ico { flex-shrink: 0; margin-top: 1px; }
.alert--success { background: var(--green-100); border-color: color-mix(in srgb, var(--green-600) 25%, transparent); color: var(--green-600); }
.alert--danger  { background: var(--red-100);   border-color: color-mix(in srgb, var(--red-600) 25%, transparent);   color: var(--red-600); }
.alert--warning { background: var(--amber-100); border-color: color-mix(in srgb, var(--amber-500) 25%, transparent); color: var(--amber-500); }
.alert--info    { background: var(--blue-100);  border-color: color-mix(in srgb, var(--blue-500) 25%, transparent);  color: #0369a1; }
[data-theme="dark"] .alert--success { color: #4ade80; }
[data-theme="dark"] .alert--danger  { color: #f87171; }
[data-theme="dark"] .alert--warning { color: #fbbf24; }
[data-theme="dark"] .alert--info    { color: #7dd3fc; }
.alert__close { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.alert__close:hover { opacity: 1; }

.flash-stack { position: fixed; top: calc(var(--topbar-h) + 12px); right: 16px; z-index: 90; max-width: 380px; }
.flash-stack .alert { box-shadow: var(--shadow-lg); background-color: var(--surface); }

/* --- Estado vacío ----------------------------------------------------- */
.empty {
    text-align: center; padding: 2.75rem 1.25rem; color: var(--muted);
}
.empty .ico { width: 46px; height: 46px; opacity: .35; margin-bottom: .6rem; }
.empty h3 { color: var(--text-2); font-size: 1rem; }
.empty p { max-width: 420px; margin: 0 auto 1rem; font-size: .875rem; }

/* --- Paginación ------------------------------------------------------- */
.pagination { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; justify-content: center; padding: .9rem; }
.pagination a, .pagination span {
    min-width: 34px; height: 34px; padding: 0 .55rem;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: .83rem; color: var(--text-2); background: var(--surface);
    transition: all var(--transition);
}
.pagination a:hover { border-color: var(--navy-500); color: var(--navy-600); }
.pagination .current { background: var(--navy-700); border-color: var(--navy-700); color: #fff; font-weight: 600; }
.pagination .disabled { opacity: .4; pointer-events: none; }
.pagination .info { border: 0; background: none; color: var(--muted); font-size: .8rem; }

/* --- Pestañas --------------------------------------------------------- */
.tabs {
    display: flex; gap: .15rem; border-bottom: 1px solid var(--border);
    overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    padding: .62rem .95rem;
    font-size: .865rem; font-weight: 550; color: var(--muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0;
    font-family: inherit;
    transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--navy-700); border-bottom-color: var(--gold-500); font-weight: 600; }
[data-theme="dark"] .tab.active { color: var(--gold-400); }
.tab .count { background: var(--surface-3); border-radius: 20px; padding: 0 .38rem; font-size: .72rem; margin-left: .3rem; }

.tab-panel { display: none; animation: fade-in .25s ease; }
.tab-panel.active { display: block; }

/* --- Línea de tiempo -------------------------------------------------- */
.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before {
    content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px;
    width: 2px; background: var(--border);
}
.timeline__item { position: relative; padding-bottom: 1.15rem; }
.timeline__item::before {
    content: ''; position: absolute; left: -1.6rem; top: 5px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--navy-600);
    box-shadow: 0 0 0 3px var(--surface);
}
.timeline__item.is-gold::before  { border-color: var(--gold-500); }
.timeline__item.is-green::before { border-color: var(--green-600); }
.timeline__item.is-red::before   { border-color: var(--red-500); }
.timeline__date { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.timeline__title { font-weight: 600; font-size: .9rem; margin: .1rem 0; }
.timeline__body { font-size: .845rem; color: var(--text-2); }

/* --- Etapas ----------------------------------------------------------- */
.stage {
    display: flex; gap: .9rem; align-items: flex-start;
    padding: .85rem 0; border-bottom: 1px solid var(--border);
}
.stage:last-child { border-bottom: 0; }
.stage__num {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--surface-3); color: var(--muted);
    font-size: .8rem; font-weight: 700;
}
.stage.done .stage__num  { background: var(--green-600); color: #fff; }
.stage.doing .stage__num { background: var(--navy-700); color: #fff; }
.stage.paused .stage__num{ background: var(--amber-500); color: #fff; }
.stage__body { flex: 1; min-width: 0; }
.stage__title { font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.stage__meta { font-size: .775rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .8rem; margin-top: .18rem; }
.stage__actions { display: flex; gap: .3rem; flex-shrink: 0; }

/* --- Modales ---------------------------------------------------------- */
.modal {
    position: fixed; inset: 0; z-index: 100;
    display: none; align-items: flex-start; justify-content: center;
    padding: 1rem; overflow-y: auto;
    background: rgba(9, 17, 30, .55);
    backdrop-filter: blur(3px);
}
.modal.open { display: flex; animation: fade-in .18s ease; }
.modal__box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 620px;
    margin: 3vh auto;
    animation: pop-in .22s cubic-bezier(.34, 1.3, .64, 1);
    overflow: hidden;
}
.modal__box.lg { max-width: 900px; }
.modal__box.sm { max-width: 430px; }
.modal__header {
    display: flex; align-items: center; gap: .6rem;
    padding: .95rem 1.2rem; border-bottom: 1px solid var(--border);
}
.modal__header h3 { margin: 0; font-size: 1rem; }
.modal__close {
    margin-left: auto; background: none; border: 0; cursor: pointer;
    color: var(--muted); font-size: 1.35rem; line-height: 1; padding: 0 .2rem;
}
.modal__close:hover { color: var(--text); }
.modal__body { padding: 1.2rem; max-height: 72vh; overflow-y: auto; }
.modal__footer { padding: .85rem 1.2rem; border-top: 1px solid var(--border); display: flex; gap: .55rem; justify-content: flex-end; background: var(--surface-2); }

/* --- Menú desplegable ------------------------------------------------- */
.dropdown { position: relative; }
.dropdown__menu {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 214px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: .35rem;
    display: none;
    z-index: 70;
    animation: slide-down .16s ease;
}
.dropdown.open .dropdown__menu { display: block; }
.dropdown__menu a, .dropdown__menu button {
    display: flex; align-items: center; gap: .55rem;
    width: 100%; padding: .5rem .6rem;
    border-radius: var(--radius-sm);
    font-size: .855rem; color: var(--text-2);
    background: none; border: 0; cursor: pointer; text-align: left;
    font-family: inherit;
}
.dropdown__menu a:hover, .dropdown__menu button:hover { background: var(--surface-3); color: var(--text); }
.dropdown__menu .danger { color: var(--red-600); }
.dropdown__divider { height: 1px; background: var(--border); margin: .3rem 0; }
.dropdown__header { padding: .5rem .6rem .3rem; font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* --- Avatar ----------------------------------------------------------- */
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--navy-700); color: #fff;
    display: grid; place-items: center;
    font-size: .8rem; font-weight: 650;
    flex-shrink: 0; object-fit: cover;
    text-transform: uppercase;
}
.avatar.sm { width: 26px; height: 26px; font-size: .68rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar.gold { background: var(--gold-500); color: var(--navy-900); }
.avatar.green { background: var(--green-600); }

/* --- Notificaciones --------------------------------------------------- */
.notif-btn { position: relative; }
.notif-btn .count {
    position: absolute; top: 1px; right: 1px;
    min-width: 16px; height: 16px; padding: 0 3px;
    background: var(--red-500); color: #fff;
    border-radius: 20px; font-size: .64rem; font-weight: 700;
    display: grid; place-items: center;
    border: 2px solid var(--surface);
}
.notif-item {
    display: flex; gap: .65rem; padding: .6rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.notif-item:hover { background: var(--surface-3); }
.notif-item.unread { background: color-mix(in srgb, var(--blue-500) 7%, transparent); }
.notif-item__icon {
    width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--surface-3); color: var(--navy-600);
}
.notif-item__title { font-size: .845rem; font-weight: 600; }
.notif-item__body { font-size: .79rem; color: var(--muted); }
.notif-item__time { font-size: .72rem; color: var(--muted); margin-top: .12rem; }

/* --- Calendario ------------------------------------------------------- */
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th {
    padding: .5rem; font-size: .73rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border);
}
.calendar td {
    border: 1px solid var(--border); vertical-align: top;
    height: 106px; padding: .3rem; position: relative;
    transition: background var(--transition);
}
.calendar td:hover { background: var(--surface-2); }
.calendar td.other-month { background: var(--surface-2); opacity: .55; }
.calendar td.today { background: color-mix(in srgb, var(--gold-500) 9%, transparent); }
.calendar td.today .day-num { background: var(--gold-500); color: var(--navy-900); border-radius: 50%; }
.day-num {
    display: inline-grid; place-items: center;
    width: 23px; height: 23px; font-size: .77rem; font-weight: 600; color: var(--text-2);
}
.cal-event {
    display: block; font-size: .715rem; padding: .13rem .32rem; margin-bottom: 2px;
    border-radius: 5px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    cursor: pointer; transition: filter var(--transition);
}
.cal-event:hover { filter: brightness(1.13); color: #fff; }
.cal-more { font-size: .69rem; color: var(--muted); padding-left: .3rem; }

.agenda-day { border-left: 3px solid var(--navy-600); padding-left: .85rem; margin-bottom: 1.15rem; }
.agenda-day__date { font-weight: 650; font-size: .9rem; margin-bottom: .4rem; }
.agenda-item {
    display: flex; gap: .7rem; align-items: flex-start;
    padding: .55rem .65rem; border-radius: var(--radius-sm);
    background: var(--surface-2); margin-bottom: .35rem;
}
.agenda-item__time { font-size: .78rem; font-weight: 650; color: var(--muted); min-width: 46px; font-variant-numeric: tabular-nums; }

/* --- Gráficos --------------------------------------------------------- */
.chart-wrap { position: relative; width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .35rem .95rem; margin-top: .7rem; font-size: .78rem; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }

/* --- Documentos ------------------------------------------------------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(198px, 1fr)); gap: .8rem; }
.doc-card {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: .85rem; background: var(--surface);
    transition: all var(--transition); position: relative;
}
.doc-card:hover { border-color: var(--navy-500); box-shadow: var(--shadow); transform: translateY(-2px); }
.doc-card__icon {
    width: 40px; height: 40px; border-radius: 10px; margin-bottom: .55rem;
    display: grid; place-items: center; font-size: .68rem; font-weight: 700; color: #fff;
    background: var(--muted); text-transform: uppercase;
}
.doc-card__icon.pdf   { background: #b91c1c; }
.doc-card__icon.word  { background: #1d4ed8; }
.doc-card__icon.excel { background: #15803d; }
.doc-card__icon.image { background: #7c3aed; }
.doc-card__icon.audio { background: #b45309; }
.doc-card__icon.zip   { background: #475569; }
.doc-card__title { font-size: .845rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card__meta { font-size: .73rem; color: var(--muted); margin-top: .18rem; }

/* --- Utilidades ------------------------------------------------------- */
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.1rem; align-items: start; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .35rem; } .gap-2 { gap: .7rem; } .gap-3 { gap: 1.1rem; }
.ml-auto { margin-left: auto; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--muted); }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .74rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green-600); } .neg { color: var(--red-600); }
[data-theme="dark"] .pos { color: #4ade80; } [data-theme="dark"] .neg { color: #f87171; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: .85rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.breadcrumb { display: flex; gap: .4rem; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: .4rem; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--navy-600); }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: .45rem .8rem; font-size: .865rem; }
.kv dt { color: var(--muted); font-size: .8rem; }
.kv dd { margin: 0; color: var(--text); font-weight: 500; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: .1rem .8rem; } .kv dd { margin-bottom: .5rem; } }

/* --- Autenticación ---------------------------------------------------- */
.auth {
    min-height: 100vh;
    display: grid; grid-template-columns: 1fr 1fr;
    background: var(--bg);
}
.auth__side {
    background: linear-gradient(150deg, var(--navy-900) 0%, var(--navy-700) 55%, var(--navy-600) 100%);
    color: #fff; padding: 3rem;
    display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
.auth__side::after {
    content: ''; position: absolute; width: 460px; height: 460px; border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 162, 39, .19), transparent 68%);
    bottom: -170px; right: -130px;
}
.auth__side h1 { color: #fff; font-size: 2rem; letter-spacing: -.02em; }
.auth__side p { color: rgba(255, 255, 255, .78); max-width: 380px; }
.auth__features { list-style: none; padding: 0; margin: 1.8rem 0 0; display: grid; gap: .65rem; }
.auth__features li { display: flex; gap: .6rem; align-items: center; color: rgba(255, 255, 255, .88); font-size: .89rem; }
.auth__features .ico { color: var(--gold-400); flex-shrink: 0; }

.auth__main { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth__card { width: 100%; max-width: 388px; }
.auth__logo {
    width: 54px; height: 54px; border-radius: 15px; margin-bottom: 1.1rem;
    background: linear-gradient(135deg, var(--navy-700), var(--navy-600));
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.2rem;
    box-shadow: var(--shadow); object-fit: cover;
}

@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; }
    .auth__side { display: none; }
}

/* --- Impresión -------------------------------------------------------- */
@media print {
    .sidebar, .topbar, .no-print, .form-actions, .pagination, .filters { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0; }
    .card { border: 0; box-shadow: none; page-break-inside: avoid; }
    body { background: #fff; font-size: 11pt; }
}

/* --- Animaciones ------------------------------------------------------ */
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-7px); } to { opacity: 1; transform: none; } }
@keyframes pop-in   { from { opacity: 0; transform: scale(.96) translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes spin     { to { transform: rotate(360deg); } }

.spinner {
    width: 17px; height: 17px; border-radius: 50%;
    border: 2px solid var(--border-strong); border-top-color: var(--navy-600);
    animation: spin .7s linear infinite; display: inline-block;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* --- Responsive ------------------------------------------------------- */
.sidebar__backdrop {
    position: fixed; inset: 0; background: rgba(9, 17, 30, .5);
    z-index: 55; display: none; backdrop-filter: blur(2px);
}

@media (max-width: 1200px) {
    .split { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .app.is-open .sidebar { transform: none; }
    .app.is-open .sidebar__backdrop { display: block; }
    .main, .app.is-collapsed .main { margin-left: 0; }
    .content { padding: 1rem; }
}

@media (max-width: 768px) {
    body { font-size: 14px; }
    .form-grid > [class^="col-"] { grid-column: span 12; }
    .stats-grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: .6rem; }
    .stat { padding: .8rem; }
    .stat__value { font-size: 1.32rem; }
    .stat__icon { display: none; }
    .page-head .actions { width: 100%; }
    .page-head .actions .btn { flex: 1; }
    .filters .field, .filters .field.wide { max-width: none; flex-basis: 100%; }
    .filters .actions { width: 100%; }
    .filters .actions .btn { flex: 1; }
    .topbar { padding: 0 .75rem; }
    .topbar__title { font-size: .93rem; }
    .modal__box { margin: 0 auto; }
    .calendar td { height: 74px; font-size: .8rem; }
    .flash-stack { left: 12px; right: 12px; max-width: none; }
    .table th, .table td { padding: .55rem .6rem; }
}

/* Tabla adaptable: en móvil cada fila se muestra como ficha */
@media (max-width: 640px) {
    .table-cards thead { display: none; }
    .table-cards tbody tr {
        display: block; border: 1px solid var(--border);
        border-radius: var(--radius); margin-bottom: .6rem; padding: .35rem .1rem;
        background: var(--surface);
    }
    .table-cards td {
        display: flex; justify-content: space-between; gap: 1rem;
        border: 0; padding: .38rem .75rem; text-align: right;
    }
    .table-cards td::before {
        content: attr(data-label);
        font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
        color: var(--muted); font-weight: 600; text-align: left; flex-shrink: 0;
    }
    .table-cards td.actions { justify-content: flex-end; border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .5rem; }
    .table-cards td.actions::before { content: ''; }
}
