/* ============================================================================
   Product Codes — management console theme (dark)
   A single global stylesheet: design tokens, app shell, and component styles
   (including overrides of the Bootstrap classes still used by some pages).
   ========================================================================== */

:root {
    --bg: #0c0f17;
    --surface: #141926;
    --surface-2: #1a2030;
    --surface-3: #10151f;
    --border: #262d3d;
    --border-strong: #333c4f;

    --text: #e7ebf3;
    --text-soft: #b6bdcc;
    --muted: #7f8899;

    --sidebar: #0a0d14;
    --sidebar-2: #0e121c;
    --sidebar-text: #9aa3b5;
    --sidebar-text-dim: #616b80;

    --accent: #6366f1;
    --accent-hover: #7c7ef5;
    --accent-soft: rgba(99, 102, 241, 0.16);
    --accent-ring: rgba(99, 102, 241, 0.40);

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --warn: #fbbf24;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.30);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    /* Chevron used for every native <select> (light stroke for dark UI). */
    --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%237f8899' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
}

html, body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    color-scheme: dark;
}

h1, h2, h3, h4 { color: var(--text); }
a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); }

/* ── App shell ──────────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 258px;
    flex-shrink: 0;
    background: var(--sidebar);
    background-image: linear-gradient(180deg, var(--sidebar-2), var(--sidebar));
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border);
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 60px;
    background: rgba(12, 15, 23, 0.80);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.app-content { padding: 28px 32px 48px; max-width: 1180px; width: 100%; }

/* ── Sidebar: brand ─────────────────────────────────────────────────────── */
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 18px 14px;
}
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), #8b8cf7);
    color: #fff; font-weight: 700; font-size: 12px; letter-spacing: .3px;
    box-shadow: 0 2px 10px rgba(99, 102, 241, .5);
}
.brand-text { color: #fff; font-weight: 600; font-size: 15px; letter-spacing: .2px; }

/* ── Sidebar: application switcher ──────────────────────────────────────── */
.appsw { padding: 6px 16px 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.appsw-label {
    display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
    color: var(--sidebar-text-dim); margin: 0 0 6px 2px; font-weight: 600;
}
.appsw-control { position: relative; }
.appsw-select {
    width: 100%;
    appearance: none; -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 9px 32px 9px 11px;
    font-size: 13.5px; font-weight: 500;
    cursor: pointer;
}
.appsw-select:hover { background: rgba(255, 255, 255, 0.08); }
.appsw-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.appsw-select option { color: #e7ebf3; background: #10131c; }
.appsw-muted { color: var(--sidebar-text-dim); cursor: default; }
.appsw-caret {
    position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
    width: 12px; height: 12px; color: var(--sidebar-text); pointer-events: none;
}

/* ── Sidebar: nav ───────────────────────────────────────────────────────── */
.nav-groups { padding: 4px 12px 20px; }
.nav-group { margin-bottom: 18px; }
.nav-group-title {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
    color: var(--sidebar-text-dim); font-weight: 600;
    padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 8px 10px; margin: 1px 0;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px; font-weight: 500;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--accent); color: #fff; box-shadow: 0 2px 12px rgba(99,102,241,.45); }
.nav-item.active .nav-ico { color: #fff; opacity: 1; }
.nav-ico { width: 18px; height: 18px; display: inline-flex; opacity: .82; }
.nav-ico svg { width: 18px; height: 18px; }

/* ── Topbar bits ────────────────────────────────────────────────────────── */
.topbar-context { display: flex; align-items: center; gap: 10px; }
.ctx-chip {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--accent-soft); color: var(--accent-hover);
    border: 1px solid rgba(99,102,241,.30);
    padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.ctx-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.user-role {
    font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
    color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--border);
    padding: 2px 8px; border-radius: 6px;
}
.logout-form { margin: 0; }
.btn-signout {
    background: transparent; border: 1px solid var(--border-strong); color: var(--text-soft);
    padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn-signout:hover { background: var(--surface-2); color: var(--text); border-color: var(--muted); }

/* ── Page primitives ────────────────────────────────────────────────────── */
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0; }
.page-sub strong { color: var(--text-soft); font-weight: 600; }

.empty-state {
    background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
    padding: 40px 24px; text-align: center; color: var(--muted); font-size: 14.5px;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card, .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.card-header, .panel-header {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 14.5px; color: var(--text);
    background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0;
}
.card-body, .panel-body { padding: 18px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.toolbar .grow { flex: 1; min-width: 160px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label, .form-label {
    font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin: 0;
}
.input, .form-control, .form-select, textarea.input, textarea.form-control {
    background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: 9px 12px; font-size: 14px; color: var(--text); width: 100%;
    transition: border-color .12s, box-shadow .12s;
}
.input:focus, .form-control:focus, .form-select:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
.input::placeholder, .form-control::placeholder { color: #6a7385; }
textarea.input, textarea.form-control { min-height: 90px; resize: vertical; }

/* Every native dropdown gets an explicit chevron so it reads as a select. */
select, select.form-select, select.input {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    background-image: var(--caret);
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
    cursor: pointer;
}
select option { background: var(--surface-3); color: var(--text); }

.form-check { display: inline-flex; align-items: center; gap: 7px; }
.form-check-input {
    width: 16px; height: 16px; border: 1px solid var(--border-strong); border-radius: 4px;
    accent-color: var(--accent); cursor: pointer; background: var(--surface-3);
}
.form-check-label { font-size: 13.5px; color: var(--text-soft); cursor: pointer; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
    line-height: 1.1; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-ghost, .btn-outline-secondary {
    background: var(--surface-2); border-color: var(--border-strong); color: var(--text-soft);
}
.btn-ghost:hover, .btn-outline-secondary:hover:not(:disabled) { border-color: var(--muted); color: var(--text); background: var(--surface-2); }
.btn-danger, .btn-outline-danger {
    background: var(--danger-soft); border-color: rgba(248,113,113,.35); color: var(--danger);
}
.btn-danger:hover:not(:disabled), .btn-outline-danger:hover:not(:disabled) { background: rgba(248,113,113,.22); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-link { background: none; border: none; color: var(--accent-hover); font-weight: 600; cursor: pointer; padding: 6px 8px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table.table, table.data { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0; }
.table thead th, .data thead th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 600; padding: 11px 16px;
    background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table tbody td, .data tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-soft); vertical-align: middle; }
.table tbody tr:last-child td, .data tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td, .data tbody tr:hover td { background: rgba(255,255,255,0.02); }
.table td code, .data td code { font-size: 12.5px; color: var(--text); background: var(--surface-3); padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border); }

/* ── Alerts / result blocks ─────────────────────────────────────────────── */
.alert { border-radius: var(--radius-sm); padding: 12px 15px; font-size: 14px; margin-top: 16px; border: 1px solid transparent; }
.alert-danger { background: var(--danger-soft); border-color: rgba(248,113,113,.3); color: #fca5a5; }
.alert-success { background: var(--success-soft); border-color: rgba(52,211,153,.3); color: #6ee7b7; }
.alert-info { background: var(--accent-soft); border-color: rgba(99,102,241,.3); color: var(--accent-hover); }

.result {
    margin-top: 16px; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px 16px;
}
.result-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.code-block {
    font-family: var(--mono); font-size: 12.5px; background: #080b11; color: #cdd6e6;
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; overflow-x: auto;
    white-space: pre-wrap; word-break: break-all; margin: 8px 0 0;
}

/* ── Badges / pills ─────────────────────────────────────────────────────── */
.badge-pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
    background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border);
}
.badge-admin { background: var(--accent-soft); color: var(--accent-hover); border-color: rgba(99,102,241,.3); }
.badge-dev { background: rgba(56,140,220,.16); color: #86bdf2; border-color: rgba(56,140,220,.3); }
.badge-ok { background: var(--success-soft); color: #6ee7b7; border-color: rgba(52,211,153,.3); }
.badge-off { background: var(--surface-2); color: var(--muted); }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.text-muted { color: var(--muted) !important; }

/* dashboard cards */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tile {
    display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 18px; text-decoration: none; color: inherit; transition: box-shadow .14s, transform .14s, border-color .14s;
}
.tile:hover { text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--border-strong); }
.tile-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-hover); margin-bottom: 12px; }
.tile-ico svg { width: 19px; height: 19px; }
.tile-title { font-weight: 600; font-size: 15px; margin: 0 0 3px; color: var(--text); }
.tile-desc { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.45; }

/* ── Error overlay (kept from template) ─────────────────────────────────── */
#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; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
    .app-shell { flex-direction: column; }
    .app-sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
    .nav-groups { display: flex; flex-wrap: wrap; gap: 4px 14px; }
    .nav-group { margin-bottom: 8px; }
    .app-content { padding: 20px 18px 40px; }
}

.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 4px 0 2px; align-items: center; }

/* ── Neutralize Bootstrap's light table painting (dark mode) ────────────── */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-soft);
    --bs-table-accent-bg: transparent;
    --bs-table-striped-bg: transparent;
    --bs-table-striped-color: var(--text-soft);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-color: var(--text);
    --bs-table-border-color: var(--border);
    color: var(--text-soft);
    background-color: transparent;
}
.table > :not(caption) > * > * {
    background-color: transparent;
    box-shadow: none;
    color: inherit;
}
.table thead th { background: var(--surface-2); color: var(--muted); }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }

a.user-name { color: var(--text); text-decoration: none; cursor: pointer; }
a.user-name:hover { color: var(--accent-hover); text-decoration: underline; }
