:root {
    --navy: #0d1a3d;
    --navy-2: #162953;
    --navy-3: #233b6f;
    --gold: #c69a30;
    --gold-dark: #9b741b;
    --gold-soft: #f8f1df;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #fafbfc;
    --text: #11182b;
    --muted: #667085;
    --muted-2: #98a2b3;
    --line: #e6e9f0;
    --danger: #b42318;
    --success: #067647;
    --shadow-sm: 0 8px 22px rgba(13, 26, 61, .07);
    --shadow: 0 22px 58px rgba(13, 26, 61, .11);
    --sidebar-width: 264px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
html, body { margin: 0; }
body { min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* =========================================================
   App shell
   ========================================================= */
.app-body { overflow-x: hidden; }
.app-frame { min-height: 100vh; }
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    box-shadow: 8px 0 30px rgba(13, 26, 61, .035);
}
.sidebar-brand {
    min-height: 86px;
    padding: 20px 22px 18px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { width: 196px; max-height: 48px; object-fit: contain; object-position: left center; }
.sidebar-nav { padding: 18px 14px; display: grid; gap: 5px; overflow-y: auto; }
.sidebar-section-title {
    color: var(--muted-2);
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .13em;
    padding: 14px 12px 6px;
}
.nav-item {
    min-height: 44px;
    border-radius: 11px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #344054;
    font-size: .92rem;
    font-weight: 650;
}
a.nav-item:hover { text-decoration: none; background: #f8f9fc; color: var(--navy); }
.nav-item.active { background: #f4f0e6; color: var(--navy); }
.nav-item.active .nav-dot { background: var(--gold); box-shadow: 0 0 0 4px rgba(198, 154, 48, .14); }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: #cbd1dc; flex: 0 0 auto; }
.nav-item small { margin-left: auto; font-size: .66rem; color: var(--gold-dark); background: var(--gold-soft); padding: 3px 6px; border-radius: 999px; }
.nav-item-disabled { color: #8f98aa; cursor: default; }
.sidebar-footer {
    margin-top: auto;
    padding: 18px 22px 22px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 7px;
    color: var(--muted);
}
.sidebar-footer small { font-size: .74rem; }
.build-badge {
    width: fit-content;
    color: var(--navy);
    background: var(--gold-soft);
    border: 1px solid #ead9aa;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: .72rem;
    font-weight: 800;
}
.app-main { min-height: 100vh; margin-left: var(--sidebar-width); }
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 74px;
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    padding: 12px clamp(18px, 3vw, 36px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.page-context { display: grid; gap: 2px; min-width: 0; }
.page-context small { color: var(--muted); font-size: .72rem; }
.page-context strong { color: var(--navy); font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: 14px; }
.user-copy { display: grid; gap: 2px; text-align: right; }
.user-copy small { color: var(--muted); font-size: .7rem; }
.user-copy strong { color: var(--navy); font-size: .86rem; max-width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-brand { display: none; align-items: center; gap: 8px; color: var(--navy); font-weight: 800; }
.mobile-brand:hover { text-decoration: none; }
.mobile-brand img { width: 34px; height: 34px; object-fit: contain; }
.menu-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 11px;
    display: none;
    place-content: center;
    gap: 4px;
    cursor: pointer;
}
.menu-toggle span { width: 18px; height: 2px; background: var(--navy); border-radius: 99px; display: block; }
.sidebar-overlay { display: none; }
.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 32px 0 56px; }

/* =========================================================
   Public / authentication pages
   ========================================================= */
.public-body { background: #f7f8fb; }
.public-shell { min-height: 100vh; }
.auth-stage {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(390px, 46%) 1fr;
}
.auth-brand-panel {
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, #0b1737 0%, #122654 60%, #1d3568 100%);
    color: white;
    padding: clamp(42px, 7vw, 84px);
    display: flex;
    align-items: center;
}
.auth-brand-glow { position: absolute; border-radius: 50%; filter: blur(2px); pointer-events: none; }
.auth-brand-glow-one { width: 360px; height: 360px; right: -140px; top: -110px; background: rgba(198, 154, 48, .15); }
.auth-brand-glow-two { width: 260px; height: 260px; left: -120px; bottom: -70px; background: rgba(255, 255, 255, .055); }
.auth-brand-content { position: relative; z-index: 1; width: min(560px, 100%); display: grid; gap: 34px; }
.auth-logo-surface {
    width: min(460px, 100%);
    background: rgba(255, 255, 255, .98);
    border-radius: 28px;
    padding: 26px 30px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .2);
}
.auth-logo-surface img { width: 100%; max-height: 220px; object-fit: contain; }
.auth-logo-surface-compact { padding: 24px; }
.auth-logo-surface-compact img { max-height: 92px; }
.auth-brand-copy { max-width: 560px; }
.auth-brand-copy h2 { margin: 9px 0 14px; font-size: clamp(1.8rem, 3vw, 3rem); line-height: 1.04; letter-spacing: -.03em; }
.auth-brand-copy p { margin: 0; color: #d6dbea; line-height: 1.65; font-size: 1rem; }
.eyebrow-light { color: #f0cf78 !important; }
.auth-brand-points { display: flex; flex-wrap: wrap; gap: 9px; }
.auth-brand-points span { border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.07); border-radius: 999px; padding: 8px 11px; font-size: .75rem; color: #edf0f7; }
.auth-form-panel {
    min-width: 0;
    padding: clamp(26px, 5vw, 68px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(circle at 100% 0%, rgba(198,154,48,.07), transparent 30%),
        #f7f8fb;
}
.auth-card {
    width: min(470px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 26px;
    padding: clamp(26px, 4vw, 42px);
    box-shadow: var(--shadow);
}
.auth-card-wide { width: min(690px, 100%); }
.auth-mobile-logo { display: none; width: min(300px, 75%); margin-bottom: 24px; }
.auth-heading { margin-bottom: 26px; }
.auth-heading h1, .dashboard-hero h1, .panel h1, .panel h2 { margin: 8px 0 10px; line-height: 1.08; letter-spacing: -.025em; }
.auth-heading h1 { font-size: clamp(1.75rem, 3vw, 2.35rem); color: var(--navy); }
.auth-heading p, .dashboard-hero p, .panel p, .status-card p { color: var(--muted); margin: 0; line-height: 1.58; }
.eyebrow { font-size: .72rem; font-weight: 850; letter-spacing: .13em; color: var(--gold-dark); }
.auth-links { margin-top: 16px; text-align: center; }
.muted-link { color: var(--muted); font-size: .82rem; }
.muted-link strong { color: var(--navy); }
.auth-divider { margin: 24px 0 18px; display: flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.auth-footer { display: grid; gap: 7px; color: var(--muted); font-size: .86rem; }
.auth-footer-centered { text-align: center; }
.auth-footer small { line-height: 1.45; }
.setup-link { font-weight: 750; color: var(--navy); }
.auth-legal { margin: 22px 0 0; color: var(--muted-2); font-size: .76rem; }

/* =========================================================
   Forms and buttons
   ========================================================= */
.form-stack { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { font-size: .86rem; font-weight: 750; color: #344054; }
input, select, textarea {
    width: 100%;
    border: 1px solid #d2d7e1;
    border-radius: 12px;
    background: #fff;
    padding: 13px 14px;
    color: var(--text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: #a6adba; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(198, 154, 48, .13); }
.field span, .validation-summary { color: var(--danger); font-size: .81rem; }
.validation-summary:empty { display: none; }
.validation-summary ul { margin: 0; padding: 12px 14px 12px 30px; border-radius: 10px; background: #fff4f2; border: 1px solid #ffd5cf; }
.btn {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 800;
    letter-spacing: .02em;
    cursor: pointer;
    transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 10px 24px rgba(13, 26, 61, .16); }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f7f8fb; }
.btn-compact { min-height: 38px; padding: 8px 13px; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-block { width: 100%; }

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 18px; font-size: .88rem; line-height: 1.5; }
.alert-success { background: #ecfdf3; color: var(--success); border: 1px solid #abefc6; }
.alert-danger { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; }

/* =========================================================
   Dashboard / content
   ========================================================= */
.dashboard-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #fff 0%, #fbfaf6 100%);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: clamp(24px, 4vw, 36px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.dashboard-hero::after { content: ""; position: absolute; width: 190px; height: 190px; right: -80px; top: -90px; border: 34px solid rgba(198,154,48,.08); border-radius: 50%; }
.dashboard-hero-copy { position: relative; z-index: 1; }
.dashboard-hero h1 { color: var(--navy); font-size: clamp(1.9rem, 3.4vw, 3rem); }
.clock-card {
    position: relative;
    z-index: 1;
    min-width: 340px;
    background: var(--navy);
    color: white;
    border-radius: 18px;
    padding: 19px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 15px 34px rgba(13, 26, 61, .18);
}
.clock-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--gold); color: var(--navy); font-size: .75rem; font-weight: 900; }
.clock-card > div:last-child { display: grid; gap: 5px; }
.clock-card span { color: #cfd5e4; font-size: .78rem; }
.clock-card strong { font-size: 1.02rem; }
.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.status-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    display: flex;
    gap: 13px;
    min-height: 145px;
    box-shadow: var(--shadow-sm);
}
.status-card small { display: block; color: var(--muted); margin-bottom: 5px; }
.status-card strong { display: block; color: var(--navy); margin-bottom: 6px; }
.status-icon { width: 38px; height: 38px; border-radius: 11px; background: var(--gold-soft); color: var(--gold-dark); display: grid; place-items: center; flex: 0 0 auto; font-size: .72rem; font-weight: 900; border: 1px solid #ead9aa; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow-sm); }
.feature-panel { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr); gap: 28px; }
.feature-list { display: grid; gap: 10px; }
.feature-list span { background: #f8f9fb; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; color: #475467; font-size: .84rem; }
.feature-list b { color: var(--gold-dark); margin-right: 8px; }
.next-panel { background: linear-gradient(150deg, var(--navy) 0%, var(--navy-2) 100%); border-color: transparent; color: white; }
.next-panel .eyebrow { color: #f3d485; }
.next-panel h2 { color: white; font-size: 2rem; }
.next-panel p { color: #d4dae8; }
.next-chip { display: inline-flex; margin-top: 18px; padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.12); color: #fff; font-size: .73rem; }
.narrow-panel { max-width: 620px; margin: 40px auto; }
.state-panel { text-align: center; padding-block: 38px; }
.state-panel .btn { margin-top: 22px; }
.state-icon { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-dark); font-size: 1.4rem; font-weight: 900; border: 1px solid #ead9aa; }
.request-id { margin-top: 14px !important; font-size: .82rem; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1100px) {
    .status-grid { grid-template-columns: 1fr 1fr; }
    .status-card:last-child { grid-column: 1 / -1; }
    .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
    .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(13, 26, 61, .18); }
    .app-main { margin-left: 0; }
    .menu-toggle { display: grid; }
    .page-context { display: none; }
    .mobile-brand { display: flex; }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 35; border: 0; background: rgba(13, 26, 61, .44); opacity: 0; pointer-events: none; display: block; transition: opacity .2s ease; }
    .sidebar-open .app-sidebar { transform: translateX(0); }
    .sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }

    .auth-stage { grid-template-columns: 1fr; }
    .auth-brand-panel { display: none; }
    .auth-mobile-logo { display: block; }
    .auth-form-panel { min-height: 100vh; padding: 28px 20px; }
}

@media (max-width: 760px) {
    .page-shell { width: min(100% - 24px, 1180px); padding-top: 20px; }
    .app-topbar { min-height: 66px; padding-inline: 12px; }
    .user-copy { display: none; }
    .topbar-user { gap: 8px; }
    .dashboard-hero { display: grid; padding: 22px; }
    .clock-card { min-width: 0; }
    .status-grid { grid-template-columns: 1fr; }
    .status-card:last-child { grid-column: auto; }
    .feature-panel { grid-template-columns: 1fr; }
    .field-grid { grid-template-columns: 1fr; }
    .auth-card { border-radius: 20px; padding: 24px; }
}

@media (max-width: 480px) {
    .mobile-brand span { font-size: .88rem; }
    .page-shell { width: min(100% - 16px, 1180px); }
    .dashboard-hero { border-radius: 18px; padding: 18px; }
    .dashboard-hero h1 { font-size: 1.75rem; }
    .clock-card { padding: 15px; border-radius: 15px; }
    .status-card, .panel { border-radius: 15px; padding: 18px; }
    .auth-form-panel { padding: 18px 12px 24px; justify-content: flex-start; }
    .auth-mobile-logo { width: 230px; margin: 18px auto 18px; }
    .auth-card { padding: 20px 18px; border-radius: 18px; }
    input, select, textarea { min-height: 50px; font-size: 16px; }
    .btn { min-height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* =========================================================
   Paso 2 - administración
   ========================================================= */
.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}
.page-heading h1 { margin: 7px 0 7px; color: var(--navy); font-size: clamp(1.8rem, 3vw, 2.6rem); letter-spacing: -.03em; }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.55; }
.form-panel { max-width: 900px; }
.form-panel-narrow { max-width: 560px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.field-help { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.info-box { border: 1px solid #d9e3f2; background: #f5f8fc; color: #475467; border-radius: 12px; padding: 12px 14px; font-size: .84rem; line-height: 1.5; }
.margin-top { margin-top: 16px; }

.check-row, .selection-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}
.check-row input, .selection-card input {
    width: auto;
    min-height: auto;
    margin-top: 3px;
    accent-color: var(--navy);
}
.check-row { padding: 10px 0; }
.selection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.selection-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    transition: border-color .15s ease, background .15s ease;
}
.selection-card:has(input:checked) { border-color: #d5b25a; background: #fffcf4; }
.selection-card span { display: grid; gap: 3px; color: var(--text); }
.selection-card strong { color: var(--navy); font-size: .86rem; }
.selection-card small { color: var(--muted); font-size: .76rem; line-height: 1.35; }
.permission-group { display: grid; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.permission-group:last-child { border-bottom: 0; }
.permission-group-title { color: var(--gold-dark); font-weight: 900; font-size: .74rem; letter-spacing: .08em; }

.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-sm); overflow: hidden; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: #667085; font-size: .73rem; text-transform: uppercase; letter-spacing: .06em; background: #fafbfc; white-space: nowrap; }
td { color: #344054; font-size: .86rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.table-title { color: var(--navy); font-weight: 800; margin-bottom: 2px; }
td small { color: var(--muted); line-height: 1.35; }
.table-actions { white-space: nowrap; text-align: right; }
.table-actions .btn + .btn { margin-left: 5px; }
.empty-cell { text-align: center; color: var(--muted); padding: 30px 16px; }
code { background: #f1f3f7; color: var(--navy); border-radius: 6px; padding: 3px 6px; font-size: .78rem; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: .7rem; font-weight: 800; white-space: nowrap; margin: 2px 3px 2px 0; }
.badge-success { background: #ecfdf3; color: #027a48; border: 1px solid #abefc6; }
.badge-muted { background: #f2f4f7; color: #667085; border: 1px solid #e4e7ec; }
.badge-gold { background: var(--gold-soft); color: var(--gold-dark); border: 1px solid #ead9aa; }
.badge-warning { background: #fffaeb; color: #b54708; border: 1px solid #fedf89; }

@media (max-width: 760px) {
    .page-heading { align-items: stretch; flex-direction: column; }
    .page-heading > .btn { width: 100%; }
    .form-grid-2, .selection-grid { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .topbar-password { display: none; }
    .table-card { border-radius: 14px; }
}
.read-only-value { min-height: 46px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; background: #f8f9fb; color: var(--navy); font-weight: 800; }
