:root {
  --red: #c8102e;
  --red2: #a80b25;
  --ink: #1b2430;
  --muted: #687382;
  --line: #e1e5ea;
  --bg: #f4f6f8;
  --green: #169b62;
  --orange: #dc7a05;
  --blue: #4d86bd;
  --danger: #b2102a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Arial, Helvetica, sans-serif; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }
.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; }
.noscript-message { margin: 20px; padding: 16px; border: 1px solid #f0c5cd; border-radius: 8px; background: #fff2f5; color: var(--danger); }

.shell { min-height: 100vh; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: linear-gradient(180deg, #1d2730, #15202a); color: #fff; display: flex; flex-direction: column; overflow-y: auto; }
.brand { min-height: 112px; padding: 24px 20px; background: linear-gradient(145deg, #d30d2e, #b90023); display: flex; align-items: center; gap: 10px; text-transform: uppercase; font-size: 10px; line-height: 1.15; letter-spacing: .08em; }
.brand-mark { font-size: 30px; font-weight: 850; letter-spacing: -.08em; border-right: 1px solid #ffffff8c; padding-right: 10px; }
.nav-label { padding: 18px 20px 4px; color: #82909c; font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.sidebar nav { padding: 4px 8px; display: flex; flex-direction: column; gap: 6px; }
.sidebar nav a { color: #d9e0e6; text-decoration: none; padding: 11px 13px; border-radius: 7px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.sidebar nav a:hover, .sidebar nav a.active { background: var(--red); color: #fff; }
.dashboard-nav a { border: 1px solid #ffffff14; background: #ffffff08; }
.dashboard-nav a[aria-current="page"] { border-color: #ffffff2b; background: #ffffff14; }
.sidebar-note { margin: auto 16px 20px; padding: 15px; border-top: 1px solid #ffffff24; display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: #9eabb7; }
.sidebar-note strong { color: #fff; }

.content { min-width: 0; padding: 28px 30px 18px; max-width: 1600px; width: 100%; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 5px; color: var(--red); font-size: 11px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
h1 { margin: 0; font-size: 29px; letter-spacing: -.035em; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.period { min-width: 112px; background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 8px 13px; display: flex; flex-direction: column; }
.period span { font-size: 10px; color: var(--muted); }
.period strong { font-size: 14px; }
.data-status { min-height: 43px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; background: #effaf5; color: #087b4b; border: 1px solid #c9e9da; border-radius: 7px; font-size: 11px; }
.data-status i { width: 8px; height: 8px; background: var(--green); border-radius: 50%; }
.data-status.warning { background: #fff8e9; color: #8a5209; border-color: #f4dcae; }
.data-status.warning i { background: #e99a09; }
.user-area { min-height: 43px; display: flex; align-items: center; gap: 8px; padding: 0 10px; background: #fff; border: 1px solid var(--line); border-radius: 7px; font-size: 11px; }
.user-area button { border: 0; border-radius: 5px; padding: 5px 8px; color: var(--red); background: #fff2f5; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi, .panel { background: #fff; border: 1px solid var(--line); box-shadow: 0 2px 7px #1b243009; }
.kpi { min-height: 125px; border-radius: 9px; padding: 19px; display: flex; align-items: center; gap: 15px; }
.kpi.primary { border-top: 3px solid var(--green); }
.kpi.academic { border-top: 3px solid var(--blue); }
.kpi-icon { width: 48px; height: 48px; flex: 0 0 48px; border: 1px solid #ecd8dd; background: #fff8fa; color: var(--red); border-radius: 10px; display: grid; place-items: center; font-size: 27px; }
.kpi-icon.green { color: var(--green); background: #f3fbf7; }
.kpi-icon.orange { color: var(--orange); background: #fff9f1; }
.kpi-icon.blue { color: #2468a9; background: #f2f7fc; }
.kpi div:last-child { min-width: 0; display: flex; flex-direction: column; }
.kpi span { color: #3d4650; font-size: 12px; }
.kpi strong { margin: 2px 0; font-size: 32px; line-height: 1; }
.kpi small { color: var(--muted); font-size: 10.5px; }
.green-text { color: var(--green); }
.orange-text { color: var(--orange); }

.panel { border-radius: 9px; }
.insight-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(285px, .75fr); gap: 16px; margin-bottom: 16px; }
.chart-card, .progress-card { min-height: 378px; padding: 20px; }
.panel-title { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.panel-title h2, .table-header h2 { margin: 0; font-size: 17px; }
.panel-title p, .table-header p { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 15px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; gap: 6px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 2px; }
.dot-meta { background: #dde2e7; }
.dot-fin { background: var(--green); }
.dot-aca { background: var(--blue); }
.bar-chart { margin-top: 23px; display: flex; flex-direction: column; gap: 15px; }
.bar-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 12px; padding-right: 38px; }
.bar-label { text-align: right; font-size: 11px; }
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar { position: relative; min-width: 2px; max-width: 100%; height: 10px; border-radius: 0 3px 3px 0; }
.bar.meta { background: #dde2e7; }
.bar.fin { background: var(--green); }
.bar.aca { background: var(--blue); }
.bar b { position: absolute; left: calc(100% + 7px); top: -3px; font-size: 10px; }
.donut { width: 154px; height: 154px; margin: 22px auto 15px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.donut::after { content: ""; width: 116px; height: 116px; position: absolute; border-radius: 50%; background: #fff; }
.donut div { z-index: 1; display: flex; flex-direction: column; align-items: center; }
.donut strong { color: var(--green); font-size: 29px; }
.donut span { color: var(--muted); font-size: 10px; }
.status-summary { border-top: 1px solid var(--line); }
.status-summary > div { padding: 10px 1px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; font-size: 11px; }
.status-summary span { display: flex; align-items: center; gap: 8px; color: #4b5661; }
.status-summary i, .badge i { width: 8px; height: 8px; border-radius: 50%; }

.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 22px 2px 14px; }
.section-heading h2 { margin: 0; font-size: 23px; }
.section-heading p:last-child { color: var(--muted); font-size: 11px; margin: 5px 0 0; }
.funnel-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.funnel-kpis article { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--red); border-radius: 8px; padding: 15px 17px; display: flex; flex-direction: column; }
.funnel-kpis article:nth-child(2) { border-top-color: #e24a62; }
.funnel-kpis article:nth-child(3) { border-top-color: #e78539; }
.funnel-kpis article:nth-child(4) { border-top-color: var(--green); }
.funnel-kpis span { font-size: 11px; }
.funnel-kpis strong { font-size: 28px; margin: 3px 0; }
.funnel-kpis small { color: var(--muted); font-size: 10px; }
.funnel-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(270px, .7fr); gap: 12px; margin-bottom: 12px; }
.funnel-card, .funnel-note { padding: 19px 20px; }
.funnel-chart { min-height: 250px; margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.funnel-stage { min-height: 48px; color: #fff; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 18px; padding: 0 18px; border-radius: 5px; }
.funnel-stage:nth-child(1) { background: #c8102e; }
.funnel-stage:nth-child(2) { background: #e24a62; }
.funnel-stage:nth-child(3) { background: #e78539; }
.funnel-stage:nth-child(4) { background: var(--green); }
.funnel-stage span { font-size: 11px; font-weight: 650; }
.funnel-stage strong { font-size: 20px; }
.funnel-stage small { min-width: 48px; text-align: right; font-size: 10px; }
.funnel-note h2 { margin: 0 0 12px; font-size: 17px; }
.funnel-note > div { border-bottom: 1px solid var(--line); padding: 12px 0; display: flex; justify-content: space-between; }
.funnel-note > div span { font-size: 12px; }
.funnel-note > div strong { font-size: 22px; }
.funnel-note p { background: #fff7e9; color: #73521d; border: 1px solid #f0ddb9; border-radius: 6px; padding: 11px; font-size: 10.5px; line-height: 1.45; }

.table-card { overflow: hidden; margin-bottom: 16px; }
.table-header { padding: 17px 20px; display: flex; justify-content: space-between; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 9px; }
.filters select, .search { height: 39px; border: 1px solid #cfd4da; border-radius: 6px; background: #fff; color: #37414b; }
.filters select { padding: 0 12px; min-width: 160px; font-size: 12px; }
.search { display: flex; align-items: center; min-width: 230px; padding: 0 10px; gap: 8px; }
.search:focus-within { border-color: var(--red); box-shadow: 0 0 0 2px #c8102e1f; }
.search input { border: 0; outline: 0; width: 100%; font-size: 12px; }
.table-scroll { overflow: auto; max-height: 550px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead { position: sticky; top: 0; z-index: 2; background: #f9fafb; }
th, td { padding: 11px 18px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: #59636d; font-size: 10.5px; }
th button { background: none; border: 0; padding: 0; color: inherit; font-weight: inherit; }
th button:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
tbody tr:hover { background: #fffafb; }
td:first-child { white-space: normal; min-width: 285px; }
.online-meta { color: var(--red); }
.academic-value { color: #2468a9; }
.cell-progress { display: flex; align-items: center; gap: 9px; min-width: 150px; }
.cell-progress > span { width: 50px; }
.cell-progress > i { width: 80px; height: 5px; background: #eceff2; border-radius: 10px; overflow: hidden; }
.cell-progress > i b { display: block; height: 100%; background: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid; border-radius: 999px; padding: 4px 9px; font-size: 10px; }
.badge.success { color: #087b4b; background: #effaf5; border-color: #c9e9da; }
.badge.success i { background: var(--green); }
.badge.warning { color: #a45c00; background: #fff8e9; border-color: #f4dcae; }
.badge.warning i { background: #e99a09; }
.badge.progress { color: #b14d08; background: #fff5ec; border-color: #f4d5bd; }
.badge.progress i { background: #dc7215; }
.badge.danger { color: var(--danger); background: #fff2f5; border-color: #f1cbd3; }
.badge.danger i { background: var(--red); }
.badge.muted { color: #69737e; background: #f5f6f7; border-color: #dfe3e6; }
.badge.muted i { background: #9099a2; }
footer { color: #7b858f; font-size: 10px; padding: 14px 2px; text-align: right; line-height: 1.5; }

.status-screen { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: #f4f6f8eb; backdrop-filter: blur(3px); }
.status-screen.ready { display: none; }
.status-card { width: min(440px, 100%); padding: 28px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 50px #1b243026; }
.status-card h2 { margin: 14px 0 6px; font-size: 20px; }
.status-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.status-spinner { width: 34px; height: 34px; display: inline-block; border: 3px solid #f1cbd3; border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
.status-screen.error .status-spinner { animation: none; border: 0; width: auto; height: auto; color: var(--red); font-size: 30px; }
.status-screen.error .status-spinner::before { content: "!"; }
.retry-button { margin-top: 18px; border: 0; border-radius: 7px; padding: 10px 16px; color: #fff; background: var(--red); font-weight: 700; }
.retry-button:hover { background: var(--red2); }
@keyframes spin { to { transform: rotate(360deg); } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(145deg, #f4f6f8, #e9edf1); }
.login-card { width: min(440px, 100%); padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 50px #1b24301c; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand .brand-mark { color: var(--red); border-color: #d5d9de; }
.login-card h1 { font-size: 24px; }
.login-card > p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-form { display: grid; gap: 14px; margin-top: 22px; }
.login-form label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; }
.login-form input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #cfd4da; border-radius: 7px; outline: 0; }
.login-form input:focus { border-color: var(--red); box-shadow: 0 0 0 2px #c8102e1f; }
.login-form button { height: 44px; border: 0; border-radius: 7px; color: #fff; background: var(--red); font-weight: 700; }
.login-form button:disabled { cursor: not-allowed; opacity: .55; }
.login-message { margin-top: 14px; padding: 11px; border-radius: 7px; background: #f5f6f7; color: #59636d; font-size: 12px; line-height: 1.45; }
.login-message.error { background: #fff2f5; color: var(--danger); }

@media (max-width: 1300px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
  .kpi-grid, .funnel-kpis { grid-template-columns: repeat(2, 1fr); }
  .insight-grid, .funnel-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; overflow: visible; }
  .brand { min-height: auto; padding: 14px 18px; }
  .nav-label { display: none; }
  .sidebar nav { padding: 8px; flex-direction: row; overflow: auto; }
  .sidebar nav a { flex: 0 0 auto; padding: 9px 12px; }
  .sidebar-note { display: none; }
  .content { padding: 20px 14px; }
  .topbar, .section-heading { flex-direction: column; align-items: stretch; }
  .top-actions { justify-content: stretch; }
  .period, .data-status { flex: 1; }
  .kpi-grid, .funnel-kpis { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 112px 1fr; }
  .bar-label { font-size: 9px; }
  .table-header { align-items: stretch; flex-direction: column; }
  .filters { flex-direction: column; }
  .filters select, .search { width: 100%; }
  .search { min-width: 0; }
  .funnel-stage { width: 100% !important; }
}
