/* =================================================================
   TMS Design System v3 — premium SaaS aesthetic
   Typefaces: Sora (headings/brand) + Inter (body/UI)
   Palette: deep slate ink + violet-blue accent + refined semantic colors
   ================================================================= */

/* Self-hosted fonts (no external font CDN) - Inter for body/UI, Sora for headings/brand. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
    src: url('/lib/fonts/inter/inter-latin-400-normal.woff2') format('woff2'), url('/lib/fonts/inter/inter-latin-400-normal.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
    src: url('/lib/fonts/inter/inter-latin-500-normal.woff2') format('woff2'), url('/lib/fonts/inter/inter-latin-500-normal.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
    src: url('/lib/fonts/inter/inter-latin-600-normal.woff2') format('woff2'), url('/lib/fonts/inter/inter-latin-600-normal.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
    src: url('/lib/fonts/inter/inter-latin-700-normal.woff2') format('woff2'), url('/lib/fonts/inter/inter-latin-700-normal.woff') format('woff'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 600; font-display: swap;
    src: url('/lib/fonts/sora/sora-latin-600-normal.woff2') format('woff2'), url('/lib/fonts/sora/sora-latin-600-normal.woff') format('woff'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 700; font-display: swap;
    src: url('/lib/fonts/sora/sora-latin-700-normal.woff2') format('woff2'), url('/lib/fonts/sora/sora-latin-700-normal.woff') format('woff'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 800; font-display: swap;
    src: url('/lib/fonts/sora/sora-latin-800-normal.woff2') format('woff2'), url('/lib/fonts/sora/sora-latin-800-normal.woff') format('woff'); }

:root {
    /* Neutrals */
    --ink-900: #0f1420;
    --ink-800: #1a2133;
    --ink-700: #2a3349;
    --ink-500: #5c6580;
    --ink-400: #8891a8;
    --ink-200: #e3e6ef;
    --ink-100: #eef0f6;
    --ink-50:  #f6f7fb;
    --surface: #ffffff;

    /* Accent */
    --accent-600: #5b3df0;
    --accent-500: #6d5ef3;
    --accent-400: #8b7ff7;
    --accent-50:  #f0eeff;
    --accent-ring: rgba(93, 71, 240, 0.18);
    --accent-grad: linear-gradient(135deg, #6d5ef3 0%, #4f6df5 100%);

    /* Semantic */
    --ok-600: #059669;   --ok-50:  #e9fbf3;
    --warn-600: #d97706; --warn-50: #fff6e8;
    --danger-600: #e11d48; --danger-50: #fdecf0;
    --info-600: #0284c7;  --info-50: #e7f6fd;

    /* Elevation + radius */
    --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-pill: 999px;
    --sh-1: 0 1px 2px rgba(15, 20, 32, 0.05);
    --sh-2: 0 4px 16px rgba(15, 20, 32, 0.07), 0 1px 3px rgba(15, 20, 32, 0.04);
    --sh-3: 0 16px 40px rgba(15, 20, 32, 0.14);

    /* Typefaces - overridable per company (Admin > Company Details > Font Style). See themes.css for data-font overrides. */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-heading: 'Sora', 'Inter', sans-serif;
}

* { letter-spacing: -0.011em; box-sizing: border-box; }

html, body { height: 100%; }

body {
    background: var(--ink-50);
    color: var(--ink-800);
    font-family: var(--font-body);
    font-size: 0.925rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink-900);
}

a { color: var(--accent-600); }
a:hover { color: var(--accent-600); }

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

/* ---------------- Sidebar ---------------- */
.sidebar {
    width: 264px;
    flex-shrink: 0;
    background: var(--ink-900);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: #fff;
    padding: 1.4rem 1.35rem 1.2rem;
}

.sidebar .brand-mark {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--accent-grad);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(109, 94, 243, 0.45);
}

.sidebar .brand-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.02rem;
    color: #fff;
}

.sidebar-scroll-wrap {
    flex: 1;
    min-height: 0; /* required for the child's overflow-y:auto to actually scroll within the flex column, instead of the whole sidebar growing past the viewport */
    position: relative;
}

.sidebar-scroll {
    height: 100%;
    overflow-y: auto;
    padding-bottom: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 5px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 10px; }
.sidebar-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

/* Soft fade at the top/bottom of the scroll area so it's visually clear there's more content, instead of an abrupt hard cut */
.sidebar-scroll-wrap::before, .sidebar-scroll-wrap::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 18px;
    pointer-events: none;
    z-index: 2;
}
.sidebar-scroll-wrap::before { top: 0; background: linear-gradient(var(--ink-900), transparent); }
.sidebar-scroll-wrap::after { bottom: 0; background: linear-gradient(transparent, var(--ink-900)); }

.sidebar .nav-section-label {
    color: rgba(255,255,255,0.28);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    padding: 1.15rem 1.35rem 0.5rem;
    font-weight: 700;
}

.sidebar a.nav-link-item {
    color: #aab1c8;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.58rem 0.9rem;
    margin: 0.08rem 0.7rem;
    border-radius: var(--r-sm);
    font-size: 0.855rem;
    font-weight: 500;
    position: relative;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar a.nav-link-item i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar a.nav-link-item:hover { background: rgba(255,255,255,0.06); color: #fff; }

.sidebar a.nav-link-item.active {
    background: rgba(109, 94, 243, 0.18);
    color: #fff;
    font-weight: 600;
}
.sidebar a.nav-link-item.active::before {
    content: "";
    position: absolute;
    left: -0.7rem; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px;
    background: var(--accent-500);
    border-radius: 0 4px 4px 0;
}

/* Collapsible menu groups (Masters, Settings, User Management, etc.) */
.sidebar button.nav-group-toggle {
    /* Explicit resets instead of "all: unset" - unset also resets `display`
       to its initial value (inline), which is then overridden below anyway,
       but relying on a blanket reset for an interactive element risks
       inconsistent behavior across different positioning/stacking contexts
       (this sidebar is `position: sticky` on desktop, `position: fixed` on
       mobile) - explicit properties are safer and behave identically in both. */
    background: none;
    border: none;
    outline: none;
    font-family: inherit;
    text-align: left;
    appearance: none;
    box-sizing: border-box;
    width: calc(100% - 1.4rem);
    color: #aab1c8;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.58rem 0.9rem;
    margin: 0.08rem 0.7rem;
    border-radius: var(--r-sm);
    font-size: 0.855rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.sidebar button.nav-group-toggle i.nav-group-icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar button.nav-group-toggle:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar button.nav-group-toggle.group-active { color: #fff; font-weight: 600; }
.sidebar button.nav-group-toggle .nav-group-chevron {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform .18s ease;
}
.sidebar button.nav-group-toggle[aria-expanded="true"] .nav-group-chevron { transform: rotate(90deg); }

.sidebar .nav-group-body .nav-link-item {
    padding-left: 2.15rem;
    font-size: 0.82rem;
}
.sidebar .nav-group-body .nav-link-item i { font-size: 0.9rem; }

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

/* ---------------- Topbar ---------------- */
.topbar {
    background: rgba(246, 247, 251, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--ink-200);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar .crumb {
    color: var(--ink-500);
    font-size: 0.82rem;
    font-weight: 500;
}

/* ---------------- Content ---------------- */
main.content { padding: 1.75rem 2.25rem 3rem; max-width: 1440px; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.page-header .eyebrow {
    color: var(--accent-600);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.25rem;
}
.page-header h4 { font-size: 1.5rem; margin-bottom: 0.15rem; }
.page-header .subtitle { color: var(--ink-500); font-size: 0.87rem; }
.page-header .page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ============================= COMPONENTS ============================= */

/* Cards */
.card {
    border: 1px solid var(--ink-200);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
    background: var(--surface);
}
.card-header {
    border-bottom: 1px solid var(--ink-200);
    font-weight: 700;
    font-family: var(--font-heading);
    font-size: 0.92rem;
    background: var(--surface);
    border-top-left-radius: var(--r-lg) !important;
    border-top-right-radius: var(--r-lg) !important;
    padding: 0.95rem 1.25rem;
}
.card-body { padding: 1.35rem; }

/* Stat cards */
.stat-card {
    border-radius: var(--r-md);
    border: 1px solid var(--ink-200);
    background: var(--surface);
    box-shadow: var(--sh-1);
    padding: 0.85rem 1rem;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--ink-200); }
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-card .stat-icon {
    width: 30px; height: 30px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center; font-size: 0.92rem;
}
.stat-card .stat-label { color: var(--ink-500); font-size: 0.72rem; font-weight: 600; }
.stat-card .stat-value { font-family: var(--font-heading); font-size: 1.45rem; font-weight: 700; color: var(--ink-900); line-height: 1; }

.stat-card.accent-new .stat-icon { background: var(--accent-50); color: var(--accent-600); }
.stat-card.accent-progress .stat-icon { background: var(--warn-50); color: var(--warn-600); }
.stat-card.accent-done .stat-icon { background: var(--ok-50); color: var(--ok-600); }

/* Buttons */
.btn {
    border-radius: var(--r-sm);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.52rem 1.05rem;
    transition: all .15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-sm { font-size: 0.78rem; padding: 0.35rem 0.75rem; }

.btn-primary { background: var(--accent-grad); border: none; box-shadow: 0 2px 8px rgba(109,94,243,0.3); }
.btn-primary:hover, .btn-primary:focus { filter: brightness(1.06); box-shadow: 0 6px 16px rgba(109,94,243,0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-outline-primary { color: var(--accent-600); border-color: var(--accent-400); }
.btn-outline-primary:hover { background: var(--accent-600); border-color: var(--accent-600); }

.btn-outline-secondary { color: var(--ink-500); border-color: var(--ink-200); }
.btn-outline-secondary:hover { background: var(--ink-100); color: var(--ink-800); border-color: var(--ink-200); }

.btn-outline-success { color: var(--ok-600); border-color: var(--ok-600); }
.btn-outline-success:hover { background: var(--ok-600); }
.btn-outline-danger { color: var(--danger-600); border-color: var(--danger-600); }
.btn-outline-danger:hover { background: var(--danger-600); }
.btn-outline-warning { color: var(--warn-600); border-color: var(--warn-600); }
.btn-outline-warning:hover { background: var(--warn-600); color: #fff; }

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

.btn-success { background: var(--ok-600); border-color: var(--ok-600); }
.btn-success:hover { background: #047a57; border-color: #047a57; }

.btn-warning { background: var(--warn-600); border-color: var(--warn-600); color: #fff; }
.btn-warning:hover { background: #b45f04; border-color: #b45f04; color: #fff; }

/* Tables */
.table { margin-bottom: 0; }
.table thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-500);
    font-weight: 700;
    border-bottom: 1px solid var(--ink-200);
    background: var(--ink-50);
    padding: 0.75rem 1rem;
}
.table td, .table th { vertical-align: middle; padding: 0.8rem 1rem; border-color: var(--ink-100); }
.table-hover tbody tr { transition: background-color .1s ease; }
.table-hover tbody tr:hover { background-color: var(--accent-50); }
tr.due-soon { background-color: var(--warn-50) !important; }

.table-empty { text-align: center; padding: 3rem 1rem; color: var(--ink-400); }
.table-empty i { font-size: 2rem; display: block; margin-bottom: 0.6rem; opacity: 0.6; }

/* Badges — pill style with dot */
.badge {
    font-weight: 600;
    padding: 0.38em 0.75em 0.38em 0.6em;
    border-radius: var(--r-pill);
    font-size: 0.71rem;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.badge-status-new { background: var(--accent-50); color: var(--accent-600); }
.badge-status-accepted { background: var(--info-50); color: var(--info-600); }
.badge-status-inprocess { background: var(--warn-50); color: var(--warn-600); }
.badge-status-waiting { background: #fdf0f8; color: #be185d; }
.badge-status-completed { background: var(--ok-50); color: var(--ok-600); }

.badge-priority-low { background: var(--ink-100); color: var(--ink-500); }
.badge-priority-normal { background: var(--accent-50); color: var(--accent-600); }
.badge-priority-high { background: var(--warn-50); color: var(--warn-600); }
.badge-priority-urgent { background: var(--danger-50); color: var(--danger-600); }

/* Attachment chips (timeline, task details) - no status-dot, just an icon+name pill */
.badge-file {
    background: var(--ink-100);
    color: var(--ink-700);
    font-weight: 500;
    padding: 0.35em 0.7em;
    border-radius: var(--r-pill);
    font-size: 0.74rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    transition: background-color .12s ease;
}
.badge-file:hover { background: var(--accent-50); color: var(--accent-600); }
.badge-file::before { content: none; }

/* Timeline */
.timeline-item { position: relative; padding-left: 1.2rem; border-left: 2px solid var(--ink-200); padding-bottom: 1.3rem; }
/* Timeline grouped by day ("time tree"): date is the parent node, the day's
   entries branch off it via their own indented, dashed sub-line. */
.timeline-day { margin-bottom: 1.1rem; }
.timeline-day:last-child { margin-bottom: 0; }
.timeline-day-label { font-weight: 600; font-size: .85rem; color: var(--ink-600); display: flex; align-items: center; gap: .4rem; margin-bottom: .6rem; }
.timeline-day-items { margin-left: .35rem; padding-left: .85rem; border-left: 2px dashed var(--ink-200); }
.timeline-day-items .timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: ""; position: absolute; left: -6px; top: 3px;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--accent-500); box-shadow: 0 0 0 4px var(--accent-50);
}
.timeline-item:last-child { padding-bottom: 0; }

/* Forms */
.form-label { font-weight: 600; font-size: 0.82rem; color: var(--ink-800); margin-bottom: 0.35rem; }
.form-control, .form-select {
    border-radius: var(--r-sm);
    border-color: var(--ink-200);
    font-size: 0.87rem;
    padding: 0.58rem 0.85rem;
    background: var(--surface);
}
.form-control:focus, .form-select:focus { border-color: var(--accent-500); box-shadow: 0 0 0 4px var(--accent-ring); }
.form-control::placeholder { color: var(--ink-400); }
.form-check-input:checked { background-color: var(--accent-600); border-color: var(--accent-600); }
.form-check-input:focus { box-shadow: 0 0 0 4px var(--accent-ring); }
.form-text, small.text-muted { color: var(--ink-400) !important; }

/* Section divider inside forms */
.form-section-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--ink-800);
    margin: 1.5rem 0 0.9rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--ink-200);
}
.form-section-title:first-child { margin-top: 0; }

/* Avatar */
.avatar-circle {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-grad);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}

/* Filter bar */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--r-md);
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.1rem;
}

/* Nav pills (status filters) */
.pill-nav { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.pill-nav a {
    padding: 0.4rem 0.9rem;
    border-radius: var(--r-pill);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-500);
    background: var(--surface);
    border: 1px solid var(--ink-200);
    text-decoration: none;
    transition: all .15s ease;
}
.pill-nav a:hover { border-color: var(--accent-400); color: var(--accent-600); }
.pill-nav a.active { background: var(--accent-grad); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(109,94,243,0.3); }

/* Dropdown */
.dropdown-menu { border: 1px solid var(--ink-200); border-radius: var(--r-md); box-shadow: var(--sh-2); padding: 0.4rem; }
.dropdown-item { border-radius: var(--r-sm); font-size: 0.86rem; padding: 0.5rem 0.7rem; }
.dropdown-item:hover { background: var(--ink-50); }

/* Alerts (used for validation summaries) */
.alert { border-radius: var(--r-md); border: none; font-size: 0.86rem; }
.alert-danger { background: var(--danger-50); color: var(--danger-600); }
.alert-success { background: var(--ok-50); color: var(--ok-600); }

/* Modal */
.modal-content { border-radius: var(--r-lg); border: none; box-shadow: var(--sh-3); }
.modal-header { border-bottom: 1px solid var(--ink-200); font-family: var(--font-heading); }

/* Toasts */
.toast { border-radius: var(--r-md); border: none; box-shadow: var(--sh-3); }

/* Misc utilities */
.text-muted-2 { color: var(--ink-500); }
.text-ink { color: var(--ink-800); }
.surface-muted { background: var(--ink-50); border-radius: var(--r-md); padding: 1rem; }
/* Many views still use Bootstrap's "shadow-sm" utility on cards - keep it
   visually consistent with our card elevation instead of Bootstrap's flatter default. */
.shadow-sm { box-shadow: var(--sh-1) !important; }

/* ============================= AUTH PAGES ============================= */
.auth-page { min-height: 100vh; display: flex; }

.auth-panel-brand {
    background:
        radial-gradient(circle at 15% 15%, rgba(109,94,243,0.35), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(79,109,245,0.3), transparent 45%),
        linear-gradient(160deg, #0f1420 0%, #171e33 60%, #211a46 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3.2rem;
    position: relative;
}

.auth-panel-form {
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-feature { display: flex; align-items: flex-start; gap: 0.85rem; margin-bottom: 1.15rem; }
.auth-feature .icon {
    width: 38px; height: 38px; border-radius: var(--r-sm);
    background: rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.12);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-2);
    padding: 2.2rem;
}

@media (max-width: 991px) { .auth-panel-brand { display: none; } }

/* Desktop menu collapse/expand (topbar button) - mirrors the mobile
   hamburger's show/hide behavior instead of a mini icon-rail, so it's the
   exact same mental model at every screen size: the menu is either fully
   open or fully out of the way. Scoped to md+ so it can never fight with
   the mobile slide-in/out transform above. */
@media (min-width: 769px) {
    body.sidebar-collapsed .sidebar { display: none; }
}

/* ============================= RESPONSIVE ============================= */
@media (max-width: 768px) {
    .sidebar { position: fixed; z-index: 1030; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.show { transform: translateX(0); }
    main.content { padding: 1rem; }

    /* Full-screen tap-to-close overlay behind the mobile sidebar - without
       this, once the sidebar is open it sits directly over the hamburger
       button in the topbar (which is now off-screen underneath it), leaving
       no way to close the menu again. */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1025; /* below .sidebar (1030), above page content */
    }
    .sidebar.show ~ .sidebar-backdrop { display: block; }
}

/* ============================= CHAT ============================= */
.chat-shell { display: flex; height: calc(100vh - 160px); min-height: 480px; border: 1px solid var(--ink-200); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.chat-contacts { width: 300px; flex-shrink: 0; border-right: 1px solid var(--ink-200); overflow-y: auto; }
.chat-contact-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1rem; text-decoration: none; color: inherit; border-bottom: 1px solid var(--ink-100); cursor: pointer; transition: background-color .1s ease; }
.chat-contact-item:hover { background: var(--ink-50); }
.chat-contact-item.active { background: var(--accent-50); }
.chat-contact-item .name { font-weight: 600; font-size: 0.87rem; }
.chat-contact-item .preview { font-size: 0.78rem; color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.badge-unread { background: var(--accent-600); color: #fff; border-radius: var(--r-pill); font-size: 0.68rem; font-weight: 700; line-height: 1.4; padding: 0.15em 0.55em; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header { padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--ink-200); font-weight: 700; font-family: var(--font-heading); }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; background: var(--ink-50); }
.chat-bubble { max-width: 62%; padding: 0.55rem 0.85rem; border-radius: 14px; font-size: 0.87rem; line-height: 1.4; }
.chat-bubble.mine { align-self: flex-end; background: var(--accent-grad); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.theirs { align-self: flex-start; background: var(--surface); border: 1px solid var(--ink-200); border-bottom-left-radius: 4px; }
.chat-bubble .meta { font-size: 0.68rem; opacity: 0.75; margin-top: 0.25rem; }
.chat-bubble .attachment-link { display: inline-flex; align-items: center; gap: 0.3rem; text-decoration: none; color: inherit; font-weight: 600; }
.chat-input-bar { padding: 0.75rem; border-top: 1px solid var(--ink-200); display: flex; gap: 0.5rem; align-items: center; }
.chat-empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--ink-400); flex-direction: column; gap: 0.5rem; }

/* ============================= FULLCALENDAR THEME ============================= */
.fc { font-family: var(--font-body); font-size: 0.85rem; }
.fc .fc-toolbar-title { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 700; color: var(--ink-900); }
.fc .fc-button-primary {
    background: var(--surface); border-color: var(--ink-200); color: var(--ink-700);
    text-transform: capitalize; font-weight: 600; box-shadow: none;
}
.fc .fc-button-primary:hover { background: var(--ink-50); border-color: var(--ink-200); color: var(--ink-900); }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { background: var(--accent-grad); border-color: transparent; color: #fff; }
.fc-addEventBtn-button { background: var(--accent-grad) !important; border: none !important; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--ink-100); }
.fc-daygrid-day.fc-day-today { background: var(--accent-50) !important; }
.fc-event { border-radius: 5px; border: none; padding: 1px 4px; font-size: 0.76rem; }

/* ============================= BILL FORM (Generate/Edit Customer Bill) ============================= */
.bill-no-chip {
    display: inline-flex; align-items: center; gap: 0.25em;
    font-family: var(--font-body); font-size: 0.72rem; font-weight: 700;
    color: var(--accent-600); background: var(--accent-50);
    border-radius: var(--r-pill); padding: 0.22em 0.7em 0.22em 0.55em;
    vertical-align: middle; margin-left: 0.6rem;
}
.bill-no-chip i { font-size: 0.7rem; }

.bf-card-header { display: flex; align-items: center; gap: 0.5rem; }
.bf-card-header i { color: var(--accent-600); }

.bf-line-items-table .row-number::before {
    content: attr(data-row);
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--ink-100); color: var(--ink-500);
    font-size: 0.7rem; font-weight: 700;
}
.bf-line-items-table tbody tr:hover { background-color: var(--accent-50); }
.bf-line-items-table td { padding: 0.5rem 0.6rem; }

/* Move up/down/remove for a line item - shrunk below Bootstrap's own .btn-sm so all three
   fit on one line next to the Description/Amount inputs instead of wrapping onto a second
   line in the narrower left column of the two-column bill form layout. */
.bf-row-actions { white-space: nowrap; }
.bf-row-actions .btn {
    padding: 0.18rem 0.4rem;
    font-size: 0.72rem;
    line-height: 1;
}
.bf-row-actions .btn i { font-size: 0.72rem; }

.bf-add-line-btn {
    width: 100%;
    border-style: dashed;
    padding: 0.6rem;
    justify-content: center;
}

.bf-summary-sticky { position: sticky; top: 1rem; }
@media (max-width: 991px) { .bf-summary-sticky { position: static; } }

.bf-summary-total {
    margin-top: 0.6rem; padding-top: 0.75rem;
    border-top: 1px dashed var(--ink-200);
    font-weight: 700; font-size: 0.95rem; color: var(--ink-900);
}
.bf-summary-total-value { font-family: var(--font-heading); font-size: 1.25rem; }
.preview-currency-symbol { font-weight: 600; color: var(--ink-500); font-size: 0.85em; }
