:root {
    --ink: #122029;
    --ink-soft: #5d6e78;
    --line: #e3eaee;
    --paper: #f3f6f8;
    --panel: #ffffff;
    --side: #0c1820;
    --side-text: #d7e3e8;
    --side-muted: #8ea3ae;
    --accent: #0f766e;
    --accent-strong: #0f5f59;
    --danger: #9f2d2d;
    --ok: #157a45;
    --warn: #8a5a12;
    --shadow: 0 1px 2px rgba(16, 33, 43, .05), 0 8px 24px rgba(16, 33, 43, .04);
    --sidebar: 260px;
    --radius: 16px;
    --font: "Segoe UI", "Noto Naskh Arabic", "Geeza Pro", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(900px 420px at 100% -10%, rgba(15, 118, 110, .06), transparent 60%),
        var(--paper);
    font-size: 15px;
    line-height: 1.5;
    font-feature-settings: "ss01" on, "tnum" on;
}

::selection { background: rgba(15, 118, 110, .18); }

a { color: var(--accent-strong); text-underline-offset: 2px; }

.shell {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    min-height: 100vh;
}

.shell-side {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 180px),
        var(--side);
    color: var(--side-text);
    display: flex;
    flex-direction: column;
    padding: 18px 12px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 0;
}

.side-scroll {
    overflow: auto;
    flex: 1;
    min-height: 0;
    padding-inline-end: 2px;
}

.side-scroll::-webkit-scrollbar { width: 8px; }
.side-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 99px; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 10px 16px;
    text-decoration: none;
    color: white;
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    object-fit: cover;
    background: white;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(160deg, #2dd4bf, #0f766e);
    display: grid;
    place-items: center;
    font-weight: 700;
    letter-spacing: .04em;
    font-size: 13px;
    color: white;
    box-shadow: 0 8px 18px rgba(15, 118, 110, .35);
}

.brand-name { font-weight: 700; letter-spacing: .08em; font-size: 14px; }
.brand-sub { display: block; color: var(--side-muted); font-size: 12px; letter-spacing: 0; font-weight: 450; margin-top: 1px; }

.nav-label {
    margin: 14px 12px 6px;
    color: var(--side-muted);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.shell-nav { display: flex; flex-direction: column; gap: 2px; }

.shell-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--side-text);
    text-decoration: none;
    border-radius: 11px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
}

.shell-nav a svg { flex: 0 0 auto; opacity: .8; }

.shell-nav a:hover { background: rgba(255, 255, 255, .06); color: white; }

.shell-nav a.is-active {
    background: rgba(45, 212, 191, .14);
    color: white;
    box-shadow: inset 3px 0 0 #2dd4bf;
}

html[dir="rtl"] .shell-nav a.is-active { box-shadow: inset -3px 0 0 #2dd4bf; }

.side-foot {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.side-user { padding: 6px 12px 10px; }
.side-user strong { display: block; color: white; font-size: 14px; }
.side-user span { color: var(--side-muted); font-size: 12px; }

.side-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 8px; }

.side-actions a {
    color: var(--side-text);
    text-decoration: none;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 999px;
    padding: 5px 10px;
}

.side-actions a:hover { color: white; border-color: rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .04); }

.shell-main { min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 32px 14px;
    position: sticky;
    top: 0;
    z-index: 8;
    background: color-mix(in srgb, var(--paper) 82%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid transparent;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 650;
    letter-spacing: -.03em;
}

.topbar p { margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }

.top-search { margin-inline-start: auto; position: relative; }

.top-search input {
    width: min(280px, 36vw);
    min-height: 40px;
    padding-inline-start: 36px;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235d6e78' stroke-width='1.8' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='6'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px 50%,
        white;
}

html[dir="rtl"] .top-search input {
    background-position: right 12px center;
}

.shell-toggle {
    display: none;
    border: 1px solid var(--line);
    background: white;
    border-radius: 12px;
    width: 40px;
    height: 40px;
}

.page { padding: 8px 32px 56px; overflow-wrap: anywhere; }

.page > .h5,
.page h2.h5 {
    margin: 28px 0 12px;
    font-size: 13px;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.flash { margin-bottom: 16px; border: 0; border-radius: 12px; }

.alert-success { background: #e8f6ef; color: #0f5b34; }
.alert-danger { background: #fdecec; color: #8d2424; }

.auth-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(280px, 42%) 1fr;
}

.auth-panel {
    background:
        radial-gradient(500px 280px at 20% 0%, rgba(45, 212, 191, .2), transparent 60%),
        var(--side);
    color: white;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-panel h2 { font-size: 36px; line-height: 1.15; font-weight: 650; letter-spacing: -.03em; margin: 24px 0 12px; }
.auth-panel p { color: #c5d2d8; max-width: 36ch; }

.auth-form {
    display: grid;
    place-items: center;
    padding: 32px 20px;
}

.auth-card {
    width: min(440px, 100%);
    background: white;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.auth-card h1 { font-size: 26px; margin: 0 0 18px; letter-spacing: -.02em; }

.kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px 14px;
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.kpi::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 99px;
    background: var(--accent);
}

a.kpi:hover { border-color: #b7d4cf; transform: translateY(-1px); }

.kpi span { display: block; color: var(--ink-soft); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.kpi strong { display: block; margin-top: 6px; font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: -.04em; font-weight: 650; }
.kpi em { font-style: normal; color: var(--accent); font-size: 12px; }

.board {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, .85fr);
    gap: 14px;
    align-items: start;
}

.panel, .card, .table {
    background: var(--panel);
    border: 1px solid var(--line) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card.card-body { padding: 18px; }

.card .h6,
.card h2.h6 {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }

.panel-body { padding: 6px 16px 12px; }

.row-line {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

.row-line:last-child { border-bottom: 0; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .04em;
    background: #eef3f6;
    color: var(--ink);
    text-transform: uppercase;
}

.badge.warn { background: #f8efdf; color: var(--warn); }
.badge.ok { background: #e7f6ee; color: var(--ok); }
.badge.danger { background: #fdecec; color: var(--danger); }

.empty { color: var(--ink-soft); padding: 16px 0; margin: 0; }

.table { overflow: hidden; margin-bottom: 0; }

.table > :not(caption) > * > * {
    padding: 12px 14px;
    border-bottom-color: var(--line);
    vertical-align: middle;
}

.table thead th {
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    font-weight: 650;
    background: #f7fafb;
    border-bottom: 1px solid var(--line);
}

.table tbody tr:hover { background: #f6fbfa; }

.btn {
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.btn-sm { border-radius: 8px; }

.btn-dark, .btn-dark:hover, .btn-dark:focus, .btn-dark:active {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn-outline-dark {
    color: var(--ink);
    background: white;
    border-color: #cfd9df;
}

.btn-outline-dark:hover, .btn-outline-dark:focus {
    color: var(--ink);
    background: #f4f8f8;
    border-color: #a9bcc4;
}

.form-control, .form-select {
    border-color: #d5dee4;
    border-radius: 10px;
    min-height: 40px;
    background-color: white;
}

.form-control-sm, .form-select-sm { min-height: 34px; border-radius: 8px; }

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .16);
}

.form-control::placeholder { color: #8b9aa3; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}

@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .board { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .shell-side {
        position: fixed;
        z-index: 30;
        width: min(86vw, 320px);
        inset-inline-start: 0;
        top: 0;
        transform: translateX(-105%);
        transition: transform .18s ease;
    }
    html[dir="rtl"] .shell-side { transform: translateX(105%); }
    .shell-side.is-open,
    html[dir="rtl"] .shell-side.is-open { transform: none; }
    .shell-toggle { display: inline-grid; place-items: center; }
    .topbar, .page { padding-inline: 16px; }
    .top-search { width: 100%; }
    .top-search input { width: 100%; }
    .topbar { flex-wrap: wrap; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-panel { display: none; }
    .kpis { grid-template-columns: 1fr; }
    .scrim {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(12, 24, 32, .48);
        z-index: 20;
    }
    .scrim.is-open { display: block; }
}
