:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --sidebar: #101828;
    --sidebar-muted: #98a2b3;
    --canvas: #f4f6f9;
    --border: #e4e7ec;
    --text: #101828;
    --muted: #667085;
    --success: #12b76a;
    --warning: #f79009;
    --danger: #f04438;
}

html, body {
    min-height: 100%;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--canvas);
}

a { text-decoration: none; }
.btn { border-radius: .55rem; font-weight: 600; }
.btn-primary { background: var(--primary); border-color: var(--primary); box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.form-control, .form-select, .input-group-text { min-height: 44px; border-color: #d0d5dd; }
.form-control:focus { border-color: #84adff; box-shadow: 0 0 0 .22rem rgba(37, 99, 235, .12); }
.form-label { color: #344054; font-size: .875rem; font-weight: 600; }
.validation-message { color: var(--danger); display: block; font-size: .8rem; margin-top: .3rem; }

.admin-shell { min-height: 100vh; }
.sidebar {
    align-items: stretch;
    background: var(--sidebar);
    bottom: 0;
    color: #fff;
    display: flex;
    flex-direction: column;
    left: 0;
    padding: 1.5rem 1rem;
    position: fixed;
    top: 0;
    width: 268px;
    z-index: 1040;
}
.brand { align-items: center; color: #fff; display: flex; gap: .75rem; padding: 0 .6rem; }
.brand:hover { color: #fff; }
.brand-mark {
    align-items: center;
    background: linear-gradient(145deg, #3b82f6, #1d4ed8);
    border-radius: .75rem;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .28);
    display: flex;
    font-size: 1.25rem;
    height: 42px;
    justify-content: center;
    width: 42px;
}
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 1.08rem; letter-spacing: -.02em; }
.brand small { color: #98a2b3; font-size: .72rem; letter-spacing: .12em; margin-top: .2rem; text-transform: uppercase; }

.sidebar-nav { display: flex; flex: 1; flex-direction: column; gap: .3rem; margin-top: 2.25rem; }
.nav-caption { color: #667085; font-size: .68rem; font-weight: 700; letter-spacing: .1em; margin: 1.15rem .75rem .35rem; }
.sidebar-nav a {
    align-items: center;
    border-radius: .6rem;
    color: var(--sidebar-muted);
    display: flex;
    font-size: .9rem;
    font-weight: 500;
    gap: .8rem;
    padding: .72rem .8rem;
    transition: .15s ease;
}
.sidebar-nav a i { font-size: 1.05rem; }
.sidebar-nav a:hover { background: rgba(255,255,255,.055); color: #fff; }
.sidebar-nav a.active { background: #1d2939; color: #fff; box-shadow: inset 3px 0 var(--primary); }

.sidebar-user { align-items: center; border-top: 1px solid #273142; display: flex; gap: .7rem; padding: 1.1rem .4rem 0; }
.avatar { align-items: center; background: #dbeafe; border-radius: 50%; color: #1d4ed8; display: inline-flex; flex: 0 0 auto; font-size: .82rem; font-weight: 700; height: 38px; justify-content: center; width: 38px; }
.user-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.user-copy strong { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { color: #667085; font-size: .7rem; }
.logout-link { color: #98a2b3; padding: .3rem; }
.logout-link:hover { color: #fff; }

.main-content { margin-left: 268px; min-height: 100vh; }
.topbar {
    align-items: center;
    background: rgba(255,255,255,.92);
    border-bottom: 1px solid var(--border);
    display: flex;
    height: 68px;
    padding: 0 2.25rem;
    position: sticky;
    top: 0;
    backdrop-filter: blur(12px);
    z-index: 1020;
}
.system-state { align-items: center; color: var(--muted); display: flex; font-size: .78rem; font-weight: 600; gap: .45rem; }
.system-state span { background: var(--success); border-radius: 50%; box-shadow: 0 0 0 4px rgba(18,183,106,.13); height: 8px; width: 8px; }
.content-area { margin: 0 auto; max-width: 1600px; padding: 2.15rem 2.25rem 3rem; }

.page-heading { align-items: flex-end; display: flex; justify-content: space-between; margin-bottom: 1.75rem; }
.page-heading h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -.035em; margin: .2rem 0 .35rem; }
.page-heading p { color: var(--muted); font-size: .94rem; margin: 0; }
.eyebrow { color: var(--primary); display: block; font-size: .68rem; font-weight: 800; letter-spacing: .12em; }
.back-link { color: var(--muted); display: inline-block; font-size: .82rem; font-weight: 600; margin-bottom: .5rem; }
.back-link:hover { color: var(--primary); }

.metric-card, .summary-card {
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: .85rem;
    box-shadow: 0 1px 2px rgba(16,24,40,.035);
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
}
.metric-card div, .summary-card div { display: flex; flex-direction: column; }
.metric-card-link { color: var(--text); transition: border-color .15s, box-shadow .15s; }
.metric-card-link:hover, .metric-card-link:focus-visible { color: var(--text); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.metric-card small, .summary-card small { color: var(--muted); font-size: .78rem; font-weight: 600; }
.metric-card strong, .summary-card strong { font-size: 1.65rem; letter-spacing: -.04em; line-height: 1.2; margin-top: .2rem; }
.metric-icon { align-items: center; border-radius: .7rem; display: inline-flex; flex: 0 0 auto; font-size: 1.25rem; height: 48px; justify-content: center; width: 48px; }
.metric-icon.blue { background: #eff6ff; color: #2563eb; }
.metric-icon.green { background: #ecfdf3; color: #039855; }
.metric-icon.amber { background: #fffaeb; color: #dc6803; }
.metric-icon.red { background: #fef3f2; color: #d92d20; }

.panel { background: #fff; border: 1px solid var(--border); border-radius: .85rem; box-shadow: 0 1px 3px rgba(16,24,40,.04); overflow: hidden; }
.panel-header { align-items: center; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; padding: 1.15rem 1.35rem; }
.panel-header h2 { font-size: .98rem; font-weight: 700; margin: 0 0 .2rem; }
.panel-header p { color: var(--muted); font-size: .78rem; margin: 0; }
.panel-body { padding: 1.4rem; }
.form-panel { overflow: visible; }

.admin-table { font-size: .84rem; margin: 0; }
.admin-table > thead > tr > th { background: #f9fafb; border-bottom: 1px solid var(--border); color: var(--muted); font-size: .69rem; font-weight: 700; letter-spacing: .04em; padding: .75rem 1.25rem; text-transform: uppercase; white-space: nowrap; }
.admin-table > tbody > tr > td { border-color: #f0f1f3; padding: .9rem 1.25rem; }
.admin-table > tbody > tr:hover > td { background: #fcfcfd; }
.table-title { align-items: center; display: flex; gap: .75rem; min-width: 190px; }
.table-title > div { display: flex; flex-direction: column; }
.table-title small { color: var(--muted); font-size: .72rem; max-width: 270px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-icon { align-items: center; background: #eff6ff; border-radius: .5rem; color: var(--primary); display: flex; height: 36px; justify-content: center; width: 36px; }
.file-cell { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-badge { background: #f2f4f7; border-radius: .35rem; color: #344054; font-size: .7rem; font-weight: 700; padding: .3rem .5rem; }
.status-badge { align-items: center; border-radius: 999px; display: inline-flex; font-size: .7rem; font-weight: 700; gap: .3rem; padding: .32rem .55rem; white-space: nowrap; }
.status-badge.success { background: #ecfdf3; color: #027a48; }
.status-badge.warning { background: #fffaeb; color: #b54708; }
.status-badge.danger { background: #fef3f2; color: #b42318; }
.failure-reason { color: var(--danger); display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storage-failure-file { color: var(--muted); min-width: 180px; max-width: 280px; overflow-wrap: anywhere; }
.storage-failure-reason { color: var(--danger); min-width: 240px; max-width: 480px; white-space: pre-wrap; overflow-wrap: anywhere; }
.btn-icon { align-items: center; border: 0; color: var(--muted); display: inline-flex; height: 34px; justify-content: center; padding: 0; width: 34px; }
.btn-icon:hover { background: #f2f4f7; color: var(--primary); }
.btn-icon.danger:hover { background: #fef3f2; color: var(--danger); }
.btn-icon:disabled { opacity: .3; }

.empty-state { align-items: center; color: var(--muted); display: flex; flex-direction: column; gap: .45rem; padding: 3.5rem 1rem; text-align: center; }
.empty-state i { color: #98a2b3; font-size: 2rem; }
.empty-state strong { color: #344054; font-size: .95rem; }
.empty-state .btn { margin-top: .6rem; }
.empty-inline { align-items: center; color: var(--muted); display: flex; gap: .6rem; justify-content: center; padding: 2rem; }
.loading-state { align-items: center; color: var(--muted); display: flex; gap: .8rem; justify-content: center; min-height: 280px; }

.optional { color: #98a2b3; font-size: .7rem; font-weight: 400; }
.info-card { align-items: flex-start; background: #eff6ff; border: 1px solid #dbeafe; border-radius: .75rem; color: #1e40af; display: flex; gap: .8rem; padding: 1rem; }
.info-card > i { font-size: 1.15rem; }
.info-card strong { font-size: .82rem; }
.info-card p { color: #475467; font-size: .76rem; margin: .25rem 0 0; }
.form-actions { align-items: center; display: flex; gap: .75rem; justify-content: flex-end; padding-top: 1.5rem; }
.small-avatar { height: 36px; width: 36px; }

.account-shell { background: #fff; display: grid; min-height: 100vh; grid-template-columns: minmax(420px, 46%) 1fr; }
.account-showcase {
    background:
        radial-gradient(circle at 15% 80%, rgba(59,130,246,.2), transparent 28%),
        radial-gradient(circle at 90% 10%, rgba(37,99,235,.16), transparent 25%),
        linear-gradient(145deg, #101828, #172554);
    color: #fff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
    padding: 2.5rem 3.5rem;
    position: relative;
}
.account-showcase::after { border: 1px solid rgba(255,255,255,.06); border-radius: 50%; content: ""; height: 520px; position: absolute; right: -250px; top: 20%; width: 520px; }
.account-brand { padding: 0; position: relative; z-index: 1; }
.showcase-copy { margin: auto 0; max-width: 580px; position: relative; z-index: 1; }
.showcase-copy .eyebrow { color: #93c5fd; margin-bottom: 1.2rem; }
.showcase-copy h1 { font-size: clamp(2.2rem, 3.5vw, 3.7rem); font-weight: 700; letter-spacing: -.055em; line-height: 1.06; margin-bottom: 1.4rem; }
.showcase-copy h1:focus { outline: none; }
.showcase-copy > p { color: #cbd5e1; font-size: 1.02rem; line-height: 1.7; max-width: 500px; }
.showcase-features { display: flex; flex-direction: column; gap: .75rem; margin-top: 2rem; }
.showcase-features span { color: #e2e8f0; font-size: .86rem; }
.showcase-features i { color: #60a5fa; margin-right: .5rem; }
.showcase-footer { color: #64748b; position: relative; z-index: 1; }
.account-content { align-items: center; background: #fff; display: flex; justify-content: center; padding: 2.5rem; }
.account-card { max-width: 440px; width: 100%; }
.account-heading { margin-bottom: 2rem; }
.account-heading h2 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.035em; margin: .4rem 0 .5rem; }
.account-heading p { color: var(--muted); line-height: 1.6; margin: 0; }
.account-input .input-group-text { background: #fff; border-right: 0; color: #98a2b3; }
.account-input .form-control { border-left: 0; padding-left: .2rem; }
.form-link { color: var(--primary); font-size: .8rem; font-weight: 600; }
.account-switch { color: var(--muted); font-size: .84rem; margin: 1.5rem 0 0; text-align: center; }
.account-switch a { color: var(--primary); font-weight: 600; }
.pending-card { text-align: center; }
.pending-icon { align-items: center; background: #fffaeb; border-radius: 50%; color: #dc6803; display: inline-flex; font-size: 1.65rem; height: 64px; justify-content: center; margin-bottom: 1rem; width: 64px; }
.pending-icon.success { background: #ecfdf3; color: #039855; }
.pending-card h3 { font-size: 1.3rem; font-weight: 700; }
.pending-card p { color: var(--muted); line-height: 1.6; margin: .6rem 0 1.5rem; }

#blazor-error-ui { background: #fef3f2; bottom: 0; box-shadow: 0 -1px 4px rgba(0,0,0,.1); color: #b42318; display: none; left: 0; padding: .8rem 1.25rem; position: fixed; right: 0; z-index: 2000; }
#blazor-error-ui .dismiss { background: transparent; border: 0; float: right; }
#blazor-error-ui .reload { color: #b42318; font-weight: 700; margin-left: .5rem; }

@media (max-width: 991.98px) {
    .sidebar { box-shadow: 20px 0 40px rgba(16,24,40,.22); transform: translateX(-105%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar { padding: 0 1.25rem; }
    .content-area { padding: 1.5rem 1.25rem; }
    .account-shell { display: block; }
    .account-showcase { display: none; }
    .account-content { min-height: 100vh; }
}
@media (max-width: 575.98px) {
    .page-heading { align-items: flex-start; flex-direction: column; gap: 1rem; }
    .page-heading .btn { width: 100%; }
    .content-area { padding: 1.25rem .85rem; }
    .account-content { padding: 1.5rem; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
}
