/* =========================================================================
   Portal de clientes
   ========================================================================= */
body.portal { background: var(--bg-soft); }
.portal-shell { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }

.portal-side {
    background: var(--grad-dark); color: #CFC4F0; padding: 26px 18px; display: flex; flex-direction: column; gap: 8px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: #A99BD9; margin: 18px 12px 6px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: #E4DCFF; font-weight: 600; transition: background .2s; }
.side-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav a.active { background: #fff; color: var(--primary-700); box-shadow: 0 8px 20px rgba(0,0,0,.2); }
.side-cta { margin-top: auto; background: linear-gradient(135deg, rgba(255,79,163,.35), rgba(107,62,242,.35)); border: 1px solid rgba(255,255,255,.18); border-radius: 18px; padding: 18px; color: #fff; }
.side-cta p { font-size: .85rem; color: #EDE6FF; margin: 6px 0 12px; }
.side-help { padding: 14px 12px 0; font-size: .85rem; }
.side-help small { display: block; color: #A99BD9; }
.side-help a { color: #fff; word-break: break-all; }

.portal-main { display: flex; flex-direction: column; min-width: 0; }
.portal-top { display: flex; align-items: center; gap: 16px; padding: 16px 32px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.side-toggle { display: none; background: var(--primary-50); border: 0; width: 42px; height: 42px; border-radius: 12px; font-size: 1.2rem; color: var(--primary); }
.top-institution small { display: block; color: var(--muted); font-size: .75rem; }
.top-institution strong { font-family: var(--font-head); }
.top-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-user-info strong { display: block; font-size: .9rem; }
.top-user-info small { color: var(--muted); font-size: .8rem; }
.avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; font-family: var(--font-head); flex-shrink: 0; }
.avatar.sm { width: 34px; height: 34px; border-radius: 10px; font-size: .85rem; }

.portal-content { padding: 32px; flex: 1; max-width: 1320px; width: 100%; }
.portal-foot { padding: 20px 32px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head h1 { font-size: 1.9rem; margin-bottom: 4px; }
.page-head p { margin: 0; }
.section-title { font-size: 1.3rem; margin: 30px 0 16px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; gap: 14px; align-items: center; }
.kpi-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.kpi small { display: block; color: var(--muted); font-size: .8rem; }
.kpi strong { font-family: var(--font-head); font-size: 1.7rem; line-height: 1.1; display: block; }
.kpi strong.kpi-sm { font-size: 1.05rem; word-break: break-all; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 26px; margin-bottom: 24px; min-width: 0; }
.panel h2 { font-size: 1.25rem; }
.panel h3 { font-size: 1.1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.panel-actions { display: flex; gap: 10px; align-items: center; }
.panel-actions input { margin: 0; padding: 8px 12px; width: 200px; }
.count { font-size: .85rem; background: var(--primary-50); color: var(--primary); border-radius: 999px; padding: 3px 10px; margin-left: 6px; vertical-align: middle; }
.two-col { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
.two-col.even { grid-template-columns: 1fr 1fr; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 30px; }

/* Licencias */
.license-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.license-card { background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 24px; position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 18px; }
.license-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; }
.lc-escuela::before { background: linear-gradient(90deg, #6B3EF2, #9B5CF6); }
.lc-volumen::before { background: linear-gradient(90deg, #FF4FA3, #FF8A3D); }
.lc-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.lc-plan { font-family: var(--font-head); font-weight: 800; font-size: 1.2rem; display: block; }
.lc-key { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.lc-key code, .lh-key code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-weight: 700; letter-spacing: .06em; background: var(--bg-soft); padding: 4px 10px; border-radius: 8px; color: var(--primary-700); }
.copy-btn { border: 1px solid var(--line); background: #fff; color: var(--primary); border-radius: 8px; padding: 3px 10px; font-size: .78rem; font-weight: 700; }
.copy-btn:hover { background: var(--primary-50); }
.copy-btn.light { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.3); color: #fff; }
.lc-seats-row { display: flex; justify-content: space-between; font-size: .9rem; color: var(--ink-2); margin-bottom: 6px; }
.progress { height: 10px; background: var(--primary-50); border-radius: 999px; overflow: hidden; }
.progress.big { height: 8px; margin: 12px 0 20px; }
.progress span { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width .6s ease; }
.lc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; }
.lc-meta dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.lc-meta dd { margin: 0; font-weight: 600; font-size: .92rem; }

.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.badge-success { background: #DDF8EC; color: #0E7A50; }
.badge-warning { background: #FFF3D6; color: #8A5A00; }
.badge-danger { background: #FFE4E4; color: #B42318; }
.badge-muted { background: #EEECF3; color: #5E5873; }

.license-hero { border-radius: 26px; padding: 32px; color: #fff; display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; position: relative; overflow: hidden; }
.license-hero.lc-escuela { background: var(--grad-dark); }
.license-hero.lc-volumen { background: linear-gradient(135deg, #2E1570 0%, #7A2A9E 50%, #FF4FA3 100%); }
.license-hero::after { content: ""; position: absolute; width: 340px; height: 340px; border-radius: 50%; background: rgba(255,255,255,.07); right: -80px; top: -120px; }
.license-hero h1 { font-size: 2rem; margin: 10px 0 4px; }
.license-hero p { color: #E4DCFF; margin-bottom: 18px; }
.license-hero .badge-success { background: rgba(34,197,139,.2); color: #9DF3CF; }
.lh-key small { display: block; color: #CFC4F0; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.lh-key code { background: rgba(255,255,255,.12); color: #fff; font-size: 1.15rem; padding: 8px 14px; margin-right: 8px; }
.lh-seats { text-align: center; position: relative; z-index: 1; }
.lh-seats > span { display: block; margin-top: 10px; font-weight: 600; color: #EDE6FF; }
.ring { --p: 0; width: 130px; height: 130px; border-radius: 50%; background: conic-gradient(#FFC940 calc(var(--p) * 1%), rgba(255,255,255,.15) 0); display: grid; place-items: center; }
.ring > div { width: 100px; height: 100px; border-radius: 50%; background: #2A1463; display: grid; place-items: center; align-content: center; }
.ring strong { font-family: var(--font-head); font-size: 2rem; line-height: 1; }
.ring small { color: #CFC4F0; }

.seg { display: inline-flex; background: var(--bg-soft); border-radius: 12px; padding: 4px; margin-bottom: 18px; width: 100%; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 12px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }

/* Tabla */
.table-wrap { overflow-x: auto; margin: 0 -8px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #FCFBFF; }
.member { display: flex; gap: 10px; align-items: center; }
.member strong { display: block; }
.member small { color: var(--muted); }
.block { display: block; }
.nowrap { white-space: nowrap; }
.code-sm { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; background: var(--bg-soft); padding: 2px 8px; border-radius: 6px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; position: relative; }
.row-actions form { margin: 0; }
.role { font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--primary-50); color: var(--primary-700); white-space: nowrap; }
.role-coordinador { background: #FFE6F2; color: #C81E78; }
.role-directivo { background: #FFEEDF; color: #C2560E; }
.role-administrador { background: #E1ECFF; color: #1E5BD8; }
.role-orientador { background: #DDF8EC; color: #0E8A5C; }

.edit-pop { position: relative; }
.edit-pop summary { list-style: none; }
.edit-pop summary::-webkit-details-marker { display: none; }
.edit-pop .pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 280px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-lg); text-align: left; }
.edit-pop .pop label { margin-bottom: 10px; }

.empty { text-align: center; background: #fff; border: 2px dashed var(--line); border-radius: 22px; padding: 50px 24px; }
.small-empty { border: 0; padding: 30px 10px; }
.empty-icon { font-size: 2.6rem; margin-bottom: 10px; }

.steps-list { padding-left: 0; list-style: none; counter-reset: s; margin: 16px 0 0; }
.steps-list li { counter-increment: s; position: relative; padding: 8px 0 8px 42px; color: var(--ink-2); }
.steps-list li::before { content: counter(s); position: absolute; left: 0; top: 5px; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-50); color: var(--primary); font-weight: 800; display: grid; place-items: center; font-size: .85rem; }
.steps-list li.done { color: var(--muted); text-decoration: line-through; }
.steps-list li.done::before { content: "✓"; background: var(--green); color: #fff; }

.side-backdrop { display: none; }

/* Login */
.auth { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-art { background: var(--grad-dark); color: #fff; padding: 44px; display: flex; flex-direction: column; justify-content: space-between; gap: 30px; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; width: 480px; height: 480px; border-radius: 50%; background: radial-gradient(circle, rgba(255,79,163,.35), transparent 70%); right: -160px; bottom: -160px; }
.auth-art h1 { font-size: clamp(2rem, 3.4vw, 2.8rem); }
.auth-art p { color: #D9CFF5; font-size: 1.1rem; }
.auth-art small { color: #A99BD9; }
.auth-points { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; position: relative; z-index: 1; }
.auth-points li { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: 12px 16px; font-weight: 600; }
.auth-form-wrap { display: grid; place-items: center; padding: 40px 20px; background: var(--bg-soft); }
.auth-form { width: 100%; max-width: 420px; background: #fff; padding: 36px; border-radius: 24px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-form h2 { font-size: 1.7rem; }

@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .two-col, .two-col.even, .help-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .portal-shell { grid-template-columns: 1fr; }
    .portal-side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .3s ease; }
    .side-open .portal-side { transform: none; }
    .side-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(20,10,50,.45); z-index: 55; }
    .side-toggle { display: grid; place-items: center; }
    .portal-top { padding: 12px 16px; }
    .top-user-info, .top-institution { display: none; }
    .portal-content { padding: 20px 16px; }
    .auth { grid-template-columns: 1fr; }
    .auth-art { padding: 28px 20px; }
    .auth-points { display: none; }
    .license-grid { grid-template-columns: 1fr; }
    .panel-actions input { width: 140px; }
}
@media (max-width: 520px) {
    .kpis { grid-template-columns: 1fr; }
    .license-hero { padding: 24px 20px; }
    .lh-key code { font-size: .95rem; }
    .auth-form { padding: 24px; }
}

/* Administración */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px; }
.filters input, .filters select { margin: 0; width: auto; flex: 1; min-width: 180px; padding: 9px 12px; }
.filters select { flex: 0 1 220px; }
.pop-wide { width: 360px; }
.page-head .edit-pop .pop { top: calc(100% + 8px); }
.mt-12 { margin-top: 12px; }
.msg-cell { max-width: 360px; font-size: .88rem; color: var(--ink-2); }
.member .role { margin-left: 6px; font-size: .7rem; padding: 2px 8px; }
.summary-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px dashed var(--line); color: var(--ink-2); }

/* Precios y planes */
.plans-admin { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 24px; }
.plan-edit h2 small { font-size: .8rem; font-weight: 500; }
.price-input { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 14px 0 18px; }
.price-input label { margin-bottom: 10px; }
.money-field { display: flex; align-items: center; margin-top: 6px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; padding-left: 14px; }
.money-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(107,62,242,.12); }
.money-field span { font-family: var(--font-head); font-weight: 800; font-size: 1.4rem; color: var(--primary); }
.money-field input { border: 0; box-shadow: none !important; margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 1.6rem; padding: 10px 12px; }
.price-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .85rem; color: var(--ink-2); }
.plan-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
@media (max-width: 520px) { .plans-admin { grid-template-columns: 1fr; } }
