:root {
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-soft: #eff6ff;
    --sidebar-bg: #0f172a;
    --sidebar-bg2: #1e293b;
    --sidebar-text: #94a3b8;
    --content-bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--content-bg);
    color: var(--text);
    margin: 0;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 264px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
    color: var(--sidebar-text);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: 0.01em;
}

.brand:hover { color: #ffffff; }

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.55rem;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.58rem 0.8rem;
    margin: 0.08rem 0;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.92rem;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-link:hover { background: rgba(148, 163, 184, 0.12); color: #ffffff; }

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-nav .nav-link svg { width: 1.15rem; height: 1.15rem; flex-shrink: 0; }
.brand-icon svg { width: 1.15rem; height: 1.15rem; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-brand { font-weight: 600; color: var(--text); font-size: 0.95rem; display: inline-flex; align-items: center; }
.topbar-brand svg { width: 1rem; height: 1rem; }

.content { padding: 1.5rem; flex: 1; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------- Page header ---------- */
h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 1.25rem;
}

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    overflow: hidden;
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 0.85rem 1.1rem;
}

.card-body { padding: 1.1rem; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }

.table thead th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding: 0.7rem 0.9rem;
    white-space: nowrap;
}

.table tbody td { padding: 0.72rem 0.9rem; vertical-align: middle; border-color: #f1f5f9; }

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

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 500; transition: all 0.15s ease; }

.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    border: none;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-outline-primary { color: var(--brand); border-color: #bfdbfe; }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.82rem; }

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

.form-label { font-weight: 500; color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Badges & alerts ---------- */
.badge { font-weight: 500; border-radius: 0.4rem; }
.alert { border-radius: var(--radius-sm); }

/* ---------- Validation ---------- */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

/* ---------- Blazor error boundary ---------- */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred." }

/* ---------- Auth pages ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #2563eb 0%, #274060 55%, #0f172a 100%);
}

.auth-card { width: 100%; max-width: 26rem; }

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    font-size: 2rem;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #274060);
    border-radius: 1rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.2);
}

/* ---------- Responsive ---------- */
.sidebar-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.55rem;
    color: var(--text);
    line-height: 1;
    margin-right: 0.75rem;
    cursor: pointer;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform 0.2s ease; }
    .app-shell.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 15;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    .app-shell.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}
/* ---------- Table card look ---------- */
.table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-collapse: separate;
    border-spacing: 0;
    box-shadow: var(--shadow-sm);
}
.table thead th:first-child { border-top-left-radius: var(--radius); }
.table thead th:last-child { border-top-right-radius: var(--radius); }
.table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
.table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }

/* ---------- Table action links as pill buttons ---------- */
.table td a:not(.btn) {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.28rem 0.6rem;
    border-radius: 0.4rem;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    transition: all 0.15s ease;
}
.table td a:not(.btn):hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
}

.sidebar-nav .nav-item { padding-left: 0; padding-right: 0; }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.sidebar-nav .nav-section {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: rgba(148, 163, 184, 0.5);
    font-weight: 700;
    padding: 1rem 0.8rem 0.3rem;
    white-space: nowrap;
}

/* ---------- Landing / marketing ---------- */
.landing { min-height: 100vh; display: flex; flex-direction: column; background: #fff; }

.landing-nav {
    background: #0f172a;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    position: sticky;
    top: 0;
    z-index: 50;
}
.landing-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.landing-actions { display: flex; gap: 0.6rem; }

.hero {
    background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 55%, #2563eb 100%);
    color: #fff;
    text-align: center;
    padding: 5rem 1.5rem;
}
.hero-inner { max-width: 820px; margin: 0 auto; }
.hero-badge {
    display: inline-block;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 1.25rem;
}
.hero-title { font-size: 2.6rem; font-weight: 800; line-height: 1.15; margin-bottom: 1rem; }
.hero-sub { font-size: 1.15rem; color: rgba(255, 255, 255, 0.85); max-width: 620px; margin: 0 auto 2rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.features { padding: 4rem 1.5rem; background: #f8fafc; }
.features-inner { max-width: 1200px; margin: 0 auto; }
.features-title { text-align: center; font-size: 1.8rem; font-weight: 700; margin-bottom: 2.5rem; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }
.feature-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.feature-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-soft);
    color: var(--brand);
    margin-bottom: 1rem;
}
.feature-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }
.feature-card p { color: var(--text-muted); margin: 0; }

.landing-footer { background: #0f172a; color: #94a3b8; }
.landing-footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.landing-footer a { color: #94a3b8; }
.landing-footer a:hover { color: #fff; }
