/* ============================================================================
   EngageHub — Design System
   A modern, premium UI with light/dark themes, soft shadows, gradients and
   micro-interactions. All colors are driven by CSS custom properties.
   ========================================================================== */

/* ---- Fonts ---------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

/* ---- Theme tokens --------------------------------------------------------- */
:root {
    /* Brand */
    --brand: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --accent: #ec4899;
    --accent-600: #db2777;

    --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    --gradient-brand-soft: linear-gradient(135deg, rgba(99,102,241,.12), rgba(236,72,153,.12));
    --gradient-success: linear-gradient(135deg, #10b981, #059669);
    --gradient-warning: linear-gradient(135deg, #f59e0b, #d97706);
    --gradient-danger: linear-gradient(135deg, #ef4444, #dc2626);
    --gradient-info: linear-gradient(135deg, #3b82f6, #2563eb);

    /* Semantic */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Light theme surfaces */
    --bg: #f4f5fb;
    --bg-soft: #eef0f8;
    --surface: #ffffff;
    --surface-2: #f8f9fd;
    --surface-hover: #f1f2f9;
    --border: #e6e8f0;
    --border-strong: #d6d9e6;

    --text: #1e2138;
    --text-soft: #565b7a;
    --text-muted: #8b90a8;
    --text-invert: #ffffff;

    --shadow-xs: 0 1px 2px rgba(24, 27, 56, .06);
    --shadow-sm: 0 2px 8px rgba(24, 27, 56, .06);
    --shadow: 0 6px 20px rgba(24, 27, 56, .08);
    --shadow-md: 0 12px 30px rgba(24, 27, 56, .10);
    --shadow-lg: 0 24px 50px rgba(24, 27, 56, .14);
    --shadow-brand: 0 12px 30px rgba(99, 102, 241, .35);

    --radius-sm: 10px;
    --radius: 14px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-full: 999px;

    --sidebar-w: 264px;
    --topbar-h: 68px;

    --font-sans: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;

    --ease: cubic-bezier(.4, 0, .2, 1);
    --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
}

/* Dark theme */
:root[data-theme="dark"] {
    --bg: #0b0f1e;
    --bg-soft: #0d1226;
    --surface: #141a2e;
    --surface-2: #1a2138;
    --surface-hover: #1e2540;
    --border: #262d47;
    --border-strong: #333c5c;

    --text: #e8eaf3;
    --text-soft: #a5abc7;
    --text-muted: #6b7192;
    --text-invert: #0b0f1e;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-md: 0 14px 34px rgba(0, 0, 0, .45);
    --shadow-lg: 0 26px 54px rgba(0, 0, 0, .55);
    --gradient-brand-soft: linear-gradient(135deg, rgba(99,102,241,.18), rgba(236,72,153,.16));
}

/* ---- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background .4s var(--ease), color .3s var(--ease);
    min-height: 100vh;
}
h1, h2, h3, h4, h5 { font-family: var(--font-sans); font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ul { list-style: none; padding: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(99, 102, 241, .25); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Layout: shell -------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    transition: transform .35s var(--ease);
}
.sidebar__brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 0 1.4rem;
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 1.15rem;
    border-bottom: 1px solid var(--border);
}
.sidebar__logo {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: var(--gradient-brand);
    display: grid; place-items: center;
    color: #fff; font-size: 1.1rem;
    box-shadow: var(--shadow-brand);
    flex-shrink: 0;
}
.sidebar__brand span b { background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 1rem .8rem; }
.nav-section { margin-bottom: 1.4rem; }
.nav-section__label {
    font-size: .68rem; font-weight: 700; letter-spacing: .09em;
    text-transform: uppercase; color: var(--text-muted);
    padding: 0 .8rem; margin-bottom: .5rem;
}
.nav-link {
    display: flex; align-items: center; gap: .8rem;
    padding: .72rem .85rem; border-radius: var(--radius-sm);
    color: var(--text-soft); font-weight: 500; font-size: .92rem;
    transition: all .2s var(--ease); position: relative; margin-bottom: 2px;
}
.nav-link i { font-size: 1.15rem; width: 22px; text-align: center; transition: transform .2s var(--ease); }
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link:hover i { transform: scale(1.12); }
.nav-link.active { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-brand); }
.nav-link.active i { color: #fff; }
.nav-link .badge-count {
    margin-left: auto; background: var(--brand); color: #fff;
    font-size: .68rem; font-weight: 700; padding: .12rem .5rem; border-radius: var(--radius-full);
}
.nav-link.active .badge-count { background: rgba(255,255,255,.25); }

.sidebar__footer { padding: .9rem; border-top: 1px solid var(--border); }
.user-chip {
    display: flex; align-items: center; gap: .7rem; padding: .55rem;
    border-radius: var(--radius-sm); transition: background .2s;
}
.user-chip:hover { background: var(--surface-hover); }
.user-chip__meta { overflow: hidden; }
.user-chip__meta strong { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__meta span { font-size: .76rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* Main column */
.app-main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-h);
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.6rem; position: sticky; top: 0; z-index: 40;
}
.topbar__title h1 { font-size: 1.25rem; }
.topbar__title p { font-size: .82rem; color: var(--text-muted); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }

.icon-btn {
    width: 42px; height: 42px; border-radius: var(--radius-sm);
    display: grid; place-items: center; color: var(--text-soft);
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: 1.15rem; transition: all .2s var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.page { padding: 1.8rem; max-width: 1440px; width: 100%; margin: 0 auto; }
.page-enter { animation: pageIn .5s var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Mobile menu toggle */
.menu-toggle { display: none; }
.sidebar__backdrop { display: none; }

/* ---- Cards ---------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .3s var(--ease), transform .3s var(--ease), border-color .3s;
}
.card--hover:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.card__body { padding: 1.4rem; }
.card__head { padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .8rem; }
.card__head h3 { font-size: 1.02rem; }
.card__head .card__actions { margin-left: auto; display: flex; gap: .5rem; }

/* ---- Stat cards ----------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.1rem; }
.stat-card {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 1.35rem; box-shadow: var(--shadow-sm);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-card::after {
    content: ''; position: absolute; right: -30px; top: -30px;
    width: 120px; height: 120px; border-radius: 50%;
    background: var(--gradient-brand-soft); opacity: .7;
}
.stat-card__icon {
    width: 50px; height: 50px; border-radius: 14px;
    display: grid; place-items: center; font-size: 1.4rem; color: #fff;
    position: relative; z-index: 1; margin-bottom: 1rem;
}
.stat-card__icon.i-brand { background: var(--gradient-brand); box-shadow: var(--shadow-brand); }
.stat-card__icon.i-success { background: var(--gradient-success); }
.stat-card__icon.i-warning { background: var(--gradient-warning); }
.stat-card__icon.i-info { background: var(--gradient-info); }
.stat-card__icon.i-accent { background: linear-gradient(135deg, #ec4899, #db2777); }
.stat-card__value { font-family: var(--font-sans); font-size: 2rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; position: relative; z-index: 1; }
.stat-card__label { color: var(--text-muted); font-size: .86rem; font-weight: 500; margin-top: .35rem; position: relative; z-index: 1; }
.stat-card__trend { display: inline-flex; align-items: center; gap: .25rem; font-size: .78rem; font-weight: 600; margin-top: .7rem; position: relative; z-index: 1; }
.stat-card__trend.up { color: var(--success); }
.stat-card__trend.down { color: var(--danger); }

/* ---- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .68rem 1.25rem; border-radius: var(--radius-sm);
    font-family: var(--font-sans); font-weight: 600; font-size: .9rem;
    border: 1px solid transparent; transition: all .22s var(--ease);
    white-space: nowrap; position: relative; overflow: hidden;
}
.btn i { font-size: 1.05rem; }
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-brand); }
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(99,102,241,.45); }
.btn--secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: var(--surface-hover); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn--ghost { background: transparent; color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn--danger { background: var(--gradient-danger); color: #fff; }
.btn--danger:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(239,68,68,.4); }
.btn--success { background: var(--gradient-success); color: #fff; }
.btn--sm { padding: .48rem .85rem; font-size: .82rem; }
.btn--lg { padding: .9rem 1.7rem; font-size: 1rem; }
.btn--block { width: 100%; }
.btn--icon { padding: .6rem; width: 42px; }
.btn[disabled], .btn.is-loading { opacity: .65; pointer-events: none; }
.btn.is-loading::after {
    content: ''; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.5); border-top-color: #fff;
    animation: spin .7s linear infinite; margin-left: .2rem;
}
.btn--secondary.is-loading::after { border-color: var(--border-strong); border-top-color: var(--brand); }

/* ---- Badges --------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .28rem .7rem; border-radius: var(--radius-full);
    font-size: .74rem; font-weight: 600; line-height: 1;
}
.badge i { font-size: .8rem; }
.badge--brand { background: rgba(99,102,241,.12); color: var(--brand-600); }
.badge--success { background: rgba(16,185,129,.14); color: #059669; }
.badge--warning { background: rgba(245,158,11,.15); color: #d97706; }
.badge--danger { background: rgba(239,68,68,.13); color: #dc2626; }
.badge--info { background: rgba(59,130,246,.13); color: #2563eb; }
.badge--muted { background: var(--surface-hover); color: var(--text-muted); }
:root[data-theme="dark"] .badge--success { color: #34d399; }
:root[data-theme="dark"] .badge--warning { color: #fbbf24; }
:root[data-theme="dark"] .badge--danger { color: #f87171; }
:root[data-theme="dark"] .badge--info { color: #60a5fa; }
:root[data-theme="dark"] .badge--brand { color: #a5b4fc; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--success { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.dot--warning { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.dot--muted { background: var(--text-muted); }

/* ---- Avatars -------------------------------------------------------------- */
.avatar {
    border-radius: 50%; background: var(--gradient-brand); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-family: var(--font-sans);
    flex-shrink: 0; overflow: hidden; object-fit: cover;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 34px; height: 34px; font-size: .8rem; }
.avatar--md { width: 42px; height: 42px; font-size: .9rem; }
.avatar--lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar--xl { width: 96px; height: 96px; font-size: 2rem; }

/* ---- Forms ---------------------------------------------------------------- */
.form-group { margin-bottom: 1.15rem; }
.form-label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .45rem; color: var(--text); }
.form-label .req { color: var(--danger); }
.form-label .hint { font-weight: 400; color: var(--text-muted); font-size: .78rem; }
.form-control {
    width: 100%; padding: .72rem .9rem; background: var(--surface-2);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: .92rem; transition: all .2s var(--ease); color: var(--text);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px rgba(99,102,241,.14); }
.form-control.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(239,68,68,.12); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238b90a8' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .9rem center; padding-right: 2.4rem; }
.form-error { color: var(--danger); font-size: .78rem; margin-top: .35rem; display: flex; align-items: center; gap: .3rem; }
.form-hint { color: var(--text-muted); font-size: .78rem; margin-top: .35rem; }
.input-group { position: relative; }
.input-group .input-icon { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.05rem; pointer-events: none; }
.input-group .form-control { padding-left: 2.7rem; }
.input-group .toggle-pass { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.05rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: .7rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track { width: 46px; height: 26px; border-radius: 20px; background: var(--border-strong); transition: background .25s; position: relative; flex-shrink: 0; }
.switch__track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease-bounce); box-shadow: var(--shadow-sm); }
.switch input:checked + .switch__track { background: var(--gradient-brand); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }

/* Color swatch input */
.color-field { display: flex; align-items: center; gap: .6rem; }
.color-field input[type=color] { width: 46px; height: 42px; border-radius: 10px; border: 1.5px solid var(--border); padding: 3px; background: var(--surface-2); cursor: pointer; }

/* File dropzone */
.dropzone {
    border: 2px dashed var(--border-strong); border-radius: var(--radius);
    padding: 1.6rem; text-align: center; color: var(--text-muted);
    transition: all .25s var(--ease); cursor: pointer; background: var(--surface-2);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: var(--gradient-brand-soft); color: var(--text); }
.dropzone i { font-size: 1.8rem; color: var(--brand); }
.dropzone__preview { max-height: 120px; border-radius: var(--radius-sm); margin: .5rem auto 0; }

/* ---- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table thead th {
    text-align: left; padding: .85rem 1rem; font-size: .74rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
    border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2);
}
.table tbody td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .18s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table .th-sort { cursor: pointer; user-select: none; }
.table .th-sort:hover { color: var(--text); }
.cell-user { display: flex; align-items: center; gap: .7rem; }
.cell-user strong { font-weight: 600; font-size: .9rem; }
.cell-user span { font-size: .78rem; color: var(--text-muted); }

/* ---- Empty state ---------------------------------------------------------- */
.empty-state { text-align: center; padding: 3.5rem 1.5rem; }
.empty-state__icon {
    width: 90px; height: 90px; border-radius: 26px; margin: 0 auto 1.3rem;
    display: grid; place-items: center; font-size: 2.6rem; color: var(--brand);
    background: var(--gradient-brand-soft);
}
.empty-state h3 { font-size: 1.2rem; margin-bottom: .4rem; }
.empty-state p { color: var(--text-muted); max-width: 420px; margin: 0 auto 1.5rem; }

/* ---- Skeleton loading ----------------------------------------------------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-text { height: 12px; margin-bottom: .5rem; }
.skeleton-text.w-60 { width: 60%; } .skeleton-text.w-40 { width: 40%; } .skeleton-text.w-80 { width: 80%; }
.skeleton-card { height: 130px; border-radius: var(--radius-md); }

/* ---- Toasts --------------------------------------------------------------- */
.toast-stack { position: fixed; top: 1.2rem; right: 1.2rem; z-index: 9999; display: flex; flex-direction: column; gap: .7rem; max-width: 380px; }
.toast {
    display: flex; align-items: flex-start; gap: .8rem; padding: .95rem 1.1rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    animation: toastIn .45s var(--ease-bounce) both; position: relative; overflow: hidden;
}
.toast.hide { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(120%); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(120%); } }
.toast__icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex-shrink: 0; font-size: 1.05rem; }
.toast--success .toast__icon { background: var(--gradient-success); }
.toast--error .toast__icon { background: var(--gradient-danger); }
.toast--warning .toast__icon { background: var(--gradient-warning); }
.toast--info .toast__icon { background: var(--gradient-info); }
.toast__body strong { display: block; font-size: .9rem; font-weight: 600; }
.toast__body p { font-size: .82rem; color: var(--text-soft); margin: 0; }
.toast__close { color: var(--text-muted); font-size: 1.1rem; margin-left: auto; }
.toast__bar { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--brand); animation: toastBar 4s linear forwards; }
.toast--success .toast__bar { background: var(--success); }
.toast--error .toast__bar { background: var(--danger); }
.toast--warning .toast__bar { background: var(--warning); }
@keyframes toastBar { from { width: 100%; } to { width: 0; } }

/* ---- Modal ---------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,14,30,.55); backdrop-filter: blur(4px); z-index: 200; display: grid; place-items: center; padding: 1.2rem; opacity: 0; pointer-events: none; transition: opacity .25s; }
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); transform: translateY(20px) scale(.98); transition: transform .3s var(--ease-bounce); max-height: 90vh; display: flex; flex-direction: column; }
.modal-backdrop.open .modal { transform: none; }
.modal__head { padding: 1.3rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .8rem; }
.modal__head h3 { font-size: 1.1rem; }
.modal__body { padding: 1.5rem; overflow-y: auto; }
.modal__foot { padding: 1.1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .7rem; justify-content: flex-end; }

/* ---- Progress & meters ---------------------------------------------------- */
.progress { height: 8px; border-radius: 20px; background: var(--surface-hover); overflow: hidden; }
.progress__bar { height: 100%; border-radius: 20px; background: var(--gradient-brand); transition: width .6s var(--ease); }
.meter-row { display: flex; align-items: center; gap: .8rem; margin-bottom: .9rem; }
.meter-row__label { min-width: 130px; font-size: .85rem; font-weight: 500; display: flex; align-items: center; gap: .5rem; }
.meter-row .progress { flex: 1; }
.meter-row__value { min-width: 44px; text-align: right; font-weight: 700; font-size: .85rem; }

/* ---- Tabs ----------------------------------------------------------------- */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tab { padding: .75rem 1.1rem; font-weight: 600; font-size: .9rem; color: var(--text-muted); border-bottom: 2px solid transparent; transition: all .2s; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---- Tooltip -------------------------------------------------------------- */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
    background: var(--text); color: var(--surface); font-size: .74rem; font-weight: 500; white-space: nowrap;
    padding: .35rem .6rem; border-radius: 8px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%); }

/* ---- Chips / filters ------------------------------------------------------ */
.chip-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip { padding: .5rem .95rem; border-radius: var(--radius-full); background: var(--surface-2); border: 1px solid var(--border); font-size: .84rem; font-weight: 500; color: var(--text-soft); transition: all .2s; cursor: pointer; }
.chip:hover { background: var(--surface-hover); }
.chip.active { background: var(--gradient-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-brand); }

/* ---- Section header ------------------------------------------------------- */
.section-head { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.section-head h2 { font-size: 1.35rem; }
.section-head p { color: var(--text-muted); font-size: .88rem; }
.section-head__actions { margin-left: auto; display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---- Search box ----------------------------------------------------------- */
.search-box { position: relative; }
.search-box i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-box input { padding-left: 2.7rem; min-width: 240px; }

/* ---- Pagination ----------------------------------------------------------- */
.pagination { display: flex; gap: .35rem; align-items: center; justify-content: center; margin-top: 1.5rem; }
.pagination button { min-width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .85rem; color: var(--text-soft); transition: all .2s; }
.pagination button:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.pagination button.active { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---- Grid helpers --------------------------------------------------------- */
.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.col-span-2 { grid-column: span 2; }

/* ---- Utilities ------------------------------------------------------------ */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; } .flex-wrap { flex-wrap: wrap; } .flex-1 { flex: 1; }
.text-muted { color: var(--text-muted); } .text-soft { color: var(--text-soft); } .text-center { text-align: center; }
.text-sm { font-size: .84rem; } .text-xs { font-size: .76rem; } .text-lg { font-size: 1.1rem; }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.gradient-text { background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius); }
.shadow { box-shadow: var(--shadow); }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .col-span-2 { grid-column: span 1; }
}
@media (max-width: 900px) {
    :root { --sidebar-w: 260px; }
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .app-main { margin-left: 0; }
    .menu-toggle { display: grid; }
    .sidebar__backdrop { display: block; position: fixed; inset: 0; background: rgba(10,14,30,.5); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .3s; }
    .sidebar__backdrop.open { opacity: 1; pointer-events: auto; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .page { padding: 1.1rem; }
    .topbar { padding: 0 1rem; }
    .topbar__title h1 { font-size: 1.05rem; }
    .topbar__title p { display: none; }
    .stat-card__value { font-size: 1.7rem; }
    .section-head__actions { width: 100%; }
    .section-head__actions .btn { flex: 1; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
