html { color-scheme: dark; }
* { box-sizing: border-box; }
:root {
    --sidebar-width: 272px;
    --sidebar-collapsed-width: 84px;
    --surface-0: #08111f;
    --surface-1: #0b1627;
    --surface-2: #0d192b;
    --line: #203149;
    --line-soft: #233650;
    --text: #e8eef6;
    --muted: #8fa5bd;
    --accent: #55a7ff;
}
body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--surface-0);
    color: var(--text);
}
.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.topbar { border-bottom: 1px solid var(--line); background: var(--surface-1); }
.topbar-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.subtitle { margin-left: 12px; color: var(--muted); font-size: 13px; }
.environment { color: #71a7df; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.content { padding: 40px 0 56px; }
.hero { max-width: 780px; margin-bottom: 32px; }
.eyebrow { color: var(--accent); font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
h1 { margin: 8px 0 12px; font-size: clamp(30px, 5vw, 50px); line-height: 1.05; }
h2 { font-size: 20px; }
.lead, .muted { color: #9eb0c3; }
.status-card, .architecture-note {
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    padding: 24px;
    background: var(--surface-2);
    margin-bottom: 24px;
}
.status-card.success { border-color: #1d634d; }
.status-card.error { border-color: #753c42; }
.status-heading { display: flex; align-items: center; gap: 12px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #55d69b; box-shadow: 0 0 18px #55d69b; }
.error .status-dot { background: #ff7582; box-shadow: 0 0 18px #ff7582; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 22px 0 0; }
.status-grid > div { padding: 14px; border-radius: 10px; background: #101f34; }
dt { color: #7f94aa; font-size: 12px; margin-bottom: 6px; }
dd { margin: 0; font-weight: 600; }
li { margin: 8px 0; color: #b9c8d8; }
.user-area { display: flex; align-items: center; gap: 14px; }
.user-area form { margin: 0; }
.link-button, .primary-link {
    border: 0;
    background: transparent;
    color: #79b7f3;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
    padding: 0;
}
.link-button:hover, .primary-link:hover { color: #b8dcff; text-decoration: underline; }
.login-shell { min-height: calc(100vh - 190px); display: grid; place-items: center; }
.login-card {
    width: min(460px, 100%);
    padding: 32px;
    border: 1px solid var(--line-soft);
    border-radius: 18px;
    background: var(--surface-2);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}
.login-card h1 { font-size: 34px; }
.login-form { display: grid; gap: 9px; margin-top: 24px; }
.login-form label { color: #c6d4e3; font-size: 13px; font-weight: 650; margin-top: 7px; }
.form-control {
    width: 100%;
    border: 1px solid #314966;
    border-radius: 10px;
    background: #081421;
    color: #eef6ff;
    padding: 12px 13px;
    outline: none;
    font: inherit;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(85, 167, 255, .12); }
.primary-button {
    margin-top: 12px;
    border: 1px solid #4d9be9;
    border-radius: 10px;
    background: #1672ce;
    color: white;
    padding: 12px 16px;
    font-weight: 700;
    cursor: pointer;
}
.primary-button:hover { background: #2081df; }
.validation-summary, .field-validation { color: #ff9aa5; font-size: 13px; }
.validation-summary:empty, .field-validation:empty { display: none; }
.security-note {
    margin-top: 24px;
    border-top: 1px solid #22334a;
    padding-top: 16px;
    color: #8097af;
    font-size: 12px;
    line-height: 1.55;
}

/* Desktop application shell */
.app-frame { min-height: 100vh; display: flex; }
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: #0a1525;
    border-right: 1px solid var(--line);
    z-index: 1030;
    transition: width .2s ease;
}
.sidebar-brand { min-height: 72px; padding: 12px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.brand-link { min-width: 0; flex: 1; display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; overflow: hidden; }
.brand-mark { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 12px; background: #1672ce; color: #fff; font-weight: 800; font-size: 20px; }
.brand-copy { min-width: 0; display: flex; flex-direction: column; white-space: nowrap; }
.brand-copy strong { letter-spacing: .08em; }
.brand-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.sidebar-toggle { width: 32px; height: 32px; flex: 0 0 32px; border: 1px solid #29405c; border-radius: 9px; background: #101e31; color: #bcd0e3; font-size: 24px; line-height: 1; cursor: pointer; }
.sidebar-toggle:hover { border-color: #42658c; color: #fff; }
.sidebar-nav { flex: 1; min-height: 0; padding: 14px 10px 18px; overflow-y: auto; overflow-x: hidden; }
.nav-group + .nav-group { margin-top: 16px; }
.nav-group-title { padding: 0 10px 7px; color: #647e99; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; white-space: nowrap; }
.side-link {
    width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 8px 10px;
    border: 0; border-radius: 10px; background: transparent; color: #b9c8d8; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.side-link:hover, .side-link.is-active { background: #13243a; color: #fff; }
.side-link.is-active { box-shadow: inset 3px 0 0 var(--accent); }
.nav-icon { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border-radius: 8px; background: #101f34; color: #82bfff; font-size: 14px; font-weight: 800; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--line); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; overflow: hidden; }
.user-avatar { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 50%; background: #193654; color: #cfe7ff; font-weight: 800; }
.user-copy { display: flex; flex-direction: column; min-width: 0; white-space: nowrap; }
.user-copy strong { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.user-copy small { color: var(--muted); font-size: 10px; }
.side-link.compact { min-height: 38px; font-size: 13px; }
.side-link.compact .nav-icon { width: 28px; height: 28px; flex-basis: 28px; }
.app-main { min-width: 0; width: calc(100% - var(--sidebar-width)); margin-left: var(--sidebar-width); transition: width .2s ease, margin-left .2s ease; }
.app-topbar { height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(11,22,39,.92); position: sticky; top: 0; z-index: 1020; backdrop-filter: blur(14px); }
.topbar-page-title { color: #d7e4f2; font-weight: 700; }
.topbar-user { color: #7894b0; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.content-container { width: min(1480px, calc(100% - 48px)); margin: 0 auto; }
.app-content { min-height: calc(100vh - 58px); }

.app-frame.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed-width); }
.app-frame.sidebar-collapsed .app-main { width: calc(100% - var(--sidebar-collapsed-width)); margin-left: var(--sidebar-collapsed-width); }
.app-frame.sidebar-collapsed .brand-copy,
.app-frame.sidebar-collapsed .nav-label,
.app-frame.sidebar-collapsed .nav-group-title,
.app-frame.sidebar-collapsed .user-copy { opacity: 0; width: 0; pointer-events: none; }
.app-frame.sidebar-collapsed .sidebar-brand { padding-left: 18px; padding-right: 10px; }
.app-frame.sidebar-collapsed .brand-link { flex: 0 0 40px; }
.app-frame.sidebar-collapsed .sidebar-toggle { margin-left: auto; transform: rotate(180deg); }
.app-frame.sidebar-collapsed .side-link { justify-content: center; padding-left: 8px; padding-right: 8px; }
.app-frame.sidebar-collapsed .sidebar-user { justify-content: center; padding-left: 0; padding-right: 0; }

/* P4 workflow summary */
.status-summary-card {
    min-height: 86px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    padding: 13px 15px;
    background: #0d192b;
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.status-summary-card span { color: #8fa5bd; font-size: 12px; font-weight: 700; }
.status-summary-card strong { font-size: 26px; line-height: 1; }
.status-summary-card:hover, .status-summary-card.active { border-color: #4d8fd0; background: #11243b; transform: translateY(-1px); }

/* Global operation feedback */
.sentek-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(3, 9, 17, .70);
    backdrop-filter: blur(3px);
}
.sentek-loading-overlay[hidden] { display: none !important; }
.sentek-loading-card {
    min-width: min(360px, calc(100vw - 40px));
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border: 1px solid #315376;
    border-radius: 14px;
    background: #0b1829;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .42);
}
.sentek-loading-spinner {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 3px solid rgba(85, 167, 255, .22);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: sentek-spin .75s linear infinite;
}
.sentek-loading-title { font-weight: 750; color: #edf6ff; }
.sentek-loading-message { margin-top: 2px; color: var(--muted); font-size: 13px; }
body.sentek-is-busy { cursor: progress; }
body.sentek-is-busy .sentek-loading-overlay { cursor: progress; }
@keyframes sentek-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .sentek-loading-spinner { animation-duration: 1.6s; }
}

/* Mobile navigation */
.mobile-bottom-nav, .mobile-menu-canvas { display: none; }
.mobile-menu-group { padding: 4px 0 18px; }
.mobile-menu-group + .mobile-menu-group { border-top: 1px solid var(--line); padding-top: 18px; }
.mobile-menu-title { margin-bottom: 7px; color: #6f8aa6; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.mobile-menu-group a, .mobile-logout { display: block; width: 100%; padding: 11px 2px; border: 0; background: transparent; color: #dbe8f5; text-decoration: none; text-align: left; }
.mobile-menu-group a:hover, .mobile-logout:hover { color: #8bc5ff; }

@media (max-width: 991.98px) {
    body { padding-bottom: 72px; }
    .app-sidebar, .app-topbar { display: none; }
    .app-main, .app-frame.sidebar-collapsed .app-main { width: 100%; margin-left: 0; }
    .content-container { width: min(100% - 24px, 900px); }
    .content { padding-top: 24px; padding-bottom: 32px; }
    .mobile-bottom-nav {
        position: fixed; z-index: 1040; left: 0; right: 0; bottom: 0; min-height: 64px; display: flex; align-items: stretch; justify-content: space-around;
        padding: 5px max(8px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        border-top: 1px solid #2b4059; background: rgba(8,17,31,.97); backdrop-filter: blur(18px);
    }
    .mobile-nav-link { flex: 1 1 0; max-width: 96px; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; border-radius: 10px; background: transparent; color: #8ea5bd; text-decoration: none; padding: 5px 4px; }
    .mobile-nav-link span { font-size: 18px; font-weight: 800; line-height: 1; }
    .mobile-nav-link small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
    .mobile-nav-link:hover, .mobile-nav-link.is-active { color: #fff; background: #13243a; }
    .mobile-menu-canvas {
        display: flex;
        flex-direction: column;
        width: min(390px, 92vw) !important;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        background: #0b1627;
        overflow: hidden;
    }
    .mobile-menu-canvas .offcanvas-header { flex: 0 0 auto; }
    .mobile-menu-canvas .offcanvas-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 575.98px) {
    .login-card { padding: 24px 20px; }
    .shell { width: calc(100% - 24px); }
    .content-container { width: calc(100% - 20px); }
}
