:root {
    --app-bg: #f6f8fc;
    --app-ink: #0f172a;
    --app-muted: #64748b;
    --app-primary: #1d4ed8;
    --app-primary-dark: #173ea9;
    --app-accent: #22c55e;
    --app-surface: #ffffff;
    --app-border: #dbe4f0;
    --app-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
    --status-success-bg: #dcfce7;
    --status-success-text: #166534;
    --status-warning-bg: #fef3c7;
    --status-warning-text: #92400e;
    --status-danger-bg: #fee2e2;
    --status-danger-text: #991b1b;
    --status-info-bg: #dbeafe;
    --status-info-text: #1e40af;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    color: var(--app-ink);
    background: var(--app-bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

button,
a,
input {
    touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(29, 78, 216, 0.32);
    outline-offset: 3px;
}

.eyebrow,
.panel-kicker,
.topbar-kicker,
.sidebar-title {
    display: inline-flex;
    color: #60a5fa;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.guest-container {
    width: 100%;
    max-width: 1280px;
    padding: 1.5rem 1rem;
    margin: 0 auto;
}

.saas-login-page {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
    gap: clamp(1rem, 3vw, 1.5rem);
    min-height: calc(100vh - 3rem);
}

.login-only-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.saas-login-hero,
.saas-login-panel,
.dashboard-header,
.data-card,
.stat-card {
    border: 1px solid var(--app-border);
    border-radius: 28px;
    box-shadow: var(--app-shadow);
}

.saas-login-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: clamp(1.5rem, 4vw, 2.5rem);
    min-height: 620px;
    padding: clamp(1.5rem, 4vw, 3rem);
    overflow: hidden;
    color: #ffffff;
    background:
        radial-gradient(circle at 18% 18%, rgba(96, 165, 250, 0.36), transparent 18rem),
        radial-gradient(circle at 82% 76%, rgba(34, 197, 94, 0.18), transparent 20rem),
        linear-gradient(135deg, #07111f 0%, #12326d 48%, #0f172a 100%);
}

.saas-login-hero::before {
    position: absolute;
    inset: 1rem;
    pointer-events: none;
    content: '';
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
}

.saas-login-brand,
.saas-login-content,
.saas-login-insights {
    position: relative;
    z-index: 1;
}

.saas-login-brand,
.admin-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.saas-login-mark,
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 900;
    background: var(--app-primary);
}

.saas-login-mark {
    width: 52px;
    height: 52px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 18px;
}

.saas-login-brand strong,
.saas-login-brand span,
.admin-brand strong,
.admin-brand span {
    display: block;
}

.saas-login-brand span,
.saas-login-copy,
.insight-card span {
    color: rgba(226, 232, 240, 0.78);
}

.saas-login-title {
    max-width: 720px;
    margin: 0.7rem 0 1rem;
    font-size: clamp(3rem, 7vw, 6rem);
    font-weight: 900;
    line-height: 0.92;
    letter-spacing: -0.05em;
}

.saas-login-copy {
    max-width: 620px;
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.65;
}

.saas-login-insights {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
}

.insight-card {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.insight-card-primary {
    background: rgba(37, 99, 235, 0.42);
}

.insight-card span,
.insight-card strong {
    display: block;
}

.insight-card strong {
    margin-top: 0.35rem;
    font-size: 2.3rem;
    line-height: 1;
}

.saas-login-panel {
    align-self: center;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(18px);
}

.login-only-page .saas-login-panel {
    width: min(100%, 460px);
}

.login-panel-header {
    margin-bottom: 1.5rem;
}

.login-panel-header h1 {
    margin: 0.45rem 0 0;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 900;
    letter-spacing: -0.04em;
}

.login-panel-header h2 {
    margin: 0.45rem 0 0;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 900;
    letter-spacing: -0.04em;
}

.form-group,
.mb-3 {
    margin-bottom: 1rem;
}

.form-label,
.form-check-label {
    display: inline-flex;
    margin-bottom: 0.45rem;
    color: var(--app-ink);
    font-size: 0.9rem;
    font-weight: 800;
}

.form-control {
    display: block;
    width: 100%;
    min-height: 54px;
    padding: 0.85rem 1rem;
    color: var(--app-ink);
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.form-control:focus {
    border-color: var(--app-primary);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(29, 78, 216, 0.14);
}

.form-check,
.login-check {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.form-check-input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--app-primary);
}

.invalid-feedback,
.help-block,
.help-inline {
    display: block;
    margin-top: 0.4rem;
    color: var(--status-danger-text);
    font-size: 0.85rem;
    font-weight: 700;
}

.btn,
.logout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.72rem 1rem;
    font-weight: 850;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.btn-primary,
.login-submit {
    color: #ffffff;
    background: var(--app-primary);
    border-color: var(--app-primary);
    box-shadow: 0 16px 32px rgba(29, 78, 216, 0.22);
}

.btn-primary:hover,
.btn-primary:focus,
.login-submit:hover,
.login-submit:focus {
    background: var(--app-primary-dark);
    border-color: var(--app-primary-dark);
}

.login-submit {
    width: 100%;
    min-height: 54px;
    margin-top: 0.4rem;
}

.btn:disabled,
.login-submit:disabled,
.logout-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.admin-body {
    min-height: 100vh;
    background: var(--app-bg);
}

.admin-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 1.25rem;
    color: #e2e8f0;
    background: linear-gradient(180deg, #0f172a 0%, #172033 56%, #10275f 100%);
}

.admin-brand {
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
}

.admin-brand span,
.platform-item {
    color: #94a3b8;
    font-size: 0.82rem;
}

.sidebar-nav,
.platform-list {
    display: grid;
    gap: 0.45rem;
}

.sidebar-link,
.platform-item {
    display: block;
    padding: 0.82rem 0.9rem;
    text-decoration: none;
    border-radius: 16px;
}

.sidebar-link {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-link:hover,
.sidebar-link:focus {
    color: #ffffff;
    background: rgba(37, 99, 235, 0.36);
}

.platform-section {
    padding-top: 1.25rem;
    margin-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.platform-list {
    margin-top: 0.75rem;
}

.platform-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-main {
    min-width: 0;
}

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--app-border);
    backdrop-filter: blur(14px);
}

.admin-topbar h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.logout-button {
    min-height: 36px;
    padding: 0.45rem 0.75rem;
    color: #334155;
    background: #ffffff;
    border-color: var(--app-border);
}

.logout-button:hover,
.logout-button:focus {
    color: var(--app-primary-dark);
    border-color: #bfdbfe;
}

.admin-content {
    padding: 1.5rem;
}

.dashboard-page {
    display: grid;
    gap: 1.25rem;
}

.dashboard-header,
.data-card,
.stat-card {
    background: var(--app-surface);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: clamp(1.25rem, 3vw, 2rem);
}

.dashboard-header h2 {
    margin: 0.35rem 0 0;
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 900;
    letter-spacing: -0.05em;
}

.header-actions,
.stats-grid,
.dashboard-grid {
    display: grid;
    gap: 1rem;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card,
.data-card {
    padding: 1.25rem;
}

.stat-card span,
.stat-card small,
.system-status-item span,
.warning-item span {
    display: block;
    color: var(--app-muted);
}

.stat-card strong {
    display: block;
    margin: 0.35rem 0;
    font-size: 2rem;
    line-height: 1;
}

.stat-primary strong { color: var(--app-primary); }
.stat-success strong { color: var(--status-success-text); }
.stat-warning strong { color: var(--status-warning-text); }
.stat-danger strong { color: var(--status-danger-text); }

.dashboard-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.75fr);
}

.data-card-wide {
    grid-row: span 2;
}

.card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-heading h3 {
    margin: 0.35rem 0 0;
    font-size: 1.15rem;
    font-weight: 900;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 0.85rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--app-border);
    white-space: nowrap;
}

.admin-table th {
    color: var(--app-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.admin-table tbody tr:hover {
    background: #f8fafc;
}

.scope-pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 850;
    border-radius: 999px;
}

.scope-pill,
.status-badge.info {
    color: var(--status-info-text);
    background: var(--status-info-bg);
}

.status-badge.success { color: var(--status-success-text); background: var(--status-success-bg); }
.status-badge.warning { color: var(--status-warning-text); background: var(--status-warning-bg); }
.status-badge.danger { color: var(--status-danger-text); background: var(--status-danger-bg); }
.status-badge.neutral { color: #334155; background: #e2e8f0; }

.warning-list,
.system-status-list {
    display: grid;
    gap: 0.75rem;
}

.warning-item,
.system-status-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem;
    background: #f8fafc;
    border: 1px solid var(--app-border);
    border-radius: 16px;
}

.warning-item strong,
.warning-item span {
    display: block;
}

@media (max-width: 1199px) {
    .admin-shell {
        grid-template-columns: 248px minmax(0, 1fr);
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 991px) {
    .saas-login-page,
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-shell {
        display: block;
    }

    .admin-sidebar {
        position: static;
        height: auto;
    }

    .saas-login-hero {
        min-height: auto;
    }

    .saas-login-panel {
        align-self: stretch;
    }

    .admin-topbar,
    .dashboard-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 767px) {
    .saas-login-page {
        min-height: auto;
    }

    .saas-login-insights,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .saas-login-title {
        font-size: clamp(2.5rem, 14vw, 4rem);
    }

    .admin-content,
    .admin-topbar {
        padding: 1rem;
    }
}
