  :root {
    --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --color-brand: #0088ff;
    --color-brand-hover: #0077e6;
    --color-brand-light: #38bdf8;
    --color-bg: #f4f5f7;
    --color-sidebar: #0d1219;
    --color-sidebar-hover: rgba(255,255,255,0.06);
    --color-border: #e1e5eb;
    --color-text: #11141a;
    --color-text-muted: #5c6673;
    --color-text-faint: #a0aabf;
    --color-danger: #d93025;
    --radius-sm: 8px;
    --radius-md: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  }

  body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    display: flex;
    height: 100vh;
    background-color: var(--color-bg);
  }

  .sidebar {
    width: 240px;
    background-color: var(--color-sidebar);
    color: #cfd3d8;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
  }

  .sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .brand-logo {
    /* Real file is 516x600 (portrait) - constrain by height only and let width
       follow naturally, instead of forcing a square and crushing it. */
    height: 44px;
    width: auto;
    max-width: 100px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
  }

  .brand-logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--color-brand-light), var(--color-brand));
    color: #ffffff;
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 15px;
  }

  .brand-name {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 17px;
    color: var(--color-brand-light);
    letter-spacing: 0.2px;
    white-space: nowrap;
  }

  .sidebar-nav {
    list-style-type: none;
    padding: 12px;
    margin: 0;
    flex-grow: 1;
  }

  .sidebar-nav li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: #9aa4b6;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
  }

  .sidebar-nav li:hover {
    background-color: var(--color-sidebar-hover);
    color: #ffffff;
  }

  .sidebar-nav li.active {
    background-color: var(--color-brand);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 136, 255, 0.35);
  }

  .nav-icon {
    display: flex;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .nav-badge {
    margin-left: auto;
    background-color: var(--color-danger);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    border-radius: 9px;
    padding: 3px 7px;
    flex-shrink: 0;
  }

  .sidebar-nav li.active .nav-badge {
    background-color: #ffffff;
    color: var(--color-brand);
  }

  .nav-icon svg {
    width: 100%;
    height: 100%;
  }

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

  .sidebar-username {
    font-size: 12px;
    color: #6b7688;
    padding: 4px 12px 8px;
  }

  .sidebar-username strong {
    color: #cfd3d8;
    font-weight: 700;
  }

  .sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: #9aa4b6;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
  }

  .sidebar-logout:hover {
    background-color: var(--color-sidebar-hover);
    color: #ffffff;
  }

  /* Hidden on desktop; the mobile media query below turns it on. */
  .hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--color-border);
    background: #ffffff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
    color: var(--color-text);
    padding: 0;
  }

  .hamburger-btn svg {
    width: 20px;
    height: 20px;
  }

  /* Off-canvas backdrop for the mobile sidebar; only shown (via .show) below the
     breakpoint, so it never affects desktop layout. */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 2050;
  }

  .sidebar-backdrop.show {
    display: block;
  }

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

  .top-bar {
    min-height: 64px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
    /* Right padding is deliberately larger than left - this is the edge closest to
       the action buttons, so extra clearance here buys the most protection against
       a browser/renderer clipping content near the edge of the window. */
    padding: 12px 48px 12px 24px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
  }

  .top-bar h1 {
    margin: 0;
    font-size: 19px;
    color: var(--color-text);
    font-weight: 700;
  }

  /* flex-wrap here (plus min-height/wrap on .top-bar above) is a safety net, not the
     normal case - these buttons comfortably fit on one line at any screen size this app
     targets. But a fixed single-line height with no wrap turns any unexpected width
     pressure (a wider fallback font when Manrope fails to load, an aggressive OS/browser
     zoom level) into a button silently clipped off past the edge of the screen instead
     of visibly dropping to a second line. */
  .top-bar-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .btn {
    background-color: var(--color-brand);
    color: #ffffff;
    border: none;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
  }

  .btn:hover {
    background-color: var(--color-brand-hover);
    box-shadow: 0 4px 12px rgba(0, 136, 255, 0.3);
  }

  .btn:active {
    transform: translateY(1px);
  }

  .btn-secondary {
    background-color: #ffffff;
    color: var(--color-text);
    border: 1px solid var(--color-border);
  }

  .btn-secondary:hover {
    background-color: var(--color-bg);
    box-shadow: none;
  }

  .content-area {
    padding: 24px;
    flex-grow: 1;
    overflow: auto;
  }

  /* Search + filter bar above the Leads / Contacts / Accounts tables */
  .table-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }

  .search-box {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 1 320px;
  }

  .search-box .search-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--color-text-faint);
    pointer-events: none;
  }

  #tableSearch {
    width: 100%;
    box-sizing: border-box;
    height: 38px;
    padding: 0 12px 0 36px;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--color-text);
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }

  #tableSearch:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(0, 136, 255, 0.12);
  }

  #tableSearch::placeholder {
    color: var(--color-text-faint);
  }

  .filter-select {
    height: 38px;
    padding: 0 12px;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--color-text);
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
    max-width: 220px;
  }

  .filter-select:focus {
    border-color: var(--color-brand);
  }

  #clearFiltersBtn {
    height: 38px;
  }

  /* Scrolls the table horizontally on its own, independent of the toolbar above it.
     cursor:grab hints that it's click-and-drag pannable for mouse users (script.js).
     Bounded height + its own vertical scroll (rather than relying on .content-area's)
     keeps a long table from pushing the rest of the page down. */
  .table-scroll {
    max-height: 65vh;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
    /* auto (not hidden) still clips to this radius, and unlike `overflow:hidden` on the
       table itself, doesn't break position:sticky for the pinned action column inside it. */
    border-radius: var(--radius-md);
  }

  /* The custom scrollbar in .table-footer replaces this one - hiding it (Chrome/Edge/
     Safari only; Firefox has no per-axis scrollbar control) avoids showing two
     horizontal scrollbars stacked on top of each other. `height` is what sizes a
     WebKit horizontal scrollbar (its "thickness"); leaving `width` alone keeps the
     vertical one, which has no custom equivalent, visible at its normal size. */
  .table-scroll::-webkit-scrollbar {
    height: 0;
  }

  .table-scroll.dragging {
    cursor: grabbing;
    user-select: none;
  }

  .table-scroll.dragging * {
    cursor: grabbing;
    user-select: none;
  }

  /* Zoho-style footer: always-visible scrollbar (native ones auto-hide on touch/Mac)
     plus a running record count. Sticky to the bottom of .content-area's own scroll
     viewport (not the table's) so it's visible without scrolling past every row, and
     stays put while you scroll through them - only the table body scrolls under it. */
  .table-footer {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    /* Right padding is deliberately larger than left - same reasoning as .top-bar's
       padding above: extra clearance on the edge nearest the record count. */
    padding: 8px 32px 8px 4px;
    margin-top: 8px;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
  }

  /* Same safety-net reasoning as .top-bar-buttons above - this is the one item in the
     row actually meant to flex, so it needs to be free to shrink all the way to 0
     under width pressure (a flex item's default min-width:auto would otherwise refuse
     to shrink below its content size) rather than pushing the record count after it
     past the row's own edge. */
  .table-scrollbar-track {
    min-width: 0;
  }

  .table-scroll-btn {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    background: #ffffff;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
  }

  .table-scroll-btn:hover {
    background: var(--color-bg);
    color: var(--color-text);
  }

  .table-scrollbar-track {
    position: relative;
    flex: 1 1 auto;
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    cursor: pointer;
  }

  .table-scrollbar-thumb {
    position: absolute;
    top: 0;
    height: 100%;
    min-width: 30px;
    background: #b7c0cf;
    border-radius: 4px;
    cursor: grab;
  }

  .table-scrollbar-thumb:hover {
    background: var(--color-text-faint);
  }

  .table-footer-count {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
  }

  /* Table sizes to its content (min 100% of the area) and scrolls horizontally when
     there are many columns, instead of squashing every column into a sliver. */
  .data-table {
    width: auto;
    min-width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    /* No `overflow: hidden` here (moved the rounded-corner clipping to .table-scroll,
       which already clips via overflow-x/y:auto) - an overflow!=visible ancestor
       between a sticky cell and its real scroll container breaks position:sticky. */
  }

  .data-table th, .data-table td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* Compact, single-line uppercase headers read far cleaner than wrapped 14px bold. */
  .data-table th {
    background-color: #f8f9fa;
    color: var(--color-text-muted);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .data-table th.sortable-col {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s, color 0.15s;
  }

  .data-table th.sortable-col:hover {
    background-color: #eef1f5;
    color: var(--color-text);
  }

  .sort-arrow {
    color: var(--color-brand);
    font-size: 9px;
  }

  .data-table tbody tr:nth-child(even) td {
    background-color: #fafbfc;
  }

  .data-table tbody tr:hover td {
    background-color: #eef4ff;
  }

  /* Cells display as plain text and only become an input when clicked, so the grid
     reads as data, not a wall of form fields. Long values truncate with an ellipsis
     (full text on hover) rather than getting chopped mid-word. */
  .cell-view {
    max-width: 240px;
    min-width: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
    padding: 3px 6px;
    margin: -3px -6px;
    border-radius: 6px;
    transition: background-color 0.12s;
  }

  .cell-view:hover {
    background-color: rgba(0, 136, 255, 0.08);
  }

  .cell-view.empty {
    color: var(--color-text-faint);
  }

  .col-id {
    color: var(--color-text-faint);
    font-weight: 700;
  }

  .cell-view.inline-input-id {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--color-text-faint);
  }

  .inline-input-id {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--color-text-faint) !important;
  }

  /* Pinned Column Styles */
  .data-table th.sticky-col, .data-table td.sticky-col {
    position: sticky;
    left: 0;
    background-color: inherit;
    /* Being `position: sticky` with its own z-index makes this <td> a stacking
       context - a fixed-position action menu inside it only wins z-index
       comparisons made *within* this context, not against an unrelated sibling
       like .table-footer (its own stacking context too). Rather than raise this
       cell's static z-index to beat every other stacked element on the page, the
       open menu's own containing cell gets a one-off z-index boost above
       everything for as long as it's open - see elevateMenuAncestors in
       script.js. This is just the base, everyday value. */
    z-index: 2;
    width: 30px;
    text-align: center;
    border-right: 1px solid var(--color-border);
    padding: 8px 5px;
  }

  .data-table th.sticky-col {
    background-color: #f8f9fa;
    z-index: 3;
  }

  /* Action Menu Styles */
  .action-dropdown {
    position: relative;
    display: inline-block;
  }

  .action-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s, color 0.2s;
  }

  .action-btn:hover {
    background-color: var(--color-border);
    color: var(--color-text);
  }

  .action-menu-content {
    /* position:fixed + JS-computed coords so the menu escapes any scroll/overflow
       container (Kanban columns especially) instead of being clipped at its edge. */
    display: none;
    position: fixed;
    background-color: #ffffff;
    min-width: 150px;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    z-index: 1000;
    overflow: hidden;
  }

  .action-menu-content.show { display: block; }

  .action-menu-content a {
    color: var(--color-text);
    padding: 10px 14px;
    text-decoration: none;
    display: block;
    font-size: 13px;
    text-align: left;
    transition: background-color 0.2s;
  }

  .action-menu-content a:hover { background-color: #f9fbfd; }

  .inline-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid transparent;
    background-color: transparent;
    padding: 6px 4px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border 0.2s, background-color 0.2s;
    border-radius: 6px;
  }

  select.inline-input {
    cursor: pointer;
  }

  .inline-input:hover {
    background-color: var(--color-bg);
  }

  .inline-input:focus {
    border: 1px solid var(--color-brand);
    background-color: #ffffff;
  }

  .inline-input::placeholder {
    color: var(--color-text-faint);
    font-style: italic;
  }

  .draggable-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border: 1px solid var(--color-border);
    margin-bottom: 6px;
    background: #ffffff;
    border-radius: var(--radius-sm);
    transition: box-shadow 0.2s;
  }

  .draggable-item:hover {
    box-shadow: var(--shadow-sm);
  }

  .draggable-item .drag-handle {
    cursor: grab;
    color: var(--color-text-faint);
    margin-right: 12px;
  }

  .draggable-item .drag-handle:active {
    cursor: grabbing;
  }

  /* Shared badge (Kanban column counts) */
  .badge {
    display: inline-block;
    background-color: var(--color-border);
    color: var(--color-text-muted);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
  }

  /* Kanban filter bar */
  .kanban-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
  }

  .kanban-hint {
    font-size: 12px;
    color: var(--color-text-faint);
  }

  .kanban-hint strong {
    color: var(--color-text-muted);
  }

  .kanban-card-move-btn {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
  }

  .kanban-card-move-btn:hover {
    background: var(--color-bg);
    color: var(--color-text);
  }

  /* Kanban board (Deals) */
  .kanban-board {
    display: flex;
    gap: 16px;
    height: 100%;
    overflow-x: auto;
  }

  .kanban-column {
    flex: 1 1 260px;
    min-width: 240px;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    background-color: #f9fbfd;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .kanban-column.stage-other {
    border-style: dashed;
  }

  .kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 13px;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background-color: inherit;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .kanban-column-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 60px;
  }

  .kanban-column-body.drag-over {
    background-color: #eaf4ff;
  }

  .kanban-empty-placeholder {
    color: var(--color-text-faint);
    text-align: center;
    padding: 20px 10px;
    font-size: 13px;
  }

  .kanban-card {
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    cursor: grab;
    transition: box-shadow 0.2s, opacity 0.2s;
  }

  .kanban-card:hover {
    box-shadow: var(--shadow-md);
  }

  .kanban-card.dragging {
    opacity: 0.5;
  }

  .kanban-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 8px;
  }

  .kanban-card-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .kanban-card-account {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid #f4f5f7;
  }

  .kanban-card-amount {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-brand);
  }

  .kanban-card-age {
    font-size: 11px;
    color: var(--color-text-faint);
  }

  /* Analytics */
  .analytics-view {
    height: 100%;
    overflow-y: auto;
  }

  .analytics-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
  }

  .kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
  }

  .kpi-delta {
    font-size: 11px;
    font-weight: 700;
    margin-top: 6px;
    min-height: 14px;
  }

  .kpi-delta.up { color: #15803d; }
  .kpi-delta.down { color: var(--color-danger); }
  .kpi-delta.flat { color: var(--color-text-faint); }

  .kpi-tile {
    flex: 1;
    min-width: 160px;
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
  }

  .kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.2;
  }

  .kpi-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-top: 4px;
  }

  .kpi-sublabel {
    font-size: 11px;
    color: var(--color-text-faint);
    margin-top: 2px;
  }

  .chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
  }

  .chart-card {
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
  }

  .chart-card h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 12px 0;
  }

  .chart-canvas-wrap {
    position: relative;
    height: 280px;
  }

  .chart-empty-placeholder {
    color: var(--color-text-faint);
    text-align: center;
    padding: 20px;
    font-size: 13px;
  }

  .overdue-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 2px;
    border-bottom: 1px solid #f4f5f7;
  }

  .overdue-row:last-child {
    border-bottom: none;
  }

  .overdue-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .overdue-days {
    font-size: 12px;
    font-weight: 700;
    color: #b45309;
    background: #fef3c7;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .overdue-never {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-danger);
    background: #fce8e6;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .overdue-more {
    font-size: 12px;
    color: var(--color-text-faint);
    text-align: center;
    padding-top: 10px;
  }

  /* Manage Columns modal: "add new column" panel + shared stacked-field styling.
     Every field/button gets its own full-width row on purpose - see the comment
     in showManageColumnsModal() in script.txt for why. */
  .form-field {
    margin-bottom: 14px;
    text-align: left;
  }

  .form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-bottom: 6px;
  }

  .swal-field-input, .swal-field-select {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    height: 40px !important;
    font-size: 14px !important;
    font-family: var(--font-sans) !important;
  }

  .swal-field-select {
    cursor: pointer;
  }

  .add-column-panel {
    text-align: left;
    background: var(--color-bg);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    margin-bottom: 16px;
  }

  .add-column-btn {
    width: 100%;
    margin-top: 4px;
  }

  .manage-columns-hint {
    font-size: 12px;
    color: var(--color-text-faint);
    margin-bottom: 10px;
    text-align: left;
  }

  .manage-columns-empty {
    color: var(--color-text-faint);
    text-align: center;
    padding: 24px;
    font-size: 13px;
  }

  .draggable-item-name {
    font-weight: 600;
    color: var(--color-text);
  }

  .draggable-item-type {
    font-size: 11px;
    color: var(--color-text-faint);
    font-weight: 500;
  }

  .btn-danger-outline {
    color: var(--color-danger) !important;
    border-color: #fad2d0 !important;
    background-color: #ffffff !important;
  }

  .btn-danger-outline:hover {
    background-color: #fff5f5 !important;
  }

  /* Documents (file manager) */
  .documents-view {
    height: 100%;
    overflow-y: auto;
  }

  .doc-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
    font-size: 14px;
  }

  .doc-crumb {
    color: var(--color-brand);
    cursor: pointer;
    font-weight: 600;
  }

  .doc-crumb:hover {
    text-decoration: underline;
  }

  .doc-crumb-sep {
    color: var(--color-text-faint);
  }

  .doc-crumb-current {
    color: var(--color-text);
    font-weight: 700;
  }

  .doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }

  .doc-tile {
    position: relative;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px 14px 14px;
    background: #ffffff;
    cursor: pointer;
    text-align: center;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  }

  .doc-tile:hover {
    box-shadow: var(--shadow-md);
    border-color: #cfd8e3;
  }

  .doc-tile:active {
    transform: translateY(1px);
  }

  .doc-tile-icon {
    width: 46px;
    height: 46px;
    margin: 0 auto 10px;
  }

  .doc-tile-icon svg {
    width: 100%;
    height: 100%;
  }

  .doc-tile-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    min-height: 34px;
  }

  .doc-tile-meta {
    font-size: 11px;
    color: var(--color-text-faint);
    margin-top: 4px;
  }

  .doc-tile-menu-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    font-size: 16px;
    line-height: 1;
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.15s, background-color 0.15s;
  }

  .doc-tile:hover .doc-tile-menu-btn {
    opacity: 1;
  }

  .doc-tile-menu-btn:hover {
    background-color: var(--color-bg);
    color: var(--color-text);
  }

  .doc-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--color-text-faint);
    padding: 48px 20px;
    font-size: 14px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
  }

  /* User Settings (admin only) */
  .users-view { height: 100%; overflow-y: auto; }

  /* Home / Today dashboard */
  .home-view { height: 100%; overflow-y: auto; }

  .home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
  }

  .home-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .home-count {
    display: inline-block;
    background: var(--color-brand);
    color: #ffffff;
    border-radius: 10px;
    padding: 1px 9px;
    font-size: 12px;
    font-weight: 700;
  }

  .home-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 9px 2px;
    border-bottom: 1px solid #f4f5f7;
  }

  .home-row:last-child { border-bottom: none; }

  .home-row-clickable {
    cursor: pointer;
    border-radius: 6px;
    margin: 0 -6px;
    padding-left: 6px;
    padding-right: 6px;
    transition: background-color 0.12s;
  }

  .home-row-clickable:hover {
    background-color: var(--color-bg);
  }

  .home-row-main {
    font-size: 13px;
    color: var(--color-text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-sub { color: var(--color-text-faint); font-weight: 400; }

  .home-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    padding: 1px 6px;
    margin-right: 4px;
  }

  .home-row-meta {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-faint);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .home-row-meta.is-late { color: #b45309; }
  .home-row-meta.is-never { color: var(--color-danger); }

  .home-empty {
    color: var(--color-text-faint);
    font-size: 13px;
    padding: 16px 2px;
    margin: 0;
  }

  /* Calendar */
  .calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .calendar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
  }

  .calendar-nav { display: flex; gap: 8px; }

  .calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 14px;
    font-size: 12px;
    color: var(--color-text-muted);
  }

  .calendar-legend-item { display: flex; align-items: center; gap: 6px; }

  .calendar-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .calendar-dot-lead, .calendar-event-lead { background-color: var(--color-brand); }
  .calendar-dot-deal, .calendar-event-deal { background-color: #b45309; }
  .calendar-dot-visit, .calendar-event-visit { background-color: #16a34a; }
  .calendar-dot-task, .calendar-event-task { background-color: #5c6673; }
  .calendar-event-overdue { background-color: var(--color-danger); }

  .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background-color: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
  }

  .calendar-weekday {
    background-color: #ffffff;
    padding: 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-text-muted);
  }

  .calendar-day {
    background-color: #ffffff;
    min-height: 92px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    transition: background-color 0.12s;
  }

  .calendar-day:hover { background-color: var(--color-bg); }

  .calendar-day-outside { background-color: #fafbfc; }
  .calendar-day-outside .calendar-day-num { color: var(--color-text-faint); }

  .calendar-day-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text);
  }

  .calendar-day-today .calendar-day-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--color-brand);
    color: #ffffff;
  }

  .calendar-day-events {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
  }

  .calendar-event {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 5px;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .calendar-more {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-text-muted);
  }

  @media (max-width: 720px) {
    .calendar-day { min-height: 64px; padding: 4px; }
    .calendar-legend { gap: 10px; }
  }

  /* Duplicate detect & merge */
  .dup-group {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
  }

  .dup-group-head {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .dup-member {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
  }

  .dup-member:hover { background: var(--color-bg); }

  .dup-member-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
  }

  .dup-filled {
    font-size: 11px;
    color: var(--color-text-faint);
    flex-shrink: 0;
  }

  /* --- Modal (local swal.js drop-in) --- */
  .swal2-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 3000;
    animation: swal2-fade 0.15s ease;
  }
  @keyframes swal2-fade { from { opacity: 0; } to { opacity: 1; } }

  .swal2-popup {
    position: relative;
    box-sizing: border-box;
    width: 32em;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.25);
    padding: 24px 24px 20px;
    text-align: center;
    font-family: var(--font-sans);
    color: var(--color-text);
  }

  .swal2-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--color-text-faint);
    cursor: pointer;
  }
  .swal2-close:hover { color: var(--color-text); }

  .swal2-icon {
    width: 74px;
    height: 74px;
    margin: 6px auto 14px;
    border-radius: 50%;
    border: 4px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
  }
  .swal2-icon-success { border-color: #16a34a; color: #16a34a; }
  .swal2-icon-error { border-color: var(--color-danger); color: var(--color-danger); }
  .swal2-icon-warning { border-color: #f59e0b; color: #f59e0b; }
  .swal2-icon-info { border-color: var(--color-brand); color: var(--color-brand); }
  .swal2-icon-question { border-color: var(--color-text-faint); color: var(--color-text-faint); }

  .swal2-title {
    font-family: var(--font-sans);
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    margin: 4px 0 8px;
  }

  .swal2-html-container {
    font-size: 15px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 4px 0 6px;
  }

  .swal2-input-label {
    display: block;
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 10px 0 4px;
  }

  .swal2-input, .swal2-select, .swal2-textarea, .swal2-file {
    box-sizing: border-box;
    width: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--color-text);
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
    margin: 10px 0 0;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .swal2-input, .swal2-select, .swal2-file { height: 40px; padding: 0 12px; }
  .swal2-select { cursor: pointer; }
  .swal2-file { padding: 8px 12px; height: auto; }
  .swal2-textarea { min-height: 80px; padding: 10px 12px; resize: vertical; }
  .swal2-input:focus, .swal2-select:focus, .swal2-textarea:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(0, 136, 255, 0.12);
  }

  .swal2-validation-message {
    display: none;
    background: #fce8e6;
    color: var(--color-danger);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin: 12px 0 0;
    text-align: center;
  }

  .swal2-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
  }

  .swal2-styled {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: #ffffff;
  }
  .swal2-confirm { background: var(--color-brand); }
  .swal2-confirm:hover { background: var(--color-brand-hover); }
  .swal2-deny { background: var(--color-text-muted); }
  .swal2-cancel { background: #ffffff; color: var(--color-text); border: 1px solid var(--color-border); }
  .swal2-cancel:hover { background: var(--color-bg); }

  .swal2-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
    font-size: 13px;
    color: var(--color-text-muted);
  }

  /* Record Profile modal - all fields at a glance, plus attachments in the same view. */
  .profile-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    text-align: left;
    margin-bottom: 8px;
  }

  .profile-field-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-text-faint);
    margin-bottom: 3px;
  }

  .profile-field-value {
    font-size: 14px;
    color: var(--color-text);
    word-break: break-word;
    cursor: text;
    padding: 3px 6px;
    margin: -3px -6px;
    border-radius: 6px;
    transition: background-color 0.12s;
  }

  .profile-field-value:hover {
    background-color: rgba(0, 136, 255, 0.08);
  }

  .profile-field-input {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--color-text);
    background: #ffffff;
    border: 1px solid var(--color-brand);
    border-radius: 6px;
    padding: 3px 6px;
    outline: none;
  }

  select.profile-field-input {
    cursor: pointer;
  }

  .profile-field-empty {
    color: var(--color-text-faint);
  }

  .profile-attachments-section {
    text-align: left;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
  }

  .profile-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 10px;
  }

  .swal2-loader {
    width: 44px;
    height: 44px;
    margin: 18px auto 4px;
    border: 5px solid var(--color-border);
    border-top-color: var(--color-brand);
    border-radius: 50%;
    animation: swal2-spin 0.9s linear infinite;
  }
  @keyframes swal2-spin { to { transform: rotate(360deg); } }

  /* ============ Login page ============ */
  .login-body {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    background: linear-gradient(160deg, var(--color-sidebar), #182233);
  }

  /* Two soft blurred glows behind the card - purely decorative, kept out of the card's
     own stacking context via z-index so they never interfere with the form. */
  .login-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.35;
    z-index: 0;
    pointer-events: none;
  }

  .login-glow-a {
    width: 420px;
    height: 420px;
    top: -120px;
    left: -100px;
    background: var(--color-brand);
  }

  .login-glow-b {
    width: 360px;
    height: 360px;
    bottom: -140px;
    right: -90px;
    background: var(--color-brand-light);
  }

  .login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 380px;
    background: #ffffff;
    border-radius: 20px;
    border-top: 4px solid var(--color-brand);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    padding: 36px 32px 30px;
    margin: 20px;
    box-sizing: border-box;
  }

  .login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 26px;
  }

  .login-logo-badge {
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    border-radius: 18px;
    margin-bottom: 12px;
  }

  .login-logo-img {
    max-width: 46px;
    max-height: 46px;
    object-fit: contain;
  }

  .login-logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--color-brand-light), var(--color-brand));
    color: #ffffff;
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 19px;
  }

  .login-brand-name {
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 20px;
    color: var(--color-text);
  }

  .login-brand-sub {
    font-size: 13px;
    color: var(--color-text-faint);
    text-align: center;
  }

  .login-error {
    background: #fce8e6;
    color: var(--color-danger);
    font-size: 13px;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    text-align: center;
  }

  .login-error-hint {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--color-danger);
    opacity: 0.8;
    margin-top: 4px;
  }

  .login-input-group {
    position: relative;
    display: flex;
    align-items: center;
  }

  .login-input-icon {
    position: absolute;
    left: 13px;
    width: 17px;
    height: 17px;
    color: var(--color-text-faint);
    pointer-events: none;
  }

  .login-input {
    width: 100%;
    box-sizing: border-box;
    height: 44px;
    padding: 0 14px 0 40px;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--color-text);
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }

  .login-input:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(0, 136, 255, 0.12);
  }

  .login-input::placeholder {
    color: var(--color-text-faint);
  }

  .login-submit {
    width: 100%;
    margin-top: 10px;
    height: 44px;
    font-size: 15px;
  }

  /* ============ Mobile responsive (sidebar becomes off-canvas below this width) ============ */
  @media (max-width: 860px) {
    .hamburger-btn {
      display: flex;
    }

    .sidebar {
      position: fixed;
      top: 0;
      left: 0;
      height: 100vh;
      z-index: 2100;
      transform: translateX(-100%);
      transition: transform 0.25s ease;
      box-shadow: var(--shadow-md);
    }

    .sidebar.open {
      transform: translateX(0);
    }

    .top-bar {
      height: auto;
      min-height: 64px;
      padding: 10px 14px;
      flex-wrap: wrap;
      row-gap: 10px;
    }

    .top-bar h1 {
      font-size: 16px;
      flex: 1 1 auto;
    }

    .top-bar-buttons {
      flex-wrap: wrap;
      width: 100%;
      justify-content: flex-start;
    }

    .content-area {
      padding: 14px;
    }

    .search-box {
      flex: 1 1 100%;
    }

    .filter-select {
      max-width: none;
      flex: 1 1 auto;
    }

    .kanban-board {
      height: auto;
    }

    .kanban-column {
      min-width: 220px;
      max-height: 70vh;
    }

    .chart-canvas-wrap {
      height: 220px;
    }

    /* Without this, auto-fit(minmax(380px,1fr)) never fits a phone-width column, so
       every chart forces a sideways scroll instead of stacking like everything else. */
    .chart-grid {
      grid-template-columns: 1fr;
    }

    /* The ⋮ action-menu trigger is the busiest control on mobile (only way to reach
       Edit/Delete/Convert/Move-to-Stage without hover) - its padding otherwise sizes
       to ~24px, under the ~44px touch-target guideline. */
    .action-btn {
      padding: 10px 12px;
    }

    .swal2-popup {
      width: 100%;
      padding: 18px 16px 16px;
    }

    .swal2-title {
      font-size: 19px;
    }
  }
