:root {
    color-scheme: light;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-soft: #eff6ff;
    --color-accent: #ea580c;
    --color-accent-hover: #c2410c;
    --color-background: #f8fafc;
    --color-surface: #ffffff;
    --color-foreground: #172033;
    --color-muted-foreground: #64748b;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;
    --color-success: #15803d;
    --color-success-soft: #f0fdf4;
    --color-warning: #b45309;
    --color-warning-soft: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-soft: #fef2f2;
    --sidebar-bg: #0b1220;
    --sidebar-surface: #131d31;
    --sidebar-text: #cbd5e1;
    --sidebar-muted: #7f8ca3;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, .07);
    --sidebar-width: 278px;
    --header-height: 74px;
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    scroll-padding-top: calc(var(--header-height) + 16px);
    background: var(--color-background);
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 85% -10%, rgba(37, 99, 235, .08), transparent 28rem),
        var(--color-background);
    color: var(--color-foreground);
    font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--color-primary); }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid rgba(37, 99, 235, .42);
    outline-offset: 2px;
}

::selection { background: #bfdbfe; color: #172033; }

.app-icon {
    display: block;
    flex: 0 0 auto;
}

body .app-shell {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

.app-shell .sidebar {
    position: sticky;
    inset-block-start: 0;
    width: var(--sidebar-width);
    height: 100vh;
    flex: 0 0 var(--sidebar-width);
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    z-index: 50;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 18rem),
        var(--sidebar-bg);
    border-inline-start: 1px solid rgba(255, 255, 255, .06);
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.sidebar .brand {
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.sidebar .brand-logo {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: white;
    border-radius: 13px;
    background: linear-gradient(145deg, #3b82f6, #1d4ed8);
    box-shadow: 0 10px 24px rgba(37, 99, 235, .28);
}

.sidebar .brand-copy { display: grid; min-width: 0; }
.sidebar .brand-name { color: white; font-size: 1.08rem; font-weight: 800; letter-spacing: -.02em; }
.sidebar .brand-copy small { color: var(--sidebar-muted); font-size: .72rem; }

.sidebar-search-area {
    padding: 12px 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.nav-search-wrapper .search-icon {
    position: absolute;
    inset-inline-start: 10px;
    color: var(--sidebar-muted);
    pointer-events: none;
    display: grid;
    place-items: center;
}

.nav-search-input {
    width: 100%;
    height: 38px;
    padding-inline-start: 34px;
    padding-inline-end: 28px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #f8fafc;
    font-size: 0.82rem;
    font-weight: 500;
    outline: none;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.nav-search-input:focus {
    background: rgba(255, 255, 255, 0.09);
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.nav-search-input::placeholder {
    color: var(--sidebar-muted);
}

.search-clear-btn {
    position: absolute;
    inset-inline-end: 8px;
    background: none;
    border: none;
    color: var(--sidebar-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}

.search-clear-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-view-actions {
    display: flex;
    justify-content: flex-end;
    padding-inline: 4px;
}

.nav-toggle-all-btn {
    background: none;
    border: none;
    color: var(--sidebar-muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.nav-toggle-all-btn:hover {
    color: #93c5fd;
    background: rgba(255, 255, 255, 0.05);
}

.search-results-meta {
    padding: 6px 12px 10px;
    color: #93c5fd;
    font-size: 0.74rem;
    font-weight: 700;
}

.search-hit-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-link-cat {
    font-size: 0.65rem;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 7px;
    border-radius: 6px;
    flex-shrink: 0;
    font-weight: 600;
}

.nav-no-results {
    padding: 28px 14px;
    text-align: center;
    color: var(--sidebar-muted);
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.btn-clear-search {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-clear-search:hover {
    background: rgba(255, 255, 255, 0.18);
}

.sidebar .nav-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 12px 24px;
}

.primary-nav-link {
    margin-bottom: 6px;
    background: rgba(37, 99, 235, 0.12) !important;
    border: 1px solid rgba(96, 165, 250, 0.22) !important;
    color: #e2e8f0 !important;
    font-weight: 700 !important;
}

.primary-nav-link:hover {
    background: rgba(37, 99, 235, 0.22) !important;
    color: #ffffff !important;
}

.primary-nav-link.active {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.45), rgba(29, 78, 216, 0.5)) !important;
    border-color: #60a5fa !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25) !important;
}

.nav-section-group {
    margin-block-start: 4px;
    border-radius: 11px;
    transition: background 0.18s ease;
}

.nav-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    background: none;
    border: none;
    border-radius: 9px;
    color: var(--sidebar-muted);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    text-align: start;
    user-select: none;
}

.nav-group-header:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.045);
}

.group-header-lead {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.group-icon {
    color: #60a5fa;
    flex-shrink: 0;
    opacity: 0.9;
}

.group-title {
    font-size: 0.78rem;
    font-weight: 750;
    color: #cbd5e1;
    letter-spacing: 0.01em;
}

.group-count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 999px;
}

.group-chevron {
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--sidebar-muted);
}

.nav-section-group.is-open .group-chevron {
    transform: rotate(-90deg);
    color: #60a5fa;
}

.nav-section-group.is-collapsed .nav-group-content {
    display: none;
}

.nav-group-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px 0 5px 0;
    margin-inline-start: 12px;
    border-inline-start: 1.5px solid rgba(255, 255, 255, 0.08);
    padding-inline-start: 6px;
}

.sidebar .nav-list .nav-link {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 11px;
    color: var(--sidebar-text);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.sidebar .nav-list .nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.055);
    transform: translateX(-2px);
}

.sidebar .nav-list .nav-link.active {
    color: white;
    background: var(--sidebar-surface);
    border-color: rgba(96, 165, 250, 0.25);
    box-shadow: inset -3px 0 0 #60a5fa, 0 3px 10px rgba(0, 0, 0, 0.2);
    font-weight: 700;
}

.sidebar .nav-list .nav-link.active .app-icon { color: #60a5fa; }

.sidebar .nav-footer {
    margin-top: auto;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 42px;
    align-items: center;
    gap: 10px;
    padding: 15px 14px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    background: rgba(0, 0, 0, .12);
}

.user-avatar {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: white;
    background: #334155;
    border: 1px solid #475569;
    border-radius: 50%;
    font-size: .88rem;
    font-weight: 800;
}

.user-copy { display: grid; min-width: 0; }
.user-copy strong { color: #f8fafc; font-size: .76rem; font-weight: 700; }
.sidebar .nav-user { overflow: hidden; color: var(--sidebar-muted); font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .nav-logout { width: 42px; height: 42px; display: grid; place-items: center; color: #fda4af; border-radius: 10px; text-decoration: none; }
.sidebar .nav-logout:hover { color: white; background: rgba(220, 38, 38, .16); }

.app-shell .main-col {
    min-width: 0;
    flex: 1 1 auto;
    background: transparent;
}

.main-col .scope-bar {
    position: sticky;
    inset-block-start: 0;
    z-index: 30;
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px clamp(18px, 3vw, 36px);
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid rgba(226, 232, 240, .9);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.scope-heading { display: grid; min-width: 150px; }
.scope-heading .scope-eyebrow { color: var(--color-muted-foreground); font-size: .68rem; font-weight: 700; letter-spacing: .06em; }
.scope-heading strong { color: var(--color-foreground); font-size: .95rem; font-weight: 800; }
.scope-context { margin-inline-start: auto; display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.main-col .scope-chip {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 11px;
    color: #1e40af;
    background: var(--color-primary-soft);
    border: 1px solid #dbeafe;
    border-radius: 10px;
    font-size: .77rem;
    font-weight: 700;
}

.main-col .scope-warn {
    padding: 7px 11px;
    color: var(--color-warning);
    background: var(--color-warning-soft);
    border: 1px solid #fde68a;
    border-radius: 10px;
    font-size: .78rem;
    font-weight: 700;
}

.mobile-menu-button {
    display: none;
    width: 44px;
    height: 44px;
    place-items: center;
    color: var(--color-foreground);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 11px;
    cursor: pointer;
}

.nav-backdrop { display: none; }

.main-col .content-area {
    width: 100%;
    max-width: 1640px;
    margin-inline: auto;
    padding: clamp(20px, 3vw, 38px);
}

.content-area h1.pt,
.content-area h1.page-title {
    margin: 0 0 24px;
    color: var(--color-foreground);
    font-size: clamp(1.55rem, 2.2vw, 2rem);
    font-weight: 800;
    letter-spacing: -.035em;
    line-height: 1.3;
}

.content-area h1.pt::after,
.content-area h1.page-title::after {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    margin-block-start: 10px;
    background: var(--color-accent);
    border-radius: 999px;
}

.content-area .hint { margin: -14px 0 22px; color: var(--color-muted-foreground); font-size: .9rem; }

body .content-area .card,
body .content-area .setup-card {
    position: relative;
    max-width: none;
    margin-bottom: 20px;
    padding: clamp(18px, 2.2vw, 26px);
    overflow-x: auto;
    background: rgba(255, 255, 255, .96);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

body .content-area .card::before {
    content: "";
    position: absolute;
    inset-block: 22px;
    inset-inline-start: 0;
    width: 3px;
    background: #bfdbfe;
    border-radius: 0 4px 4px 0;
}

.content-area .card h2,
.content-area .card h3,
.content-area .setup-card h2 {
    margin: 0 0 18px;
    color: var(--color-foreground);
    font-size: 1rem;
    font-weight: 800;
}

body .content-area .grid { gap: 16px; margin-bottom: 20px; }
body .content-area .f label,
body .content-area .setup-grid label { margin-bottom: 7px; color: #334155; font-size: .78rem; font-weight: 700; }

body .content-area :where(input:not([type="checkbox"]), select, textarea),
body .login-wrap :where(input, select, textarea) {
    min-height: 46px;
    width: 100%;
    padding: 10px 13px;
    color: var(--color-foreground);
    background: white;
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, .025);
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

body .content-area :where(input:not([type="checkbox"]), select, textarea):hover,
body .login-wrap :where(input, select, textarea):hover { border-color: #94a3b8; }

body .content-area :where(input:not([type="checkbox"]), select, textarea):focus,
body .login-wrap :where(input, select, textarea):focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--color-primary); }

body .content-area button.btn,
body .content-area .setup-button,
body .content-area a.btn-link,
body .login-wrap button.btn,
body .wrap a.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    color: white;
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: 10px;
    box-shadow: 0 5px 14px rgba(37, 99, 235, .16);
    font-size: .88rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

body .content-area button.btn:hover:not(:disabled),
body .content-area .setup-button:hover:not(:disabled),
body .login-wrap button.btn:hover:not(:disabled) {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    box-shadow: 0 8px 20px rgba(37, 99, 235, .2);
    transform: translateY(-1px);
}

body .content-area button:disabled,
body .login-wrap button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

body .content-area button.mini {
    min-height: 38px;
    padding: 7px 12px;
    color: #1e40af;
    background: var(--color-primary-soft);
    border: 1px solid #dbeafe;
    border-radius: 9px;
    font-size: .76rem;
    font-weight: 700;
    cursor: pointer;
}

body .content-area table {
    width: 100%;
    min-width: 680px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .82rem;
}

body .content-area th {
    padding: 12px 14px;
    color: #475569;
    background: #f8fafc;
    border-block: 1px solid var(--color-border);
    font-size: .72rem;
    font-weight: 800;
    text-align: start;
    white-space: nowrap;
}

body .content-area th:first-child { border-start-start-radius: 10px; border-end-start-radius: 10px; }
body .content-area th:last-child { border-start-end-radius: 10px; border-end-end-radius: 10px; }
body .content-area td { padding: 13px 14px; color: #334155; border-bottom: 1px solid #edf2f7; font-size: .82rem; vertical-align: middle; }
body .content-area tbody tr { transition: background-color 140ms ease; }
body .content-area tbody tr:hover { background: #f8fbff; }

/* Shared administration pattern: compact forms, discoverable filters and safe record actions. */
.admin-page-head { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom:20px; }
.admin-page-head h1 { margin:0; color:var(--color-foreground); font-size:clamp(1.45rem, 2vw, 1.9rem); }
.admin-page-head p { margin:5px 0 0; color:var(--color-muted-foreground); font-size:.84rem; }
.admin-count { min-width:84px; padding:8px 12px; color:#1e40af; background:var(--color-primary-soft); border:1px solid #dbeafe; border-radius:999px; font-size:.76rem; font-weight:800; text-align:center; }
.admin-card-title { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; }
.admin-card-title h2 { margin:0; color:var(--color-foreground); font-size:1rem; }
.admin-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(185px,1fr)); gap:14px; margin-bottom:18px; align-items:end; }
.admin-field label { display:block; margin-bottom:7px; color:#334155; font-size:.76rem; font-weight:800; }
.admin-field input:not([type=checkbox]), .admin-field select { width:100%; min-height:42px; box-sizing:border-box; padding:9px 11px; color:var(--color-foreground); background:white; border:1px solid var(--color-border); border-radius:9px; font:inherit; font-size:.84rem; }
.admin-check { min-height:42px; display:flex; align-items:center; }
.admin-check label { display:flex; align-items:center; gap:8px; margin:0; cursor:pointer; }
.admin-check input { width:17px; height:17px; accent-color:var(--color-primary); }
.admin-form-actions, .admin-row-actions, .admin-pagination { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.admin-form-actions .btn { display:inline-flex; align-items:center; justify-content:center; gap:7px; }
.admin-secondary, .admin-table-action { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-height:38px; padding:7px 11px; color:#1e40af; background:white; border:1px solid #bfdbfe; border-radius:9px; font-size:.75rem; font-weight:800; cursor:pointer; transition:background-color 160ms ease, border-color 160ms ease, color 160ms ease; }
.admin-secondary:hover, .admin-table-action:hover { background:var(--color-primary-soft); border-color:#93c5fd; }
.admin-table-action.danger { color:#b91c1c; border-color:#fecaca; }
.admin-table-action.danger:hover { background:#fff1f2; border-color:#fca5a5; }
.admin-table-action.restore { color:#047857; border-color:#a7f3d0; }
.admin-table-action.restore:hover { background:#ecfdf5; border-color:#6ee7b7; }
.admin-toolbar { display:flex; align-items:end; justify-content:space-between; gap:12px; margin-bottom:16px; }
.admin-filters { flex:1; display:grid; grid-template-columns:minmax(220px, 1fr) minmax(150px, 190px); gap:10px; }
.admin-search { position:relative; }
.admin-search .app-icon { position:absolute; inset-inline-start:12px; top:50%; transform:translateY(-50%); color:#64748b; pointer-events:none; }
.admin-search input { padding-inline-start:40px !important; }
.table-wrap { width:100%; overflow-x:auto; border-radius:10px; }
.admin-status { display:inline-flex; align-items:center; gap:6px; padding:5px 9px; border-radius:999px; font-size:.7rem; font-weight:800; white-space:nowrap; }
.admin-status::before { content:""; width:6px; height:6px; border-radius:50%; background:currentColor; }
.admin-status.active { color:#047857; background:#ecfdf5; }
.admin-status.archived { color:#64748b; background:#f1f5f9; }
.admin-status.current { color:#1d4ed8; background:#eff6ff; }
.admin-confirm { display:flex; align-items:center; justify-content:space-between; gap:14px; margin:0 0 16px; padding:13px 14px; color:#9f1239; background:#fff1f2; border:1px solid #fecdd3; border-radius:11px; font-size:.82rem; font-weight:700; }
.admin-empty { padding:28px 16px; color:var(--color-muted-foreground); background:#f8fafc; border:1px dashed #cbd5e1; border-radius:11px; text-align:center; }
.admin-empty strong { display:block; margin-bottom:4px; color:#334155; }
.admin-pagination { justify-content:space-between; margin-top:16px; padding-top:14px; border-top:1px solid var(--color-border); color:var(--color-muted-foreground); font-size:.76rem; }
.admin-pagination-controls { display:flex; gap:7px; }
.admin-pagination button { min-width:38px; min-height:36px; color:#334155; background:white; border:1px solid var(--color-border); border-radius:8px; cursor:pointer; }
.admin-pagination button:hover:not(:disabled) { color:var(--color-primary); border-color:#93c5fd; background:var(--color-primary-soft); }
.admin-pagination button:disabled { opacity:.45; cursor:not-allowed; }
.admin-feedback { margin-bottom:16px; padding:12px 14px; border-radius:11px; font-size:.82rem; }
.admin-feedback.success { color:#047857; background:#ecfdf5; border:1px solid #a7f3d0; }
.visually-hidden { position:absolute !important; width:1px !important; height:1px !important; padding:0 !important; margin:-1px !important; overflow:hidden !important; clip:rect(0,0,0,0) !important; white-space:nowrap !important; border:0 !important; }

body .content-area :where(.err, .error-box) {
    padding: 12px 14px;
    color: #991b1b;
    background: var(--color-danger-soft);
    border: 1px solid #fecaca;
    border-radius: 11px;
    font-size: .84rem;
}

body .content-area .ok { color: var(--color-success); background: var(--color-success-soft); border: 1px solid #bbf7d0; border-radius: 11px; }
body .content-area .warn { color: var(--color-warning); background: var(--color-warning-soft); border: 1px solid #fde68a; border-radius: 11px; }
body .content-area .muted { color: var(--color-muted-foreground); }

body .content-area .tiles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

body .content-area .tile {
    min-height: 154px;
    display: grid;
    grid-template-columns: 52px 1fr;
    grid-template-rows: 1fr auto;
    align-items: start;
    gap: 8px 14px;
    padding: 22px;
    color: var(--color-foreground);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    transition: transform 190ms ease, box-shadow 190ms ease, border-color 190ms ease;
}

body .content-area .tile:hover { border-color: #bfdbfe; box-shadow: var(--shadow-md); transform: translateY(-3px); }
.tile-icon { grid-row: 1 / 3; width: 52px; height: 52px; display: grid; place-items: center; color: var(--color-primary); background: var(--color-primary-soft); border-radius: 14px; }
body .content-area .tile-num { align-self: end; color: var(--color-foreground); font-size: 2rem; font-weight: 800; line-height: 1; }
body .content-area .tile-lbl { color: var(--color-muted-foreground); font-size: .8rem; font-weight: 700; }

body .login-wrap {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    padding: 24px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #0b1220;
}

body .login-wrap::before,
body .login-wrap::after {
    content: "";
    position: absolute;
    z-index: -1;
    width: 32rem;
    height: 32rem;
    border-radius: 50%;
    filter: blur(2px);
}

body .login-wrap::before { inset: -14rem -10rem auto auto; background: radial-gradient(circle, rgba(37, 99, 235, .55), transparent 68%); }
body .login-wrap::after { inset: auto auto -17rem -10rem; background: radial-gradient(circle, rgba(234, 88, 12, .25), transparent 68%); }

body .login-card {
    width: min(100%, 430px);
    padding: clamp(28px, 5vw, 42px);
    color: var(--color-foreground);
    background: rgba(255, 255, 255, .98);
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 22px;
    box-shadow: 0 32px 90px rgba(0, 0, 0, .34);
    text-align: start;
}

body .login-logo {
    width: 62px;
    height: 62px;
    margin: 0 auto 20px;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(145deg, #3b82f6, #1d4ed8);
    border-radius: 18px;
    box-shadow: 0 14px 30px rgba(37, 99, 235, .25);
}

body .login-title { margin: 0; color: var(--color-foreground); font-size: 1.45rem; font-weight: 800; text-align: center; }
body .login-sub { margin: 6px 0 28px; color: var(--color-muted-foreground); font-size: .86rem; text-align: center; }
body .login-wrap .field { margin-bottom: 17px; text-align: start; }
body .login-wrap .field label { margin-bottom: 7px; color: #334155; font-size: .78rem; font-weight: 700; }
body .login-wrap button.btn { width: 100%; margin-top: 4px; }
body .login-wrap .error { color: #991b1b; background: var(--color-danger-soft); border: 1px solid #fecaca; }

#blazor-error-ui { z-index: 1000; color: #7c2d12; background: #fff7ed; border-top: 1px solid #fed7aa; }

@media (max-width: 1180px) {
    body .content-area .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 959px) {
    :root { --header-height: 66px; }
    body .app-shell { display: block; }
    .app-shell .sidebar {
        position: fixed;
        inset: 0 0 0 auto;
        width: min(86vw, 300px);
        height: 100dvh;
        transform: translateX(105%);
        transition: transform 220ms ease;
        box-shadow: -24px 0 60px rgba(2, 6, 23, .28);
    }
    .app-shell.menu-open .sidebar { transform: translateX(0); }
    .mobile-menu-button { display: grid; }
    .nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 40;
        display: block;
        width: 100%;
        height: 100%;
        padding: 0;
        background: rgba(2, 6, 23, .48);
        border: 0;
        backdrop-filter: blur(2px);
        cursor: pointer;
    }
    .main-col .scope-bar { padding-inline: 14px; }
    .scope-heading { min-width: 0; }
}

@media (max-width: 640px) {
    .main-col .content-area { padding: 18px 14px 28px; }
    .scope-context { display: none; }
    .scope-heading { margin-inline-end: auto; }
    body .content-area .tiles { grid-template-columns: 1fr; }
    body .content-area .tile { min-height: 124px; }
    body .content-area .grid { grid-template-columns: 1fr; }
    body .content-area .hdr { align-items: stretch; }
    body .content-area .search { min-width: 100%; }
    body .content-area button.btn,
    body .content-area .setup-button { width: 100%; }
    .admin-page-head, .admin-toolbar, .admin-confirm { align-items:stretch; flex-direction:column; }
    .admin-count { align-self:flex-start; }
    .admin-filters { grid-template-columns:1fr; }
    .admin-form-actions > *, .admin-confirm .admin-row-actions > * { flex:1; }
    .admin-pagination { align-items:stretch; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
/* ========================================================
   Page Guide & Help System
   ======================================================== */

.scope-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-inline-start: 12px;
}

.scope-guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px 5px 10px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    color: #1d4ed8;
    font-size: 0.82rem;
    font-weight: 750;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.08);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.scope-guide-btn:hover {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-color: #93c5fd;
    color: #1e40af;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.16);
}

.scope-guide-btn:active {
    transform: translateY(0);
}

.scope-guide-btn .guide-btn-icon {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    background: #2563eb;
    color: white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
    flex-shrink: 0;
}

.floating-guide-trigger {
    position: fixed;
    bottom: 24px;
    inset-inline-start: 24px;
    z-index: 95;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px 10px 12px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.86rem;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4), 0 2px 6px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.floating-guide-trigger:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 14px 32px rgba(37, 99, 235, 0.5);
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.floating-guide-trigger:active {
    transform: translateY(0) scale(0.97);
}

.floating-icon-wrap {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    flex-shrink: 0;
}

.page-inline-guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    color: #1d4ed8;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
}

.page-inline-guide-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
    transform: translateY(-1px);
}

/* Page Guide Drawer Overlay */
.guide-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    justify-content: flex-start;
    align-items: stretch;
    animation: guideFadeIn 0.2s ease;
}

.guide-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(5px);
    cursor: pointer;
}

.guide-drawer {
    position: relative;
    z-index: 10;
    width: min(520px, 94vw);
    height: 100vh;
    background: #ffffff;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: guideSlideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

[dir="rtl"] .guide-drawer {
    border-inline-end: 1px solid #e2e8f0;
}

.guide-drawer-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 22px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #f8fafc, #ffffff);
}

.guide-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    display: grid;
    place-items: center;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
    flex-shrink: 0;
}

.guide-header-text {
    flex: 1;
    min-width: 0;
}

.guide-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.guide-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 750;
}

.guide-path-tag {
    font-family: monospace;
    font-size: 0.72rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 7px;
    border-radius: 6px;
    direction: ltr;
    font-weight: 600;
}

.guide-drawer-title {
    margin: 0;
    font-size: 1.18rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.3;
}

.guide-close-btn {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.guide-close-btn:hover {
    background: #fee2e2;
    border-color: #fecaca;
    color: #dc2626;
}

.guide-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.guide-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.guide-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.guide-section-head h3 {
    margin: 0;
    font-size: 0.94rem;
    font-weight: 800;
    color: #1e293b;
}

.guide-head-icon {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.guide-head-icon.target-icon {
    background: #eff6ff;
    color: #2563eb;
}

.guide-head-icon.steps-icon {
    background: #f0fdf4;
    color: #16a34a;
}

.guide-head-icon.tips-icon {
    background: #fffbeb;
    color: #d97706;
}

.guide-head-icon.links-icon {
    background: #f5f3ff;
    color: #7c3aed;
}

.guide-summary-card {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border: 1px solid #bae6fd;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.08);
}

.guide-summary-text {
    margin: 0;
    color: #0369a1;
    font-size: 0.88rem;
    line-height: 1.6;
    font-weight: 600;
}

.guide-steps-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.guide-step-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.guide-step-item:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.guide-step-number {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    display: grid;
    place-items: center;
    font-size: 0.78rem;
    font-weight: 800;
    flex-shrink: 0;
    margin-top: 1px;
}

.guide-step-content {
    flex: 1;
    color: #334155;
    font-size: 0.86rem;
    line-height: 1.55;
    font-weight: 550;
}

.guide-tips-card {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 14px;
    padding: 14px 16px;
}

.guide-tips-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guide-tip-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: #92400e;
    font-size: 0.83rem;
    line-height: 1.5;
    font-weight: 600;
}

.guide-tip-bullet {
    color: #d97706;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.guide-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.guide-link-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #4338ca;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: start;
}

.guide-link-btn:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #3730a3;
    transform: translateX(-2px);
}

.guide-link-arrow {
    color: #a5b4fc;
}

.guide-drawer-footer {
    padding: 16px 22px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

.guide-btn-primary {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
    transition: all 0.2s ease;
}

.guide-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.38);
    transform: translateY(-1px);
}

.guide-btn-primary:active {
    transform: translateY(0);
}

@keyframes guideFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes guideSlideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

[dir="rtl"] @keyframes guideSlideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@media print {
    .sidebar, .scope-bar, .mobile-menu-button, .nav-backdrop { display: none !important; }
    .content-area { max-width: none !important; padding: 0 !important; }
    body { background: white !important; }
    body .content-area .card { border: 0; box-shadow: none; }
}
