:root {
    --bg: #eef2ff;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --border: rgba(15, 23, 42, 0.08);
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #e2e8f0;
    --success: #059669;
    --danger: #be123c;
    --amber: #d97706;
    --shadow: 0 28px 60px rgba(15, 23, 42, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(5, 150, 105, 0.14), transparent 24%),
        linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

code {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: rgba(15, 23, 42, 0.06);
    border-radius: 6px;
    padding: 0.1rem 0.35rem;
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.92);
    color: white;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand,
.card-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-mark {
    width: 2.7rem;
    height: 2.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.9rem;
    background: #ffffff;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-title,
.page-header h1,
.panel-head h2,
.stat-card strong,
.login-hero h1 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.brand-title {
    font-weight: 700;
}

.brand-subtitle,
.muted,
.page-kicker,
.panel-head p,
.stat-note,
.helper-copy,
.definition-list dt {
    color: var(--muted);
}

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

.nav-link {
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    color: rgba(255, 255, 255, 0.72);
    transition: 160ms ease;
}

.nav-link:hover,
.nav-link.is-active {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-radius: 1.2rem;
    background: rgba(255, 255, 255, 0.05);
}

.session-user {
    margin: 10px 0 0;
    font-weight: 600;
}

.content {
    padding: 2rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0.15rem 0;
    font-size: clamp(1.9rem, 2vw, 2.6rem);
}

.page-header p,
.page-kicker {
    margin: 0;
}

.page-kicker,
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
}

.stats-grid,
.panel-grid,
.form-grid,
.health-grid {
    display: grid;
    gap: 1rem;
}

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

.panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.panel-grid-charts {
    align-items: stretch;
}

.chart-container {
    position: relative;
    width: 100%;
}

.chart-container canvas {
    max-height: 100%;
}

.panel-span-2 {
    grid-column: span 2;
}

.panel,
.stat-card,
.login-card,
.hero-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.panel,
.login-card {
    border-radius: 1.5rem;
    padding: 1.35rem;
}

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

.panel-head h2,
.stat-card strong {
    margin: 0;
    font-size: 1.05rem;
}

.panel-head p,
.stat-card span,
.helper-copy,
.definition-list dd,
.plain-list {
    margin: 0;
    font-size: 0.95rem;
}

.stat-card {
    padding: 1.25rem;
    border-radius: 1.35rem;
    display: grid;
    gap: 0.3rem;
}

.stat-card strong {
    font-size: 2.4rem;
}

.stat-label {
    color: var(--muted);
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.accent-blue { border-top: 4px solid #2563eb; }
.accent-green { border-top: 4px solid #059669; }
.accent-amber { border-top: 4px solid #d97706; }
.accent-rose { border-top: 4px solid #be123c; }

a.stat-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    display: grid;
}

a.stat-card-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
    text-decoration: none;
    color: inherit;
}

a.stat-card-link:active {
    transform: translateY(-1px);
    opacity: 0.9;
}

.alert {
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.alert-danger {
    background: rgba(244, 63, 94, 0.08);
    color: #9f1239;
}

.alert-success {
    background: rgba(5, 150, 105, 0.08);
    color: #065f46;
}

.alert-info {
    background: rgba(37, 99, 235, 0.08);
    color: #1e3a8a;
    border-color: rgba(37, 99, 235, 0.18);
}

.toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.toolbar-end {
    justify-content: flex-end;
}

.button {
    border: 0;
    border-radius: 0.95rem;
    padding:0.45rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 0.875rem;
}

.button-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.button-secondary {
    background: var(--secondary);
    color: var(--text);
}

.button-block {
    width: 100%;
}

.input,
select.input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 0.95rem;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    font: inherit;
}

.input:focus,
select.input:focus {
    outline: 2px solid rgba(37, 99, 235, 0.18);
    border-color: rgba(37, 99, 235, 0.45);
}

.label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.92rem;
    font-weight: 600;
}

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

.table th,
.table td {
    text-align: left;
    padding: 0.95rem 0.8rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    vertical-align: top;
}

.table th {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.table th a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.empty-cell {
    text-align: center;
    color: var(--muted);
}

.table-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem 0.75rem;
}

.filter-input {
    flex: 1;
    max-width: 340px;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.filter-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.filter-select {
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
}

.filter-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.filter-count {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

.pagination-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-top: 1rem;
}

.pagination {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.page-link {
    padding: 0.55rem 0.8rem;
    border-radius: 0.75rem;
    background: rgba(148, 163, 184, 0.15);
}

.page-link.is-active {
    background: var(--primary);
    color: white;
}

.sort-indicator {
    color: var(--primary);
}

.definition-list,
.plain-list,
.stack-md,
.stack-lg {
    display: grid;
    gap: 0.9rem;
}

.definition-list dt {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.2rem;
}

.definition-list dd {
    margin-left: 0;
}

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

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

.health-tile {
    border-radius: 1rem;
    padding: 1rem;
    background: rgba(241, 245, 249, 0.72);
}

.health-tile strong {
    display: block;
    margin-top: 0.3rem;
    font-size: 1.7rem;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 20%, rgba(148, 163, 184, 0.2), transparent 30%),
        radial-gradient(circle at 82% 85%, rgba(59, 130, 246, 0.18), transparent 28%),
        linear-gradient(145deg, #0f1f3b 0%, #1f3f73 48%, #2c4f8f 100%);
}

.login-body::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='340' height='140'%3E%3Ctext x='170' y='70' font-family='Arial%2C sans-serif' font-size='19' font-weight='700' fill='rgba(255%2C255%2C255%2C0.07)' text-anchor='middle' dominant-baseline='middle' transform='rotate(-35%2C170%2C70)'%3EData Feeds Center%3C%2Ftext%3E%3C%2Fsvg%3E");
    background-repeat: repeat;
    background-size: 340px 140px;
    pointer-events: none;
    z-index: 0;
}

.login-body::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(8, 16, 32, 0.1) 0%, rgba(8, 16, 32, 0.22) 100%);
    pointer-events: none;
    z-index: 0;
}

.auth-page {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 860px;
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(100%, 410px);
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 20px;
    box-shadow: 0 26px 50px rgba(31, 41, 55, 0.26);
    text-align: center;
    padding: 2rem 2rem 1.8rem;
    color: #111827;
    animation: login-card-enter 420ms ease-out both;
}

.auth-logo-wrap {
    display: grid;
    place-items: center;
    min-height: 66px;
    margin-bottom: 0.65rem;
}

.auth-logo {
    max-width: 142px;
    width: 100%;
    height: auto;
}

.auth-logo-fallback {
    display: none;
    min-height: 52px;
    border-radius: 14px;
    padding: 0.6rem 1.1rem;
    background: #ecf3ff;
    color: #29549a;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.auth-kicker {
    margin: 0;
    color: #6b7280;
    font-size: 0.95rem;
}

.auth-title {
    margin: 0.95rem 0 1.2rem;
    font-size: 2.15rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.05;
}

.auth-social-stack {
    display: grid;
    gap: 0.85rem;
}

.oauth-btn {
    width: 100%;
    border-radius: 10px;
    border: 2px solid #d1d5db;
    background: #ffffff;
    color: #1f2937;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 1.04rem;
    font-weight: 600;
    padding: 0.82rem 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.48rem;
    cursor: pointer;
    opacity: 1;
    transition: background 160ms ease, border-color 160ms ease;
}

.oauth-btn:hover {
    background: #f3f4f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.10);
}

.oauth-btn:active {
    transform: translateY(0);
    box-shadow: none;
    background: #e9eaec;
}

.oauth-unavailable {
    cursor: pointer;
}

.oauth-google {
    border-color: #d6454f;
}

.oauth-google:hover {
    border-color: #b91c1c;
    background: #fff5f5;
}

.oauth-microsoft {
    border-color: #2597cc;
}

.oauth-microsoft:hover {
    border-color: #1575a8;
    background: #f0f8ff;
}

.oauth-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #111827;
    font-size: 0.72rem;
    font-weight: 700;
    transition: background 160ms ease;
}

.oauth-btn:hover .oauth-mark {
    background: #e5e7eb;
}

.auth-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    margin: 1.4rem 0 1.2rem;
    color: #8c9098;
    font-size: 0.94rem;
    font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    border-top: 1px solid #e5e7eb;
}

.credentials-toggle {
    margin: 0 0 1rem;
    text-align: left;
}

.credentials-toggle summary {
    cursor: pointer;
    color: #374151;
    font-size: 0.92rem;
    font-weight: 600;
}

.credentials-form {
    margin-top: 0.85rem;
}

.auth-terms {
    margin: 0.3rem 0 0;
    color: #6b7280;
    line-height: 1.45;
    font-size: 0.92rem;
}

@keyframes login-card-enter {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 1100px) {
    .shell {
        grid-template-columns: 1fr;
    }

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

    .stats-grid,
    .panel-grid,
    .form-grid,
    .health-grid {
        grid-template-columns: 1fr;
    }

    .panel-span-2 {
        grid-column: auto;
    }

    .login-card {
        margin: 0;
    }
}

@media (max-width: 720px) {
    .content,
    .auth-page {
        padding: 1rem;
    }

    .auth-card {
        padding: 1.5rem 1rem;
        border-radius: 16px;
    }

    .auth-title {
        font-size: 1.8rem;
    }

    .oauth-btn {
        font-size: 0.96rem;
    }

    .toolbar,
    .pagination-row {
        flex-direction: column;
        align-items: stretch;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}