/* =========================================================
   Sistema Dental M · Aplicación
   ========================================================= */
:root {
    --brand: #0B7FB3;
    --brand-600: #086A96;
    --brand-700: #07516F;
    --brand-800: #063E56;
    --brand-050: #F1FAFD;
    --brand-100: #DFF3FB;
    --brand-200: #BFE7F5;

    --gray: #8A939B;
    --gray-100: #F1F4F6;
    --gray-200: #E4EAEE;
    --gray-500: #6B7A84;
    --gray-700: #43535C;

    --ink: #13262F;
    --ink-soft: #5A6C76;
    --muted: #84949D;
    --line: #E2EAEF;
    --line-strong: #D3DEE5;

    --surface: #F4F7F9;
    --surface-2: #EDF3F6;
    --card: #FFFFFF;

    --success: #0E9F7A;
    --success-bg: #E8F8F1;
    --warning: #D97706;
    --warning-bg: #FEF4E6;
    --danger: #CF3346;
    --danger-bg: #FDEEF0;
    --violet: #7C3AED;
    --violet-bg: #F2EDFE;

    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius: 12px;
    --radius-sm: 9px;

    --shadow-xs: 0 1px 2px rgba(15, 45, 60, .06);
    --shadow-sm: 0 4px 14px -8px rgba(12, 48, 65, .18);
    --shadow-md: 0 18px 38px -22px rgba(8, 45, 62, .28);
    --shadow-lg: 0 34px 70px -30px rgba(6, 39, 54, .4);

    --sidebar-w: 266px;
    --topbar-h: 78px;

    --font: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --serif: 'Fraunces', Georgia, 'Times New Roman', serif;

    --ease: cubic-bezier(.2, .8, .25, 1);
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
[hidden] { display: none !important; }

::selection { background: rgba(11, 127, 179, .2); }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================================
   Boot
   ========================================================= */
.boot {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background:
        radial-gradient(600px 400px at 50% 40%, #EAF7FC 0%, transparent 70%),
        var(--surface);
}

.boot-logo {
    width: 108px;
    height: 108px;
    animation: bootPulse 1.8s ease-in-out infinite;
}

@keyframes bootPulse {
    0%, 100% { transform: scale(1); opacity: .92; }
    50% { transform: scale(1.04); opacity: 1; }
}

.boot-bar {
    width: 168px;
    height: 5px;
    border-radius: 99px;
    background: #DBE9F0;
    overflow: hidden;
}

.boot-bar span {
    display: block;
    width: 45%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #38A9D6, #075B80);
    animation: bootSlide 1.15s var(--ease) infinite;
}

@keyframes bootSlide {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(260%); }
}

.boot p {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* =========================================================
   Layout
   ========================================================= */
.layout {
    display: flex;
    min-height: 100vh;
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(7, 30, 42, .46);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s, visibility .25s;
}

.sidebar {
    position: fixed;
    z-index: 70;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    padding: 22px 16px 18px;
    color: #E9F6FB;
    background:
        radial-gradient(420px 260px at 20% 0%, rgba(56, 169, 214, .24), transparent 62%),
        radial-gradient(500px 420px at 110% 100%, rgba(9, 96, 130, .5), transparent 60%),
        linear-gradient(178deg, #072F41 0%, #063C52 46%, #06334A 100%);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, .05);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .2) transparent;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 99px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 8px 0;
    margin-bottom: 26px;
}

.sidebar-logo {
    width: 208px;
    height: auto;
    filter: drop-shadow(0 10px 18px rgba(0, 15, 22, .35));
}

.sidebar-close { display: none; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 24px; padding-bottom: 14px; }

.nav-group { display: flex; flex-direction: column; gap: 4px; }

.nav-label {
    padding: 0 12px 6px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: rgba(174, 214, 230, .52);
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(222, 242, 250, .72);
    text-decoration: none;
    transition: background .16s, color .16s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
    text-decoration: none;
}

.nav-item svg {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    color: rgba(157, 213, 233, .8);
    transition: color .16s;
}

.nav-item span.nav-text { flex: 1; }

.nav-item.is-active {
    background: linear-gradient(100deg, rgba(47, 169, 213, .28), rgba(47, 169, 213, .08));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(120, 213, 241, .18);
}

.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: -16px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: #63D2F3;
    box-shadow: 0 0 14px rgba(99, 210, 243, .8);
}

.nav-item.is-active svg { color: #8BE1FA; }

.nav-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    border-radius: 99px;
    background: rgba(255, 255, 255, .12);
    color: #D6F3FC;
    font-size: 10px;
    font-weight: 800;
}

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .08); }

.user-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 12px;
    background: rgba(255, 255, 255, .05);
    color: #EAF7FC;
    text-align: left;
    transition: background .16s;
}

.user-mini:hover { background: rgba(255, 255, 255, .09); }
.user-mini-text { flex: 1; min-width: 0; }
.user-mini-text strong { display: block; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini-text small { display: block; font-size: 10.5px; color: rgba(196, 228, 240, .62); }
.user-mini-chev { width: 14px; height: 14px; color: rgba(196, 228, 240, .5); }

.sidebar-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 9.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(178, 214, 228, .4);
    font-weight: 600;
}

.sidebar-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 30px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.page-heading h1 {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: #10242D;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-heading p {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.today-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 12px;
    border-radius: 99px;
    background: var(--brand-050);
    border: 1px solid #DFEFF6;
    color: var(--brand-700);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    text-transform: capitalize;
}

.today-chip svg { width: 14px; height: 14px; }

.user-menu { position: relative; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 8px 5px 5px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    transition: background .16s, border-color .16s;
}

.user-chip:hover, .user-chip[aria-expanded="true"] { background: #F4F8FA; border-color: var(--line); }
.user-chip > svg { width: 14px; height: 14px; color: var(--muted); }
.user-chip-text { text-align: left; line-height: 1.25; }
.user-chip-text strong { display: block; font-size: 12px; font-weight: 700; color: #253942; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-text small { display: block; font-size: 10px; color: var(--muted); }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 250px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow-lg);
    animation: dropIn .16s var(--ease) both;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-5px) scale(.985); }
    to { opacity: 1; transform: none; }
}

.user-dropdown-head {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    margin-bottom: 5px;
    border-radius: 10px;
    background: var(--brand-050);
}

.user-dropdown-head strong { display: block; font-size: 12.5px; color: #17303B; }
.user-dropdown-head small { display: block; font-size: 10.5px; color: var(--muted); word-break: break-all; }

.user-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    font-size: 12.5px;
    font-weight: 600;
    color: #33464F;
    text-align: left;
}

.user-dropdown button:hover { background: #F3F8FA; }
.user-dropdown button svg { width: 17px; height: 17px; color: var(--gray-500); }
.user-dropdown button.danger { color: #B5293A; }
.user-dropdown button.danger svg { color: #C54555; }
.user-dropdown button.danger:hover { background: #FDF1F2; }
.user-dropdown-sep { height: 1px; background: var(--line); margin: 5px 4px; }

.view {
    flex: 1;
    width: 100%;
    max-width: 1560px;
    margin: 0 auto;
    padding: 26px 30px 48px;
}

.app-foot {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 30px 22px;
    border-top: 1px solid var(--line);
    color: #9AAAB2;
    font-size: 10.5px;
    letter-spacing: .02em;
}

.bottom-nav { display: none; }

/* =========================================================
   Botones e iconos
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    transition: background .16s, border-color .16s, color .16s, transform .14s, box-shadow .18s;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: 0 0 16px; }

.btn--primary {
    color: #fff;
    background: linear-gradient(135deg, #0E8FC6, #086A96);
    box-shadow: 0 10px 20px -12px rgba(8, 106, 150, .7);
}

.btn--primary:hover { background: linear-gradient(135deg, #1198D2, #075E86); box-shadow: 0 14px 24px -12px rgba(8, 106, 150, .8); }

.btn--outline {
    color: #2F4652;
    background: #fff;
    border-color: var(--line-strong);
    box-shadow: var(--shadow-xs);
}

.btn--outline:hover { border-color: #B9CAD3; background: #FBFDFE; }

.btn--soft {
    color: var(--brand-700);
    background: var(--brand-050);
    border-color: #D8EEF7;
}

.btn--soft:hover { background: #E8F7FC; }

.btn--ghost { color: var(--gray-700); background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }

.btn--danger { color: #fff; background: #C83B4C; }
.btn--danger:hover { background: #B32D3D; }

.btn--danger-soft { color: #AA2B3A; background: var(--danger-bg); border-color: #F4D7DB; }
.btn--danger-soft:hover { background: #FBE3E6; }

.btn--sm { height: 34px; padding: 0 12px; font-size: 11.5px; border-radius: 9px; }
.btn--sm svg { width: 14px; height: 14px; flex-basis: 14px; }
.btn--lg { height: 46px; padding: 0 22px; font-size: 13.5px; border-radius: 12px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--gray-500);
    transition: background .16s, color .16s, border-color .16s;
}

.icon-btn:hover { background: var(--surface-2); color: var(--brand-700); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn--sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn--sm svg { width: 16px; height: 16px; }
.icon-btn--danger:hover { background: var(--danger-bg); color: #B02E3E; }

.avatar {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 12px;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .02em;
    background: linear-gradient(135deg, #2BA5D3, #075B80);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
    overflow: hidden;
}

.avatar--sm { width: 32px; height: 32px; flex-basis: 32px; border-radius: 9px; font-size: 10.5px; }
.avatar--lg { width: 58px; height: 58px; flex-basis: 58px; border-radius: 16px; font-size: 19px; }
.avatar--xl { width: 76px; height: 76px; flex-basis: 76px; border-radius: 20px; font-size: 25px; }

.avatar--photo { background: var(--surface-2); }
.avatar--photo img { width: 100%; height: 100%; object-fit: cover; }

/* =========================================================
   Tarjetas y estructura de página
   ========================================================= */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card--flush { padding: 0; overflow: hidden; }

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px 14px;
}

.card-head h3 {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: #18313C;
}

.card-head p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.card-head .card-actions { display: flex; align-items: center; gap: 8px; }

.card-body { padding: 20px; }
.card-body--tight { padding: 14px 16px; }

.page-stack { display: flex; flex-direction: column; gap: 20px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.page-head h2 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.025em;
    color: #10242D;
}

.page-head p { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar--spread { justify-content: space-between; }
.toolbar .spacer { flex: 1; }

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* =========================================================
   Formularios
   ========================================================= */
.form-grid { display: grid; gap: 16px; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-col-span-2 { grid-column: span 2; }
.form-col-span-3 { grid-column: span 3; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field > label, .field-label {
    font-size: 11.5px;
    font-weight: 700;
    color: #3C505A;
    letter-spacing: .01em;
}

.field .hint { font-size: 10.5px; color: var(--muted); line-height: 1.5; }
.field .req { color: #CF4A5B; }

.input, .select, .textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1.5px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    color: var(--ink);
    outline: none;
    transition: border-color .16s, box-shadow .16s;
}

.textarea { min-height: 88px; resize: vertical; line-height: 1.6; }

.input::placeholder, .textarea::placeholder { color: #A6B5BD; }

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3.5px rgba(11, 127, 179, .11);
}

.input.is-invalid, .select.is-invalid, .textarea.is-invalid {
    border-color: #D14A5B;
    box-shadow: 0 0 0 3.5px rgba(207, 51, 70, .1);
}

.select {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7A84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 15px;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: #8FA1AB;
    pointer-events: none;
}
.input-group .input { padding-left: 36px; }
.input-group .input-group-action { position: absolute; right: 6px; }

.input-search { position: relative; min-width: 220px; flex: 1; max-width: 380px; }
.input-search .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: #8FA1AB; }
.input-search .input { padding-left: 36px; padding-right: 32px; background: #fff; }
.input-search .clear-search {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 26px; height: 26px; display: grid; place-items: center;
    border: 0; border-radius: 7px; background: transparent; color: #95A5AD;
}
.input-search .clear-search:hover { background: var(--surface-2); color: var(--danger); }
.input-search .clear-search svg { width: 14px; height: 14px; }

.field-error {
    display: none;
    font-size: 10.5px;
    color: #C43043;
    line-height: 1.4;
}
.field.has-error .field-error { display: block; }

.check {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 12.5px;
    color: #3B4F59;
    cursor: pointer;
    user-select: none;
}

.check input {
    appearance: none;
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    border: 1.5px solid var(--line-strong);
    border-radius: 5px;
    background: #fff;
    display: grid;
    place-content: center;
    transition: background .15s, border-color .15s;
}

.check input::after {
    content: "";
    width: 9px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) scale(0);
    transition: transform .12s;
    margin-top: -2px;
}

.check input:checked { background: var(--brand); border-color: var(--brand); }
.check input:checked::after { transform: rotate(-45deg) scale(1); }

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    font-weight: 600;
    color: #40535D;
    cursor: pointer;
    white-space: nowrap;
}

.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch .track {
    position: relative;
    width: 38px;
    height: 22px;
    flex: 0 0 38px;
    border-radius: 99px;
    background: #C9D6DD;
    transition: background .18s;
}

.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    transition: transform .18s var(--ease);
}

.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    gap: 2px;
}

.segmented button {
    border: 0;
    border-radius: 7px;
    padding: 6px 12px;
    background: transparent;
    font-size: 11.5px;
    font-weight: 700;
    color: #6E7F88;
    transition: background .15s, color .15s, box-shadow .15s;
}

.segmented button.is-active {
    background: #fff;
    color: var(--brand-700);
    box-shadow: var(--shadow-xs);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 99px;
    background: #fff;
    font-size: 11px;
    font-weight: 600;
    color: #52656F;
}

.chip--selectable { cursor: pointer; transition: all .14s; }
.chip--selectable:hover { border-color: var(--brand-200); background: var(--brand-050); }
.chip--selectable.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.table thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #81949D;
    background: #F8FBFC;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #EDF2F5;
    vertical-align: middle;
    color: #344A54;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FAFCFD; }
.table tbody tr.is-muted { opacity: .62; }

.table .cell-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.table .cell-main strong { display: block; font-size: 12.5px; font-weight: 700; color: #1A303A; white-space: nowrap; }
.table .cell-main small { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }

.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { display: flex; justify-content: flex-end; gap: 2px; white-space: nowrap; }

.table th:last-child, .table td:last-child { text-align: right; }

.table--compact tbody td { padding: 9px 12px; }
.table--compact thead th { padding: 8px 12px; }

.table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 16px;
    border-top: 1px solid var(--line);
    background: #FCFDFE;
    font-size: 11.5px;
    color: var(--muted);
    flex-wrap: wrap;
}

.pagination { display: flex; align-items: center; gap: 4px; }

.pagination button {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-size: 11.5px;
    font-weight: 600;
    color: #5B6D76;
}

.pagination button:hover:not(:disabled) { border-color: var(--brand-200); color: var(--brand-700); background: var(--brand-050); }
.pagination button.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination button:disabled { opacity: .45; cursor: not-allowed; }

/* =========================================================
   Badges y estados
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 7px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .01em;
    white-space: nowrap;
    line-height: 1.35;
}

.badge::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.badge--none::before { display: none; }
.badge--blue { color: #066A94; background: #E7F5FB; }
.badge--green { color: #067A5B; background: #E5F8F0; }
.badge--amber { color: #A55B05; background: #FDF2DF; }
.badge--red { color: #B0273A; background: #FCEBEE; }
.badge--gray { color: #5F7079; background: #EEF2F5; }
.badge--violet { color: #6431C9; background: #F1EBFE; }
.badge--teal { color: #087A76; background: #E4F7F5; }
.badge--outline { color: #4C5F69; background: #fff; border: 1px solid var(--line-strong); }

.badge--soft-blue { color: #0A6E97; background: var(--brand-050); }

.tag-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* =========================================================
   Modales
   ========================================================= */
.modal-open { overflow: hidden; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(6, 28, 40, .55);
    backdrop-filter: blur(4px);
    animation: fadeIn .16s ease both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    position: relative;
    width: min(100%, 560px);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow-lg);
    animation: modalIn .22s var(--ease) both;
    overflow: hidden;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(.985); }
    to { opacity: 1; transform: none; }
}

.modal--sm { width: min(100%, 430px); }
.modal--lg { width: min(100%, 780px); }
.modal--xl { width: min(100%, 980px); }

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px 15px;
    border-bottom: 1px solid var(--line);
}

.modal-head h3 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: #142B35;
}

.modal-head p { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.modal-close {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: #7C8D96;
    flex: 0 0 32px;
}

.modal-close:hover { background: #F7FAFB; color: var(--danger); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--line);
    background: #FBFDFE;
    flex-wrap: wrap;
}

.modal-foot .spacer { flex: 1; }

.modal-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--brand-050);
    color: var(--brand);
    margin-bottom: 12px;
}

.modal-icon--danger { background: var(--danger-bg); color: var(--danger); }
.modal-icon svg { width: 22px; height: 22px; }

/* =========================================================
   Toasts
   ========================================================= */
.toasts {
    position: fixed;
    z-index: 300;
    top: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(94vw, 370px);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    font-size: 12.5px;
    line-height: 1.5;
    color: #2C414B;
    animation: toastIn .25s var(--ease) both;
    pointer-events: auto;
}

.toast.is-out { animation: toastOut .22s ease both; }

@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

.toast-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    display: grid;
    place-items: center;
    border-radius: 8px;
}

.toast-icon svg { width: 15px; height: 15px; }
.toast--success .toast-icon { background: var(--success-bg); color: var(--success); }
.toast--error .toast-icon { background: var(--danger-bg); color: var(--danger); }
.toast--info .toast-icon { background: var(--brand-050); color: var(--brand); }
.toast--warning .toast-icon { background: var(--warning-bg); color: var(--warning); }

.toast strong { display: block; font-size: 12px; font-weight: 800; margin-bottom: 1px; }
.toast .toast-msg { color: var(--ink-soft); font-size: 12px; }

/* =========================================================
   Estados vacíos / carga
   ========================================================= */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 46px 24px;
    text-align: center;
    color: var(--muted);
}

.empty-icon {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: var(--surface-2);
    color: #9AAAB2;
    margin-bottom: 4px;
}

.empty-icon svg { width: 24px; height: 24px; }
.empty strong { font-size: 13px; color: #4E626C; font-weight: 700; }
.empty p { font-size: 11.5px; max-width: 340px; line-height: 1.6; }

.skeleton-line, .skeleton-block {
    border-radius: 7px;
    background: linear-gradient(90deg, #EDF2F5 25%, #F6FAFB 50%, #EDF2F5 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s linear infinite;
}

.skeleton-line { height: 11px; margin: 7px 0; }
.skeleton-block { height: 110px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.loading-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .65);
    backdrop-filter: blur(2px);
    border-radius: inherit;
    z-index: 5;
}

.spinner {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2.5px solid #D9E7EE;
    border-top-color: var(--brand);
    animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Responsivo base
   ========================================================= */
@media (max-width: 1180px) {
    .today-chip { display: none; }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-102%);
        transition: transform .28s var(--ease);
        box-shadow: 20px 0 60px rgba(2, 22, 33, .3);
    }
    .layout.nav-open .sidebar { transform: none; }
    .layout.nav-open .scrim { opacity: 1; visibility: visible; }
    .sidebar-close { display: grid; color: rgba(255, 255, 255, .7); }
    .sidebar-close:hover { background: rgba(255, 255, 255, .1); color: #fff; }
    .main { margin-left: 0; }
    .menu-btn { display: grid; }
    .topbar { padding: 0 20px; }
    .view { padding: 22px 20px 44px; }
    .app-foot { padding: 14px 20px 88px; }
    .bottom-nav {
        position: fixed;
        z-index: 45;
        left: 12px;
        right: 12px;
        bottom: max(10px, env(safe-area-inset-bottom));
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        gap: 4px;
        padding: 6px;
        border: 1px solid rgba(222, 234, 239, .9);
        border-radius: 18px;
        background: rgba(255, 255, 255, .94);
        backdrop-filter: blur(16px);
        box-shadow: 0 18px 40px -18px rgba(7, 40, 54, .35);
    }
    .bottom-nav a, .bottom-nav button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 7px 4px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        font-size: 9px;
        font-weight: 700;
        color: #778A94;
        text-decoration: none;
    }
    .bottom-nav a svg, .bottom-nav button svg { width: 19px; height: 19px; }
    .bottom-nav .is-active { background: var(--brand-050); color: var(--brand-700); }
    .user-chip-text { display: none; }
    .user-chip > svg { display: none; }
}

@media (max-width: 860px) {
    .topbar { height: 68px; }
    .page-heading h1 { font-size: 17px; }
    .page-heading p { font-size: 10.5px; }
    .topbar-right .btn--primary span { display: none; }
    .topbar-right .btn--primary { width: 36px; padding: 0; }
    .form-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-col-span-3 { grid-column: span 2; }
    .view { padding: 18px 16px 92px; }
    .page-head h2 { font-size: 19px; }
    .card-head { padding: 16px 16px 12px; }
    .card-body { padding: 16px; }
    .table-foot { padding: 11px 13px; }
}

@media (max-width: 640px) {
    .input, .select, .textarea { font-size: 16px; }
    .form-grid--2, .form-grid--3 { grid-template-columns: 1fr; }
    .form-col-span-2, .form-col-span-3 { grid-column: auto; }
    .modal-backdrop { padding: 0; align-items: flex-end; }
    .modal {
        width: 100%;
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
        animation: sheetIn .26s var(--ease) both;
    }
    @keyframes sheetIn { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
    .modal-head { padding: 16px 17px 12px; }
    .modal-body { padding: 16px 17px; }
    .modal-foot { padding: 12px 17px calc(12px + env(safe-area-inset-bottom)); }
    .toasts { top: 10px; right: 10px; left: 10px; width: auto; }
    .page-head-actions { width: 100%; }
    .page-head-actions .btn { flex: 1; }
    .toolbar { gap: 8px; }
    .input-search { max-width: none; flex-basis: 100%; }
    .app-foot { flex-direction: column; gap: 4px; font-size: 9.5px; padding-bottom: 92px; }
    .page-stack { gap: 14px; }
}
