: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; }
}

/* V04 homepage, multi-role, and work-order additions */
.single-login-shell { width: min(560px, calc(100% - 32px)); justify-content: center; }
.login-panel-simple { width: 100%; padding: clamp(22px, 5vw, 40px); }
.compact-brand { margin-bottom: 18px; }
.login-center-copy { margin: 22px 0 24px; }
.login-center-copy h2 { margin: 16px 0 8px; font-size: clamp(42px, 9vw, 72px); line-height: .9; letter-spacing: -.08em; }
.login-center-copy p, .muted-copy { color: var(--muted); line-height: 1.5; }
.login-form-simple { margin-top: 18px; }
.signup-strip { margin-top: 18px; padding-top: 18px; border-top: 1px solid #dbe6f2; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.signup-strip span { color: var(--muted); font-weight: 800; }
.form-bottom-actions { margin-top: 18px; align-items: center; }
small { color: var(--muted); font-weight: 700; }
@media (max-width: 560px) {
    .single-login-shell { width: min(100% - 18px, 560px); }
    .login-panel-simple { border-radius: 22px; padding: 18px; }
    .signup-strip .secondary-btn { width: 100%; }
}

/* V06 admin usability and separate-login cleanup */
.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 900;
    color: var(--blue-dark);
    background: rgba(238,245,255,.82);
    border: 1px solid rgba(207,226,251,.9);
    text-decoration: none;
}
.nav-link:hover { text-decoration: none; background: #fff; }
.table-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.table-title-row h2 { margin-bottom: 0; }
.inline-form {
    display: grid;
    gap: 8px;
    min-width: 210px;
}
.inline-form select {
    min-height: 40px;
    padding: 9px 10px;
    border-radius: 12px;
}
.small-btn { min-height: 38px; padding: 8px 12px; }
.tiny-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 900;
}
.danger-panel {
    border-color: rgba(190,32,32,.2);
    background: rgba(255,255,255,.94);
}
.danger-btn {
    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;
    color: #fff;
    background: linear-gradient(135deg, #b91c1c, #ef4444);
    box-shadow: 0 12px 28px rgba(185,28,28,.22);
}
@media (max-width: 760px) {
    .app-topbar { position: relative; gap: 12px; }
    .app-nav { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .app-nav .ghost-link, .app-nav .user-pill { grid-column: 1 / -1; }
    .nav-link { border-radius: 14px; }
    .page-wrap, .page-wrap.wide { width: min(100% - 18px, 1320px); margin-top: 16px; }
    .responsive-table table { min-width: 760px; }
}

/* V07 admin cleanup and login editing */
.admin-clean-grid .dash-card strong { font-size: 22px; }
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 900;
    color: var(--ink);
}
.checkbox-row input[type="checkbox"] {
    width: 24px;
    height: 24px;
    accent-color: var(--blue);
}
input[readonly] {
    background: rgba(238, 245, 251, .75);
    color: var(--muted);
}

/* V10 separate admin and dealer/technician login pages */
.login-small-link {
    margin-top: 16px;
    text-align: center;
    font-weight: 900;
}
.login-small-link a {
    color: var(--blue-dark);
}
.admin-login-panel .mini-tag {
    background: rgba(255, 181, 71, .18);
    color: #995a04;
    border-color: rgba(255, 181, 71, .26);
}


/* V15 dashboard polish and mobile alignment */
.app-brand strong { font-size: 18px; letter-spacing: -.035em; }
.app-brand small { display: block; margin-top: 2px; }
.page-head h1, .table-card h2 { word-break: normal; overflow-wrap: anywhere; }
.dash-grid { align-items: stretch; }
.dash-card { min-height: 164px; }
.table-card { overflow: hidden; }
.wrap-email { overflow-wrap: anywhere; word-break: break-word; }

@media (max-width: 760px) {
    .page-wrap, .page-wrap.wide { width: min(100% - 22px, 1320px); margin-top: 18px; }
    .dash-grid { gap: 14px; }
    .dash-card, .form-panel, .table-card { border-radius: 22px; }
    .dash-card { min-height: 0; padding: 20px; }
    .table-card { padding: 20px; }
    .responsive-table { overflow: visible; }
    .responsive-table table { min-width: 0; width: 100%; }
    .responsive-table thead { display: none; }
    .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
    .responsive-table tr {
        border: 1px solid #dfe8f2;
        border-radius: 16px;
        padding: 12px;
        margin: 0 0 12px;
        background: rgba(255,255,255,.62);
    }
    .responsive-table td {
        border-bottom: 1px solid #e6edf5;
        padding: 10px 0;
        color: #24344b;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    .responsive-table td:last-child { border-bottom: 0; padding-bottom: 0; }
    .responsive-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--blue-dark);
        font-size: 11px;
        font-weight: 900;
        letter-spacing: .09em;
        text-transform: uppercase;
    }
    .responsive-table td[colspan]::before { display: none; }
    .responsive-table .secondary-btn { width: 100%; }
    .app-topbar { padding: 14px 16px; }
    .app-brand { width: 100%; }
    .app-brand strong { font-size: 19px; }
    .brand-box { width: 44px; height: 44px; border-radius: 13px; }
}

@media (max-width: 420px) {
    .page-wrap, .page-wrap.wide { width: min(100% - 16px, 1320px); }
    .page-head, .table-card { padding: 18px; }
    .page-head.compact h1 { font-size: clamp(30px, 11vw, 46px); }
}

/* V16 New Account Form cleanup */
textarea {
    width: 100%;
    border: 1px solid #ced8e5;
    background: rgba(255,255,255,.94);
    border-radius: 14px;
    padding: 13px 14px;
    color: var(--ink);
    outline: none;
    resize: vertical;
    min-height: 110px;
    font: inherit;
}
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(23,100,201,.12); }
.new-account-form { display: grid; gap: 18px; }
.form-section-primary { border-color: rgba(68, 143, 236, .35); }
.editable-table table input, .editable-table table select { min-width: 170px; }
.row-number { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 12px; background: #eef5ff; color: var(--blue-dark); font-weight: 900; }
.flash-success { background: #e9f9ef; color: #166534; border-color: #b7ebc8; }
@media (max-width: 760px) {
    .editable-table table input, .editable-table table select { min-width: 0; }
    .editable-table .row-number { width: 100%; justify-content: flex-start; padding-left: 12px; }
    .form-bottom-actions .primary-btn, .form-bottom-actions .secondary-btn { width: 100%; }
}
