/* =========================================================================
   Codarize — design system
   Every colour is a token so the dark theme is a variable swap, not a rewrite.
   ========================================================================= */

:root {
    color-scheme: light;

    /* Brand */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-200: #c7d2fe;
    --brand-400: #818cf8;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;

    /* Semantic accents */
    --success: #059669;
    --success-soft: #d1fae5;
    --success-text: #065f46;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --warning-text: #92400e;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --danger-text: #991b1b;
    --info: #0891b2;
    --info-soft: #cffafe;
    --info-text: #155e75;

    /* Surfaces */
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --surface-hover: #f8fafc;

    /* Text */
    --text: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    --text-inverse: #ffffff;

    /* Lines */
    --border: #e6e8f0;
    --border-strong: #cbd5e1;

    /* Sidebar */
    --sidebar-bg: #0f1729;
    --sidebar-surface: #1a2338;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;

    /* Elevation */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, .07), 0 2px 6px -2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, .12), 0 4px 12px -4px rgba(15, 23, 42, .06);
    --shadow-xl: 0 24px 56px -12px rgba(15, 23, 42, .18);
    --ring: 0 0 0 3px rgba(99, 102, 241, .18);

    /* Geometry */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --sidebar-w: 264px;
    --topbar-h: 68px;
}

[data-theme="dark"] {
    color-scheme: dark;

    --brand-50:  #1e1b4b;
    --brand-100: #272561;
    --brand-200: #312e81;
    --brand-400: #818cf8;
    --brand-500: #818cf8;
    --brand-600: #6366f1;
    --brand-700: #4f46e5;

    --success: #34d399;
    --success-soft: rgba(16, 185, 129, .15);
    --success-text: #6ee7b7;
    --warning: #fbbf24;
    --warning-soft: rgba(245, 158, 11, .15);
    --warning-text: #fcd34d;
    --danger: #f87171;
    --danger-soft: rgba(239, 68, 68, .15);
    --danger-text: #fca5a5;
    --info: #22d3ee;
    --info-soft: rgba(6, 182, 212, .15);
    --info-text: #67e8f9;

    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #161f31;
    --surface-3: #1c2739;
    --surface-hover: #18212f;

    --text: #e8edf7;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    --border: #243044;
    --border-strong: #334155;

    --sidebar-bg: #080d18;
    --sidebar-surface: #141d2f;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, .55);
    --shadow-xl: 0 24px 56px -12px rgba(0, 0, 0, .65);
    --ring: 0 0 0 3px rgba(129, 140, 248, .25);
}

/* ---------------------------------------------------------------- base --- */

* { -webkit-tap-highlight-color: transparent; }

/* Components below set display explicitly (.alert is flex, .pill is inline-flex), which
   would otherwise beat the user-agent rule for [hidden]. */
[hidden] { display: none !important; }

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    font-size: .9375rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 700; letter-spacing: -.015em; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }

hr { border-color: var(--border); opacity: 1; }

::selection { background: var(--brand-200); color: var(--brand-700); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* Bootstrap utility overrides so stock classes follow the tokens. */
.text-muted { color: var(--text-muted) !important; }
.text-dark { color: var(--text) !important; }
.text-primary { color: var(--brand-600) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.bg-white { background-color: var(--surface) !important; }
.bg-light { background-color: var(--surface-2) !important; }
.border { border-color: var(--border) !important; }
.border-top, .border-bottom, .border-start, .border-end { border-color: var(--border) !important; }
.font-monospace { font-family: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, monospace; }

/* ------------------------------------------------------------- layout --- */

.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
}

.sidebar::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(120% 55% at 0% 0%, rgba(99, 102, 241, .22), transparent 62%);
}

.sidebar > * { position: relative; z-index: 1; }

.sidebar-brand {
    padding: 1.35rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -.02em;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.sidebar-brand .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    box-shadow: 0 6px 16px -4px rgba(79, 70, 229, .6);
    flex-shrink: 0;
}

.sidebar-brand small {
    display: block;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--sidebar-text);
}

.sidebar-menu {
    padding: 1rem .75rem;
    margin: 0;
    list-style: none;
    flex: 1 1 auto;
    overflow-y: auto;
}

.sidebar-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #576076;
    padding: .9rem .75rem .35rem;
    font-weight: 700;
}

.sidebar-item { margin-bottom: .15rem; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .65rem .8rem;
    color: var(--sidebar-text);
    border-radius: 10px;
    font-weight: 500;
    font-size: .9rem;
    position: relative;
    transition: background-color .16s ease, color .16s ease;
}

.sidebar-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; flex-shrink: 0; }

.sidebar-link:hover { color: #fff; background: rgba(255, 255, 255, .06); }

.sidebar-link.active {
    color: var(--sidebar-text-active);
    background: linear-gradient(135deg, var(--brand-600), var(--brand-500));
    box-shadow: 0 8px 20px -8px rgba(79, 70, 229, .85);
}

.sidebar-link .link-badge {
    margin-left: auto;
    font-size: .7rem;
    font-weight: 700;
    padding: .1rem .45rem;
    border-radius: 99px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255, 255, 255, .07); }

.client-info-card {
    background: var(--sidebar-surface);
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: var(--r-md);
    padding: .8rem;
    display: flex;
    align-items: center;
    gap: .7rem;
    margin-bottom: .7rem;
}

.client-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-400), var(--brand-700));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

.main-content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.content-container { padding: 1.75rem; flex: 1 1 auto; max-width: 1600px; width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.4rem; margin: 0 0 .2rem; }
.page-head p { color: var(--text-muted); font-size: .875rem; margin: 0; }

.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(2px);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

/* ------------------------------------------------------------- cards --- */

.card, .metric-card, .chart-card, .table-card, .filter-card, .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}

.panel { padding: 1.35rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.15rem; flex-wrap: wrap; }
.panel-title { font-size: 1rem; font-weight: 700; margin: 0; }
.panel-subtitle { font-size: .8rem; color: var(--text-muted); margin: .1rem 0 0; }

.metric-card {
    padding: 1.25rem;
    height: 100%;
    position: relative;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
    opacity: 0;
    transition: opacity .18s ease;
}

.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.metric-card:hover::before { opacity: 1; }

.metric-icon-bg {
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.metric-icon-blue   { background: var(--brand-50);     color: var(--brand-600); }
.metric-icon-green  { background: var(--success-soft); color: var(--success); }
.metric-icon-amber  { background: var(--warning-soft); color: var(--warning); }
.metric-icon-purple { background: var(--brand-100);    color: var(--brand-700); }
.metric-icon-red    { background: var(--danger-soft);  color: var(--danger); }
.metric-icon-cyan   { background: var(--info-soft);    color: var(--info); }

.metric-title {
    font-size: .74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: .3rem;
}

.metric-value {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--text);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.metric-value.sm { font-size: 1.15rem; }
.metric-subtitle { font-size: .78rem; color: var(--text-muted); margin-top: .55rem; }

.chart-card { padding: 1.35rem; height: 100%; }
.chart-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.chart-title { font-size: .98rem; font-weight: 700; margin: 0; }
.chart-body { position: relative; }

.table-card { overflow: hidden; }
.filter-card { padding: 1.15rem 1.25rem; margin-bottom: 1.25rem; }

.empty-state { padding: 3rem 1.5rem; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; color: var(--text-subtle); display: block; margin-bottom: .75rem; }
.empty-state h6 { color: var(--text); margin-bottom: .3rem; }

/* ------------------------------------------------------------ tables --- */

.custom-table { margin: 0 !important; width: 100%; border-collapse: collapse; color: var(--text); }

.custom-table thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.custom-table tbody td {
    padding: .85rem 1.1rem;
    vertical-align: middle;
    font-size: .875rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.custom-table tbody tr:last-child td { border-bottom: 0; }
.custom-table tbody tr { transition: background-color .12s ease; }
.custom-table tbody tr:hover td { background: var(--surface-hover); }
.custom-table tfoot td { padding: .85rem 1.1rem; background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border); }

.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.cell-truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sortable header, driven by js/table.js */
.custom-table th[data-sortable] { cursor: pointer; user-select: none; }
.custom-table th[data-sortable]:hover { color: var(--text); }
.custom-table th[data-sortable]::after {
    content: "\F0DC";
    font-family: "bootstrap-icons";
    font-size: .7rem;
    margin-left: .35rem;
    opacity: .3;
}
.custom-table th[data-sort-dir="asc"]::after  { content: "\F0DD"; opacity: 1; color: var(--brand-600); }
.custom-table th[data-sort-dir="desc"]::after { content: "\F0DE"; opacity: 1; color: var(--brand-600); }

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.table-search { position: relative; flex: 1 1 260px; max-width: 340px; }
.table-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-subtle); font-size: .9rem; }
.table-search input { padding-left: 2.2rem; }

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .85rem 1.15rem;
    border-top: 1px solid var(--border);
    font-size: .82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.pager { display: flex; gap: .3rem; }

.pager button {
    min-width: 34px;
    height: 34px;
    padding: 0 .55rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 600;
}

.pager button:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.pager button[aria-current="true"] { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ------------------------------------------------------------ badges --- */

.badge { font-weight: 600; letter-spacing: .01em; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .28rem .65rem;
    border-radius: 99px;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

.pill-success, .badge-billable, .badge-status-pago { background: var(--success-soft); color: var(--success-text); }
.pill-danger, .badge-non-billable { background: var(--danger-soft); color: var(--danger-text); }
.pill-warning, .badge-status-pendente { background: var(--warning-soft); color: var(--warning-text); }
.pill-info { background: var(--info-soft); color: var(--info-text); }
.pill-brand { background: var(--brand-50); color: var(--brand-700); }
.pill-neutral { background: var(--surface-3); color: var(--text-muted); }

.pill-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted); }

.code-chip {
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: .8rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: .25rem .6rem;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

/* ------------------------------------------------------------- forms --- */

.form-label { font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.form-text, .form-hint { font-size: .78rem; color: var(--text-muted); }

.form-control, .form-select {
    background-color: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text);
    padding: .55rem .8rem;
    font-size: .9rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control::placeholder { color: var(--text-subtle); }

.form-control:focus, .form-select:focus {
    background-color: var(--surface);
    border-color: var(--brand-500);
    box-shadow: var(--ring);
    color: var(--text);
}

.form-control:disabled, .form-select:disabled { background-color: var(--surface-3); color: var(--text-muted); }

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

.form-control-lg, .form-select-lg { padding: .75rem 1rem; font-size: .95rem; border-radius: var(--r-md); }

/* Native pickers are dark-unaware without this. */
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="month"] { color-scheme: dark; }

.form-check-input { border-color: var(--border-strong); background-color: var(--surface); }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.form-check-input:focus { box-shadow: var(--ring); border-color: var(--brand-500); }
.form-check-label { font-size: .875rem; }

.input-group-text {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text-muted);
    border-radius: var(--r-sm);
}

.field-error { color: var(--danger); font-size: .78rem; margin-top: .25rem; display: block; }
.input-validation-error { border-color: var(--danger) !important; }

/* ----------------------------------------------------------- buttons --- */

.btn {
    font-weight: 600;
    font-size: .875rem;
    border-radius: var(--r-sm);
    padding: .55rem 1rem;
    transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--ring); outline: none; }
.btn-lg { padding: .75rem 1.35rem; font-size: .95rem; border-radius: var(--r-md); }
.btn-sm { padding: .38rem .75rem; font-size: .8rem; }

.btn-primary {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-500));
    border: none;
    color: #fff;
    box-shadow: 0 4px 14px -4px rgba(79, 70, 229, .5);
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
    color: #fff;
    box-shadow: 0 6px 20px -4px rgba(79, 70, 229, .6);
}

.btn-secondary, .btn-light {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.btn-secondary:hover, .btn-light:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

.btn-outline-secondary { border-color: var(--border-strong); color: var(--text-muted); background: transparent; }
.btn-outline-secondary:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.93); background: var(--success); border-color: var(--success); color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-outline-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(.93); background: var(--warning); border-color: var(--warning); color: #fff; }

.btn-outline-light { border-color: rgba(255, 255, 255, .22); color: #cbd5e1; background: transparent; }
.btn-outline-light:hover { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .3); }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--r-sm);
    flex-shrink: 0;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: inline-grid;
    place-items: center;
    font-size: 1rem;
    transition: background-color .15s ease, color .15s ease;
}

.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ------------------------------------------------------------ modals --- */

.modal-content {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xl);
}

.modal-header { border-bottom: 1px solid var(--border); padding: 1.15rem 1.35rem; }
.modal-title { font-size: 1.02rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.modal-body { padding: 1.35rem; }
.modal-footer { border-top: 1px solid var(--border); padding: 1rem 1.35rem; gap: .5rem; }
.modal-backdrop.show { opacity: .55; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.8); }

/* ------------------------------------------------------------ alerts --- */

.alert {
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: .9rem 1.1rem;
    font-size: .88rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
}

.alert i { font-size: 1.05rem; line-height: 1.4; flex-shrink: 0; }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success-text); }
.alert-danger  { background: var(--danger-soft);  border-color: color-mix(in srgb, var(--danger) 30%, transparent);  color: var(--danger-text); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--warning-text); }
.alert-info    { background: var(--info-soft);    border-color: color-mix(in srgb, var(--info) 30%, transparent);    color: var(--info-text); }
.alert-dismissible .btn-close { padding: 1rem; }

/* Floating notifications */
.toast-stack {
    position: fixed;
    top: calc(var(--topbar-h) + 12px);
    right: 1.25rem;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    max-width: min(420px, calc(100vw - 2.5rem));
}

.toast-stack .alert {
    box-shadow: var(--shadow-lg);
    animation: toast-in .28s cubic-bezier(.16, 1, .3, 1);
    margin: 0;
}

@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------------------- auth --- */

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(60% 50% at 15% 10%, rgba(99, 102, 241, .35), transparent 60%),
        radial-gradient(50% 45% at 85% 90%, rgba(14, 165, 233, .25), transparent 60%),
        #070c18;
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 2.25rem 2rem;
    box-shadow: var(--shadow-xl);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--text);
    margin-bottom: 1.25rem;
}

.auth-logo .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    box-shadow: 0 8px 20px -6px rgba(79, 70, 229, .7);
}

.auth-card h1 { font-size: 1.2rem; margin-bottom: .3rem; }
.auth-card .lede { color: var(--text-muted); font-size: .87rem; margin-bottom: 1.5rem; }
.auth-divider { border-top: 1px solid var(--border); margin-top: 1.5rem; padding-top: 1.15rem; }

.password-field { position: relative; }
.password-field .toggle-visibility {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    color: var(--text-subtle);
    padding: .35rem .5rem;
    border-radius: var(--r-sm);
}
.password-field .toggle-visibility:hover { color: var(--text); background: var(--surface-3); }

/* ------------------------------------------------------------- misc ---- */

.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: inline-grid;
    place-items: center;
    font-size: 1.05rem;
}

.theme-toggle:hover { background: var(--surface-3); color: var(--text); }
.theme-toggle .bi-moon-stars { display: none; }
[data-theme="dark"] .theme-toggle .bi-sun { display: none; }
[data-theme="dark"] .theme-toggle .bi-moon-stars { display: block; }

.breadcrumb { margin: 0; font-size: .85rem; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-subtle); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand-600); }
.breadcrumb-item.active { color: var(--text); font-weight: 600; }

.stat-inline { display: flex; align-items: baseline; gap: .4rem; }
.stat-inline .label { font-size: .78rem; color: var(--text-muted); }
.stat-inline .value { font-weight: 700; font-variant-numeric: tabular-nums; }

.progress { background: var(--surface-3); border-radius: 99px; height: 8px; }
.progress-bar { background: linear-gradient(90deg, var(--brand-600), var(--brand-400)); border-radius: 99px; }

.list-group-item { background: transparent; border-color: var(--border); color: var(--text); }

.divider-y { border-left: 1px solid var(--border); align-self: stretch; }

/* -------------------------------------------------------- responsive --- */

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        transition: transform .24s cubic-bezier(.16, 1, .3, 1);
        box-shadow: var(--shadow-xl);
    }

    body.sidebar-open .sidebar { transform: none; }
    .sidebar-toggle { display: inline-flex; }
    .content-container { padding: 1.15rem; }
    .topbar { padding: 0 1rem; }
    .toast-stack { left: 1rem; right: 1rem; max-width: none; }
}

@media (max-width: 575.98px) {
    .page-head h1 { font-size: 1.2rem; }
    .metric-value { font-size: 1.35rem; }
    .content-container { padding: 1rem .85rem; }
    .modal-body { padding: 1.1rem; }
}

@media print {
    .sidebar, .topbar, .table-toolbar, .table-footer, .btn, .toast-stack, .no-print { display: none !important; }
    .content-container { padding: 0; }
    .card, .panel, .table-card, .metric-card, .chart-card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
    body { background: #fff; }
}

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