/* VX SPACE — design system (self-contained, no external CDN dependency) */

@font-face {
    font-family: 'Hubot Sans';
    src: url('../fonts/HubotSans-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Hubot Sans';
    src: url('../fonts/HubotSans-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* -------------------------------------------------------------------- */
/* Color system — grayscale base + one accent. Everything else derives  */
/* from these variables so theming stays centralized.                   */
/* -------------------------------------------------------------------- */

:root {
    --bg: #ffffff;
    --bg-secondary: #f7f7f8;
    --surface: #ffffff;
    --surface-hover: #f4f4f5;
    --border: #e7e7ea;
    --border-strong: #d4d4d8;
    --text-primary: #18181b;
    --text-secondary: #6b7280;
    --text-tertiary: #a1a1aa;

    --accent: #5b5fef;
    --accent-hover: #4a4ee0;
    --accent-fg: #ffffff;
    --accent-subtle: #eef0fe;

    --success: #16a34a;
    --success-subtle: #ecfdf3;
    --danger: #dc2626;
    --danger-subtle: #fef2f2;
    --warning: #d97706;
    --warning-subtle: #fffbeb;
    --info: #2563eb;
    --info-subtle: #eff6ff;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 15, 20, .04);
    --shadow: 0 1px 3px rgba(15, 15, 20, .06), 0 4px 12px rgba(15, 15, 20, .04);
    --shadow-lg: 0 8px 30px rgba(15, 15, 20, .12);

    --sidebar-w: 250px;
    --sidebar-w-collapsed: 68px;
    --topbar-h: 60px;

    --ease: cubic-bezier(.4, 0, .2, 1);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { color-scheme: dark; }
}

[data-theme="dark"] {
    --bg: #0b0b0d;
    --bg-secondary: #131316;
    --surface: #18181c;
    --surface-hover: #1f1f24;
    --border: #27272c;
    --border-strong: #34343a;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;

    --accent: #7477f2;
    --accent-hover: #8a8cf5;
    --accent-fg: #ffffff;
    --accent-subtle: #201f3a;

    --success: #22c55e;
    --success-subtle: #0f2318;
    --danger: #f87171;
    --danger-subtle: #2a1516;
    --warning: #fbbf24;
    --warning-subtle: #2a2110;
    --info: #60a5fa;
    --info-subtle: #14203a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

/* -------------------------------------------------------------------- */
/* Base                                                                  */
/* -------------------------------------------------------------------- */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Hubot Sans', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    transition: background-color .2s var(--ease), color .2s var(--ease);
}
input, select, textarea, button { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -.01em; }
p { margin: 0; }
::selection { background: var(--accent-subtle); }

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

/* -------------------------------------------------------------------- */
/* Layout shell                                                          */
/* -------------------------------------------------------------------- */

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

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 40;
    transition: width .22s var(--ease);
    overflow: hidden;
}
.shell.collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.brand-row { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    background: var(--text-primary); color: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-weight: 400; font-size: 13px;
}
.brand-name { font-weight: 400; font-size: 14.5px; white-space: nowrap; }
.sidebar-toggle {
    width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.sidebar-toggle:hover { background: var(--surface-hover); color: var(--text-primary); }
.sidebar-toggle .icon-expand { display: none; }
.shell.collapsed .sidebar-toggle .icon-collapse { display: none; }
.shell.collapsed .sidebar-toggle .icon-expand { display: flex; }
.shell.collapsed .sidebar-brand { justify-content: center; padding: 0; }
.shell.collapsed .brand-row { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 10px 16px; }
.nav-group { margin-bottom: 4px; }
.nav-group + .nav-group { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.nav-group-label {
    font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-tertiary); padding: 4px 10px 6px; white-space: nowrap;
}
.shell.collapsed .nav-group-label { display: none; }

.nav-item {
    display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin-bottom: 2px;
    border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13.5px; font-weight: 400;
    cursor: pointer; white-space: nowrap; position: relative; border: none; background: none; width: 100%;
    text-align: left; transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-item .icon { flex-shrink: 0; }
.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-subtle); color: var(--accent); font-weight: 400; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.nav-item .chevron { flex-shrink: 0; transition: transform .18s var(--ease); }
.nav-item.expanded .chevron { transform: rotate(180deg); }
.shell.collapsed .nav-item .label,
.shell.collapsed .nav-item .chevron,
.shell.collapsed .nav-group-label { display: none; }
.shell.collapsed .nav-item { justify-content: center; }

.nav-submenu {
    overflow: hidden; max-height: 0; transition: max-height .22s var(--ease), opacity .18s var(--ease); opacity: 0;
    padding-left: 26px; position: relative;
}
.nav-submenu.open { max-height: 600px; opacity: 1; }
.nav-submenu::before {
    content: ''; position: absolute; left: 15px; top: 4px; bottom: 8px; width: 1px; background: var(--border-strong);
}
.nav-subitem {
    display: block; padding: 7px 10px 7px 14px; margin: 1px 0; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 13px; position: relative;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-subitem:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-subitem.active { color: var(--text-primary); font-weight: 400; background: var(--surface-hover); }
.nav-subgroup-label {
    font-size: 10px; font-weight: 400; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-tertiary); padding: 10px 10px 3px 14px; white-space: nowrap;
}
.nav-subgroup-label:first-child { padding-top: 2px; }
.shell.collapsed .nav-submenu { display: none; }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); flex-shrink: 0; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 39;
    opacity: 0; transition: opacity .2s var(--ease);
}

/* -------------------------------------------------------------------- */
/* Topbar + content                                                      */
/* -------------------------------------------------------------------- */

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

.topbar {
    height: var(--topbar-h); flex-shrink: 0; position: sticky; top: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; padding: 0 20px;
}
.mobile-menu-toggle { display: none; }
.topbar-search {
    flex: 1; max-width: 380px; display: flex; align-items: center; gap: 8px;
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 7px 10px; color: var(--text-tertiary); font-size: 13px;
}
.topbar-search input { border: none; background: none; outline: none; color: var(--text-primary); width: 100%; }
.topbar-search kbd {
    font-size: 11px; color: var(--text-tertiary); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
    width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid transparent; background: none;
    color: var(--text-secondary); display: flex; align-items: center; justify-content: center; cursor: pointer;
    position: relative; transition: background-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.icon-btn:active { transform: scale(.92); }
.icon-btn .dot {
    position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%;
    background: var(--danger); border: 2px solid var(--surface);
}

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

.user-menu-trigger { display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 5px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; background: none; }
.user-menu-trigger:hover { background: var(--surface-hover); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-fg);
    display: flex; align-items: center; justify-content: center; font-weight: 400; font-size: 12px; flex-shrink: 0;
}
.user-menu-name { font-size: 13px; font-weight: 400; line-height: 1.2; }
.user-menu-role { font-size: 11.5px; color: var(--text-tertiary); line-height: 1.2; }

.dropdown { position: relative; }
.dropdown-panel {
    position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
    z-index: 50; opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
    transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.dropdown-panel.wide { min-width: 340px; }
.dropdown-panel.search-panel { left: 0; right: auto; width: 420px; max-width: calc(100vw - 40px); max-height: 70vh; overflow-y: auto; }
.search-result-group + .search-result-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
.search-result-item .dropdown-item-title { font-weight: 400; color: var(--text-primary); }
.search-result-item .dropdown-item-sub { font-size: 11.5px; color: var(--text-tertiary); }
.dropdown.open .dropdown-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.dropdown-item {
    display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-sm);
    font-size: 13px; color: var(--text-secondary); cursor: pointer; white-space: nowrap;
}
.dropdown-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px 2px; }
.dropdown-header { padding: 8px 10px 4px; font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); }
.dropdown-empty { padding: 24px 10px; text-align: center; color: var(--text-tertiary); font-size: 13px; }

.link-btn {
    background: none; border: none; padding: 0; color: var(--accent); font-size: 12.5px; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.notif-item { white-space: normal; align-items: flex-start; gap: 8px; }
.notif-unread-dot {
    width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; background: transparent;
}
.notif-item.unread .notif-unread-dot { background: var(--accent); }
.notif-item.unread .notif-title { font-weight: 400; color: var(--text-primary); }
.notif-title { display: block; font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.notif-time { display: block; font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }

.content { flex: 1; padding: 24px 28px 60px; animation: fade-in-up .22s var(--ease); }

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 500; }
.page-sub { color: var(--text-secondary); font-size: 13.5px; margin-top: 3px; }

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

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 400;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); cursor: pointer;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease), opacity .15s var(--ease);
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: none; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

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

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 400; color: var(--text-secondary); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--text-tertiary); margin-top: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="tel"], select, textarea {
    width: 100%; padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg); color: var(--text-primary); outline: none;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
.otp-input { text-align: center; letter-spacing: 10px; font-size: 22px; font-weight: 400; }

/* -------------------------------------------------------------------- */
/* Cards / KPI / badges / alerts                                        */
/* -------------------------------------------------------------------- */

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 18px; box-shadow: var(--shadow-sm);
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.kpi-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 400; }
.kpi-value { font-size: 26px; font-weight: 400; margin-top: 6px; letter-spacing: -.02em; }
.kpi-trend { font-size: 12px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

.kpi-spark { flex-shrink: 0; }
.kpi-spark.up { color: var(--success); }
.kpi-spark.down { color: var(--danger); }
.sparkline { display: block; }

.agenda-list { display: flex; flex-direction: column; gap: 2px; }
.agenda-item {
    display: flex; align-items: flex-start; gap: 10px; padding: 8px 6px; border-radius: var(--radius-sm);
    color: inherit; font-size: 13px;
}
.agenda-item:hover { background: var(--surface-hover); }
.agenda-item svg { margin-top: 1px; color: var(--text-tertiary); flex-shrink: 0; }
.agenda-label { display: block; color: var(--text-primary); line-height: 1.4; }
.agenda-date { display: block; font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }

.activity-feed { display: flex; flex-direction: column; gap: 12px; }
.activity-item { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.activity-item svg { margin-top: 2px; color: var(--text-tertiary); flex-shrink: 0; }
.activity-item span { color: var(--text-secondary); line-height: 1.4; }

.badge {
    display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 400;
    padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.badge-gray { background: var(--surface-hover); color: var(--text-secondary); }
.badge-green { background: var(--success-subtle); color: var(--success); }
.badge-red { background: var(--danger-subtle); color: var(--danger); }
.badge-amber { background: var(--warning-subtle); color: var(--warning); }
.badge-blue { background: var(--info-subtle); color: var(--info); }
.badge-accent { background: var(--accent-subtle); color: var(--accent); }

.alert { border-radius: var(--radius); padding: 11px 14px; font-size: 13.5px; margin-bottom: 16px; display: flex; align-items: center; gap: 9px; }
.alert-success { background: var(--success-subtle); color: var(--success); }
.alert-error { background: var(--danger-subtle); color: var(--danger); }

/* -------------------------------------------------------------------- */
/* Toasts                                                                */
/* -------------------------------------------------------------------- */

.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: var(--radius);
    padding: 12px 14px; min-width: 260px; max-width: 340px; display: flex; align-items: flex-start; gap: 10px; font-size: 13px;
    animation: toast-in .22s var(--ease);
}
.toast.hide { animation: toast-out .18s var(--ease) forwards; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* -------------------------------------------------------------------- */
/* Skeleton loaders                                                      */
/* -------------------------------------------------------------------- */

.skeleton {
    background: linear-gradient(90deg, var(--surface-hover) 25%, var(--border) 37%, var(--surface-hover) 63%);
    background-size: 400% 100%; animation: skeleton-shimmer 1.4s ease infinite; border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skeleton-text { height: 12px; margin-bottom: 8px; }
.skeleton-kpi { height: 92px; border-radius: var(--radius-lg); }

/* -------------------------------------------------------------------- */
/* Empty states                                                          */
/* -------------------------------------------------------------------- */

.empty-state { text-align: center; padding: 56px 20px; color: var(--text-secondary); }
.empty-state .icon { color: var(--text-tertiary); margin-bottom: 12px; }
.empty-state h3 { font-size: 15px; margin-bottom: 4px; color: var(--text-primary); }
.empty-state p { font-size: 13px; }

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

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); font-weight: 400; padding: 11px 16px; border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color .12s var(--ease); }
tbody tr:hover { background: var(--surface-hover); }

.diff-table { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.diff-row { display: grid; grid-template-columns: auto 1fr auto 1fr; align-items: center; gap: 8px; font-size: 11.5px; }
.diff-key { font-weight: 400; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .03em; font-size: 10.5px; }
.diff-old { color: var(--danger); text-decoration: line-through; opacity: .8; word-break: break-word; }
.diff-new { color: var(--success); word-break: break-word; }
.diff-arrow { color: var(--text-tertiary); flex-shrink: 0; }

/* -------------------------------------------------------------------- */
/* Bulk actions — multiselect checkboxes + floating action bar, shared   */
/* by every list page via assets/js/bulk-actions.js.                    */
/* -------------------------------------------------------------------- */

.bulk-col { width: 34px; padding-right: 0 !important; }
tbody tr.bulk-selected { background: var(--accent-subtle); }

.card-select-wrap { position: relative; }
.card-select-wrap .bulk-checkbox-overlay {
    position: absolute; top: 10px; left: 10px; z-index: 2; width: 18px; height: 18px; cursor: pointer;
}
.card-select-wrap.bulk-selected > a.card,
.card-select-wrap.bulk-selected > .card {
    outline: 2px solid var(--accent); outline-offset: -1px;
}

.bulk-bar {
    position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(80px);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: var(--radius-lg);
    padding: 10px 12px 10px 18px; display: flex; align-items: center; gap: 14px; font-size: 13.5px;
    z-index: 60; opacity: 0; pointer-events: none; transition: transform .18s var(--ease), opacity .18s var(--ease);
}
.bulk-bar.visible { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }
.bulk-bar strong { font-weight: 400; color: var(--accent); }

/* -------------------------------------------------------------------- */
/* Events — Month grid + view switcher (Week/10-day reuse the plain       */
/* agenda-list markup already styled above, no new classes needed).       */
/* -------------------------------------------------------------------- */

.view-switcher { display: flex; gap: 2px; background: var(--bg-secondary); border-radius: var(--radius-sm); padding: 2px; }
.view-switcher a {
    padding: 6px 12px; border-radius: 6px; font-size: 12.5px; color: var(--text-secondary);
    text-decoration: none; transition: background-color .12s var(--ease), color .12s var(--ease);
}
.view-switcher a.active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.view-switcher a:hover:not(.active) { color: var(--text-primary); }

.month-grid {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px;
    background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}
.month-grid-header {
    background: var(--surface); padding: 8px 4px; text-align: center; font-size: 11px;
    text-transform: uppercase; letter-spacing: .03em; color: var(--text-tertiary); font-weight: 400;
}
.month-cell { min-width: 0; background: var(--surface); min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.month-cell.outside { background: var(--bg-secondary); }
.month-cell.outside .month-cell-date { color: var(--text-tertiary); }
.month-cell.today .month-cell-date {
    display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
    background: var(--accent); color: #fff; border-radius: 50%;
}
.month-cell-date { font-size: 12px; font-weight: 400; margin-bottom: 2px; }
.month-cell-item {
    font-size: 10.5px; padding: 2px 5px; border-radius: 4px; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; display: block; text-decoration: none;
}
.month-cell-more { font-size: 10.5px; color: var(--text-tertiary); text-decoration: none; margin-top: 1px; }
.month-cell-more:hover { color: var(--text-secondary); }

.day-group { border-bottom: 1px solid var(--border); }
.day-group:last-child { border-bottom: none; }
.day-group-header {
    padding: 10px 14px; font-size: 12.5px; font-weight: 400; color: var(--text-secondary);
    background: var(--bg-secondary); display: flex; align-items: center; gap: 8px;
}
.day-group-header.today { color: var(--accent); }

/* -------------------------------------------------------------------- */
/* Login / OTP screens                                                   */
/* -------------------------------------------------------------------- */

.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-secondary); padding: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 34px; width: 400px; max-width: 100%; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }

/* -------------------------------------------------------------------- */
/* Funnel visualization (Sales Pipeline, Projects) — plain CSS, no chart  */
/* library needed for a simple ordered-stage funnel.                     */
/* -------------------------------------------------------------------- */

.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 50px; align-items: center; gap: 12px; }
.funnel-label { font-size: 12.5px; font-weight: 400; color: var(--text-secondary); }
.funnel-track { background: var(--bg-secondary); border-radius: var(--radius-sm); overflow: hidden; height: 26px; }
.funnel-bar {
    height: 100%; background: var(--accent); border-radius: var(--radius-sm);
    transition: width .5s var(--ease); min-width: 3px;
}
.funnel-count { font-size: 13px; font-weight: 400; text-align: right; }

/* -------------------------------------------------------------------- */
/* Chart containers                                                      */
/* -------------------------------------------------------------------- */

.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.chart-card h3 { font-size: 14px; margin-bottom: 14px; }
.chart-wrap { position: relative; height: 240px; }

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

@media (max-width: 880px) {
    .topbar-search { display: none; }
    .sidebar {
        position: fixed; left: 0; top: 0; width: 260px !important; transform: translateX(-100%);
        transition: transform .22s var(--ease); box-shadow: var(--shadow-lg);
    }
    .shell.mobile-open .sidebar { transform: translateX(0); }
    .shell.mobile-open .sidebar-overlay { display: block; opacity: 1; }
    .sidebar-toggle { display: none; }
    .mobile-menu-toggle { display: flex; }
    .content { padding: 18px 16px 50px; }
    .auth-card { padding: 26px; }
    .dropdown-panel.wide { min-width: min(340px, calc(100vw - 32px)); right: -10px; }

    /* Most module pages lay out multi-column sections (a form + a list, a
       sidebar + detail panel, KPI/chart rows) with an inline
       `grid-template-columns`, not a reusable class — retrofitting a class
       onto every one of those across ~30 files isn't practical, so this
       attribute-selector override collapses all of them to a single
       column below the breakpoint in one place instead. */
    [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

@media (max-width: 520px) {
    .page-head { flex-direction: column; align-items: stretch; }
}

/* -------------------------------------------------------------------- */
/* Crop modal (Cropper.js wrapper) — used for profile photo / logo      */
/* uploads across Clients, Projects, and Loans.                         */
/* -------------------------------------------------------------------- */

.crop-modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 100;
    align-items: center; justify-content: center; padding: 20px;
}
.crop-modal-overlay.open { display: flex; }
.crop-modal {
    background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
}
.crop-modal-header {
    padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 400; font-size: 14px;
    display: flex; justify-content: space-between; align-items: center;
}
.crop-modal-body { padding: 16px; background: var(--bg-secondary); flex: 1; min-height: 0; }
.crop-modal-body .crop-image-container { max-height: 360px; }
.crop-modal-body img { display: block; max-width: 100%; }
.crop-modal-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* -------------------------------------------------------------------- */
/* Email compose sidebar (invoices/receipts "Email" action, Settings ->  */
/* Mail Templates "Compose custom email") + hand-rolled rich-text editor.*/
/* -------------------------------------------------------------------- */

.email-sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 100;
    justify-content: flex-end;
}
.email-sidebar-overlay.open { display: flex; }
.email-sidebar {
    background: var(--surface); width: 100%; max-width: 460px; height: 100%;
    display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
    transform: translateX(100%); transition: transform .2s var(--ease);
}
.email-sidebar-overlay.open .email-sidebar { transform: translateX(0); }
.email-sidebar-header {
    padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 400; font-size: 15px;
    display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}
.email-sidebar-body { padding: 16px 18px; flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.email-sidebar-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }
.email-sidebar-status { padding: 8px 10px; border-radius: var(--radius-sm); font-size: 12.5px; }
.email-sidebar-status.success { background: rgba(34, 197, 94, .12); color: #22c55e; }
.email-sidebar-status.error { background: rgba(220, 38, 38, .12); color: #dc2626; }

.richtext-wrap { display: flex; flex-direction: column; flex: 1; min-height: 200px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.richtext-toolbar { display: flex; gap: 4px; padding: 6px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.richtext-btn {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 4px 9px; font-size: 12px; cursor: pointer; color: var(--text-primary);
}
.richtext-btn:hover { border-color: var(--accent); color: var(--accent); }
.richtext-editor, .richtext-source {
    flex: 1; padding: 10px; font-size: 13px; color: var(--text-primary); background: var(--surface);
    outline: none; overflow-y: auto; min-height: 160px;
}
.richtext-source { border: 0; resize: none; font-family: monospace; width: 100%; }
