/* ==========================================================================
   Nexo Flow — design system
   RTL Persian project & client portal
   ========================================================================== */

@font-face {
    font-family: 'Vazirmatn FD';
    src: url('../fonts/Vazirmatn-FD-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn FD';
    src: url('../fonts/Vazirmatn-FD-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn FD';
    src: url('../fonts/Vazirmatn-FD-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn FD';
    src: url('../fonts/Vazirmatn-FD-ExtraBold.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #F5F8F5;
    --bg-soft: #ECF2EC;
    --surface: #FFFFFF;
    --surface-2: #F8FAF8;
    --surface-3: #F1F6F2;
    --text: #12201A;
    --muted: #687A71;
    --muted-2: #91A099;
    --line: #E1E8E1;
    --line-strong: #CFD9CF;
    --primary: #0F8A6A;
    --primary-hover: #0B7258;
    --primary-soft: #E4F4EE;
    --primary-ink: #0A5A45;
    --on-primary: #FFFFFF;
    --accent: #D89A2B;
    --accent-soft: #FBF2DD;
    --accent-ink: #8A5C0D;
    --danger: #C64B4B;
    --danger-soft: #FBEAEA;
    --danger-ink: #8E2F2F;
    --warning: #B57A1C;
    --warning-soft: #FCF2DF;
    --warning-ink: #7E530F;
    --info: #2F7E9A;
    --info-soft: #E7F2F7;
    --info-ink: #205C72;
    --violet: #6B5BD2;
    --violet-soft: #EFEDFB;
    --violet-ink: #493C9E;
    --slate: #5A6A62;
    --slate-soft: #EDF1EF;
    --slate-ink: #3D4A44;
    --sidebar: #0D1F19;
    --sidebar-2: #122A21;
    --sidebar-text: #E7F1EC;
    --sidebar-muted: #8FA79C;
    --radius-sm: 9px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --shadow-sm: 0 1px 2px rgb(12 42 31 / .05);
    --shadow: 0 10px 34px rgb(13 52 38 / .07);
    --shadow-lg: 0 24px 60px rgb(8 34 25 / .18);
    --font: 'Vazirmatn FD', 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    --sidebar-w: 268px;
    --header-h: 70px;
    --ease: cubic-bezier(.2, 0, 0, 1);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0A1411;
    --bg-soft: #101E19;
    --surface: #111E19;
    --surface-2: #14241E;
    --surface-3: #182B23;
    --text: #E9F1ED;
    --muted: #97A9A1;
    --muted-2: #74877E;
    --line: #21352D;
    --line-strong: #2D463B;
    --primary: #3EC99E;
    --primary-hover: #62D9B5;
    --primary-soft: #15382C;
    --primary-ink: #B7F2DE;
    --on-primary: #06251C;
    --accent: #E7B050;
    --accent-soft: #33280F;
    --accent-ink: #F5D794;
    --danger: #E36B6B;
    --danger-soft: #3A1C1C;
    --danger-ink: #F5B5B5;
    --warning: #DDA94B;
    --warning-soft: #33270F;
    --warning-ink: #F1D395;
    --info: #6FB6CE;
    --info-soft: #142D36;
    --info-ink: #B7E2F0;
    --violet: #9A8BF0;
    --violet-soft: #251F45;
    --violet-ink: #CFC7FF;
    --slate: #9AABA2;
    --slate-soft: #1B2A24;
    --slate-ink: #CCD8D2;
    --sidebar: #08130F;
    --sidebar-2: #0D1F19;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .3);
    --shadow: 0 12px 36px rgb(0 0 0 / .35);
    --shadow-lg: 0 28px 70px rgb(0 0 0 / .5);
}

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.35; font-weight: 800; letter-spacing: -.01em; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

::selection { background: var(--primary-soft); color: var(--primary-ink); }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.skip-link {
    position: fixed;
    inset-block-start: -100px;
    inset-inline-start: 16px;
    z-index: 200;
    background: var(--surface);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    font-weight: 700;
}
.skip-link:focus { inset-block-start: 12px; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 800; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: embed; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--primary); }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 28px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 28px; }
.w-100 { width: 100%; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

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

.sidebar {
    background:
        radial-gradient(600px 300px at 80% -5%, rgb(39 160 123 / .18), transparent 60%),
        linear-gradient(180deg, var(--sidebar-2), var(--sidebar));
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 20px 14px 16px;
    position: sticky;
    inset-block-start: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgb(255 255 255 / .12) transparent;
    z-index: 40;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: rgb(255 255 255 / .14); border-radius: 99px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: 8px;
    margin-bottom: 22px;
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; }
.brand:hover { color: inherit; }
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: #07251C;
    background: linear-gradient(135deg, #A8F0D4, #4ED0A4 55%, #A8F0D4);
    box-shadow: 0 6px 18px rgb(62 201 158 / .25);
    flex: none;
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text b { font-size: 16.5px; font-weight: 800; letter-spacing: -.01em; }
.brand-text small { font-size: 9.5px; letter-spacing: .22em; color: var(--sidebar-muted); font-weight: 700; }

.sidebar-close { display: none; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
    font-size: 10.5px;
    letter-spacing: .08em;
    color: var(--sidebar-muted);
    font-weight: 700;
    padding: 16px 12px 6px;
}
.nav-label:first-child { padding-top: 2px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 9px 12px;
    border-radius: 11px;
    color: rgb(231 241 236 / .74);
    font-size: 14px;
    font-weight: 500;
    transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
    position: relative;
}
.nav-item .icon { width: 19px; height: 19px; opacity: .9; }
.nav-item:hover { background: rgb(255 255 255 / .06); color: #fff; }
.nav-item.is-active {
    background: linear-gradient(135deg, #16835F, #0E6A4D);
    color: #fff;
    box-shadow: 0 8px 20px rgb(7 70 50 / .28);
}
.nav-item.is-active::before {
    content: "";
    position: absolute;
    inset-inline-start: -14px;
    inset-block: 10px;
    width: 3px;
    border-radius: 3px;
    background: #7FE7C3;
}
.nav-badge {
    margin-inline-start: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 99px;
    background: #E7B050;
    color: #33230A;
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.nav-badge--soft { background: rgb(255 255 255 / .13); color: #fff; }
.nav-item.is-active .nav-badge { background: rgb(255 255 255 / .2); color: #fff; }

.sidebar-foot {
    margin-top: auto;
    padding-top: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid rgb(255 255 255 / .08);
}
.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    padding: 7px;
    border-radius: 12px;
    color: var(--sidebar-text);
}
.user-card:hover { background: rgb(255 255 255 / .05); color: #fff; }
.user-card-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.user-card-text b { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-text small { font-size: 11px; color: var(--sidebar-muted); }
.logout-form { flex: none; }
.icon-btn--dark { color: var(--sidebar-muted); }
.icon-btn--dark:hover { background: rgb(255 255 255 / .08); color: #fff; }

.sidebar-overlay { display: none; }

.app-main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--header-h);
    padding: 0 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    border-bottom: 1px solid var(--line);
    position: sticky;
    inset-block-start: 0;
    z-index: 30;
    backdrop-filter: blur(14px);
}
.topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-menu { display: none; }
.topbar-crumb { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.topbar-site { color: var(--muted); white-space: nowrap; }
.topbar-sep { color: var(--line-strong); }
.topbar-title { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-tools { display: flex; align-items: center; gap: 7px; }
.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 300px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 99px;
    background: var(--surface);
    color: var(--muted);
    transition: border-color .18s, box-shadow .18s;
}
.topbar-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.topbar-search .icon { width: 17px; height: 17px; }
.topbar-search input { border: 0; background: transparent; outline: 0; flex: 1; min-width: 0; font-size: 12.5px; }
.topbar-search input::placeholder { color: var(--muted-2); }
.topbar-search kbd {
    font-family: inherit;
    font-size: 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 5px;
    color: var(--muted-2);
    background: var(--surface-2);
}
.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    display: inline-grid;
    place-items: center;
    transition: background .18s, color .18s, border-color .18s;
    text-decoration: none;
    flex: none;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--text); }
.icon-btn .icon { width: 19px; height: 19px; }
.icon-btn--sm { width: 34px; height: 34px; border-radius: 9px; }
.icon-btn--sm .icon { width: 16px; height: 16px; }

[data-theme-toggle] .icon-moon { display: none; }
html[data-theme="dark"] [data-theme-toggle] .icon-sun { display: none; }
html[data-theme="dark"] [data-theme-toggle] .icon-moon { display: block; }

.notif-btn { position: relative; }
.notif-dot {
    position: absolute;
    inset-block-start: 8px;
    inset-inline-end: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--bg);
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    border-radius: 99px;
    color: var(--text);
    margin-inline-start: 4px;
}
.topbar-user:hover { background: var(--surface); color: var(--text); }
.topbar-user-name { font-size: 12.5px; font-weight: 700; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: color-mix(in srgb, var(--avatar, #0F8A6A) 16%, var(--surface));
    color: var(--avatar, #0F8A6A);
    border: 1px solid color-mix(in srgb, var(--avatar, #0F8A6A) 26%, transparent);
    font-weight: 800;
    font-size: 14px;
    flex: none;
    line-height: 1;
}
.avatar--sm { width: 30px; height: 30px; font-size: 12px; }
.avatar--lg { width: 54px; height: 54px; font-size: 19px; }
.avatar-stack { display: flex; flex-direction: row-reverse; }
.avatar-stack .avatar { margin-inline-start: -8px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar:last-child { margin-inline-start: 0; }

.page {
    width: 100%;
    max-width: 1460px;
    margin: 0 auto;
    padding: 28px 30px 48px;
    flex: 1;
}
.page--wide { max-width: 1600px; }
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-width: 70ch; }
.page-head-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-ink);
    background: var(--primary-soft);
    padding: 4px 9px;
    border-radius: 999px;
    margin-bottom: 9px;
}
.app-footer {
    margin-top: 48px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted-2);
    font-size: 11.5px;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Layout helpers
   -------------------------------------------------------------------------- */

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid--main-side { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.stack--sm { gap: 10px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}
.card--pad { padding: 22px; }
.card--flush { overflow: hidden; }
.card--soft { background: var(--surface-2); }
.card--dashed { border-style: dashed; box-shadow: none; background: transparent; }
.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 0;
}
.card--pad .card-head { padding: 0; }
.card-title { font-size: 15.5px; font-weight: 800; letter-spacing: -.01em; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-body { padding: 18px 20px 20px; }
.card--pad .card-body { padding: 14px 0 0; }
.card-foot {
    padding: 13px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 13px;
}
.section-title h2 { font-size: 17px; }
.section-title a { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 0 17px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition: background .18s var(--ease), border-color .18s, color .18s, transform .18s, box-shadow .18s;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn .icon { width: 17px; height: 17px; }
.btn--primary {
    background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 82%, #06392A));
    color: var(--on-primary);
    box-shadow: 0 7px 18px color-mix(in srgb, var(--primary) 28%, transparent);
}
.btn--primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn--secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn--secondary:hover { border-color: var(--primary); color: var(--primary-ink); background: var(--primary-soft); }
.btn--ghost { color: var(--muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--danger-soft); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--ai {
    background: linear-gradient(135deg, #0E6B52, #0F8A6A 60%, #B88322);
    color: #fff;
    box-shadow: 0 8px 22px rgb(15 138 106 / .22);
}
.btn--ai:hover { color: #fff; filter: brightness(1.05); }
.btn--sm { min-height: 34px; padding: 0 12px; border-radius: 9px; font-size: 12px; }
.btn--sm .icon { width: 15px; height: 15px; }
.btn--lg { min-height: 48px; padding: 0 24px; font-size: 14.5px; border-radius: 14px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .65; pointer-events: none; }
.btn.is-loading::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

.link-btn {
    border: 0;
    background: none;
    padding: 0;
    color: var(--primary);
    font-size: inherit;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.link-btn:hover { color: var(--primary-hover); text-decoration: underline; }

/* --------------------------------------------------------------------------
   Badges, chips, avatars
   -------------------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.45;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; opacity: .9; }
.badge--green { background: var(--primary-soft); color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 16%, transparent); }
.badge--amber { background: var(--warning-soft); color: var(--warning-ink); border-color: color-mix(in srgb, var(--warning) 18%, transparent); }
.badge--red { background: var(--danger-soft); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger) 18%, transparent); }
.badge--blue { background: var(--info-soft); color: var(--info-ink); border-color: color-mix(in srgb, var(--info) 16%, transparent); }
.badge--violet { background: var(--violet-soft); color: var(--violet-ink); border-color: color-mix(in srgb, var(--violet) 16%, transparent); }
.badge--slate { background: var(--slate-soft); color: var(--slate-ink); border-color: color-mix(in srgb, var(--slate) 14%, transparent); }
.badge--outline { background: transparent; color: var(--muted); border-color: var(--line-strong); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 99px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    transition: border-color .18s, background .18s, color .18s;
}
.chip:hover, .chip.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); }
.chip .icon { width: 15px; height: 15px; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; gap: 2px; }
.segmented a, .segmented button {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------------------
   KPI + hero + charts
   -------------------------------------------------------------------------- */

.kpi { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary-ink);
    flex: none;
}
.kpi-icon .icon { width: 19px; height: 19px; }
.kpi-icon--amber { background: var(--warning-soft); color: var(--warning-ink); }
.kpi-icon--red { background: var(--danger-soft); color: var(--danger-ink); }
.kpi-icon--blue { background: var(--info-soft); color: var(--info-ink); }
.kpi-icon--violet { background: var(--violet-soft); color: var(--violet-ink); }
.kpi-value { font-size: 29px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-foot { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.kpi-foot .icon { width: 13px; height: 13px; }
.kpi--alert .kpi-value { color: var(--danger); }

.hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    padding: 26px;
    background:
        radial-gradient(540px 280px at 92% 4%, rgb(86 221 176 / .28), transparent 58%),
        radial-gradient(420px 300px at 6% 100%, rgb(216 154 43 / .18), transparent 55%),
        linear-gradient(135deg, #0B3B2D, #0D2A21 55%, #0A1F19);
    color: #F0FBF6;
    border: 1px solid rgb(255 255 255 / .08);
    box-shadow: 0 22px 50px rgb(6 40 29 / .2);
}
.hero::after {
    content: "";
    position: absolute;
    inset-inline-end: -80px;
    inset-block-start: -90px;
    width: 280px;
    height: 280px;
    border: 1px solid rgb(255 255 255 / .1);
    border-radius: 50%;
    pointer-events: none;
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 22px; align-items: center; position: relative; z-index: 1; }
.hero h1, .hero h2 { color: #fff; font-size: 27px; letter-spacing: -.02em; }
.hero p { color: rgb(224 245 236 / .74); font-size: 13.5px; margin-top: 7px; max-width: 60ch; }
.hero-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 18px; }
.hero .btn--secondary { background: rgb(255 255 255 / .08); border-color: rgb(255 255 255 / .16); color: #fff; box-shadow: none; }
.hero .btn--secondary:hover { background: rgb(255 255 255 / .14); color: #fff; border-color: rgb(255 255 255 / .28); }
.hero-meta { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid rgb(255 255 255 / .1); }
.hero-meta div { display: flex; flex-direction: column; gap: 1px; }
.hero-meta b { font-size: 17px; font-weight: 800; color: #fff; }
.hero-meta span { font-size: 11px; color: rgb(224 245 236 / .6); }
.hero-ring { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.hero-ring small { color: rgb(224 245 236 / .66); font-size: 11px; }
.hero-side { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-inline-start: 10px; }

.ring {
    --p: 0;
    --ring: var(--primary);
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--line) 0);
    display: grid;
    place-items: center;
    position: relative;
    flex: none;
}
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring b { position: relative; z-index: 1; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.ring--sm { width: 64px; height: 64px; }
.ring--sm::before { inset: 7px; }
.ring--sm b { font-size: 13px; }
.ring--hero { --ring: #62E0B4; background: conic-gradient(#62E0B4 calc(var(--p) * 1%), rgb(255 255 255 / .14) 0); }
.ring--hero::before { background: #0D2A21; }
.ring--hero b { color: #fff; }
.ring--warning { --ring: var(--warning); }
.ring--danger { --ring: var(--danger); }

.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), #55D0A6); transition: width .5s var(--ease); }
.bar--sm { height: 6px; }
.bar--warning > i { background: linear-gradient(90deg, var(--warning), #EFC06A); }
.bar--danger > i { background: linear-gradient(90deg, var(--danger), #EE8C8C); }
.progress-line { display: flex; align-items: center; gap: 10px; }
.progress-line .bar { flex: 1; }
.progress-line b { font-size: 12px; font-weight: 700; min-width: 42px; text-align: end; }

.spark { display: flex; align-items: flex-end; gap: 7px; height: 86px; padding-top: 8px; }
.spark-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.spark-bar {
    width: 100%;
    max-width: 42px;
    min-height: 4px;
    height: var(--h, 10%);
    border-radius: 7px 7px 3px 3px;
    background: linear-gradient(180deg, #48C99C, #0F8A6A);
    opacity: .9;
    transition: height .4s var(--ease);
}
.spark-col:nth-child(even) .spark-bar { background: linear-gradient(180deg, #9BE4CB, #3BB48C); }
.spark-label { font-size: 9.5px; color: var(--muted-2); white-space: nowrap; }
.spark-empty { color: var(--muted-2); font-size: 12px; text-align: center; padding: 30px 0; }

/* --------------------------------------------------------------------------
   AI card
   -------------------------------------------------------------------------- */

.ai-card {
    position: relative;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--line));
    background:
        radial-gradient(460px 220px at 95% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 65%),
        radial-gradient(300px 180px at 0% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
        linear-gradient(135deg, color-mix(in srgb, var(--primary) 5%, var(--surface)), var(--surface) 55%, color-mix(in srgb, var(--accent) 6%, var(--surface)));
}
.ai-card::before {
    content: "";
    position: absolute;
    inset-block-start: -40px;
    inset-inline-end: -30px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%);
    pointer-events: none;
}
.ai-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; position: relative; }
.ai-id { display: flex; align-items: center; gap: 11px; }
.ai-orb {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), #0B5C46);
    color: #CFF9E9;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 25%, transparent);
    flex: none;
}
.ai-orb .icon { width: 21px; height: 21px; }
.ai-title { font-size: 14.5px; font-weight: 800; }
.ai-sub { font-size: 11px; color: var(--muted); }
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 99px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--muted);
    white-space: nowrap;
}
.ai-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.ai-badge--local .dot { background: var(--muted-2); }
.ai-body { padding: 13px 20px 4px; font-size: 13.5px; line-height: 1.95; color: var(--text); position: relative; min-height: 70px; }
.ai-body p { margin: 0 0 7px; }
.ai-body p:last-child { margin-bottom: 0; }
.ai-h { font-size: 12px; font-weight: 800; color: var(--primary-ink); margin: 10px 0 3px; }
.ai-h:first-child { margin-top: 0; }
.ai-list { margin: 0 0 8px; padding: 0; }
.ai-list li { position: relative; padding-inline-start: 14px; margin-bottom: 3px; }
.ai-list li::before { content: ""; position: absolute; inset-inline-start: 2px; inset-block-start: 10px; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); opacity: .8; }
.ai-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px 16px; flex-wrap: wrap; }
.ai-source { font-size: 10.5px; color: var(--muted-2); display: flex; align-items: center; gap: 5px; }
.ai-source .icon { width: 12px; height: 12px; }
.ai-error { font-size: 11.5px; color: var(--warning-ink); background: var(--warning-soft); border-radius: 8px; padding: 6px 9px; margin: 0 20px 10px; }
.ai-card.is-loading .ai-body { opacity: .45; }
.ai-card.is-loading .ai-foot .btn .icon { animation: spin 1s linear infinite; }
.ai-refresh { display: inline-flex; align-items: center; gap: 6px; }
.ai-refresh .icon { width: 14px; height: 14px; }

/* --------------------------------------------------------------------------
   Project cards / lists
   -------------------------------------------------------------------------- */

.project-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; transition: border-color .2s, transform .2s, box-shadow .2s; }
.project-card:hover { border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); box-shadow: var(--shadow); transform: translateY(-2px); }
.project-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.project-card h3 { font-size: 16px; font-weight: 800; }
.project-card h3 a { color: var(--text); }
.project-card h3 a:hover { color: var(--primary); }
.project-client { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; margin-top: 3px; }
.project-client .icon { width: 13px; height: 13px; }
.project-card-mid { display: flex; align-items: center; gap: 14px; }
.project-card-mid .ring { width: 64px; height: 64px; }
.project-card-mid .ring::before { inset: 7px; }
.project-card-mid .ring b { font-size: 13px; }
.project-card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; flex: 1; }
.project-stat { display: flex; flex-direction: column; gap: 1px; }
.project-stat b { font-size: 14px; font-weight: 800; }
.project-stat span { font-size: 10.5px; color: var(--muted); }
.project-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.project-eta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.project-eta .icon { width: 14px; height: 14px; }
.project-eta b { color: var(--text); font-weight: 700; }
.project-eta.is-risk b { color: var(--danger); }

.empty {
    text-align: center;
    padding: 46px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.empty-icon {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--muted);
    margin-bottom: 4px;
}
.empty-icon .icon { width: 26px; height: 26px; }
.empty h3 { font-size: 15px; }
.empty p { color: var(--muted); font-size: 12.5px; max-width: 42ch; }
.empty .btn { margin-top: 8px; }

/* --------------------------------------------------------------------------
   Task list
   -------------------------------------------------------------------------- */

.task-list { display: flex; flex-direction: column; }
.task-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 13px 18px;
    border-top: 1px solid var(--line);
    transition: background .16s;
}
.task-row:first-child { border-top: 0; }
.task-row:hover { background: var(--surface-2); }
.task-check {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 1.5px solid var(--line-strong);
    background: var(--surface);
    display: grid;
    place-items: center;
    color: transparent;
    transition: background .16s, border-color .16s, color .16s;
    flex: none;
    padding: 0;
}
.task-check .icon { width: 13px; height: 13px; }
.task-check:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.task-check.is-done { background: var(--primary); border-color: var(--primary); color: #fff; }
.task-main { min-width: 0; }
.task-title { font-size: 13.5px; font-weight: 700; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.task-title:hover { color: var(--primary); }
.task-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 3px; font-size: 11px; color: var(--muted); }
.task-meta .icon { width: 12px; height: 12px; }
.task-meta span { display: inline-flex; align-items: center; gap: 4px; }
.task-side { display: flex; align-items: center; gap: 9px; }
.task-side .avatar { width: 28px; height: 28px; font-size: 11px; }
.task-due { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.task-due.is-overdue { color: var(--danger-ink); background: var(--danger-soft); border-radius: 6px; padding: 2px 6px; }
.task-due .icon { width: 12px; height: 12px; }
.task-actions { display: flex; align-items: center; gap: 5px; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--surface); }
.table { width: 100%; min-width: 680px; font-size: 12.5px; }
.table th {
    text-align: start;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    background: var(--surface-2);
    padding: 11px 14px;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-title { font-weight: 700; color: var(--text); }
.row-title a { color: inherit; }
.row-title a:hover { color: var(--primary); }
.row-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 5px;
}
.field .req { color: var(--danger); }
.input, .select, .textarea {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    transition: border-color .18s, box-shadow .18s, background .18s;
    outline: 0;
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted-2); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.is-invalid, .textarea.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23687A71' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 11px center;
    background-size: 15px;
    padding-inline-end: 34px;
}
html[data-theme="dark"] .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2397A9A1' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.input--sm, .select--sm { min-height: 38px; font-size: 12.5px; border-radius: 9px; }
.input[type="number"] { direction: ltr; text-align: right; }
.input--ltr { direction: ltr; text-align: left; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.6; }
.field-error { font-size: 11.5px; color: var(--danger-ink); display: flex; align-items: center; gap: 4px; }
.form-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding-top: 4px; }
.form-actions--end { justify-content: flex-end; }
.check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 12.5px;
    color: var(--text);
    cursor: pointer;
    line-height: 1.6;
}
.check input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.check small { display: block; color: var(--muted); font-size: 11px; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 12.5px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 40px; height: 23px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .18s; flex: none; }
.switch-track::after { content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .2); transition: transform .18s var(--ease); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(-17px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }

.input-group { display: flex; align-items: stretch; gap: 7px; }
.input-group .input { flex: 1; }
.input-group .btn { flex: none; }

/* Date picker */
.nx-date { position: relative; }
.nx-date-box { display: flex; align-items: center; gap: 6px; }
.nx-date-text { flex: 1; min-width: 0; cursor: text; padding-inline-end: 34px; }
.nx-date-btn {
    position: absolute;
    inset-inline-end: 4px;
    inset-block-start: 4px;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    display: grid;
    place-items: center;
}
.nx-date-btn:hover { background: var(--surface-2); color: var(--primary); }
.nx-date-btn .icon { width: 17px; height: 17px; }
.nx-cal {
    position: absolute;
    z-index: 60;
    inset-block-start: calc(100% + 7px);
    inset-inline-start: 0;
    width: 292px;
    max-width: calc(100vw - 32px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 12px;
}
.nx-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 9px; }
.nx-cal-title { font-size: 13px; font-weight: 800; }
.nx-cal-nav { display: flex; gap: 2px; }
.nx-cal-nav button { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 7px; color: var(--muted); display: grid; place-items: center; }
.nx-cal-nav button:hover { background: var(--surface-2); color: var(--text); }
.nx-cal-nav .icon { width: 15px; height: 15px; }
.nx-cal-week, .nx-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.nx-cal-week span { text-align: center; font-size: 10px; color: var(--muted-2); padding: 4px 0; }
.nx-cal-day {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    height: 34px;
    font-size: 12px;
    color: var(--text);
    display: grid;
    place-items: center;
    padding: 0;
}
.nx-cal-day:hover { background: var(--primary-soft); color: var(--primary-ink); }
.nx-cal-day.is-muted { color: var(--muted-2); opacity: .5; }
.nx-cal-day.is-today { border-color: var(--primary); color: var(--primary-ink); font-weight: 700; }
.nx-cal-day.is-selected { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.nx-cal-foot { display: flex; justify-content: space-between; gap: 6px; margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); }
.nx-cal-foot button { border: 0; background: transparent; font-size: 11px; color: var(--primary); font-weight: 700; padding: 4px; }
.nx-cal-foot button:hover { text-decoration: underline; }

/* Filters */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-form { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.filter-form .input, .filter-form .select { min-height: 38px; font-size: 12px; border-radius: 9px; }
.filter-form .input { min-width: 170px; }
.filter-form .btn { min-height: 38px; }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */

.tabs {
    display: flex;
    gap: 3px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 13px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary-ink); border-bottom-color: var(--primary); }
.tab .badge { padding: 1px 6px; font-size: 10px; }

/* --------------------------------------------------------------------------
   Detail pages
   -------------------------------------------------------------------------- */

.detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    padding: 22px;
    margin-bottom: 18px;
}
.detail-head-main { min-width: 0; }
.detail-head h1 { font-size: 24px; margin-top: 4px; }
.detail-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 9px; font-size: 12px; color: var(--muted); }
.detail-meta span { display: inline-flex; align-items: center; gap: 4px; }
.detail-meta .icon { width: 14px; height: 14px; }
.detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-stat b { display: block; font-size: 18px; font-weight: 800; }
.detail-stat span { font-size: 11px; color: var(--muted); }
.detail-aside { display: flex; flex-direction: column; gap: 16px; }
.meta-list { display: flex; flex-direction: column; gap: 11px; }
.meta-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; font-size: 12px; }
.meta-row > span { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.meta-row > b, .meta-row > div { font-weight: 600; text-align: end; }
.meta-row .icon { width: 14px; height: 14px; }
.meta-row + .meta-row { padding-top: 11px; border-top: 1px dashed var(--line); }

.comment-list { display: flex; flex-direction: column; gap: 14px; }
.comment { display: flex; gap: 10px; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.comment-head b { color: var(--text); font-size: 12.5px; }
.comment-text {
    margin-top: 5px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 12.5px;
    line-height: 1.8;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.comment--internal .comment-text { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 20%, transparent); }
.comment-form textarea { min-height: 84px; }

.timeline { position: relative; display: flex; flex-direction: column; gap: 0; }
.timeline-item { position: relative; padding: 0 20px 18px 0; }
.timeline-item::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inset-block-start: 9px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.timeline-item::after {
    content: "";
    position: absolute;
    inset-inline-start: 4px;
    inset-block-start: 20px;
    bottom: 0;
    width: 1px;
    background: var(--line);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:last-child::after { display: none; }
.timeline-text { font-size: 12.5px; }
.timeline-time { font-size: 10.5px; color: var(--muted-2); margin-top: 2px; }

/* Notifications */
.notif-list { display: flex; flex-direction: column; }
.notif-item { display: flex; gap: 11px; padding: 15px 18px; border-top: 1px solid var(--line); align-items: flex-start; }
.notif-item:first-child { border-top: 0; }
.notif-item.is-unread { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.notif-icon { width: 36px; height: 36px; border-radius: 11px; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; flex: none; }
.notif-icon .icon { width: 17px; height: 17px; }
.notif-main { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 700; }
.notif-body { font-size: 12px; color: var(--muted); margin-top: 2px; }
.notif-time { font-size: 10.5px; color: var(--muted-2); margin-top: 4px; }
.notif-actions { display: flex; gap: 5px; align-items: center; }

/* Search */
.search-results { display: flex; flex-direction: column; gap: 18px; }
.result-group h2 { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.result-item { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); margin-bottom: 7px; }
.result-item:hover { border-color: var(--primary); }
.result-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.result-icon .icon { width: 16px; height: 16px; }
.result-main { flex: 1; min-width: 0; }
.result-title { font-size: 13px; font-weight: 700; }
.result-sub { font-size: 11px; color: var(--muted); }

/* Workload */
.workload { display: flex; flex-direction: column; gap: 13px; }
.workload-row { display: flex; align-items: center; gap: 10px; }
.workload-main { flex: 1; min-width: 0; }
.workload-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.workload-head b { font-weight: 700; }
.workload-head span { color: var(--muted); font-size: 11px; }

/* Alerts */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 11px 13px;
    border-radius: 11px;
    font-size: 12px;
    line-height: 1.7;
    border: 1px solid transparent;
}
.alert .icon { width: 16px; height: 16px; margin-top: 2px; flex: none; }
.alert--info { background: var(--info-soft); color: var(--info-ink); border-color: color-mix(in srgb, var(--info) 18%, transparent); }
.alert--warning { background: var(--warning-soft); color: var(--warning-ink); border-color: color-mix(in srgb, var(--warning) 20%, transparent); }
.alert--danger { background: var(--danger-soft); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.alert--success { background: var(--primary-soft); color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 18%, transparent); }

.code-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 11px;
    border: 1px dashed var(--line-strong);
    border-radius: 9px;
    background: var(--surface-2);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 11.5px;
    direction: ltr;
    text-align: left;
    overflow-x: auto;
}
.code-box code { flex: 1; white-space: nowrap; }
.copy-btn { border: 0; background: transparent; color: var(--muted); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; flex: none; }
.copy-btn:hover { background: var(--surface); color: var(--primary); }

/* Settings */
.settings-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 22px; align-items: start; }
.settings-nav { position: sticky; inset-block-start: calc(var(--header-h) + 18px); display: flex; flex-direction: column; gap: 3px; }
.settings-nav a { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 9px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.settings-nav a:hover { background: var(--surface-2); color: var(--text); }
.settings-nav a.is-active { background: var(--primary-soft); color: var(--primary-ink); }
.settings-nav .icon { width: 16px; height: 16px; }
.settings-section { scroll-margin-top: calc(var(--header-h) + 18px); }
.settings-section + .settings-section { margin-top: 18px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 16px; }
.section-head p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 25%, var(--line)); }

/* --------------------------------------------------------------------------
   Toasts + modal
   -------------------------------------------------------------------------- */

.toasts {
    position: fixed;
    z-index: 120;
    inset-block-start: calc(var(--header-h) + 12px);
    inset-inline-end: 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 11px 12px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    font-size: 12.5px;
    animation: toast-in .28s var(--ease);
}
.toast-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary-ink); }
.toast-icon .icon { width: 15px; height: 15px; }
.toast--error .toast-icon { background: var(--danger-soft); color: var(--danger-ink); }
.toast--warning .toast-icon { background: var(--warning-soft); color: var(--warning-ink); }
.toast--info .toast-icon { background: var(--info-soft); color: var(--info-ink); }
.toast-text { flex: 1; padding-top: 3px; line-height: 1.6; }
.toast-close { border: 0; background: transparent; color: var(--muted-2); padding: 4px; border-radius: 5px; }
.toast-close:hover { color: var(--text); }
.toast-close .icon { width: 13px; height: 13px; }
.toast.is-leaving { animation: toast-out .2s var(--ease) forwards; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgb(5 20 15 / .55);
    backdrop-filter: blur(4px);
    display: grid;
    place-items: center;
    padding: 20px;
}
.modal {
    width: 100%;
    max-width: 500px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    padding: 24px;
    position: relative;
    animation: modal-in .3s var(--ease);
}
.modal-x { position: absolute; inset-block-start: 14px; inset-inline-end: 14px; width: 34px; height: 34px; border: 0; background: var(--surface-2); border-radius: 9px; display: grid; place-items: center; color: var(--muted); }
.modal-x:hover { color: var(--text); }
.modal-x .icon { width: 16px; height: 16px; }
.tour-step small { color: var(--primary); font-size: 11px; font-weight: 700; }
.tour-step h2 { font-size: 19px; margin: 5px 0 7px; }
.tour-step p { color: var(--muted); font-size: 13px; }
.tour-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-ink); margin-bottom: 12px; }
.tour-icon .icon { width: 25px; height: 25px; }
.tour-icon--ai { background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft)); color: var(--primary-ink); }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.tour-dots { display: flex; gap: 5px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.tour-dots i.is-on { background: var(--primary); width: 18px; border-radius: 9px; }
.tour-actions { display: flex; gap: 7px; }

/* --------------------------------------------------------------------------
   Auth
   -------------------------------------------------------------------------- */

.auth-body { background: var(--bg); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.02fr .98fr; }
.auth-brand {
    position: relative;
    overflow: hidden;
    color: #EAF7F1;
    background:
        radial-gradient(700px 480px at 85% 0%, rgb(62 201 158 / .26), transparent 60%),
        radial-gradient(500px 420px at 0% 100%, rgb(216 154 43 / .18), transparent 55%),
        linear-gradient(155deg, #0C3A2C, #081E17 60%, #071712);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 42px;
}
.auth-brand-glow { position: absolute; inset-block-start: -180px; inset-inline-end: -120px; width: 420px; height: 420px; border-radius: 50%; border: 1px solid rgb(255 255 255 / .08); }
.auth-brand-glow::after { content: ""; position: absolute; inset: 48px; border-radius: 50%; border: 1px solid rgb(255 255 255 / .06); }
.auth-brand-inner { width: min(520px, 100%); position: relative; z-index: 1; display: flex; flex-direction: column; gap: 28px; }
.brand--auth { color: #fff; }
.brand--auth .brand-text small { color: rgb(255 255 255 / .45); }
.auth-copy h1 { color: #fff; font-size: clamp(27px, 3.2vw, 39px); line-height: 1.35; letter-spacing: -.025em; }
.auth-copy p { color: rgb(224 245 236 / .66); font-size: 13.5px; margin-top: 12px; max-width: 52ch; }
.auth-eyebrow { display: inline-block; color: #8EEBCB; font-size: 11.5px; font-weight: 700; letter-spacing: .01em; margin-bottom: 12px; }
.auth-preview {
    border: 1px solid rgb(255 255 255 / .12);
    background: rgb(255 255 255 / .055);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 15px;
    box-shadow: 0 20px 50px rgb(0 0 0 / .2);
}
.auth-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 10.5px; color: rgb(224 245 236 / .6); margin-bottom: 12px; }
.auth-preview-head > span:first-child { display: inline-flex; align-items: center; gap: 5px; }
.auth-preview-head i { width: 6px; height: 6px; border-radius: 50%; background: #7FE7C3; display: inline-block; }
.auth-preview-ai { display: inline-flex; align-items: center; gap: 4px; color: #F0D392; }
.auth-preview-ai .icon { width: 12px; height: 12px; }
.auth-preview-body { display: flex; align-items: center; gap: 15px; }
.auth-preview-ring { --p: 72; width: 68px; height: 68px; border-radius: 50%; background: conic-gradient(#6EE3BC calc(var(--p) * 1%), rgb(255 255 255 / .12) 0); display: grid; place-items: center; position: relative; flex: none; }
.auth-preview-ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #0B2A20; }
.auth-preview-ring b { position: relative; z-index: 1; font-size: 13px; color: #fff; }
.auth-preview-lines { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.auth-preview-lines strong { font-size: 11.5px; font-weight: 700; color: #fff; }
.auth-preview-lines span { font-size: 10.5px; color: rgb(224 245 236 / .58); }
.auth-preview-bar { display: block; height: 5px; border-radius: 99px; background: rgb(255 255 255 / .12); overflow: hidden; margin-top: 3px; }
.auth-preview-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6EE3BC, #D8B25C); }
.auth-features { display: flex; flex-direction: column; gap: 10px; }
.auth-features li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: rgb(234 247 241 / .78); }
.auth-features li > span { width: 30px; height: 30px; border-radius: 9px; background: rgb(255 255 255 / .07); border: 1px solid rgb(255 255 255 / .08); display: grid; place-items: center; color: #8EEBCB; flex: none; }
.auth-features .icon { width: 15px; height: 15px; }
.auth-brand-foot { display: flex; justify-content: space-between; gap: 10px; padding-top: 18px; border-top: 1px solid rgb(255 255 255 / .09); font-size: 10.5px; color: rgb(224 245 236 / .44); flex-wrap: wrap; }
.auth-secure { display: inline-flex; align-items: center; gap: 4px; }
.auth-secure .icon { width: 13px; height: 13px; }

.auth-panel { display: flex; flex-direction: column; padding: 26px 34px 22px; background: var(--bg); }
.auth-panel-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand--compact { display: none; color: var(--text); }
.auth-panel-inner { width: min(400px, 100%); margin: auto; padding-block: 30px; }
.auth-panel-foot { display: flex; justify-content: space-between; gap: 10px; color: var(--muted-2); font-size: 10.5px; flex-wrap: wrap; }
.auth-form-head { margin-bottom: 24px; }
.auth-form-head h1 { font-size: 25px; letter-spacing: -.02em; }
.auth-form-head p { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form .input { min-height: 47px; border-radius: 12px; }
.input-wrap { position: relative; }
.input-wrap .input { padding-inline-start: 43px; }
.input-wrap .input-icon { position: absolute; inset-inline-start: 13px; inset-block-start: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.input-wrap .input-icon .icon { width: 17px; height: 17px; }
.input-wrap .input-action { position: absolute; inset-inline-end: 7px; inset-block-start: 50%; transform: translateY(-50%); width: 33px; height: 33px; border: 0; background: transparent; color: var(--muted); border-radius: 7px; display: grid; place-items: center; }
.input-wrap .input-action:hover { color: var(--text); background: var(--surface-2); }
.input-wrap .input-action .icon { width: 16px; height: 16px; }
.auth-options { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }
.auth-submit { margin-top: 4px; }
.auth-hint { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 18px; }
.auth-hint a { font-weight: 700; }

/* --------------------------------------------------------------------------
   Error page
   -------------------------------------------------------------------------- */

.error-page { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 40px 20px; }
.error-code { font-size: 64px; font-weight: 800; letter-spacing: -.05em; color: var(--primary); line-height: 1; }
.error-page h1 { font-size: 22px; }
.error-page p { color: var(--muted); font-size: 13px; max-width: 50ch; }
.error-page .btn { margin-top: 10px; }

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--sidebar { grid-template-columns: minmax(0, 1fr) 310px; }
    .grid--main-side { grid-template-columns: 310px minmax(0, 1fr); }
    .topbar-search { width: 230px; }
    .topbar-user-name { display: none; }
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        width: min(290px, 86vw);
        height: 100dvh;
        transform: translateX(100%);
        transition: transform .26s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    html[dir="rtl"] .sidebar { inset-inline-start: 0; inset-inline-end: auto; }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-close { display: inline-grid; }
    .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(4 18 13 / .45); backdrop-filter: blur(2px); }
    .topbar { padding-inline: 16px; }
    .topbar-menu { display: inline-grid; }
    .topbar-search { display: none; }
    .page { padding: 22px 18px 40px; }
    .grid--sidebar, .grid--main-side { grid-template-columns: minmax(0, 1fr); }
    .detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .settings-grid { grid-template-columns: 1fr; }
    .settings-nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
    .settings-nav a { white-space: nowrap; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-panel { min-height: 100dvh; padding: 20px 22px 18px; }
    .brand--compact { display: inline-flex; }
    .auth-panel-inner { padding-block: 24px; }
}

@media (max-width: 720px) {
    .page-head { align-items: flex-start; }
    .page-head h1 { font-size: 22px; }
    .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: auto; }
    .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
    .hero-grid { grid-template-columns: minmax(0, 1fr); }
    .hero-side { flex-direction: row; justify-content: flex-start; padding-inline-start: 0; }
    .hero-ring { flex-direction: row; gap: 10px; }
    .hero h1, .hero h2 { font-size: 23px; }
    .detail-head { padding: 18px; }
    .detail-head h1 { font-size: 21px; }
    .task-row { grid-template-columns: auto minmax(0, 1fr); padding: 12px 14px; }
    .task-side { grid-column: 1 / -1; padding-inline-start: 37px; justify-content: flex-start; flex-wrap: wrap; }
    .toasts { inset-inline: 16px; width: auto; }
    .card-head { padding-inline: 16px; }
    .card-body { padding-inline: 16px; }
    .detail-stats { gap: 14px; }
    .topbar-title { max-width: 130px; }
    .app-footer { flex-direction: column; gap: 4px; }
}

@media (max-width: 460px) {
    .page { padding-inline: 14px; }
    .page-head-actions { width: 100%; }
    .page-head-actions .btn { flex: 1; }
    .kpi-value { font-size: 25px; }
    .project-card-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .topbar-user { display: none; }
    .modal { padding: 20px; }
    .tour-foot { flex-direction: column; align-items: flex-start; }
    .tour-actions { width: 100%; }
    .tour-actions .btn { flex: 1; }
}

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

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
    :root { --bg: #fff; --surface: #fff; --text: #111; --muted: #555; --line: #ddd; }
    .sidebar, .topbar, .app-footer, .toasts, .page-head-actions, .detail-actions, .no-print, .tour, .modal-backdrop { display: none !important; }
    .app-shell { display: block; }
    .page { max-width: none; padding: 0; }
    .card, .hero { box-shadow: none; break-inside: avoid; }
    .hero { color: #111; background: #f5f5f5 !important; border: 1px solid #ddd; }
    .hero h1, .hero h2, .hero p, .hero-meta b, .hero-meta span { color: #111 !important; }
    .ring--hero { background: conic-gradient(#111 calc(var(--p) * 1%), #ddd 0); }
    .ring--hero::before { background: #f5f5f5; }
    .ring--hero b { color: #111; }
    .badge { border: 1px solid #ccc; }
    a { color: #111; text-decoration: none; }
    .ai-card { background: #fafafa !important; border: 1px solid #ddd; }
}
