:root {
    --color-primary: #1e40af;
    --color-primary-hover: #1d4ed8;
    --color-sidebar: #0f172a;
    --color-sidebar-active: #1e293b;
    --color-success: #059669;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-bg: #f1f5f9;
    --color-card: #ffffff;
    --color-border: #e5e7eb;
    --shadow-card: 0 14px 35px rgba(15, 23, 42, 0.08);
}

html {
    font-family: "Noto Kufi Arabic", sans-serif;
    min-height: 100%;
    background: var(--color-bg);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--color-bg);
    font-family: "Noto Kufi Arabic", sans-serif;
    letter-spacing: 0;
    overflow-x: hidden;
}

input,
button,
select,
textarea {
    font: inherit;
}

a,
button {
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(30, 64, 175, 0.22);
    outline-offset: 2px;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(circle at top left, rgba(30, 64, 175, 0.10), transparent 28rem),
        var(--color-bg);
}

.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 40;
    width: 17.5rem;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--color-sidebar) 0%, #111827 100%);
    color: #e5e7eb;
    padding: 1.25rem;
    box-shadow: -18px 0 45px rgba(15, 23, 42, 0.22);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    padding-bottom: 1.2rem;
}

.brand-mark {
    display: grid;
    width: 3.1rem;
    height: 3.1rem;
    place-items: center;
    border-radius: 0.9rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-success));
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
}

.sidebar-brand p {
    color: #94a3b8;
    font-size: 0.78rem;
    font-weight: 700;
}

.sidebar-brand strong {
    display: block;
    margin-top: 0.15rem;
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
}

.sidebar-nav {
    display: grid;
    gap: 0.35rem;
    margin-top: 1.25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    border-radius: 0.8rem;
    color: #cbd5e1;
    font-size: 0.93rem;
    font-weight: 700;
    padding: 0.75rem 0.95rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
    background: var(--color-sidebar-active);
    color: #fff;
}

.sidebar-nav a.is-active {
    box-shadow: inset -3px 0 0 var(--color-success);
}

.sidebar-section {
    margin: 1rem 0 0.2rem;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 800;
}

.app-workspace {
    width: 100%;
    min-width: 0;
    padding-inline-start: 17.5rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4.75rem;
    border-bottom: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.92);
    padding: max(0.85rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) 0.85rem max(1.5rem, env(safe-area-inset-left));
    backdrop-filter: blur(18px);
}

.topbar-title span {
    display: block;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
}

.topbar-title strong {
    display: block;
    margin-top: 0.15rem;
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 800;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.language-switcher {
    display: inline-flex;
    gap: 0.25rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: #fff;
    padding: 0.2rem;
}

.language-switcher button {
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 800;
}

.language-switcher button.is-active {
    background: var(--color-primary);
    color: #fff;
}

.user-chip {
    min-width: 9rem;
    border: 1px solid var(--color-border);
    border-radius: 0.9rem;
    background: #fff;
    padding: 0.45rem 0.75rem;
}

.user-chip span,
.user-chip b {
    display: block;
    line-height: 1.45;
}

.user-chip span {
    color: #0f172a;
    font-size: 0.86rem;
    font-weight: 800;
}

.user-chip b {
    color: var(--color-primary);
    font-size: 0.72rem;
}

.mobile-menu-btn {
    display: none;
    width: 2.65rem;
    height: 2.65rem;
    border: 1px solid var(--color-border);
    border-radius: 0.8rem;
    background: #fff;
    padding: 0.55rem;
}

.mobile-menu-btn span {
    display: block;
    height: 2px;
    margin: 5px 0;
    border-radius: 999px;
    background: #0f172a;
}

.app-content {
    padding: 1.5rem max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
}

.has-shell .app-content > .min-h-screen {
    min-height: auto;
    background: transparent !important;
}

.has-shell .app-content > .min-h-screen > header {
    display: none;
}

.has-shell .app-content main {
    max-width: 100% !important;
    padding: 0 !important;
}

.card,
.has-shell section.rounded,
.has-shell article.rounded,
.has-shell form.rounded {
    border-color: var(--color-border) !important;
    border-radius: 1rem !important;
    background: var(--color-card) !important;
    box-shadow: var(--shadow-card) !important;
}

.section-title {
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 800;
}

.btn,
.has-shell a.rounded,
.has-shell button.rounded {
    border-radius: 0.75rem !important;
    font-weight: 800 !important;
    min-height: 2.75rem;
}

.btn-primary,
.has-shell a.bg-emerald-800,
.has-shell button.bg-emerald-800 {
    background: var(--color-primary) !important;
    color: #fff !important;
}

.btn-primary:hover,
.has-shell a.bg-emerald-800:hover,
.has-shell button.bg-emerald-800:hover {
    background: var(--color-primary-hover) !important;
}

.btn-secondary,
.has-shell a.border,
.has-shell button.border {
    border-color: var(--color-border) !important;
    background: #fff !important;
    color: #334155 !important;
}

.btn-secondary:hover,
.has-shell a.border:hover,
.has-shell button.border:hover {
    border-color: var(--color-primary) !important;
    color: var(--color-primary) !important;
}

.btn-danger,
.has-shell button.text-red-700,
.has-shell a.text-red-700 {
    color: var(--color-danger) !important;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 800;
}

.table-modern,
.has-shell table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.has-shell .overflow-x-auto,
.has-shell section,
.has-shell article,
.has-shell form {
    max-width: 100%;
}

.has-shell section:has(table),
.has-shell article:has(table) {
    overflow-x: auto;
}

.has-shell thead,
.table-modern thead {
    background: #f8fafc !important;
}

.has-shell th,
.table-modern th {
    color: #475569 !important;
    font-size: 0.78rem !important;
    letter-spacing: 0;
}

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

.form-control,
.has-shell input,
.has-shell select,
.has-shell textarea {
    border-color: #cbd5e1 !important;
    border-radius: 0.8rem !important;
    background-color: #fff;
}

.has-shell input:focus,
.has-shell select:focus,
.has-shell textarea:focus {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.12) !important;
}

.empty-state {
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    background: #f8fafc;
    padding: 2rem;
    text-align: center;
    color: #64748b;
}

.install-prompt {
    position: fixed;
    inset-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 48rem;
    margin-inline: auto;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.96);
    padding: 1rem;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(16px);
}

.install-prompt[hidden] {
    display: none;
}

.install-prompt strong,
.install-prompt span {
    display: block;
}

.install-prompt strong {
    color: #0f172a;
    font-size: 0.95rem;
    font-weight: 800;
}

.install-prompt span {
    margin-top: 0.25rem;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.8;
}

.install-prompt-actions {
    display: flex;
    flex-shrink: 0;
    gap: 0.5rem;
}

.guest-page {
    background:
        radial-gradient(circle at 15% 10%, rgba(30, 64, 175, 0.16), transparent 22rem),
        radial-gradient(circle at 85% 20%, rgba(5, 150, 105, 0.12), transparent 20rem),
        var(--color-bg);
}

.guest-page section.rounded {
    border-radius: 1.25rem !important;
    box-shadow: var(--shadow-card) !important;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(110%);
        transition: transform 0.2s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 35;
        display: none;
        background: rgba(15, 23, 42, 0.45);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .app-workspace {
        padding-inline-start: 0;
    }

    .mobile-menu-btn {
        display: block;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-user {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

@media (max-width: 640px) {
    .app-content {
        padding: 1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    }

    .topbar {
        padding: max(0.75rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.75rem max(1rem, env(safe-area-inset-left));
    }

    .topbar-title span {
        display: none;
    }

    .user-chip {
        display: none;
    }

    .topbar {
        flex-wrap: wrap;
    }

    .topbar-user {
        width: 100%;
    }

    .topbar-user .btn,
    .language-switcher {
        min-height: 2.75rem;
    }

    .has-shell table {
        min-width: 42rem;
    }

    .install-prompt {
        align-items: stretch;
        flex-direction: column;
    }

    .install-prompt-actions {
        width: 100%;
    }

    .install-prompt-actions button {
        flex: 1;
    }
}

@media print {
    @page {
        size: A4;
        margin: 14mm 12mm;
    }

    .sidebar,
    .topbar,
    .sidebar-backdrop,
    header,
    form,
    .print\:hidden {
        display: none !important;
    }

    .app-shell,
    .app-workspace,
    .app-content,
    .has-shell .app-content > .min-h-screen {
        display: block !important;
        min-height: auto !important;
        background: #fff !important;
        padding: 0 !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
    }

    article {
        break-inside: avoid;
    }

    .official-print,
    .official-print * {
        color: #000 !important;
        box-shadow: none !important;
    }

    .official-table thead {
        background: #f3f4f6 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .official-table tr,
    .print-section,
    .signature-area {
        break-inside: avoid;
    }
}
