:root {
    --navy: #07182f;
    --ink: #0f1b2d;
    --muted: #6b7a90;
    --line: rgba(166, 185, 212, .36);
    --panel: rgba(255, 255, 255, .88);
    --panel-solid: #ffffff;
    --blue: #1764c9;
    --blue-dark: #0f438c;
    --cyan: #70b9ff;
    --gold: #ffb547;
    --green: #0f7a45;
    --red: #b42318;
    --shadow: 0 24px 80px rgba(3, 21, 48, .22);
    --soft-shadow: 0 16px 40px rgba(3, 21, 48, .10);
    --radius: 26px;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #eef5fb;
}
body.portal-bg {
    background-image:
        linear-gradient(135deg, rgba(2, 13, 30, .80), rgba(13, 65, 124, .62) 43%, rgba(235, 244, 252, .92)),
        url('/assets/img/csm-static-bg.svg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, button { font: inherit; }
.brand-box {
    width: 48px; height: 48px; border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1664c8, #74baff);
    color: #fff; font-weight: 900; letter-spacing: -.04em;
    box-shadow: 0 12px 28px rgba(23, 100, 201, .30);
}
.brand-box-large { width: 62px; height: 62px; border-radius: 18px; }
.login-shell {
    width: min(1180px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 32px 0;
}
.login-shell.narrow { width: min(640px, calc(100% - 32px)); }
.glass-card {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,.68);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.login-hero { width: 100%; padding: clamp(22px, 4vw, 42px); }
.login-brand-row { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.login-brand-row h1 { margin: 0; font-size: clamp(24px, 3vw, 38px); letter-spacing: -.04em; }
.login-brand-row p { margin: 4px 0 0; color: var(--muted); font-weight: 700; }
.split-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(330px, .75fr); gap: 28px; align-items: stretch; }
.intro-panel {
    min-height: 540px;
    border-radius: 24px;
    padding: clamp(24px, 4vw, 42px);
    color: #fff;
    background: linear-gradient(145deg, rgba(6, 24, 50, .88), rgba(16, 76, 142, .66));
    overflow: hidden;
    position: relative;
}
.intro-panel:after {
    content: "";
    position: absolute;
    right: -110px; bottom: -110px;
    width: 320px; height: 320px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(112,185,255,.35), transparent 68%);
}
.intro-panel h2 { font-size: clamp(36px, 6vw, 68px); line-height: .94; letter-spacing: -.07em; margin: 18px 0 20px; max-width: 780px; }
.intro-panel p { font-size: clamp(17px, 2.2vw, 24px); line-height: 1.5; color: rgba(255,255,255,.78); max-width: 760px; margin: 0; }
.mini-tag, .warning-banner, .status-badge {
    display: inline-flex; align-items: center; gap: 8px;
    width: fit-content;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.mini-tag { background: rgba(112,185,255,.17); color: #bfe0ff; border: 1px solid rgba(191,224,255,.30); }
.warning-banner { background: rgba(255, 181, 71, .18); color: #995a04; border: 1px solid rgba(255,181,71,.26); }
.status-badge { background: rgba(15,122,69,.12); color: var(--green); border: 1px solid rgba(15,122,69,.20); }
.feature-stack { display: grid; gap: 14px; margin-top: 34px; position: relative; z-index: 1; }
.feature-stack div {
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 18px;
    padding: 18px;
}
.feature-stack strong { display: block; font-size: 17px; }
.feature-stack span { display: block; color: rgba(255,255,255,.72); margin-top: 6px; line-height: 1.35; }
.login-card {
    border-radius: 24px;
    background: rgba(255,255,255,.95);
    border: 1px solid rgba(255,255,255,.72);
    padding: clamp(22px, 4vw, 32px);
    box-shadow: var(--soft-shadow);
}
.login-card h2, .setup-card h1 { margin: 22px 0 8px; font-size: clamp(30px, 5vw, 46px); letter-spacing: -.06em; }
.login-card p, .setup-card p { color: var(--muted); line-height: 1.55; margin-bottom: 22px; }
.form-stack { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full-row { grid-column: 1 / -1; }
label { display: grid; gap: 8px; font-weight: 800; color: #26364c; }
input, select {
    width: 100%;
    border: 1px solid #ced8e5;
    background: rgba(255,255,255,.94);
    border-radius: 14px;
    padding: 13px 14px;
    color: var(--ink);
    outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(23,100,201,.12); }
input[readonly], input:disabled { background: #f3f7fb; color: #526178; }
.primary-btn, .secondary-btn, .ghost-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 46px;
    padding: 12px 18px;
    border-radius: 14px;
    font-weight: 900;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}
.primary-btn { background: linear-gradient(135deg, var(--blue), #4a96ed); color: #fff; box-shadow: 0 12px 28px rgba(23,100,201,.24); }
.primary-btn:hover { text-decoration: none; filter: brightness(1.02); }
.secondary-btn { background: #eef5ff; color: var(--blue-dark); border: 1px solid #cfe2fb; }
.ghost-link { background: rgba(255,255,255,.68); color: var(--blue-dark); border: 1px solid rgba(255,255,255,.7); }
.full { width: 100%; }
.app-topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 18px;
    padding: 16px clamp(16px, 4vw, 44px);
    background: rgba(255,255,255,.86);
    border-bottom: 1px solid rgba(166,185,212,.35);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.app-brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.app-brand strong { display: block; font-size: 16px; }
.app-brand small { color: var(--muted); font-weight: 800; }
.app-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user-pill { background: #eef5ff; color: var(--blue-dark); border: 1px solid #d6e6fb; padding: 10px 12px; border-radius: 999px; font-weight: 800; font-size: 13px; }
.page-wrap { width: min(1180px, calc(100% - 32px)); margin: 34px auto 60px; }
.page-wrap.wide { width: min(1320px, calc(100% - 32px)); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: clamp(22px, 4vw, 34px); margin-bottom: 22px; }
.page-head.compact h1 { margin: 10px 0 8px; font-size: clamp(34px, 5vw, 60px); line-height: .95; letter-spacing: -.07em; }
.page-head p { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.45; max-width: 760px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card, .dash-card, .form-panel, .table-card {
    background: rgba(255,255,255,.90);
    border: 1px solid rgba(255,255,255,.68);
    border-radius: 22px;
    box-shadow: var(--soft-shadow);
}
.stat-card { padding: 20px; }
.stat-card strong { display: block; font-size: 34px; letter-spacing: -.05em; }
.stat-card span { color: var(--muted); font-weight: 800; }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dash-card { padding: 22px; color: var(--ink); min-height: 170px; text-decoration: none; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; transition: transform .16s ease, box-shadow .16s ease; }
.dash-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.dash-card strong { display: block; font-size: 24px; letter-spacing: -.04em; }
.dash-card span:not(.mini-tag) { color: var(--muted); line-height: 1.45; margin-top: 10px; }
.form-panel, .table-card { padding: clamp(20px, 3vw, 30px); margin-bottom: 22px; }
.form-panel h2, .table-card h2 { margin: 0 0 18px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.05em; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.flash { width: min(980px, calc(100% - 32px)); margin: 18px auto; padding: 14px 18px; border-radius: 16px; font-weight: 800; box-shadow: var(--soft-shadow); }
.flash.inline { width: 100%; margin: 0 0 16px; box-shadow: none; }
.flash-success { background: #e9f8ef; color: #075c31; border: 1px solid #b7e6ca; }
.flash-error { background: #fff0ee; color: var(--red); border: 1px solid #fac5bf; }
.flash-warning { background: #fff6e8; color: #995a04; border: 1px solid #f7d49b; }
.flash-info { background: #eef5ff; color: var(--blue-dark); border: 1px solid #d0e4ff; }
.responsive-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid #e3ebf3; vertical-align: middle; }
th { color: var(--blue-dark); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
td { color: #26364c; }
table input { min-width: 150px; padding: 10px 11px; border-radius: 12px; }
.info-strip { margin-top: 16px; border-radius: 16px; padding: 14px; background: #eef5ff; color: var(--blue-dark); font-weight: 800; border: 1px solid #d0e4ff; }
.setup-card { padding: clamp(22px, 4vw, 38px); width: 100%; }
.setup-form { margin-top: 22px; }
@media (max-width: 900px) {
    .split-grid, .stats-grid, .dash-grid, .form-grid { grid-template-columns: 1fr; }
    .intro-panel { min-height: auto; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .app-topbar { align-items: flex-start; flex-direction: column; }
    .app-nav { justify-content: flex-start; }
}
@media (max-width: 560px) {
    .login-shell { width: min(100% - 18px, 1180px); padding: 12px 0; align-items: flex-start; }
    .login-hero, .setup-card { border-radius: 22px; padding: 16px; }
    .intro-panel { padding: 20px; border-radius: 20px; }
    .login-card { padding: 18px; }
    .brand-box-large { width: 54px; height: 54px; }
    .app-brand small { display: none; }
    .user-pill { width: 100%; border-radius: 14px; }
}
