:root {
    color-scheme: light;
    --navy: #111a32;
    --navy-soft: #1b2747;
    --ink: #17213a;
    --muted: #69738b;
    --line: #dde2eb;
    --surface: #ffffff;
    --canvas: #f5f6f9;
    --accent: #4d5ef7;
    --accent-dark: #3545db;
    --mint: #56d6ad;
    --coral: #ff806b;
    --gold: #f2bd62;
    --shadow: 0 18px 50px rgba(24, 35, 62, .09);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, Aptos, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a, button, input, textarea { font: inherit; }
a, button { -webkit-tap-highlight-color: transparent; }
svg { display: block; }

h1, h2, h3 {
    margin-top: 0;
    font-family: "Aptos Display", Inter, "Segoe UI", sans-serif;
    letter-spacing: -.04em;
}

h1 { margin-bottom: 12px; font-size: clamp(2.25rem, 4vw, 4rem); line-height: 1; }
h2 { margin-bottom: 0; font-size: clamp(1.55rem, 2vw, 2rem); }
p { line-height: 1.65; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 13px;
    color: var(--ink);
    text-decoration: none;
}

.brand > span:last-child { display: grid; gap: 1px; }
.brand strong { font-size: 1.1rem; letter-spacing: -.025em; }
.brand small { color: var(--muted); font-size: .67rem; letter-spacing: .025em; }

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 13px;
    background: var(--navy);
    box-shadow: 0 10px 22px rgba(17, 26, 50, .2);
}

.brand-mark svg { width: 29px; height: 29px; fill: white; }
.brand-mark .brand-spark { fill: var(--mint); }
.brand-inverse { color: white; }
.brand-inverse small { color: #96a3c4; }
.brand-inverse .brand-mark { background: rgba(255,255,255,.09); box-shadow: none; }

.public-header {
    position: relative;
    z-index: 2;
    height: 92px;
    padding: 0 clamp(24px, 6vw, 90px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(221, 226, 235, .75);
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(18px);
}

.secure-access {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 600;
}

.secure-access i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #25b682;
    box-shadow: 0 0 0 5px rgba(37,182,130,.1);
}

.public-layout {
    background:
        radial-gradient(circle at 22% 20%, rgba(77,94,247,.12), transparent 29rem),
        radial-gradient(circle at 89% 78%, rgba(86,214,173,.12), transparent 27rem),
        #f6f7fa;
}

.public-layout .page-shell { min-height: calc(100vh - 92px); }

.login-hero {
    min-height: calc(100vh - 154px);
    padding: clamp(52px, 8vh, 100px) clamp(24px, 7vw, 110px) 46px;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(380px, 520px);
    align-items: center;
    gap: clamp(50px, 9vw, 150px);
}

.login-story {
    position: relative;
    max-width: 720px;
    padding: clamp(38px, 6vw, 84px);
    overflow: hidden;
    border-radius: 36px 9px 36px 9px;
    color: white;
    background:
        linear-gradient(145deg, rgba(255,255,255,.06), transparent 42%),
        var(--navy);
    box-shadow: 0 35px 90px rgba(17, 26, 50, .22);
}

.login-story::before,
.login-story::after {
    position: absolute;
    content: "";
    border-radius: 50%;
    pointer-events: none;
}

.login-story::before {
    width: 330px;
    height: 330px;
    right: -150px;
    top: -155px;
    border: 60px solid rgba(86,214,173,.17);
}

.login-story::after {
    width: 180px;
    height: 180px;
    left: -90px;
    bottom: -90px;
    background: rgba(77,94,247,.36);
    filter: blur(2px);
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.eyebrow-light { color: var(--mint); }

.login-story h1 {
    position: relative;
    z-index: 1;
    margin: 0 0 25px;
    font-size: clamp(3rem, 6vw, 6.2rem);
    line-height: .92;
}

.login-story h1 span { color: #96a3ff; }
.login-story .lead { max-width: 560px; color: #b8c1d8; font-size: clamp(1rem, 1.4vw, 1.15rem); }

.lead { margin: 0; color: var(--muted); font-size: 1rem; }

.login-features {
    position: relative;
    z-index: 1;
    margin-top: clamp(45px, 7vh, 80px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.login-features > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.feature-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 12px;
    background: rgba(255,255,255,.07);
}

.feature-icon svg { width: 21px; fill: var(--mint); }
.login-features strong, .login-features small { display: block; }
.login-features strong { font-size: .82rem; }
.login-features small { margin-top: 3px; color: #96a3c4; font-size: .7rem; }

.login-card { align-self: center; }

.login-card-top {
    margin-bottom: clamp(55px, 9vh, 100px);
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.pulse-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--mint);
    box-shadow: 0 0 0 6px rgba(86,214,173,.15);
}

.login-card h2 { margin: 0 0 14px; font-size: clamp(2rem, 3.5vw, 3.2rem); }
.login-card > div > p:last-child { margin: 0; color: var(--muted); }
.login-card > div > p strong { color: var(--ink); }

.microsoft-button {
    width: 100%;
    min-height: 60px;
    margin-top: 35px;
    padding: 15px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid #ced4df;
    border-radius: 14px;
    background: white;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 8px 25px rgba(24,35,62,.06);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.microsoft-button > svg { width: 20px; margin-left: auto; fill: var(--accent); }
.microsoft-button:hover { transform: translateY(-2px); border-color: #aeb7c7; box-shadow: var(--shadow); }

.microsoft-logo { width: 21px; height: 21px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; flex: 0 0 auto; }
.microsoft-logo i:nth-child(1) { background: #f25022; }
.microsoft-logo i:nth-child(2) { background: #7fba00; }
.microsoft-logo i:nth-child(3) { background: #00a4ef; }
.microsoft-logo i:nth-child(4) { background: #ffb900; }

.privacy-note {
    margin: 18px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: #828b9d;
    font-size: .72rem;
}

.privacy-note svg { width: 15px; fill: #828b9d; }

.public-footer {
    padding: 0 clamp(24px, 7vw, 110px) 26px;
    display: flex;
    justify-content: space-between;
    color: #8a92a4;
    font-size: .7rem;
}

.sidebar {
    position: fixed;
    z-index: 10;
    inset: 0 auto 0 0;
    width: 260px;
    padding: 28px 20px 20px;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 10% 88%, rgba(77,94,247,.25), transparent 15rem),
        var(--navy);
    color: white;
}

.sidebar .brand { padding: 0 9px; }
.side-nav { margin-top: 65px; display: grid; gap: 5px; }
.nav-label { margin: 25px 13px 8px; color: #687596; font-size: .61rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.nav-label:first-child { margin-top: 0; }

.side-nav a {
    padding: 12px 13px;
    display: flex;
    align-items: center;
    gap: 13px;
    border-radius: 11px;
    color: #aeb8d1;
    font-size: .86rem;
    font-weight: 600;
    text-decoration: none;
    transition: color .15s ease, background .15s ease;
}

.side-nav a svg { width: 19px; fill: currentColor; opacity: .8; }
.side-nav a:hover { color: white; background: rgba(255,255,255,.05); }
.side-nav a.active { color: white; background: linear-gradient(110deg, rgba(77,94,247,.95), rgba(77,94,247,.7)); box-shadow: 0 10px 24px rgba(0,0,0,.15); }

.sidebar-user {
    margin-top: auto;
    padding: 14px 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid rgba(255,255,255,.09);
}

.avatar {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 16px;
    color: white;
    background: linear-gradient(145deg, var(--accent), #7f8bff);
    font-weight: 800;
    box-shadow: 0 9px 20px rgba(77,94,247,.22);
}

.avatar-small { width: 37px; height: 37px; border-radius: 10px; font-size: .8rem; box-shadow: none; }
.user-summary { min-width: 0; flex: 1; }
.user-summary strong, .user-summary small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-summary strong { font-size: .75rem; }
.user-summary small { margin-top: 3px; color: #7f8baa; font-size: .63rem; }
.sidebar-user form { margin: 0; }

.logout-button {
    width: 32px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #7f8baa;
    cursor: pointer;
}

.logout-button:hover { color: white; background: rgba(255,255,255,.07); }
.logout-button svg { width: 17px; fill: currentColor; }

.mobile-header { display: none; }

.app-layout .page-shell {
    width: auto;
    min-height: 100vh;
    margin-left: 260px;
    padding: clamp(42px, 6vw, 82px) clamp(28px, 6vw, 90px);
}

.flash-stack { width: min(1180px, 100%); margin: 0 auto; }
.alert { margin-bottom: 24px; padding: 14px 18px; border: 1px solid #efb7b7; border-radius: 11px; background: #fff1f1; color: #8d2424; }
.alert-success { border-color: #9ed4b1; background: #effaf3; color: #176536; }

.workspace-header,
.applications,
.profile-strip,
.admin-tabs,
.admin-heading,
.table-card,
.form-card,
.danger-zone {
    width: min(1180px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
}

.workspace-header .lead { font-size: 1.05rem; }
.connection-status { padding: 13px 17px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.connection-status strong, .connection-status small { display: block; white-space: nowrap; }
.connection-status strong { font-size: .75rem; }
.connection-status small { margin-top: 2px; color: var(--muted); font-size: .64rem; }
.status-orb { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: #e8f9f3; }
.status-orb i { width: 8px; height: 8px; border-radius: 50%; background: #26b782; box-shadow: 0 0 0 4px rgba(38,183,130,.13); }

.applications { margin-top: clamp(58px, 8vh, 90px); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.section-heading h2 { display: flex; align-items: center; gap: 10px; }
.count-badge { padding: 4px 8px; border-radius: 8px; color: var(--accent); background: #e9ebff; font: 700 .68rem Inter, sans-serif; letter-spacing: 0; }

.application-grid { margin-top: 25px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.application-card {
    min-height: 230px;
    padding: 23px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(24,35,62,.025);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.application-card:hover { transform: translateY(-4px); border-color: #cbd1df; box-shadow: var(--shadow); }
.application-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px; background: #e9ebff; font-size: 1.45rem; }
.application-card-1 .application-icon { background: #e4f8f1; }
.application-card-2 .application-icon { background: #fff0ec; }
.application-card-3 .application-icon { background: #fff6e5; }
.application-copy { margin-top: 26px; }
.application-copy strong, .application-copy small { display: block; }
.application-copy strong { font-size: 1.08rem; letter-spacing: -.02em; }
.application-copy small { margin-top: 9px; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.application-footer { margin-top: auto; padding-top: 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.application-footer em { color: #929bad; font-size: .68rem; font-style: normal; }
.application-arrow { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; background: var(--canvas); color: var(--ink); }
.application-arrow svg { width: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }
.application-card:hover .application-arrow { color: white; background: var(--accent); }

.empty-state { margin-top: 25px; padding: 50px; display: grid; justify-items: center; border: 1px dashed #bdc5d4; border-radius: 20px; color: var(--muted); text-align: center; }
.empty-state strong { margin-top: 14px; color: var(--ink); }
.empty-state p { margin: 6px 0 0; }
.empty-icon { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 13px; color: var(--accent); background: #e9ebff; font-size: 1.5rem; }

.profile-strip {
    margin-top: 65px;
    padding: 24px;
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr) minmax(340px, 1.5fr);
    align-items: center;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: white;
}

.profile-intro strong, .profile-intro small { display: block; }
.profile-intro strong { font-size: .9rem; }
.profile-intro small { margin-top: 4px; color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
.profile-strip .eyebrow { margin-bottom: 5px; font-size: .59rem; }
.profile-strip dl { margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); }
.profile-strip dl div { padding: 3px 20px; border-left: 1px solid var(--line); }
.profile-strip dt { color: var(--muted); font-size: .67rem; }
.profile-strip dd { margin: 6px 0 0; font-size: .76rem; font-weight: 700; }

.button {
    min-height: 42px;
    padding: 10px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--accent);
    border-radius: 10px;
    background: var(--accent);
    color: white;
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button:hover { background: var(--accent-dark); }
.button-secondary { border-color: var(--line); background: white; color: var(--ink); }
.button-secondary:hover { border-color: #c4cada; background: #fafbfc; }
.button-danger { border-color: #c73535; background: #c73535; }

.admin-tabs { margin-bottom: 50px; display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.admin-tabs a { padding: 12px 16px; border-bottom: 2px solid transparent; color: var(--muted); font-size: .82rem; font-weight: 700; text-decoration: none; }
.admin-tabs a.active { border-color: var(--accent); color: var(--accent); }
.admin-heading { margin-bottom: 32px; }
.admin-heading h1 { margin-bottom: 10px; font-size: clamp(2rem, 4vw, 3.3rem); }

.table-card { overflow-x: auto; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: 0 5px 18px rgba(24,35,62,.025); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 14px 18px; background: #fafbfc; color: var(--muted); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; }
td { padding: 18px; border-top: 1px solid var(--line); color: #46516a; font-size: .82rem; }
.table-identity { min-width: 230px; display: flex; align-items: center; gap: 13px; }
.table-identity strong, .table-identity small { display: block; }
.table-identity strong { color: var(--ink); }
.table-identity small { max-width: 440px; margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.mini-icon, .mini-avatar { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; background: #e9ebff; }
.mini-avatar { background: var(--navy); color: white; font-weight: 700; }
.status { padding: 5px 9px; border-radius: 999px; font-size: .68rem; font-weight: 700; white-space: nowrap; }
.status-active { background: #e8f8f1; color: #14764f; }
.status-inactive { background: #f1f2f5; color: #697386; }
.table-actions { text-align: right; }
.table-actions a { color: var(--accent); font-weight: 700; text-decoration: none; }
.empty-cell { padding: 38px; color: var(--muted); text-align: center; }

.form-card { max-width: 830px; padding: clamp(25px, 4vw, 42px); border: 1px solid var(--line); border-radius: 18px; background: white; }
.form-grid { display: grid; grid-template-columns: 1fr 160px; gap: 8px 22px; }
.form-wide { grid-column: 1 / -1; }
.form-card form > div > div, .form-grid > div { margin-bottom: 20px; }
.form-card label { margin-bottom: 8px; display: block; color: var(--ink); font-size: .8rem; font-weight: 700; }
.form-card input[type="text"], .form-card input[type="url"], .form-card textarea {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #cbd2de;
    border-radius: 9px;
    background: white;
    color: var(--ink);
}
.form-card input:focus, .form-card textarea:focus { outline: 3px solid rgba(77,94,247,.13); border-color: var(--accent); }
.form-card input[type="checkbox"] { width: 18px; height: 18px; margin-right: 8px; accent-color: var(--accent); vertical-align: -4px; }
.form-card ul { padding-left: 20px; color: #a32b2b; }
.form-card .help-text, .form-card small { color: var(--muted); }
.form-actions { margin-top: 28px; display: flex; justify-content: flex-end; gap: 10px; }
.form-note { padding: 15px; border-radius: 9px; background: #f4f6fa; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.danger-zone { max-width: 830px; margin-top: 30px; padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid #efc1c1; border-radius: 14px; background: #fffafa; }
.danger-zone p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 3px solid rgba(77,94,247,.35); outline-offset: 3px; }

@media (max-width: 1100px) {
    .login-hero { grid-template-columns: minmax(0, 1fr) minmax(340px, 430px); gap: 45px; }
    .login-story { padding: 50px 42px; }
    .application-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-strip { grid-template-columns: auto 1fr; }
    .profile-strip dl { grid-column: 1 / -1; padding-top: 18px; border-top: 1px solid var(--line); }
    .profile-strip dl div:first-child { border-left: 0; }
}

@media (max-width: 820px) {
    .public-header { height: 80px; }
    .secure-access { display: none; }
    .login-hero { min-height: auto; grid-template-columns: 1fr; padding-top: 30px; }
    .login-story { min-height: 400px; }
    .login-card { padding: 12px 5vw 35px; }
    .login-card-top { margin-bottom: 45px; }
    .public-footer { padding-top: 20px; }

    .sidebar { display: none; }
    .mobile-header {
        padding: 13px 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 15px;
        background: var(--navy);
    }
    .mobile-header .brand-mark { width: 36px; height: 36px; }
    .mobile-header nav { display: flex; gap: 14px; }
    .mobile-header nav a { color: #b9c2d9; font-size: .7rem; font-weight: 700; text-decoration: none; }
    .app-layout .page-shell { margin-left: 0; padding: 45px 24px 60px; }
}

@media (max-width: 620px) {
    .brand small { display: none; }
    .login-hero { padding-left: 16px; padding-right: 16px; }
    .login-story { min-height: 0; padding: 44px 28px; border-radius: 25px 7px 25px 7px; }
    .login-story h1 { font-size: clamp(2.8rem, 15vw, 4.4rem); }
    .login-features { grid-template-columns: 1fr; margin-top: 42px; }
    .public-footer { align-items: flex-start; flex-direction: column; gap: 5px; }

    .mobile-header { align-items: flex-start; }
    .mobile-header nav { align-items: flex-end; flex-direction: column; gap: 6px; }
    .app-layout .page-shell { padding: 38px 17px 50px; }
    .workspace-header { align-items: flex-start; flex-direction: column; }
    .connection-status { width: 100%; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .application-grid { grid-template-columns: 1fr; }
    .application-card { min-height: 210px; }
    .profile-strip { grid-template-columns: auto 1fr; padding: 20px; }
    .profile-strip dl { grid-template-columns: 1fr; gap: 15px; }
    .profile-strip dl div { padding: 0; border-left: 0; }
    .profile-strip dl div + div { padding-top: 15px; border-top: 1px solid var(--line); }
    .form-grid { grid-template-columns: 1fr; }
    .form-wide { grid-column: auto; }
    .danger-zone { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
