:root {
  --brand-navy: #112c7a;
  --brand-gold: #ffc000;
  --brand-navy-dark: #0b1f59;
  --brand-navy-soft: #e9eefc;
  --brand-gold-soft: #fff7d6;
  --surface-page: #f5f7fb;
  --surface-raised: #ffffff;
  --surface-muted: #f0f3f8;
  --border-subtle: #e2e7f0;
  --text-strong: #172033;
  --text-muted: #68738a;
  --danger: #c13737;
  --danger-soft: #fff0f0;
  --success: #188454;
  --radius-sm: .45rem;
  --radius-md: .7rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --shadow-card: 0 1px 2px rgb(15 31 74 / 4%), 0 8px 24px rgb(15 31 74 / 5%);
  --shadow-float: 0 16px 48px rgb(5 20 58 / 18%);
  --sidebar-width: 17.5rem;
  --bs-primary: var(--brand-navy);
  --bs-primary-rgb: 17, 44, 122;
  --bs-link-color: var(--brand-navy);
  --bs-link-hover-color: var(--brand-navy-dark);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { background: var(--surface-page); color: var(--text-strong); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; min-height: 100vh; }
a { color: var(--brand-navy); text-underline-offset: .2em; }
a:hover { color: var(--brand-navy-dark); }
h1, h2, h3, h4, h5, h6 { color: var(--text-strong); font-weight: 700; letter-spacing: -.02em; }
.bg-primary { background-color: var(--brand-navy) !important; }
.btn { border-radius: var(--radius-md); font-weight: 650; padding: .62rem 1rem; }
.btn-sm { padding: .4rem .7rem; }
.btn-primary { --bs-btn-bg: var(--brand-navy); --bs-btn-border-color: var(--brand-navy); --bs-btn-hover-bg: var(--brand-navy-dark); --bs-btn-hover-border-color: var(--brand-navy-dark); box-shadow: 0 4px 12px rgb(17 44 122 / 18%); }
.btn-outline-primary { --bs-btn-color: var(--brand-navy); --bs-btn-border-color: #b9c5e5; --bs-btn-hover-bg: var(--brand-navy); --bs-btn-hover-border-color: var(--brand-navy); }

.app-sidebar { background: var(--brand-navy); bottom: 0; color: white; display: flex; flex-direction: column; left: 0; padding: 1.35rem 1rem 1rem; position: fixed; top: 0; width: var(--sidebar-width); z-index: 1030; }
.sidebar-brand { color: white; display: block; margin: 0 .55rem 1.4rem; text-decoration: none; }
.sidebar-brand:hover { color: white; }
.sidebar-logo-frame { background: white; border-radius: var(--radius-md); display: block; height: 3.5rem; overflow: hidden; width: 10rem; }
.sidebar-logo-frame img { display: block; height: 100%; object-fit: cover; object-position: center; width: 100%; }
.sidebar-logo-frame--dark { background: transparent; border-radius: 0; height: 4rem; width: 10.5rem; }
.sidebar-logo-frame--dark img { object-position: center; }
.sidebar-product { color: rgb(255 255 255 / 62%); display: block; font-size: .7rem; font-weight: 700; letter-spacing: .13em; margin: .45rem 0 0 .2rem; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; }
.sidebar-label { color: rgb(255 255 255 / 42%); font-size: .67rem; font-weight: 800; letter-spacing: .13em; margin: 1.25rem .75rem .45rem; text-transform: uppercase; }
.sidebar-link { align-items: center; border-radius: var(--radius-md); color: rgb(255 255 255 / 74%); display: flex; font-size: .91rem; font-weight: 600; gap: .78rem; margin-bottom: .15rem; padding: .72rem .8rem; text-decoration: none; transition: background .15s, color .15s, transform .15s; }
.sidebar-link:hover { background: rgb(255 255 255 / 8%); color: white; transform: translateX(2px); }
.sidebar-link.is-active { background: var(--brand-gold); color: var(--brand-navy-dark); box-shadow: 0 7px 18px rgb(0 0 0 / 13%); }
.sidebar-link svg, .icon-button svg { fill: none; height: 1.2rem; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 1.2rem; }
.sidebar-link:first-of-type svg { fill: currentColor; stroke: none; }
.sidebar-footer { border-top: 1px solid rgb(255 255 255 / 10%); padding-top: .85rem; }
.sidebar-admin { color: rgb(255 255 255 / 62%); display: block; font-size: .78rem; margin: 0 .65rem .8rem; text-decoration: none; }
.sidebar-admin:hover { color: white; }
.user-summary { align-items: center; display: flex; gap: .65rem; padding: .45rem; }
.user-avatar, .mobile-avatar { align-items: center; background: var(--brand-gold); border-radius: 50%; color: var(--brand-navy-dark); display: inline-flex; font-size: .82rem; font-weight: 800; height: 2.25rem; justify-content: center; width: 2.25rem; }
.user-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.user-copy strong { color: white; font-size: .83rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { color: rgb(255 255 255 / 50%); font-size: .7rem; }
.icon-button { background: transparent; border: 0; color: rgb(255 255 255 / 60%); padding: .35rem; }
.icon-button:hover { color: var(--brand-gold); }

.app-canvas { margin-left: var(--sidebar-width); min-height: 100vh; }
.content-container { margin: 0 auto; max-width: 100rem; padding: clamp(1.5rem, 3.4vw, 3.25rem); width: 100%; }
.mobile-header, .sidebar-toggle, .sidebar-scrim { display: none; }
.auth-canvas { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 2rem 1rem; }
.auth-canvas .content-container { padding: 0; }
.auth-panel { margin: 0 auto; max-width: 28rem; width: 100%; }
.login-card { overflow: hidden; }
.login-card .card-body { padding: clamp(1.5rem, 5vw, 2.25rem); }

.page-heading { align-items: flex-end; display: flex; gap: 1.5rem; justify-content: space-between; margin-bottom: 2rem; }
.page-heading h1 { color: var(--brand-navy); font-size: clamp(1.85rem, 3vw, 2.6rem); margin: .15rem 0 .4rem; }
.page-heading p:not(.eyebrow) { color: var(--text-muted); margin: 0; }
.eyebrow { color: #8a6a00; font-size: .69rem; font-weight: 800; letter-spacing: .14em; margin: 0; text-transform: uppercase; }

.metric-grid { display: grid; gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 1.25rem; }
.metric-card { align-items: center; background: var(--surface-raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); display: flex; gap: 1rem; min-height: 8.2rem; padding: 1.25rem; transition: transform .18s, box-shadow .18s; }
.metric-card:hover { box-shadow: 0 12px 32px rgb(15 31 74 / 9%); transform: translateY(-2px); }
.metric-card--danger { border-color: rgb(193 55 55 / 28%); }
.metric-card p { color: var(--text-muted); font-size: .78rem; font-weight: 650; margin: 0; }
.metric-card strong { color: var(--brand-navy); display: block; font-size: 2rem; line-height: 1.15; }
.metric-card small { color: #9099aa; font-size: .7rem; }
.metric-icon { align-items: center; border-radius: .8rem; display: flex; flex: 0 0 2.7rem; font-size: .67rem; font-weight: 800; height: 2.7rem; justify-content: center; }
.metric-icon--navy { background: var(--brand-navy-soft); color: var(--brand-navy); }
.metric-icon--blue { background: #e8f5ff; color: #23669a; }
.metric-icon--gold { background: var(--brand-gold-soft); color: #856400; }
.metric-icon--red { background: var(--danger-soft); color: var(--danger); }
.dashboard-grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 2fr) minmax(16rem, .75fr); }
.attention-card { background: linear-gradient(145deg, var(--brand-navy), var(--brand-navy-dark)); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); color: white; padding: 1.6rem; }
.attention-card .eyebrow { color: var(--brand-gold); }
.attention-card h2 { color: white; font-size: 1.25rem; margin: .4rem 0 1.5rem; }
.attention-card p:not(.eyebrow) { color: rgb(255 255 255 / 68%); font-size: .86rem; }
.attention-card a { color: var(--brand-gold); font-weight: 700; text-decoration: none; }
.attention-number { font-size: 4rem; font-weight: 800; letter-spacing: -.06em; line-height: 1; }

.card { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.card-header { background: var(--surface-raised); border-bottom-color: var(--border-subtle); color: var(--brand-navy); }
.table-responsive { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.table { margin-bottom: 0; }
.table > :not(caption) > * > * { border-bottom-color: var(--border-subtle); padding: .85rem 1rem; vertical-align: middle; }
.table thead th { background: #f8f9fc; color: var(--text-muted); font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #fafbfe; }
.table-pagination { align-items: center; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; padding: 1rem 0; }
.pagination-summary { color: var(--text-muted); font-size: .82rem; }
.pagination-summary strong { color: var(--text-strong); }
.page-size-form { align-items: center; display: flex; gap: .55rem; margin-left: auto; }
.page-size-form label { color: var(--text-muted); font-size: .78rem; white-space: nowrap; }
.page-size-form select { background-color: var(--surface-raised); border: 1px solid #ccd4e1; border-radius: var(--radius-sm); color: var(--text-strong); min-height: 2rem; padding: .25rem 1.8rem .25rem .55rem; }
.pagination .page-link { border-color: var(--border-subtle); color: var(--brand-navy); min-width: 2rem; text-align: center; }
.pagination .active > .page-link { background-color: var(--brand-navy); border-color: var(--brand-navy); color: white; }
.pagination .disabled > .page-link { color: #9ba4b5; }
.form-control, .form-select { border-color: #ccd4e1; border-radius: var(--radius-md); min-height: 2.7rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand-gold); box-shadow: 0 0 0 .2rem rgb(255 192 0 / 20%); }
.form-label { color: #465168; font-size: .79rem; font-weight: 700; }
.app-alert { border: 0; border-left: 4px solid currentColor; border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.badge { border-radius: 999px; font-weight: 700; padding: .42em .7em; }
.badge.bg-warning { background-color: var(--brand-gold) !important; color: var(--brand-navy-dark) !important; }
.mw-form { max-width: 42rem; }
.errorlist { color: var(--danger); font-size: .8rem; margin-top: .3rem; }
input, select, textarea { max-width: 100%; }
.pipeline-board { align-items: start; display: grid; gap: 1rem; grid-auto-columns: minmax(17rem, 1fr); grid-auto-flow: column; overflow-x: auto; padding-bottom: 1rem; }
.pipeline-column { max-height: 72vh; overflow-y: auto; }
.login-logo-frame { height: 7rem; margin: -.75rem auto .75rem; max-width: 14rem; overflow: hidden; width: 100%; }
.login-logo-frame img { display: block; height: 100%; object-fit: cover; object-position: center; width: 100%; }
.page-heading > :last-child { flex-shrink: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.source-payload { background: var(--surface-muted); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); max-height: 24rem; overflow: auto; padding: 1rem; white-space: pre-wrap; word-break: break-word; }
.card details pre { background: var(--surface-muted); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); max-height: 24rem; overflow: auto; padding: 1rem; white-space: pre-wrap; word-break: break-word; }
.section-heading { align-items: end; display: flex; gap: 1rem; justify-content: space-between; }
.course-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.course-card { background: var(--surface-raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); display: flex; flex-direction: column; min-height: 17rem; padding: 1.25rem; }
.course-card--inactive { opacity: .72; }
.course-card__top, .course-card__actions { align-items: center; display: flex; gap: .75rem; justify-content: space-between; }
.course-category { color: var(--text-muted); font-size: .75rem; margin-left: .5rem; }
.course-code { color: var(--brand-navy); font-size: .72rem; letter-spacing: .08em; }
.course-card h3 { font-size: 1.2rem; margin: 1rem 0 .45rem; }
.course-card h3 a { text-decoration: none; }
.course-card > p { color: var(--text-muted); font-size: .86rem; min-height: 2.6rem; }
.course-stats { border-bottom: 1px solid var(--border-subtle); border-top: 1px solid var(--border-subtle); display: grid; grid-template-columns: 1.35fr 1fr 1fr; margin: auto 0 1rem; padding: .8rem 0; }
.course-stats div + div { border-left: 1px solid var(--border-subtle); padding-left: .75rem; }
.course-stats dt { color: var(--text-muted); font-size: .66rem; font-weight: 700; text-transform: uppercase; }
.course-stats dd { color: var(--text-strong); font-size: .86rem; font-weight: 750; margin: .15rem 0 0; }
.course-card__actions > a:first-child { font-size: .84rem; font-weight: 700; }
.filter-bar { align-items: end; background: var(--surface-raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); display: flex; flex-wrap: wrap; gap: .75rem; padding: 1rem; }
.filter-bar > div { flex: 1 1 14rem; }
.filter-bar .form-label { margin-bottom: .3rem; }
.status-badge { background: var(--surface-muted); color: var(--text-strong); }
.status-open, .status-confirmed, .status-in_progress { background: #e6f6ef; color: #11633f; }
.status-planned { background: var(--brand-navy-soft); color: var(--brand-navy); }
.status-paused { background: var(--brand-gold-soft); color: #725600; }
.status-cancelled { background: var(--danger-soft); color: var(--danger); }
.course-detail-grid { align-items: start; display: grid; gap: 1.25rem; grid-template-columns: minmax(18rem, .7fr) minmax(0, 1.3fr); }
.detail-list { margin: .5rem 0 0; }
.detail-list div { align-items: baseline; border-top: 1px solid var(--border-subtle); display: flex; gap: 1rem; justify-content: space-between; padding: .7rem 0; }
.detail-list dt { color: var(--text-muted); font-size: .78rem; }
.detail-list dd { font-weight: 700; margin: 0; text-align: right; }
.intake-stack { display: grid; gap: .65rem; }
.intake-row { align-items: center; background: var(--surface-raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); display: flex; gap: 1rem; justify-content: space-between; padding: 1rem; text-decoration: none; }
.intake-row:hover { border-color: #b9c5e5; box-shadow: var(--shadow-card); }
.intake-row > div { display: flex; flex-direction: column; gap: .25rem; }
.intake-row > div:last-child { align-items: end; flex-shrink: 0; }
.intake-row span:not(.badge), .intake-row small { color: var(--text-muted); font-size: .78rem; }
.empty-panel { background: var(--surface-raised); border: 1px dashed #bdc6d6; border-radius: var(--radius-lg); color: var(--text-muted); grid-column: 1 / -1; padding: 2rem; text-align: center; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .course-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-sidebar { box-shadow: var(--shadow-float); transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar-toggle:checked ~ .app-sidebar { transform: translateX(0); }
  .sidebar-toggle:checked ~ .sidebar-scrim { background: rgb(5 15 42 / 50%); bottom: 0; display: block; left: 0; position: fixed; right: 0; top: 0; z-index: 1020; }
  .app-canvas { margin-left: 0; padding-top: 4rem; }
  .mobile-header { align-items: center; background: var(--brand-navy); color: white; display: flex; height: 4rem; justify-content: space-between; left: 0; padding: 0 1rem; position: fixed; right: 0; top: 0; z-index: 1010; }
  .mobile-menu { cursor: pointer; display: grid; gap: .25rem; padding: .4rem; }
  .mobile-menu span { background: white; border-radius: 2px; height: 2px; width: 1.25rem; }
  .content-container { padding: 1.35rem 1rem 2.5rem; }
}
@media (max-width: 580px) {
  .page-heading { align-items: stretch; flex-direction: column; gap: 1rem; }
  .page-heading > :last-child { flex-shrink: 1; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 6.8rem; }
  .table-pagination { align-items: stretch; }
  .pagination-summary { flex: 1 0 100%; }
  .page-size-form { margin-left: 0; }
  .page-actions { justify-content: flex-start; }
  .page-actions .btn { flex: 1 1 auto; text-align: center; }
  .communication-meta, .history-meta { display: block; float: none !important; margin-top: .35rem; }
  .content-container > .d-flex.justify-content-between { align-items: stretch; flex-direction: column; gap: 1rem; }
  .content-container > .d-flex.justify-content-between > div:last-child { display: flex; flex-wrap: wrap; gap: .5rem; }
  .content-container > .d-flex.justify-content-between > div:last-child .btn { flex: 1 1 auto; margin: 0 !important; }
  .card .float-end { display: block; float: none !important; margin-top: .35rem; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar > div { flex-basis: auto; width: 100%; }
  .intake-row { align-items: flex-start; flex-direction: column; }
  .intake-row > div:last-child { align-items: start; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
