/* ==================== Acirum CRM — Dark Theme (Ink + Ember + warm Paper text) ==================== */
:root {
    /* Ink backgrounds — warm charcoal, rooted in brand Ink (#0f1012) */
    --bg-0: #0f1012;
    --bg-1: #151311;
    --bg-2: #1a1815;
    --bg-3: #211f1b;
    --bg-hover: #272420;
    --border: #2d2a25;
    --border-soft: #221f1a;

    /* Paper text — warm white from brand book, not cold grey */
    --text: #f0ede6;
    --text-1: #f0ede6;
    --text-2: #a89f94;
    --text-3: #6e6760;

    /* Acirum Ember Accent */
    --accent: #c4613a;
    --accent-hover: #a85030;
    --accent-soft: rgba(196, 97, 58, 0.14);
    --accent-border: rgba(196, 97, 58, 0.35);

    /* Status colors */
    --success: #4caf7d;
    --warning: #e0a458;
    --danger: #d0564b;
    --info: #4a90d9;

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);

    /* Manrope handles Latin / Latin-ext / Cyrillic. Noto Sans Arabic /
       SC / Georgian are explicitly listed so the browser can match them
       via unicode-range for scripts Manrope doesn't ship (Arabic,
       Chinese, Georgian). System-level fallbacks at the end keep things
       sane on Android / Windows / Linux if the web fonts fail to load. */
    --font: 'Manrope', 'Noto Sans Arabic', 'Noto Sans SC', 'Noto Sans Georgian',
        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        'Helvetica Neue', Arial, sans-serif;
}

/* ==================== Acirum Light Theme (Paper palette from brand book) ==================== */
body.theme-light {
    /* Paper backgrounds */
    --bg-0: #f4f1ea;
    --bg-1: #ffffff;
    --bg-2: #f9f7f4;
    --bg-3: #ede9e1;
    --bg-hover: #e6e1d8;
    --border: #d5cfc4;
    --border-soft: #e4dfd4;

    /* Ink text */
    --text: #0f1012;
    --text-1: #0f1012;
    --text-2: #3d3f44;
    --text-3: #7a7a80;

    /* Ember accent */
    --accent: #c4613a;
    --accent-hover: #a85030;
    --accent-soft: rgba(196, 97, 58, 0.10);
    --accent-border: rgba(196, 97, 58, 0.35);

    --shadow: 0 4px 16px rgba(15,16,18,0.08);
    --shadow-lg: 0 12px 36px rgba(15,16,18,0.12);
}

/* ==================== Soteryan Tenant — Light Theme ==================== */
body.theme-light.tenant-soteryan {
    --bg-0: #f0f2f5;
    --bg-1: #ffffff;
    --bg-2: #f5f6f8;
    --bg-3: #eaecef;
    --bg-hover: #e2e5ea;
    --border: #d4d8de;
    --border-soft: #e2e5ea;
    --text: #111316;
    --text-1: #111316;
    --text-2: #4a4f5a;
    --text-3: #888d97;
    --accent: #e2725b;
    --accent-hover: #d65f45;
    --accent-soft: rgba(226, 114, 91, 0.12);
    --accent-border: rgba(226, 114, 91, 0.40);
    --shadow: 0 4px 16px rgba(0,0,0,0.10);
    --shadow-lg: 0 12px 36px rgba(0,0,0,0.14);
}

/* ==================== Soteryan Tenant — Dark Theme ==================== */
body.tenant-soteryan {
    --bg-1: #16181c;
    --bg-2: #1c1f24;
    --bg-3: #23272e;
    --bg-hover: #2a2e36;
    --border: #2c3038;
    --border-soft: #22262d;
    --text: #ececec;
    --text-1: #ececec;
    --text-2: #b0b4bb;
    --text-3: #7a7f88;
    --accent: #e2725b;
    --accent-hover: #d65f45;
    --accent-soft: rgba(226, 114, 91, 0.14);
    --accent-border: rgba(226, 114, 91, 0.35);
}
body.tenant-soteryan .auth-left-pane {
    background:
        radial-gradient(circle at 20% 10%, rgba(226,114,91,0.18), transparent 55%),
        radial-gradient(circle at 85% 85%, rgba(226,114,91,0.10), transparent 55%),
        linear-gradient(135deg, #17191E 0%, #0F1012 100%);
    border-right: 1px solid rgba(226,114,91,0.12);
}
body.tenant-soteryan .auth-left-pane::before {
    background: radial-gradient(circle, rgba(226,114,91,0.22), transparent 70%);
}
body.tenant-soteryan .auth-left-pane::after {
    background: radial-gradient(circle, rgba(226,114,91,0.10), transparent 70%);
}
body.tenant-soteryan .brand-spinner-logo {
    filter: drop-shadow(0 0 22px rgba(226,114,91,0.45));
}
body.tenant-soteryan .brand-logo-image { box-shadow: none; }

/* ==================== Global round checkbox style ==================== */
input[type="checkbox"]:not(.check-item input):not(.toggle-input) {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 0;
    border: 2px solid var(--accent-border);
    border-radius: 50%;
    background: transparent;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
input[type="checkbox"]:not(.check-item input):not(.toggle-input)::after {
    content: '';
    width: 5px;
    height: 9px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg) translate(-1px, -1px);
    opacity: 0;
}
input[type="checkbox"]:not(.check-item input):not(.toggle-input):checked {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
input[type="checkbox"]:not(.check-item input):not(.toggle-input):checked::after {
    opacity: 1;
}
input[type="checkbox"]:not(.check-item input):not(.toggle-input):hover {
    border-color: var(--accent);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-0);
    color: var(--text-1);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
}

html { scroll-behavior: smooth; }
body { overscroll-behavior-y: none; }

body.app-loading #authScreen,
body.app-loading #mainApp {
    visibility: hidden;
}

/* ==================== Global brand loader ==================== */
.global-loader {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-0);
    animation: gl-fade-in 160ms ease both;
}
body.app-loading .global-loader,
body.loader-active .global-loader { display: flex; }
.global-loader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}
.brand-spinner {
    position: relative;
    width: 110px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 800px;
}
.brand-spinner-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 0 22px rgba(196,97,58,0.45));
    transform-origin: 50% 50%;
    transform-style: preserve-3d;
    backface-visibility: visible;
    animation: gl-coin-spin 1s linear infinite;
    will-change: transform;
}
.brand-spinner-ring { display: none; }
.brand-spinner-word {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: var(--text-1);
}
.brand-spinner-word span {
    color: var(--accent);
    margin-left: 3px;
}
@keyframes gl-coin-spin { from { transform: rotateY(0deg); } to { transform: rotateY(360deg); } }
@keyframes gl-fade-in { from { opacity: 0; } to { opacity: 1; } }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; stroke-linecap: round; stroke-linejoin: round; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ==================== Layout ==================== */
.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
    overflow: hidden;
    transition: grid-template-columns 0.25s ease;
}
.app.sidebar-collapsed {
    grid-template-columns: 64px 1fr;
}

/* ==================== Sidebar ==================== */
.sidebar {
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
    overflow: hidden;
    transition: padding 0.25s ease;
    position: relative;
}
.app.sidebar-collapsed .sidebar {
    padding: 22px 10px;
    align-items: center;
}

/* ── Collapse toggle button ── */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    margin-top: 4px;
}
.sidebar-toggle:hover {
    background: var(--bg-2);
    color: var(--text-1);
}
.sidebar-toggle svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}
.app.sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}
.sidebar-toggle span {
    transition: opacity 0.15s, max-width 0.25s;
    opacity: 1;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
}
.app.sidebar-collapsed .sidebar-toggle span {
    opacity: 0;
    max-width: 0;
}
.app.sidebar-collapsed .sidebar-toggle {
    padding: 8px 0;
    justify-content: center;
    /* Zero the base gap — the collapsed span still takes part in flex
       layout (max-width:0 keeps it in DOM for the expand transition) so
       a non-zero gap offsets the svg ~5 px left of centre. */
    gap: 0;
}

/* What's new button — lives just above the collapse toggle. Shares the
   ghost-button visuals but has a subtle accent dot on the icon so new
   release notes draw the eye without being loud. */
.sidebar-updates {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    margin-top: 4px;
    position: relative;
}
.sidebar-updates:hover {
    background: var(--bg-2);
    color: var(--text-1);
}
.sidebar-updates svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--accent);
}
.sidebar-updates span:not(.sidebar-updates-badge) {
    transition: opacity 0.15s, max-width 0.25s;
    opacity: 1;
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}
.app.sidebar-collapsed .sidebar-updates span:not(.sidebar-updates-badge) {
    opacity: 0;
    max-width: 0;
}
.app.sidebar-collapsed .sidebar-updates {
    padding: 8px 0;
    justify-content: center;
    /* Same gap-zero trick as .sidebar-toggle — otherwise the bell icon
       sits left of centre because flex still honours the 10px gap even
       when the label span collapsed to 0 width. */
    gap: 0;
}
.sidebar-updates-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.app.sidebar-collapsed .sidebar-updates-badge {
    position: absolute;
    top: 2px;
    right: 6px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px 18px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 16px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.14s, padding 0.25s ease, gap 0.25s ease;
    overflow: hidden;
    width: 100%;
}
.brand:hover { background: transparent; }
.app.sidebar-collapsed .brand {
    padding: 6px 4px 18px;
    gap: 0;
    justify-content: center;
    pointer-events: none;
}

.brand-text {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.25s ease;
    opacity: 1;
    width: auto;
}
.app.sidebar-collapsed .brand-text {
    opacity: 0;
    width: 0;
}

.brand-logo {
    width: 48px; height: 48px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #a04532);
    border-radius: var(--radius-sm);
    display: grid; place-items: center;
    font-weight: 800; font-size: 18px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(196, 97, 58, 0.35);
    transition: width 0.25s ease, height 0.25s ease;
}
.app.sidebar-collapsed .brand-logo {
    width: 40px;
    height: 40px;
}
.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: inherit;
}
.brand-logo-image {
    background: transparent;
    padding: 0;
    overflow: visible;
    box-shadow: none;
}
/* In light theme, invert the light-stroked mark so it shows as Ink (#0f1012) */
body.theme-light .brand-logo img,
body.theme-light .brand-spinner-logo {
    filter: brightness(0);
}
/* Light theme: the auth left pane also flips to a paper gradient, so
   the mark stays inverted like the rest of the app (dropping the old
   filter:none override that assumed the pane was always dark). */
body.theme-light .auth-left-content .brand-logo img {
    filter: brightness(0);
}

.brand-title { font-size: 16px; font-weight: 700; letter-spacing: 0.2px; }
.brand-title span { color: var(--accent); }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; width: 100%; overflow-y: auto; overflow-x: hidden; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, padding 0.25s ease, justify-content 0.25s ease;
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    position: relative;
}
.app.sidebar-collapsed .nav-item {
    padding: 10px 0;
    justify-content: center;
    gap: 0;
}
.nav-item span {
    overflow: hidden;
    opacity: 1;
    max-width: 200px;
    transition: opacity 0.15s ease, max-width 0.25s ease;
}
.app.sidebar-collapsed .nav-item span {
    opacity: 0;
    max-width: 0;
}
.nav-item svg { flex-shrink: 0; }

/* Pending-approval count badge on nav items (Projects, Accounts, POC) */
.nav-approval-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s ease, max-width 0.25s ease;
}
/* In collapsed mode: absolute top-right dot */
.app.sidebar-collapsed .nav-approval-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    margin-left: 0;
    min-width: 16px;
    height: 16px;
    font-size: 9px;
    padding: 0 4px;
}

.nav-item:hover { background: var(--bg-2); color: var(--text-1); }
.app.sidebar-collapsed .nav-item:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-3);
    color: var(--text-1);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    border: 1px solid var(--border);
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.nav-item.active svg { color: var(--accent); }

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
    width: 100%;
}
.app.sidebar-collapsed .sidebar-footer {
    display: flex;
    justify-content: center;
}
.app.sidebar-collapsed .user {
    padding: 8px 4px;
    gap: 0;
    justify-content: center;
}
.app.sidebar-collapsed .user-info,
.app.sidebar-collapsed #logoutBtn {
    display: none;
}

.user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent);
    display: grid; place-items: center;
    font-weight: 700; color: #fff; font-size: 13px;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-3); }

/* ==================== Main ==================== */
.main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-0);
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-0);
}
.topbar-left { min-width: 0; }

.page-title { font-size: 20px; font-weight: 700; }
.page-subtitle { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.topbar-right { display: flex; align-items: center; gap: 12px; position: relative; }

.search {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    width: 300px;
}
.search svg { color: var(--text-3); }
.search input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--text-1); font-size: 13px;
}
.search input::placeholder { color: var(--text-3); }
.search:focus-within { border-color: var(--accent-border); }

/* ── Notification bell + panel ───────────────────────────────── */
.notif-wrap { position: relative; }
.notif-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-2);
    position: relative;
    transition: color .12s, border-color .12s, background .12s;
}
.notif-btn:hover { color: var(--accent); border-color: var(--accent-border); background: var(--bg-hover); }
.notif-btn svg { width: 18px; height: 18px; }
.notif-badge {
    position: absolute; top: 2px; right: 2px;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 10px; font-weight: 700; line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--bg-2);
}
.notif-panel {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 360px; max-height: 460px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,.4);
    z-index: 50;
    overflow: hidden;
    flex-direction: column;
}
/* Show only when explicitly opened — no !important on display, so inline
   style set from JS (or the `[hidden]` attribute) can hide it. */
.notif-panel.open { display: flex; }
.notif-panel:not(.open) { display: none; }
.notif-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-1); font-weight: 600; font-size: 14px;
}
.notif-clear {
    background: transparent; border: none;
    color: var(--text-3); font-size: 11px; cursor: pointer;
    text-transform: uppercase; letter-spacing: .5px;
}
.notif-clear:hover { color: var(--accent); }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    cursor: pointer;
    transition: background .1s;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item:last-child { border-bottom: none; }
.notif-item .ni-title { font-size: 13px; font-weight: 600; color: var(--text-1); margin-bottom: 3px; }
.notif-item .ni-body  { font-size: 12px; color: var(--text-2); line-height: 1.4; }
.notif-item .ni-when  { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.notif-item .ni-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.notif-item.has-actions { cursor: default; }
.notif-item.has-actions:hover { background: var(--bg-2); }
.notif-empty {
    padding: 28px 14px; text-align: center;
    color: var(--text-3); font-size: 12.5px;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px 40px;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    border: 1px solid transparent;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-2); color: var(--text-1); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text-1); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ==================== Cards & Stats ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px; background: var(--accent);
    opacity: 0.7;
}
.stat-label { color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-delta { font-size: 12px; margin-top: 6px; color: var(--success); }
.stat-delta.down { color: var(--danger); }
.stat-icon {
    position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--accent-soft);
    display: grid; place-items: center;
    color: var(--accent);
}
.stat-icon svg { width: 22px; height: 22px; }

/* ==================== Panels ==================== */
.panel {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-soft);
}
.panel-title { font-size: 15px; font-weight: 600; }
.panel-body { padding: 16px 20px; }
.panel-body.p0 { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* ==================== Tables ==================== */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-3);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-2);
}
.table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-soft);
}
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--bg-2); }
.table tbody tr:last-child td { border-bottom: none; }
/* List-view row actions: icon-only buttons, kept on a single line so
   a narrow actions column doesn't wrap the icons under each other
   (which looked like a stacked 3-button mess before). */
.table .row-actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: nowrap; align-items: center; white-space: nowrap; min-width: 210px; padding-right: 10px; }
.table td.row-actions { overflow: visible; }
.table-subline { font-size: 11px; color: var(--text-3); margin-top: 4px; }

.icon-action {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    max-width: 30px;
    max-height: 30px;
    aspect-ratio: 1 / 1;
    flex: 0 0 30px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    background: transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.icon-action svg {
    width: 15px;
    height: 15px;
}
.icon-action:hover {
    background: var(--bg-2);
    color: var(--text-1);
    transform: translateY(-1px);
}
.icon-action:focus-visible {
    outline: none;
    border-color: var(--accent-border);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.icon-action.edit:hover {
    color: var(--accent);
    border-color: var(--accent-border);
}
.icon-action.delete:hover {
    color: var(--danger);
    border-color: rgba(208, 86, 75, 0.35);
}
.icon-action.enable:hover {
    color: var(--success);
    border-color: rgba(76, 175, 125, 0.35);
}
.icon-action.disable:hover {
    color: var(--warning);
    border-color: rgba(224, 164, 88, 0.35);
}
/* Approve — solid green fill for high visibility */
.icon-action.approve {
    color: white;
    background: #27AE60;
    border-color: #27AE60;
    box-shadow: 0 1px 3px rgba(39, 174, 96, 0.30);
}
.icon-action.approve:hover {
    background: #229954;
    border-color: #229954;
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 3px 8px rgba(39, 174, 96, 0.45);
}
/* Reject — solid red fill for high visibility */
.icon-action.reject {
    color: white;
    background: #E74C3C;
    border-color: #E74C3C;
    box-shadow: 0 1px 3px rgba(231, 76, 60, 0.30);
}
.icon-action.reject:hover {
    background: #C0392B;
    border-color: #C0392B;
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 3px 8px rgba(231, 76, 60, 0.45);
}
/* Gavel — solid purple/accent fill for "counter offer" */
.icon-action.gavel {
    color: white;
    background: #8B5CF6;
    border-color: #8B5CF6;
    box-shadow: 0 1px 3px rgba(139, 92, 246, 0.30);
}
.icon-action.gavel:hover {
    background: #7C3AED;
    border-color: #7C3AED;
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 3px 8px rgba(139, 92, 246, 0.45);
}

/* ==================== List View Advanced Filters ==================== */
/* Compact inline toolbar group — lives right after the status chips, three
   small icon buttons (filter / save / saved). No border, no background — it
   should blend with the rest of the .filters row. */
.filter-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
    position: relative;
}
.filter-toolbar-group .icon-action {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
}
.filter-toolbar-group .icon-action.filter-ico:hover { color: var(--accent); border-color: var(--accent-border); }
.filter-toolbar-group .icon-action.filter-save-ico { color: #27AE60; border-color: rgba(39,174,96,0.35); }
.filter-toolbar-group .icon-action.filter-save-ico:hover { color: white; background: #27AE60; border-color: #27AE60; }
.filter-toolbar-group .icon-action.filter-saved-ico:hover { color: var(--accent); border-color: var(--accent-border); }

/* Tiny counter dot sits on the top-right corner of the filter icons */
.filter-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 1.5px solid var(--bg);
}

/* Active-criteria chip strip — rendered as a thin row BETWEEN the status
   chips and the table. Only shows when there's at least one active filter. */
.active-filter-chip-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 0 10px 2px;
    margin-bottom: 6px;
}
.filter-criterion-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 10px;
    background: var(--accent-soft, rgba(226, 136, 88, 0.12));
    border: 1px solid var(--accent-border, rgba(226, 136, 88, 0.30));
    color: var(--text-1);
    border-radius: 14px;
    font-size: 11.5px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.filter-criterion-chip:hover {
    background: var(--accent-soft, rgba(226, 136, 88, 0.20));
    border-color: var(--accent);
    transform: translateY(-1px);
}
.filter-criterion-chip strong { font-weight: 600; color: var(--text-2); }
.filter-criterion-chip .op  { color: var(--text-3); margin: 0 1px; }
.filter-criterion-chip .val { color: var(--accent); font-weight: 600; }
.filter-criterion-chip .x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-3);
    font-size: 12px;
    line-height: 1;
    margin-left: 2px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.filter-criterion-chip .x:hover { background: var(--danger); color: white; }

.clear-filters-btn {
    background: transparent;
    border: none;
    color: var(--text-3);
    font-size: 11px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 12px;
    transition: background 0.12s, color 0.12s;
}
.clear-filters-btn:hover { background: var(--bg-2); color: var(--danger); }

.saved-filters-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    min-width: 240px;
    max-height: 320px;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 50;
    padding: 6px;
}
.saved-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-1);
    transition: background 0.12s;
}
.saved-filter-row:hover { background: var(--bg-2); }
.saved-filter-row .name  { flex: 1; }
.saved-filter-row .meta  { font-size: 11px; color: var(--text-3); }
.saved-filter-row .del {
    width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-3); font-size: 16px; line-height: 1;
    transition: background 0.12s, color 0.12s;
}
.saved-filter-row .del:hover { background: var(--danger); color: white; }

/* ==================== Global search dropdown ==================== */
.global-search-dropdown {
    position: absolute;
    z-index: 9000;
    max-height: 520px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    padding: 6px;
    display: none;
}
.global-search-dropdown .gs-head {
    padding: 10px 12px 8px;
    font-size: 11.5px;
    color: var(--text-3);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.global-search-dropdown .gs-head strong { color: var(--accent); }
.global-search-dropdown .gs-empty {
    padding: 18px 16px;
    color: var(--text-3);
    font-size: 13px;
    text-align: center;
}
.global-search-dropdown .gs-group {
    padding: 4px 0;
    border-top: 1px solid var(--border);
}
.global-search-dropdown .gs-group:first-of-type { border-top: none; }
.global-search-dropdown .gs-group-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 4px;
    font-size: 10.5px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.global-search-dropdown .gs-ic { font-size: 13px; line-height: 1; }
.global-search-dropdown .gs-count {
    margin-left: auto;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--bg-2);
    font-size: 10px;
    color: var(--text-3);
}
.global-search-dropdown .gs-row {
    padding: 8px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s;
}
.global-search-dropdown .gs-row:hover {
    background: var(--accent-soft, rgba(226, 136, 88, 0.12));
}
.global-search-dropdown .gs-primary {
    font-size: 13px;
    color: var(--text-1);
    font-weight: 500;
}
.global-search-dropdown .gs-secondary {
    font-size: 11.5px;
    color: var(--text-3);
    margin-top: 2px;
}

/* ==================== Inline-editable cells ==================== */
.inline-editable {
    cursor: pointer;
    padding: 2px 6px;
    margin: -2px -6px;
    border-radius: 6px;
    transition: background 0.12s, box-shadow 0.12s;
    position: relative;
}
.inline-editable:hover {
    background: var(--accent-soft, rgba(226, 136, 88, 0.12));
    box-shadow: inset 0 0 0 1px var(--accent-border, rgba(226, 136, 88, 0.35));
}
.inline-editable:hover::after {
    content: '✎';
    font-size: 10px;
    color: var(--accent);
    margin-left: 5px;
    opacity: 0.8;
}
.inline-editor {
    outline: none !important;
}
.inline-editor:focus {
    box-shadow: 0 0 0 3px var(--accent-soft, rgba(226, 136, 88, 0.20));
}

/* ==================== Badges ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
}
.badge.new { background: rgba(74, 144, 217, 0.15); color: var(--info); }
.badge.progress { background: rgba(224, 164, 88, 0.15); color: var(--warning); }
.badge.won { background: rgba(76, 175, 125, 0.15); color: var(--success); }
.badge.lost { background: rgba(208, 86, 75, 0.15); color: var(--danger); }
.badge.on-hold { background: rgba(122, 127, 136, 0.2); color: var(--text-2); }

.status-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid transparent;
}
.status-tag::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-tag.meeting { color: var(--accent); background: rgba(226, 114, 91, 0.12); border-color: rgba(226, 114, 91, 0.25); }
.status-tag.call { color: var(--info); background: rgba(74, 144, 217, 0.12); border-color: rgba(74, 144, 217, 0.25); }
.status-tag.deadline, .status-tag.overdue { color: var(--danger); background: rgba(208, 86, 75, 0.12); border-color: rgba(208, 86, 75, 0.25); }
.status-tag.internal, .status-tag.archive { color: var(--text-2); background: rgba(122, 127, 136, 0.16); border-color: rgba(122, 127, 136, 0.25); }
.status-tag.draft { color: var(--warning); background: rgba(224, 164, 88, 0.12); border-color: rgba(224, 164, 88, 0.25); }
.status-tag.review, .status-tag.partial { color: #f2c66d; background: rgba(242, 198, 109, 0.12); border-color: rgba(242, 198, 109, 0.25); }
.status-tag.sent { color: var(--info); background: rgba(74, 144, 217, 0.12); border-color: rgba(74, 144, 217, 0.25); }
.status-tag.signed, .status-tag.paid { color: var(--success); background: rgba(76, 175, 125, 0.12); border-color: rgba(76, 175, 125, 0.25); }
.status-tag.attended { color: var(--success); background: rgba(76, 175, 125, 0.12); border-color: rgba(76, 175, 125, 0.25); }
.status-tag.planned { color: var(--warning); background: rgba(224, 164, 88, 0.12); border-color: rgba(224, 164, 88, 0.25); }
.status-tag.ongoing { color: var(--accent); background: rgba(226, 114, 91, 0.12); border-color: rgba(226, 114, 91, 0.25); }
.status-tag.cancelled { color: var(--danger); background: rgba(208, 86, 75, 0.12); border-color: rgba(208, 86, 75, 0.25); }

.pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-3);
    color: var(--text-2);
}

/* ==================== Pipeline (Kanban) ==================== */
.pipeline {
    display: flex;
    flex-direction: row;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 12px;
    align-items: flex-start;
    /* keep columns from shrinking when there are many */
    flex-wrap: nowrap;
}
.pipeline-col {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 500px;
    /* fixed width — never shrink, never grow */
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
}
.pipeline-col-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pipeline-col-title { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.pipeline-col-title::before {
    content: ''; width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
}
.pipeline-col[data-stage="new"] .pipeline-col-title::before { background: var(--info); }
.pipeline-col[data-stage="qualified"] .pipeline-col-title::before { background: #9c6bd1; }
.pipeline-col[data-stage="proposal"] .pipeline-col-title::before { background: var(--accent); }
.pipeline-col[data-stage="negotiation"] .pipeline-col-title::before { background: var(--warning); }
.pipeline-col[data-stage="won"] .pipeline-col-title::before { background: var(--success); }

.pipeline-col-count {
    background: var(--bg-3); color: var(--text-2);
    font-size: 11px; padding: 2px 8px; border-radius: 100px;
}
.pipeline-col-total { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.pipeline-col-body {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}
.deal-card {
    --deal-stage-color: var(--accent);
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: grab;
    transition: all 0.12s;
    border-left: 3px solid var(--deal-stage-color);
}
.deal-card:hover { background: var(--bg-3); border-left-color: var(--deal-stage-color); transform: translateY(-1px); }
.deal-card.dragging { opacity: 0.5; }
.deal-card[data-stage="new"] { --deal-stage-color: var(--info); }
.deal-card[data-stage="qualified"] { --deal-stage-color: #9c6bd1; }
.deal-card[data-stage="proposal"] { --deal-stage-color: var(--accent); }
.deal-card[data-stage="negotiation"] { --deal-stage-color: var(--warning); }
.deal-card[data-stage="won"] { --deal-stage-color: var(--success); }
.deal-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.deal-client { font-size: 11.5px; color: var(--text-3); margin-bottom: 8px; }
.deal-meta { display: flex; justify-content: space-between; align-items: center; }
.deal-amount { font-size: 13px; font-weight: 700; color: var(--deal-stage-color); }
.deal-date { font-size: 11px; color: var(--text-3); }
.pipeline-col.drag-over { background: var(--accent-soft); border-color: var(--accent-border); }

/* ==================== Forms ==================== */
.form-grid {
    display: grid;
    /* Adaptive — 2 columns when there's room (≥520px), 1 column on
       narrower modals. No need to drop to a media query for this one
       pattern; auto-fit handles it and reflows automatically when the
       modal resizes (which it does on window resize via max-width). */
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.form-grid.single { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group.full { grid-column: 1 / -1; }
/* Force children to respect grid cell width — otherwise a long option
   label in a <select> or a pre-filled <input> can push the cell wider
   than its track and the whole modal horizontally scrolls. */
.form-group input, .form-group textarea, .form-group select {
    max-width: 100%;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}
.form-group label {
    font-size: 12px; color: var(--text-2); font-weight: 500;
}
.form-group input, .form-group textarea, .form-group select {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-1);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--accent);
}
.form-group textarea { min-height: 90px; resize: vertical; }

.form-actions {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
    /* Stay pinned to the bottom of the modal body when the form is
       taller than the viewport — otherwise Create/Cancel scroll away
       and the user has to scroll down to submit. */
    position: sticky;
    bottom: -22px;           /* counter the modal-body 22px bottom padding */
    background: var(--bg-1);
    margin-left: -22px;
    margin-right: -22px;
    padding-left: 22px;
    padding-right: 22px;
    padding-bottom: 22px;
    z-index: 1;
}

/* ==================== Modal ==================== */
/* When drawer is open alongside modal: no full-screen backdrop/blur —
   both panels stay fully visible and clickable. .focused raises modal
   above drawer via z-index; box-shadow signals which is on top. */
.modal-overlay.focused { z-index: 200; }

/* Shared-canvas mode (drawer open) ─────────────────────── */
/* Remove the full-screen tint+blur so the drawer behind stays fully visible. */
.modal-overlay.has-drawer {
    background: transparent;
    backdrop-filter: none;
    /* Clicks pass through the transparent overlay to the drawer/app behind.
       Only the .modal element itself keeps pointer-events. */
    pointer-events: none;
}
.modal-overlay.has-drawer .modal {
    pointer-events: auto;
}
/* Modal inactive (drawer on top): full opacity, softer shadow */
.modal-overlay.has-drawer:not(.focused) .modal {
    box-shadow: 0 2px 20px rgba(0,0,0,0.35);
    transition: box-shadow 0.18s ease;
}
/* Modal active (clicked to front): full-weight shadow */
.modal-overlay.has-drawer.focused .modal {
    box-shadow: 0 8px 48px rgba(0,0,0,0.65);
    transition: box-shadow 0.18s ease;
}
/* Drawer: always fully visible regardless of which panel is on top */
.drawer.back { }
.drawer:not(.back) { }

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    /* Was 640px — too narrow for forms with 8+ fields (the project
       creation modal in particular looked like one tall column and
       pushed buttons past the viewport). 760px gives 2 comfortable
       columns at ≈360px each without losing the centered feel. */
    max-width: 760px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-soft);
}
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close {
    font-size: 26px;
    color: var(--text-3);
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 6px;
    line-height: 1;
}
.modal-close:hover { background: var(--bg-2); color: var(--text-1); }
.modal-body { padding: 22px; overflow-y: auto; }

/* ==================== Right-side drawer ====================
   Slides in from the right when opened from a modal (Project card →
   Email / Files buttons). The modal itself shifts slightly left so
   the user sees both the context card and the drawer at once.
   Closes either via its own × or ESC. */
.drawer {
    position: fixed;
    right: -820px;
    top: 0; bottom: 0;
    width: 720px;
    max-width: 92vw;
    background: var(--bg-1);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 150;
    box-shadow: -24px 0 48px rgba(0,0,0,0.45);
    transition: right 0.32s cubic-bezier(.22,.9,.24,1);
    will-change: right;
}
.drawer.open {
    right: 0;
}
.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}
.drawer-header h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    color: var(--text-1);
}
.drawer-close {
    font-size: 26px;
    color: var(--text-3);
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 6px;
    line-height: 1;
    background: transparent;
    border: 0;
}
.drawer-close:hover { background: var(--bg-2); color: var(--text-1); }
.drawer-body {
    padding: 20px 22px 28px;
    overflow-y: auto;
    flex: 1 1 auto;
}

/* When the drawer is open, the project modal slides left so both are
   visible side-by-side on desktop. On mobile the drawer covers the
   modal — the modal stays behind but is effectively replaced. */
.modal-overlay.has-drawer .modal {
    transform: translateX(-220px);
    transition: transform 0.32s cubic-bezier(.22,.9,.24,1);
}
.modal.modal-no-slide {
    transform: none !important;
}
@media (max-width: 900px) {
    .drawer { width: 100%; max-width: 100%; right: -100vw; }
    .modal-overlay.has-drawer .modal {
        transform: translateX(-100vw); /* push fully off-screen on narrow */
    }
}

/* ==================== Project detail — quick-action icons ====================
   Replaces the old inline email-thread list. Two round buttons, each
   showing a count badge when there's content, sliding the drawer open
   with the full thread / files. */
.project-actions-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 20px 0 4px;
}
.project-action-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.project-action-btn:hover {
    background: var(--bg-3);
    border-color: var(--accent);
    color: var(--text-1);
}
.project-action-btn svg {
    width: 16px; height: 16px;
    color: var(--accent);
    flex-shrink: 0;
}
.project-action-btn .count-badge {
    position: absolute;
    top: -6px; right: -6px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    border-radius: 9px;
    display: grid;
    place-items: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

/* ==================== Drawer — email thread ==================== */
.drawer-email-msg {
    background: var(--bg-0);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
}
.drawer-email-msg.inbound { border-left: 3px solid var(--accent); }
.drawer-email-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 4px;
}
.drawer-email-from {
    font-size: 13px;
    color: var(--text-2);
    min-width: 0;
}
.drawer-email-from strong { color: var(--text-1); }
.drawer-email-when {
    font-size: 11px;
    color: var(--text-3);
    flex-shrink: 0;
    white-space: nowrap;
}
.drawer-email-subj {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
    margin: 4px 0 8px;
}
.drawer-email-body {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-2);
    white-space: pre-wrap;
    word-break: break-word;
    padding-top: 10px;
    border-top: 1px dashed var(--border-soft);
}
.drawer-email-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}
.drawer-reply-form {
    margin-top: 16px;
    padding: 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.drawer-reply-form textarea {
    width: 100%;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    min-height: 120px;
    resize: vertical;
}
.drawer-reply-form .form-actions {
    margin-top: 10px;
    justify-content: flex-end;
    gap: 8px;
}

/* ==================== Drawer — files list ==================== */
.drawer-file-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-0);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
}
.drawer-file-row:hover { border-color: var(--accent); }
.drawer-file-icon {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 9px;
    background: var(--bg-2);
    display: grid;
    place-items: center;
    font-size: 18px;
}
.drawer-file-meta {
    flex: 1;
    min-width: 0;
}
.drawer-file-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drawer-file-sub {
    font-size: 11.5px;
    color: var(--text-3);
    margin-top: 2px;
}
.drawer-verdict {
    padding: 3px 10px;
    border-radius: 11px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.drawer-verdict.clean      { background: rgba(39,174,96,0.14);  color: #27ae60; }
.drawer-verdict.suspicious { background: rgba(243,156,18,0.14); color: #f39c12; }
.drawer-verdict.infected   { background: rgba(231,76,60,0.14);  color: #e74c3c; }
.drawer-verdict.unknown    { background: rgba(138,138,154,0.14); color: #8a8a9a; }

/* ==================== Toast ==================== */
.toast-container {
    position: fixed;
    bottom: 20px; right: 20px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 200;
}
.toast {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    min-width: 260px;
    box-shadow: var(--shadow);
    animation: slideIn 0.25s ease;
    font-size: 13px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==================== Quick Add Menu ==================== */
.quick-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    display: none;
    flex-direction: column;
    min-width: 220px;
    max-width: min(260px, calc(100vw - 28px));
    z-index: 50;
    box-shadow: var(--shadow);
}
.quick-menu.active { display: flex; }
.quick-menu button {
    text-align: left;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-1);
}
.quick-menu button:hover { background: var(--accent-soft); color: var(--accent); }

/* ==================== Tabs & Filters ==================== */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-chip {
    padding: 7px 13px;
    border-radius: 100px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    font-weight: 500;
}
.filter-chip:hover { background: var(--bg-3); color: var(--text-1); }
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ==================== Calendar / Docs / Invoices ==================== */
.calendar-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.85fr) minmax(300px, 1fr);
    gap: 20px;
}
.calendar-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}
.calendar-grid-head { margin-bottom: 8px; }
.calendar-weekday {
    padding: 8px 10px;
    text-align: center;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-3);
}
.calendar-day {
    min-height: 142px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease, opacity 0.12s ease;
}
.calendar-day.muted { opacity: 0.42; }
.calendar-day:hover {
    border-color: var(--accent-border);
    transform: translateY(-1px);
}
.calendar-day.today {
    border-color: var(--accent-border);
    box-shadow: inset 0 0 0 1px rgba(226, 114, 91, 0.25);
}
.calendar-day.today .calendar-day-number { color: var(--accent); }
.calendar-day.selected {
    opacity: 1;
    border-color: var(--accent);
    background: linear-gradient(180deg, rgba(226, 114, 91, 0.16), rgba(226, 114, 91, 0.05));
}
.calendar-day.selected .calendar-day-number { color: var(--text-1); }
.calendar-day.selected.today {
    box-shadow: inset 0 0 0 2px rgba(226, 114, 91, 0.38);
}
.calendar-day-number {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
}
.calendar-day-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.calendar-event-chip {
    width: 100%;
    text-align: left;
    background: var(--bg-3);
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 7px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: background 0.12s ease, transform 0.12s ease;
}
.calendar-event-chip:hover {
    background: #2c3138;
    transform: translateY(-1px);
}
.calendar-event-chip span {
    font-size: 10px;
    color: var(--text-3);
}
.calendar-event-chip strong {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.calendar-event-chip.meeting { border-left-color: var(--accent); }
.calendar-event-chip.call { border-left-color: var(--info); }
.calendar-event-chip.deadline { border-left-color: var(--danger); }
.calendar-event-chip.internal { border-left-color: var(--text-3); }
.calendar-more {
    font-size: 11px;
    color: var(--text-3);
    padding-left: 2px;
}
.calendar-side-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.calendar-selected-date {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 4px;
}
.calendar-agenda-item {
    width: 100%;
    text-align: left;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 12px;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.calendar-agenda-item:hover {
    background: var(--bg-3);
    border-color: var(--accent-border);
}
.calendar-agenda-date {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
}
.calendar-agenda-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}
.calendar-agenda-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 11px;
    color: var(--text-3);
}
.empty.compact {
    padding: 28px 14px;
}
.conference-attention-list {
    display: grid;
    gap: 10px;
}
.conference-alert-card {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(226, 114, 91, 0.08), rgba(26, 29, 34, 0.6));
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.conference-alert-card:hover {
    transform: translateY(-1px);
    border-color: var(--accent-border);
    background: linear-gradient(135deg, rgba(226, 114, 91, 0.14), rgba(26, 29, 34, 0.75));
}
.conference-cost-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 98px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(226, 114, 91, 0.14);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}
.conference-table tbody tr,
.conference-row {
    cursor: pointer;
}
.conference-row.requires-attention {
    background: linear-gradient(90deg, rgba(226, 114, 91, 0.06), transparent 30%);
}
.conference-participant-selected td {
    background: rgba(226, 114, 91, 0.08);
}
.conference-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.conference-meta-item {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-2);
}
.conference-meta-item span {
    display: block;
    font-size: 11px;
    color: var(--text-3);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.conference-meta-item strong {
    font-size: 13px;
    font-weight: 600;
}
.conference-notes-block {
    padding: 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-2);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.conference-notes-block p {
    margin-top: 6px;
    color: var(--text-2);
    line-height: 1.5;
}
.conference-cost-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.conference-cost-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    font-size: 12px;
}
.conference-cost-chip span {
    color: var(--text-3);
}
.conference-cost-chip strong {
    color: var(--text-1);
}
.conference-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-soft);
}
.conference-summary-row:last-child {
    border-bottom: none;
}
.attachment-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.attachment-chip {
    display: inline-flex;
    align-items: center;
    max-width: 170px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.attachment-chip:hover {
    background: var(--bg-3);
    color: var(--text-1);
}
.attachment-chip.more {
    pointer-events: none;
    background: transparent;
}
.file-upload-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border: 1px dashed var(--accent-border);
    border-radius: var(--radius-sm);
    background: rgba(226, 114, 91, 0.06);
    cursor: pointer;
}
.file-upload-field input {
    display: none;
}
.file-upload-field span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
}
.file-upload-field small {
    font-size: 11px;
    color: var(--text-3);
}
.attachment-picker-list,
.attachment-manager-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}
.attachment-section {
    margin-top: 12px;
}
.attachment-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 8px;
}
.attachment-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.attachment-name,
.attachment-link {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-1);
}
.attachment-link {
    text-align: left;
}
.attachment-link:hover {
    color: var(--accent);
}
.attachment-meta {
    font-size: 11px;
    color: var(--text-3);
    white-space: nowrap;
}
.attachment-remove-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-2);
}
.attachment-remove-toggle input {
    accent-color: var(--accent);
}
.attachment-empty {
    font-size: 12px;
    color: var(--text-3);
    padding: 10px 0 2px;
}

/* ==================== Empty state ==================== */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-3);
}
.empty h3 { color: var(--text-2); margin-bottom: 8px; font-size: 15px; }
.empty p { font-size: 13px; margin-bottom: 16px; }

/* ==================== Activity feed ==================== */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
    display: flex;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-soft);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid; place-items: center;
    flex-shrink: 0;
}
.activity-content { flex: 1; }
.activity-text { font-size: 13px; }
.activity-text strong { color: var(--text-1); }
.activity-time { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ==================== Charts ==================== */
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding: 10px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar {
    width: 100%;
    background: linear-gradient(to top, var(--accent), #ff9d7a);
    border-radius: 4px 4px 0 0;
    transition: all 0.3s;
    min-height: 2px;
}
.bar:hover { filter: brightness(1.15); }
.bar-label { font-size: 11px; color: var(--text-3); }
.bar-value { font-size: 11px; color: var(--text-2); font-weight: 600; }

.donut-wrap { display: flex; align-items: center; justify-content: space-around; padding: 20px; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ==================== Checkbox ==================== */
.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
    transition: background 0.12s;
}
.check-item:hover { background: var(--bg-2); }
.check-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 2px solid var(--accent-border);
    border-radius: 50%;
    background: transparent;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.check-item input[type="checkbox"]::after {
    content: '';
    width: 5px;
    height: 9px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg) translate(-1px, -1px);
    opacity: 0;
}
.check-item input[type="checkbox"]:hover {
    border-color: var(--accent);
    transform: scale(1.03);
}
.check-item input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.check-item input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(226, 114, 91, 0.18);
}
.check-item input[type="checkbox"]:checked::after {
    opacity: 1;
}
.check-item.done .check-text { color: var(--text-3); text-decoration: line-through; }
.check-text { flex: 1; }
.check-due {
    min-width: 104px;
    text-align: right;
    font-size: 11px;
    color: var(--text-3);
}
.check-due.overdue { color: var(--danger); }
.check-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 4px;
}

/* ==================== Auth Screen ==================== */
/* Split layout: brand on the left, login form on the right. On <=900px
   viewports both collapse into a single column — see mobile override near
   the end of this section. */
.auth-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    background: var(--bg-0);
    z-index: 1000;
    overflow-y: auto;
    padding: 0;
}

/* Flex container for the two panes */
.auth-split {
    position: relative;
    z-index: 1;
    display: flex;
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
}

/* ── Left pane: brand, tagline, feature bullets, terracotta ambient glow ── */
.auth-left-pane {
    flex: 1 1 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 60px 60px 60px 80px;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 10%, rgba(196,97,58,0.18), transparent 55%),
        radial-gradient(circle at 85% 85%, rgba(196,97,58,0.10), transparent 55%),
        linear-gradient(135deg, #17191E 0%, #0F1012 100%);
    border-right: 1px solid rgba(196,97,58,0.12);
}
/* Light theme variant — keep the same warm terracotta ambient glows but
   on a paper-cream base so the login screen matches the rest of the app
   when the user has picked the light theme. */
body.theme-light .auth-left-pane {
    background:
        radial-gradient(circle at 20% 10%, rgba(196,97,58,0.14), transparent 55%),
        radial-gradient(circle at 85% 85%, rgba(196,97,58,0.08), transparent 55%),
        linear-gradient(135deg, #fbf7ef 0%, #f0ebe0 100%);
    border-right: 1px solid rgba(196,97,58,0.18);
}
body.theme-light .auth-left-pane::before {
    background: radial-gradient(circle, rgba(196,97,58,0.18), transparent 70%);
}
body.theme-light .auth-left-pane::after {
    background: radial-gradient(circle, rgba(196,97,58,0.08), transparent 70%);
}
.auth-left-pane::before {
    content: '';
    position: absolute;
    width: 520px; height: 520px;
    top: -160px; right: -180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(196,97,58,0.22), transparent 70%);
    pointer-events: none;
}
.auth-left-pane::after {
    content: '';
    position: absolute;
    width: 420px; height: 420px;
    bottom: -120px; left: -100px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(196,97,58,0.10), transparent 70%);
    pointer-events: none;
}
.auth-left-content {
    position: relative;
    z-index: 1;
    max-width: 480px;
    width: 100%;
}
.auth-left-content .brand-logo.big { margin-bottom: 26px; }
.auth-left-title {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -0.6px;
    line-height: 1.1;
    margin-bottom: 14px;
}
.auth-left-title span { color: var(--accent); }
.auth-left-tagline {
    font-size: 15px;
    color: var(--text-2);
    line-height: 1.6;
    margin-bottom: 36px;
    max-width: 460px;
}

/* ── Right pane: holds the .auth-box login card ── */
.auth-right-pane {
    flex: 1 1 50%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 60px 80px 60px 60px;
}
.auth-right-pane .auth-box {
    max-width: 460px;
    margin: 0;
}

/* Form header inside the right-pane auth-box */
.auth-form-header { margin-bottom: 24px; }
.auth-form-header h2 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.3px;
    margin: 0 0 6px;
    color: var(--text-1);
}
.auth-form-header .auth-sub {
    font-size: 13px;
    color: var(--text-3);
    margin: 0;
}

/* Accent glow — exactly at bottom-left corner, large */
.auth-screen::before {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle at bottom left, rgba(226,114,91,0.28) 0%, rgba(226,114,91,0.12) 35%, transparent 65%);
    pointer-events: none;
    z-index: 0;
}
.auth-left {
    background: linear-gradient(135deg, #1a1d22 0%, #0f1012 100%);
    padding: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--border);
}
.auth-left::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--accent-soft), transparent 70%);
    top: -150px; right: -150px;
    border-radius: 50%;
}
.auth-left::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(226, 114, 91, 0.08), transparent 70%);
    bottom: -100px; left: -100px;
    border-radius: 50%;
}
.auth-brand { position: relative; z-index: 1; margin-bottom: 40px; }
.brand-logo.big {
    width: 82px; height: 82px;
    font-size: 32px;
    border-radius: 15px;
    margin-bottom: 0;
}
.brand-logo.big.brand-logo-image { padding: 0; filter: drop-shadow(0 0 12px rgba(226,114,91,0.35)); }
.auth-brand h1 {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}
.auth-brand h1 span { color: var(--accent); }
.auth-brand p {
    font-size: 15px;
    color: var(--text-2);
    max-width: 420px;
    line-height: 1.6;
}
.auth-features {
    position: relative;
    z-index: 1;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.auth-features li {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-2);
    font-size: 14px;
}
.auth-features li::before {
    content: '✓';
    width: 22px; height: 22px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.auth-box {
    width: 100%;
    max-width: 540px;
    position: relative;
    z-index: 1;
    /* Gradient border via background-clip trick */
    background:
        linear-gradient(var(--bg-1), var(--bg-1)) padding-box,
        linear-gradient(160deg, rgba(226,114,91,0.55) 0%, rgba(226,114,91,0.08) 40%, transparent 70%) border-box;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 40px 44px;
    box-shadow:
        0 0 0 1px rgba(226,114,91,0.06),
        0 8px 32px rgba(0,0,0,0.45),
        0 24px 64px rgba(0,0,0,0.25);
}
/* Floating language switch */
.auth-lang-float {
    position: fixed;
    top: 20px;
    right: 24px;
    display: flex;
    gap: 6px;
    z-index: 10;
}
/* Brand header above login box */
.auth-brand-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 28px;
    margin-bottom: 28px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.auth-brand-top h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.3px;
    margin-top: 14px;
    margin-bottom: 5px;
}
.auth-brand-top h1 span { color: var(--accent); }
.auth-brand-top p {
    font-size: 12px;
    color: var(--text-3);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
/* Employee / Partner mode switcher */
.auth-mode-switch {
    display: flex;
    background: var(--bg-2);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    gap: 0;
}
.auth-mode-btn {
    flex: 1;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
    border-radius: 5px;
    transition: all 0.15s;
    white-space: nowrap;
}
.auth-mode-btn.active {
    background: var(--accent);
    color: #fff;
}
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-form h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}
.auth-sub {
    color: var(--text-3);
    font-size: 13px;
    margin-bottom: 24px;
}
.auth-form .form-group { margin-bottom: 12px; }
.auth-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 14px 0 20px;
    font-size: 12px;
}
/* ==================== Toggle Switch ==================== */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    cursor: pointer;
    user-select: none;
    gap: 16px;
}
.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-1);
}
.toggle-switch { flex-shrink: 0; position: relative; }
.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.toggle-track {
    display: block;
    width: 44px;
    height: 24px;
    background: var(--bg-3);
    border: 1.5px solid var(--border);
    border-radius: 999px;
    transition: background 0.2s, border-color 0.2s;
    position: relative;
}
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-3);
    transition: transform 0.2s, background 0.2s;
}
.toggle-input:checked + .toggle-track {
    background: var(--accent);
    border-color: var(--accent);
}
.toggle-input:checked + .toggle-track .toggle-thumb {
    background: #fff;
    transform: translateX(20px);
}
.toggle-row:hover .toggle-track { border-color: var(--accent); }

.check-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-2);
    cursor: pointer;
}
.check-inline input { accent-color: var(--accent); }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.auth-error {
    background: rgba(208, 86, 75, 0.12);
    border: 1px solid rgba(208, 86, 75, 0.3);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    margin-top: 14px;
    display: none;
}
.auth-error.active { display: block; }
.auth-hint {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-3);
    margin-top: 16px;
    padding: 10px;
    background: var(--bg-2);
    border-radius: 6px;
}

@media (max-width: 900px) {
    /* Collapse split layout to a single column. The left pane becomes a
       short hero header; the right pane fills the rest. */
    .auth-screen { padding: 0; }
    .auth-split {
        flex-direction: column;
        min-height: 100vh;
        min-height: 100svh;
    }
    .auth-left-pane {
        flex: 0 0 auto;
        padding: 48px 24px 28px;
        align-items: center;
        justify-content: center;
        text-align: center;
        border-right: none;
        border-bottom: 1px solid rgba(226,114,91,0.12);
    }
    .auth-left-pane::before {
        width: 400px; height: 400px;
        top: -140px; right: -140px;
    }
    .auth-left-pane::after { display: none; }
    .auth-left-content { max-width: 420px; }
    .auth-left-content .brand-logo.big { margin: 0 auto 16px; }
    .auth-left-title { font-size: 28px; margin-bottom: 8px; }
    .auth-left-tagline {
        font-size: 13.5px;
        margin: 0 auto;
        max-width: 360px;
    }
    /* Feature bullets belong only on desktop — on mobile they'd crowd out
       the form. The short tagline already sells the app. */
    .auth-left-content .auth-features { display: none; }

    .auth-right-pane {
        flex: 1 1 auto;
        padding: 24px 18px 48px;
        align-items: flex-start;
        justify-content: center;
    }
    .auth-right-pane .auth-box {
        max-width: 100%;
        width: 100%;
        padding: 24px 20px;
        border-radius: 16px;
        box-shadow: 0 4px 18px rgba(0,0,0,0.35);
    }
}

.auth-features li::before {
    content: '\2713';
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 46px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    background: transparent;
    border: 0;
    border-radius: 8px;
    transition: color 0.18s ease, background 0.18s ease;
}

.password-toggle:hover {
    color: var(--text-1);
    background: rgba(255, 255, 255, 0.06);
}

.password-toggle svg {
    width: 16px;
    height: 16px;
}

.form-note {
    margin-top: 8px;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid rgba(226, 114, 91, 0.18);
    background:
        linear-gradient(180deg, rgba(226, 114, 91, 0.08), rgba(226, 114, 91, 0.03)),
        var(--bg-2);
    color: var(--text-2);
    font-size: 12px;
    line-height: 1.45;
}

.form-note strong {
    color: var(--text-1);
}

.auth-hint {
    font-size: 12px;
    color: var(--text-2);
    padding: 12px 14px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)),
        var(--bg-2);
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* Hide admin-only nav items for non-admins */
body.role-employee .admin-only { display: none !important; }

/* Language Switch (legacy — kept for Settings screen buttons) */
.lang-switch {
    display: flex;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
}
.lang-btn {
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-3);
    border-radius: 4px;
    letter-spacing: 0.5px;
    transition: all 0.15s;
}
.lang-btn:hover { color: var(--text-1); }
.lang-btn.active {
    background: var(--accent);
    color: #fff;
}

/* Language dropdown — replaces the EN/RU toggle in the topbar so all
   three supported languages are reachable in one click. Native <select>
   keeps the keyboard + accessibility story simple; we just skin it. */
.lang-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--bg-2);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 26px 6px 10px;
    cursor: pointer;
    transition: all 0.15s;
    height: 34px;
    min-width: 118px;
}
.lang-select:hover { border-color: var(--accent); }
.lang-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(226, 136, 88, 0.18);
}

/* Theme toggle button — one icon visible at a time via body.theme-light.
   Sun shown in dark mode (click → switch to light), moon shown in light
   mode (click → back to dark). Same hover + focus treatment as the
   language dropdown so the pair reads as a group. */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    cursor: pointer;
    transition: all 0.15s;
}
.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.theme-toggle .theme-icon {
    width: 16px;
    height: 16px;
}
.theme-toggle .theme-icon-moon { display: none; }
body.theme-light .theme-toggle .theme-icon-sun  { display: none; }
body.theme-light .theme-toggle .theme-icon-moon { display: inline-block; }

.auth-lang-switch {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    gap: 4px;
    z-index: 2;
}
.auth-lang-btn {
    padding: 6px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-3);
    letter-spacing: 0.5px;
}
.auth-lang-btn:hover { color: var(--text-1); background: var(--bg-3); }
.auth-lang-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ==================== Responsive ==================== */

/* Tablets & smaller desktops */
@media (max-width: 1100px) {
    .search { width: 220px; }
    .topbar { padding: 16px 20px; }
    .content { padding: 20px 20px 32px; }
}

/* Tablets / small screens */
@media (max-width: 900px) {
    html, body {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
    }

    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: 100dvh;
    }

    /* Sidebar becomes sticky horizontal nav bar */
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 30;
        display: block;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 10px 10px 8px;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        background: rgba(22, 24, 28, 0.96);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    .brand,
    .sidebar-footer { display: none; }
    .nav {
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav-item {
        flex: 0 0 auto;
        background: var(--bg-2);
        border: 1px solid var(--border);
        padding: 9px 12px;
        font-size: 13px;
        min-height: 40px;
        white-space: nowrap;
    }
    .nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

    /* Topbar */
    .topbar {
        padding: 14px 16px;
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
    }
    .topbar-left { width: 100%; order: 1; }
    .topbar-right {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
        order: 2;
    }
    .search {
        order: 3;
        width: 100%;
        flex: 1 1 100%;
        padding: 10px 12px;
    }
    .search input { font-size: 15px; }
    #quickAddBtn { margin-left: auto; min-height: 40px; }
    .lang-switch { padding: 3px; }
    .lang-btn { padding: 6px 10px; font-size: 11px; min-height: 28px; }

    /* Content */
    .content {
        padding: 16px 14px 28px;
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
        padding-bottom: max(28px, env(safe-area-inset-bottom));
    }

    /* Stats & panels */
    .stats-grid { grid-template-columns: 1fr; gap: 12px; margin-bottom: 18px; }
    .stat-card { padding: 16px 18px; }
    .stat-value { font-size: 24px; }
    .stat-icon { width: 36px; height: 36px; right: 14px; }
    .stat-icon svg { width: 18px; height: 18px; }

    .panel { margin-bottom: 16px; }
    .panel-header {
        padding: 14px 16px;
        gap: 10px;
        flex-wrap: wrap;
        align-items: flex-start;
    }
    .panel-title { font-size: 14px; }
    .panel-body { padding: 14px 16px; }
    .panel-body.p0 {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Pipeline - horizontal scroll with snap */
    .pipeline {
        gap: 10px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 12px;
    }
    .pipeline-col {
        width: 82vw;
        min-width: 82vw;
        scroll-snap-align: start;
        min-height: 380px;
    }
    .pipeline-col-header { padding: 12px 14px; }

    /* Tables */
    .table { min-width: 600px; }
    .table th, .table td { padding: 11px 13px; }

    /* Conference */
    .conference-alert-card,
    .conference-summary-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .conference-cost-pill { min-width: auto; }
    .conference-meta-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .conference-meta-item { padding: 10px 12px; }

    /* Grids */
    .grid-2 { grid-template-columns: 1fr; gap: 16px; }
    .form-grid { grid-template-columns: 1fr; gap: 12px; }

    /* Calendar */
    .calendar-layout { grid-template-columns: 1fr; gap: 16px; }
    .calendar-toolbar { flex-wrap: wrap; }
    .calendar-grid { gap: 6px; }
    .calendar-day { min-height: 110px; padding: 8px; }
    .calendar-agenda-item { grid-template-columns: 1fr; padding: 12px; }
    .calendar-agenda-date { font-size: 11.5px; }

    /* Attachments */
    .attachment-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        padding: 10px;
    }
    .attachment-row .attachment-meta { grid-column: 1 / -1; }
    .attachment-chip { max-width: 100%; }

    /* Forms */
    .form-actions {
        flex-wrap: wrap;
        justify-content: stretch;
        gap: 8px;
    }
    .form-actions .btn {
        flex: 1 1 100%;
        justify-content: center;
        padding: 11px 14px;
        min-height: 44px;
    }

    /* Modal - bottom sheet on mobile */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .modal {
        max-height: 94vh;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        width: 100%;
    }
    .modal-header {
        padding: 14px 18px;
        position: sticky;
        top: 0;
        background: var(--bg-1);
        z-index: 2;
    }
    .modal-header h2 { font-size: 16px; }
    .modal-body {
        padding: 16px 18px 24px;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }
    .modal-close { width: 36px; height: 36px; font-size: 24px; }

    /* Toast */
    .toast-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }
    .toast {
        min-width: auto;
        width: 100%;
    }

    /* Quick menu */
    .quick-menu {
        top: calc(100% + 6px);
        right: 0;
        min-width: 200px;
    }
    .quick-menu button {
        padding: 10px 12px;
        min-height: 40px;
        font-size: 13.5px;
    }

    /* Buttons - touch-friendly */
    .btn { min-height: 40px; padding: 10px 14px; }
    .btn-sm { min-height: 34px; padding: 7px 11px; }
    .btn-icon { min-width: 40px; min-height: 40px; }
    .icon-action { width: 38px; height: 38px; }
    .icon-action svg { width: 17px; height: 17px; }

    /* Activity */
    .activity-item { padding: 12px 14px; gap: 10px; }
    .activity-dot { width: 30px; height: 30px; }

    /* Filter chips - scrollable */
    .filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        margin-bottom: 14px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .filters::-webkit-scrollbar { display: none; }
    .filter-chip {
        flex-shrink: 0;
        padding: 8px 12px;
        min-height: 34px;
    }

    /* Row actions - less cramped */
    .table .row-actions {
        justify-content: flex-start;
        gap: 4px;
    }

    /* Bar chart */
    .bar-chart { height: 160px; gap: 6px; }
    .bar-label, .bar-value { font-size: 10px; }

    /* Donut */
    .donut-wrap { padding: 16px; gap: 16px; flex-wrap: wrap; justify-content: center; }

    /* Check items */
    .check-item { padding: 12px 14px; }
    .check-due { min-width: auto; font-size: 10.5px; }
}

/* Phones */
@media (max-width: 640px) {
    .page-title { font-size: 17px; }
    .page-subtitle { font-size: 11.5px; }

    /* Prevent iOS zoom on input focus — must be 16px+ */
    .form-group input,
    .form-group textarea,
    .form-group select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    textarea,
    select { font-size: 16px; }

    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 12px 13px;
        border-radius: 8px;
    }

    /* Calendar smaller */
    .calendar-grid { gap: 3px; }
    .calendar-day {
        min-height: 78px;
        padding: 5px;
        gap: 4px;
        border-radius: 6px;
    }
    .calendar-day-number { font-size: 11px; }
    .calendar-day-events { gap: 3px; }
    .calendar-event-chip {
        padding: 4px 5px;
        border-left-width: 2px;
        border-radius: 5px;
    }
    .calendar-event-chip strong { font-size: 10px; }
    .calendar-event-chip span { display: none; }
    .calendar-weekday { padding: 6px 4px; font-size: 10px; }
    .calendar-more { font-size: 10px; }

    /* Conference meta single column */
    .conference-meta-grid { grid-template-columns: 1fr; }

    /* Quick menu full-width */
    .quick-menu {
        position: fixed;
        top: auto;
        bottom: 12px;
        left: 12px;
        right: 12px;
        min-width: auto;
        max-width: none;
        padding: 8px;
        border-radius: var(--radius);
        box-shadow: var(--shadow-lg);
    }
    .quick-menu button {
        padding: 12px 14px;
        min-height: 44px;
        font-size: 14px;
    }

    /* Pipeline - one card visible at a time */
    .pipeline-col { width: 90vw; min-width: 90vw; }

    /* Stats compact */
    .stat-value { font-size: 22px; }
    .stat-card { padding: 14px 16px; }
    .stat-icon { width: 32px; height: 32px; border-radius: 8px; }
    .stat-icon svg { width: 16px; height: 16px; }

    /* Table smaller */
    .table th, .table td { padding: 10px 12px; font-size: 12.5px; }
    .table th { font-size: 10.5px; }
    .table-subline { font-size: 10.5px; }

    /* Deal cards */
    .deal-card { padding: 10px; }
    .deal-title { font-size: 12.5px; }

    /* Badges smaller */
    .badge, .status-tag { padding: 3px 7px; font-size: 10px; }

    /* Bar chart */
    .bar-chart { height: 140px; padding: 6px 0; }
}

/* Small phones (iPhone SE etc.) */
@media (max-width: 380px) {
    html, body { font-size: 13px; }

    .topbar { padding: 12px 12px; }
    .page-title { font-size: 16px; }
    .page-subtitle { display: none; }

    .nav-item { padding: 8px 10px; font-size: 12px; }
    .nav-item svg { width: 15px; height: 15px; }

    .btn { padding: 9px 12px; font-size: 12.5px; }
    #quickAddBtn span { display: none; }
    #quickAddBtn { padding: 10px; min-width: 40px; }

    .lang-btn { padding: 5px 8px; font-size: 10px; }

    .content { padding: 14px 12px 24px; }

    .stat-label { font-size: 11px; }
    .stat-value { font-size: 20px; }

    .panel-header { padding: 12px 14px; }
    .panel-body { padding: 12px 14px; }

    .calendar-day { min-height: 64px; padding: 4px; }
}

/* Landscape on phones — reclaim vertical space */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .sidebar { padding: 6px 10px; }
    .nav-item { padding: 7px 10px; min-height: 34px; }
    .topbar { padding: 10px 14px; }
    .topbar-left h1 { font-size: 16px; }
    .topbar-left .page-subtitle { display: none; }
    .content { padding: 12px 14px 20px; }
}

/* Touch devices — remove hover effects that look stuck */
@media (hover: none) and (pointer: coarse) {
    .nav-item:hover { background: var(--bg-2); color: var(--text-2); }
    .deal-card:hover { transform: none; }
    .calendar-day:hover { transform: none; }
    .calendar-event-chip:hover { transform: none; }
    .conference-alert-card:hover { transform: none; }
    .icon-action:hover { transform: none; }
    .btn-primary:hover { background: var(--accent); }
    .table tbody tr:hover { background: transparent; }

    /* Better active feedback on touch */
    .btn:active { transform: scale(0.97); }
    .nav-item:active { background: var(--accent-soft); color: var(--accent); }
    .filter-chip:active { background: var(--bg-3); }
    .deal-card:active { background: var(--bg-3); }
    .icon-action:active { background: var(--bg-2); color: var(--text-1); }
    .calendar-day:active { background: var(--bg-3); }
}

/* Auth screen mobile polish */
@media (max-width: 900px) {
    .auth-lang-float { top: max(16px, env(safe-area-inset-top)); right: 16px; }
    .auth-box { max-width: 100%; padding: 28px 20px; border-radius: 16px; }
    .auth-form h2 { font-size: 20px; }
    .auth-sub { font-size: 12.5px; margin-bottom: 20px; }
    .auth-mode-switch { margin-bottom: 20px; }
    .auth-mode-btn { padding: 12px 10px; min-height: 42px; }
    .btn-block { padding: 13px; min-height: 46px; }
}

@media (max-width: 640px) {
    .auth-form input { font-size: 16px; padding: 12px 13px; }
    .password-field input { padding-right: 48px; }
    .password-toggle { width: 36px; height: 36px; }
}

/* ── Settings Cards ─────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.settings-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 22px 20px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color .18s, background .18s, transform .15s;
  position: relative;
  overflow: hidden;
  font-family: inherit;
}

.settings-card:hover {
  border-color: var(--accent);
  background: var(--bg-2);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(232,97,42,.12);
}

.settings-card:hover .settings-card-arrow { opacity: 1; transform: translateY(-50%) translateX(0); }
.settings-card:hover .settings-card-icon  { background: var(--accent); }
.settings-card:hover .settings-card-icon svg { stroke: white; }
/* Some icons use filled elements (AI stars, info dot, indicator pips)
   keyed to currentColor — force those to white too so the whole glyph
   inverts cleanly on hover instead of leaving orange bits behind. */
.settings-card:hover .settings-card-icon svg [fill="currentColor"] { fill: white; }
.settings-card:hover .settings-card-icon svg circle[fill],
.settings-card:hover .settings-card-icon svg path[fill]:not([fill="none"]) { fill: white; }

.settings-card-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--accent-light, rgba(232,97,42,.12));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s;
  flex-shrink: 0;
}

.settings-card-icon svg {
  stroke: var(--accent);
  transition: stroke .18s;
}

.settings-card-body { flex: 1; }

.settings-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.settings-card-sub {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
}

.settings-card-arrow {
  position: absolute;
  top: 50%;
  right: 18px;
  transform: translateY(-50%) translateX(4px);
  opacity: 0;
  transition: opacity .18s, transform .18s;
  color: var(--accent);
}

/* ── Profile Card ─────────────────────────────────────────── */
.profile-card-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 0 0 76px 16px;
  animation: fadeIn .18s ease;
}
.app.sidebar-collapsed .profile-card-overlay { padding-left: 8px; }

.profile-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 340px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  animation: slideUpFade .22s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
}

@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.profile-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.profile-card-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--accent-border);
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.profile-card-info { flex: 1; min-width: 0; }
.profile-card-name { font-size: 14px; font-weight: 600; color: var(--text); }
.profile-card-role { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.profile-card-close { margin-left: auto; }
.profile-card-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; }

.pc-field { display: flex; flex-direction: column; gap: 4px; }
.pc-field label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.pc-field input { background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--text); width: 100%; outline: none; transition: border-color .15s; }
.pc-field input:focus { border-color: var(--accent); }
.pc-field input[readonly] { color: var(--text-3); cursor: default; }

.pc-divider { height: 1px; background: var(--border-soft); margin: 2px 0; }
.pc-section-title { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; }
.pc-actions { display: flex; gap: 8px; margin-top: 4px; }
.pc-actions .btn { flex: 1; font-size: 13px; padding: 9px 12px; }

/* ── Super Admin Panel ───────────────────────────────────────── */
/* Super Admin panel spans the full content area. The old 1100px cap
   left a wide gap to the right of the action toolbar on big screens
   (Unicode Repair / Restore / Dedup / + New Tenant sat mid-screen
   instead of reaching the right edge). */
.sa-wrap { padding: 0 24px 32px; }
.sa-tenants-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 20px; }

.tenant-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
  position: relative;
}
.tenant-card:hover { border-color: var(--accent-border); box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.tenant-card.inactive { opacity: .55; }

.tenant-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tenant-card-logo { width: 36px; height: 36px; object-fit: contain; }
.tenant-card-name { font-size: 14px; font-weight: 700; color: var(--text); }
.tenant-card-slug { font-size: 11px; color: var(--text-3); }

.tenant-card-stats { display: flex; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.tenant-stat { display: flex; flex-direction: column; gap: 2px; }
.tenant-stat-val { font-size: 20px; font-weight: 700; color: var(--text); }
.tenant-stat-lbl { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }

.tenant-card-badge { position: absolute; top: 12px; right: 12px; font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }

.sa-panel { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-top: 20px; }
.sa-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.sa-panel-title { font-size: 16px; font-weight: 700; color: var(--text); }

.sa-form { display: grid; gap: 16px; }
.sa-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sa-form-row.full { grid-template-columns: 1fr; }

.sa-field { display: flex; flex-direction: column; gap: 6px; }
.sa-field label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.sa-field input, .sa-field select { background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 13px; color: var(--text); outline: none; transition: border-color .15s; }
.sa-field input:focus, .sa-field select:focus { border-color: var(--accent); }

.sa-toggles-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.sa-toggle-item { display: flex; align-items: center; gap: 10px; background: var(--bg-3); border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; cursor: pointer; transition: border-color .15s; user-select: none; }
.sa-toggle-item:hover { border-color: var(--accent-border); }
.sa-toggle-item input[type="checkbox"] { display: none; }
.sa-toggle-dot { width: 32px; height: 18px; border-radius: 9px; background: var(--bg-hover); border: 1px solid var(--border); transition: background .2s; flex-shrink: 0; position: relative; }
.sa-toggle-dot::after { content: ''; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-3); transition: left .2s, background .2s; }
.sa-toggle-item.active .sa-toggle-dot { background: var(--accent); border-color: var(--accent); }
.sa-toggle-item.active .sa-toggle-dot::after { left: 16px; background: #fff; }
.sa-toggle-label { font-size: 12px; color: var(--text); font-weight: 500; }

.sa-limits-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.sa-limit-field { display: flex; flex-direction: column; gap: 4px; }
.sa-limit-field label { font-size: 11px; color: var(--text-3); }
.sa-limit-field input { background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--text); outline: none; transition: border-color .15s; }
.sa-limit-field input:focus { border-color: var(--accent); }

.sa-section-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; margin-top: 4px; }
.sa-form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.sa-back-btn { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); cursor: pointer; background: none; border: none; padding: 0; }
.sa-back-btn:hover { color: var(--text); }
.sa-back-btn svg { width: 16px; height: 16px; }

/* ── Superadmin: tenant user rows ─────────────────────────────────────────── */
.sa-user-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-soft); gap: 12px; }
.sa-user-row:last-child { border-bottom: none; }
.sa-user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sa-user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-user-meta { font-size: 11px; color: var(--text-3); }

/* ── Invoice creation option cards ──────────────────────────────────────── */
.inv-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 8px 0 4px; }
.inv-option-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 16px; background: var(--bg-3); border: 2px solid var(--border); border-radius: 12px; cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.inv-option-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.inv-option-icon { font-size: 32px; line-height: 1; }
.inv-option-title { font-size: 14px; font-weight: 700; color: var(--text); }
.inv-option-desc { font-size: 12px; color: var(--text-3); line-height: 1.4; }

/* ── Invoice DocuSign status panel ──────────────────────────────────────── */
.inv-ds-panel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--bg-3); border: 1px solid var(--border-soft); border-radius: 8px; margin: 6px 0; font-size: 13px; }

/* ── Documents module: source & type chips ──────────────────────────────── */
.doc-source-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    /* Inherit accent colour so branded sicon() SVGs (stroke=currentColor)
       paint in terracotta instead of the dark inherited text colour. */
    color: var(--accent);
    vertical-align: middle;
}
.doc-type-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 99px; text-transform: capitalize; background: var(--bg-hover); color: var(--text-3); }
.doc-type-chip.invoice, .doc-type-chip.invoice-signed { background: rgba(232,97,42,.12); color: var(--accent); }
.doc-type-chip.email { background: rgba(42,122,181,.12); color: #2a7ab5; }
.doc-type-chip.document { background: rgba(39,174,96,.12); color: #27ae60; }
.btn-link { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font-size: inherit; text-decoration: underline; }
.btn-link:hover { color: var(--accent-hover); }

/* ── Quota-exceeded modal ────────────────────────────────────────────────── */
#quotaModal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: qmFadeIn .22s ease;
}
@keyframes qmFadeIn { from { opacity: 0 } to { opacity: 1 } }

.quota-modal-card {
  background: var(--bg-card);
  border-radius: 28px;
  padding: 56px 60px 48px;
  max-width: 520px;
  width: calc(100% - 40px);
  text-align: center;
  box-shadow: 0 48px 120px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .07);
  pointer-events: none;        /* clicks pass through card → close the backdrop */
  animation: qmScaleIn .3s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes qmScaleIn {
  from { opacity: 0; transform: scale(.86) translateY(16px) }
  to   { opacity: 1; transform: scale(1)   translateY(0)    }
}

.quota-modal-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  margin-bottom: 10px;
  border-radius: 16px;
}

.quota-modal-brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 30px;
}

.quota-modal-icon {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 18px;
}

.quota-modal-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 18px;
  line-height: 1.2;
}

.quota-modal-body {
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: 28px;
}

.quota-modal-email {
  display: inline-block;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  background: var(--accent-soft, rgba(99, 102, 241, .12));
  padding: 12px 32px;
  border-radius: 12px;
  margin-bottom: 36px;
  pointer-events: auto;        /* email link IS clickable even though card isn't */
  transition: opacity .15s;
}
.quota-modal-email:hover { opacity: .8; text-decoration: underline; }

.quota-modal-hint {
  font-size: 12px;
  color: var(--text-3);
  opacity: .7;
}

/* ── Acira AI badge tooltip ──────────────────────────────────────────── */
.acira-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: default;
  vertical-align: middle;
}

/* Pseudo-elements not used — tooltip is JS-driven via #aciraBadgeTip */
.acira-badge::after,
.acira-badge::before { display: none; }
.acira-badge { cursor: default; }

/* JS tooltip element injected once into <body> */
#aciraBadgeTip {
  position: fixed;
  z-index: 99999;
  background: var(--bg-2, #1a1815);
  border: 1px solid var(--accent, #c4613a);
  color: var(--text-1, #f0ede6);
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: .01em;
  padding: 5px 10px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .16s ease, transform .16s ease;
}
#aciraBadgeTip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Email multi-select chip widget ──────────────────────────────────────── */
.email-multi-sel {
    position: relative;
    min-height: 40px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 8px;
    cursor: text;
    transition: border-color 0.15s;
}
.email-multi-sel.focused { border-color: var(--accent); }
.email-multi-sel-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    min-height: 28px;
}
.email-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    border-radius: 20px;
    padding: 3px 10px 3px 10px;
    font-size: 12px;
    color: var(--text-1);
    max-width: 240px;
}
.email-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-chip-remove {
    flex-none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.1s, background 0.1s;
}
.email-chip-remove:hover { opacity: 1; background: rgba(196,97,58,0.25); }
.email-multi-input {
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-size: 13px;
    color: var(--text-1);
    min-width: 160px;
    flex: 1;
    padding: 2px 4px;
}
.email-multi-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: 1000;
    max-height: 220px;
    overflow-y: auto;
    display: none;
}
.email-multi-dropdown.open { display: block; }
.email-multi-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
    border-radius: 6px;
    margin: 2px 4px;
}
.email-multi-opt:hover, .email-multi-opt.active { background: var(--accent-soft); }
.email-multi-opt-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    flex-none;
}
.email-multi-opt-info { display: flex; flex-direction: column; overflow: hidden; }
.email-multi-opt-name { font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-multi-opt-email { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-multi-opt-add { color: var(--accent); font-weight: 600; }
.email-multi-empty { padding: 12px 14px; font-size: 12.5px; color: var(--text-3); text-align: center; }

/* ── Inline-editable list cells ─────────────────────────────────────────── */
.cell-editable {
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 4px;
}
.cell-editable:hover {
    background: var(--accent-soft) !important;
}
.cell-editable:hover::after {
    content: ' ✏';
    font-size: 10px;
    opacity: 0.5;
}
