@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&display=swap');

/* ==========================================================================
   IronFit CRM — design tokens mirrored from reference/css/main.css
   ========================================================================== */
:root {
    --bd-ff-body: 'Sora', sans-serif;

    --clr-common-white: #fff;
    --clr-common-black: #000;
    --clr-common-heading: #191919;
    --clr-common-body-text: #555555;

    --clr-theme-primary: #f58634;
    --clr-theme-primary-deep: #d96d1a;
    --clr-theme-soft: #fef1e6;

    --clr-text-secondary: #161616;
    --clr-text-muted: #9f9f9f;
    --clr-text-subtle: #808080;

    --clr-bg-canvas: #f7fbfc;
    --clr-bg-surface: #ffffff;
    --clr-bg-dark: #161616;
    --clr-bg-dark-2: #1f1f1f;

    --clr-border-soft: rgba(85, 85, 85, 0.14);
    --clr-border-strong: rgba(85, 85, 85, 0.28);

    --shadow-card: 0 1px 0 rgba(22,22,22,.04), 0 12px 30px -18px rgba(22,22,22,.18);
    --shadow-card-hover: 0 1px 0 rgba(22,22,22,.04), 0 24px 50px -22px rgba(22,22,22,.25);

    --radius-card: 14px;
    --radius-pill: 999px;
    --radius-control: 10px;
}

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; }

body.crm-body {
    font-family: var(--bd-ff-body);
    font-size: 15px;
    line-height: 26px;
    color: var(--clr-common-body-text);
    background: var(--clr-bg-canvas);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "tnum" off;
}

.crm-body h1, .crm-body h2, .crm-body h3,
.crm-body h4, .crm-body h5, .crm-body h6 {
    font-family: var(--bd-ff-body);
    color: var(--clr-text-secondary);
    font-weight: 600;
    line-height: 1.25;
    margin: 0;
}

.crm-body a { color: inherit; text-decoration: none; }
.crm-body a:hover { color: var(--clr-theme-primary); }

.tabular { font-variant-numeric: tabular-nums; }

/* Eyebrow / chip with bullet dot — borrowed from .section-subtitle span */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--clr-theme-soft);
    color: var(--clr-theme-primary-deep);
    border-radius: var(--radius-pill);
    padding: 7px 18px 7px 26px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .12em;
    text-transform: uppercase;
    line-height: 1;
    position: relative;
}
.eyebrow::before {
    content: "";
    position: absolute;
    left: 12px; top: 50%;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--clr-theme-primary);
    transform: translateY(-50%);
    box-shadow: 0 0 0 3px var(--clr-common-white);
}
.eyebrow.is-warning { background: rgba(245,158,11,.12); color: #b45309; }
.eyebrow.is-warning::before { background: #f59e0b; }
.eyebrow.is-success { background: rgba(16,185,129,.12); color: #047857; }
.eyebrow.is-success::before { background: #10b981; }

/* Page heading */
.page-head {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 28px;
}
.page-head h1 {
    font-size: 36px;
    letter-spacing: -.01em;
    font-weight: 600;
}
.page-head .lede {
    color: var(--clr-text-muted);
    font-size: 14px;
    margin-top: 6px;
    line-height: 22px;
}

/* ==========================================================================
   Shell — sidebar + topbar
   ========================================================================== */
.crm-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100vh;
}

.crm-sidebar {
    background: var(--clr-bg-dark);
    color: rgba(255,255,255,.75);
    padding: 18px 12px 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
/* WebKit / Chromium / Electron — full control via legacy pseudo-elements.
   Do NOT set `scrollbar-color` on this element: Chromium 121+ disables ALL
   ::-webkit-scrollbar pseudo styling when the standard property is present. */
.crm-sidebar::-webkit-scrollbar {
    width: 10px;
}
.crm-sidebar::-webkit-scrollbar-track {
    background: var(--clr-bg-dark);
    border-radius: 5px;
}
.crm-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,.22);
    border-radius: 5px;
    border: 2px solid var(--clr-bg-dark);          /* inset gap → pill shape */
    background-clip: padding-box;
    transition: background-color .2s ease, border-color .2s ease;
}
.crm-sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255,255,255,.5);
    border-color: var(--clr-bg-dark);
}
.crm-sidebar::-webkit-scrollbar-thumb:active {
    background-color: rgba(255,255,255,.7);
}
.crm-sidebar::-webkit-scrollbar-button,
.crm-sidebar::-webkit-scrollbar-corner {
    display: none;
    height: 0;
    width: 0;
}
/* Firefox only — webkit pseudos don't apply there. Gated by @supports so
   it doesn't bleed back into Chromium and disable the rules above. */
@supports not selector(::-webkit-scrollbar) {
    .crm-sidebar {
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,.22) var(--clr-bg-dark);
    }
}

.crm-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: #fff;
    font-size: 14px;
    letter-spacing: .06em;
    padding: 0 4px;
}
.crm-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    background: var(--clr-theme-primary);
    color: #fff;
    border-radius: 9px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 6px 18px -8px rgba(245,134,52,.6);
}

.crm-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.crm-nav-section {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255,255,255,.5);
    padding: 10px 8px 4px;
    cursor: pointer;
    user-select: none;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
}
.crm-nav-section:hover { color: rgba(255,255,255,.8); }
.crm-nav-section .label { flex: 1; }
.crm-nav-section .chev {
    width: 9px; height: 9px;
    stroke: currentColor; stroke-width: 2.2;
    fill: none;
    transition: transform .15s ease;
    flex-shrink: 0;
    opacity: .6;
}
.crm-nav-section[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.crm-nav-grip {
    position: absolute;
    /* Sits in the sidebar's left gutter (sidebar has 12px padding-left), clear
       of the chevron at x≈8px to avoid mis-clicks. */
    left: -8px;
    /* Offsets the asymmetric section-header padding (10px top, 4px bottom) so
       the grip lines up with the chevron+label row, not the geometric center. */
    top: calc(50% + 3px);
    transform: translateY(-50%);
    width: 10px; height: 10px;
    stroke: currentColor; stroke-width: 1.6;
    fill: none;
    opacity: 0;
    cursor: grab;
    transition: opacity .15s ease;
}
.crm-nav-group:hover .crm-nav-grip { opacity: .45; }
.crm-nav-grip:hover { opacity: .9 !important; }

/* Sortable.js placeholder during drag */
.crm-nav-group.is-dragging { opacity: .4; }
.crm-nav-group .crm-nav-grip:active,
.sortable-ghost .crm-nav-grip { cursor: grabbing; }

.crm-nav-group { display: flex; flex-direction: column; }
.crm-nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
}
.crm-nav-group[aria-expanded="false"] .crm-nav-group-items { display: none; }

/* "Terakhir Dibuka" recent-tabs section */
.crm-nav-recent .crm-nav-section { color: rgba(255,255,255,.42); }
.crm-nav-recent a { font-size: 12px; padding: 5px 10px; opacity: .9; }
.crm-nav-recent .empty {
    padding: 5px 10px;
    font-size: 11px;
    color: rgba(255,255,255,.35);
    font-style: italic;
}
.crm-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 7px;
    color: rgba(255,255,255,.85);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    transition: background .15s ease, color .15s ease;
}
.crm-nav a:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}
.crm-nav a.is-active {
    background: var(--clr-theme-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 16px -10px rgba(245,134,52,.55);
}
.crm-nav a .ico {
    width: 16px; height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 1.6;
    fill: none;
}

.crm-content {
    background: var(--clr-bg-canvas);
    min-width: 0;
}

.crm-topbar {
    height: 76px;
    background: var(--clr-bg-surface);
    border-bottom: 1px solid var(--clr-border-soft);
    padding: 0 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 5;
}
.crm-topbar .crumbs {
    color: var(--clr-text-muted);
    font-size: 13px;
}
.crm-topbar .crumbs strong {
    color: var(--clr-text-secondary);
    font-weight: 600;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.bell-btn {
    position: relative;
    width: 42px; height: 42px;
    border: 1px solid var(--clr-border-soft);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-text-secondary);
    background: #fff;
    transition: border-color .2s ease, transform .2s ease;
}
.bell-btn:hover { border-color: var(--clr-theme-primary); color: var(--clr-theme-primary); }
.bell-btn .dot {
    position: absolute;
    top: -3px; right: -3px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--clr-theme-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    padding: 0 5px;
    box-shadow: 0 0 0 2px #fff;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    background: #fff;
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-pill);
    font-size: 13px;
    color: var(--clr-text-secondary);
}
.user-chip .avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--clr-theme-primary), #ffb172);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
}
.user-chip .avatar svg {
    width: 16px; height: 16px;
    display: block;
}
.user-chip .role {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--clr-theme-primary-deep);
    background: var(--clr-theme-soft);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    margin-left: 4px;
}

main.crm-main { padding: 0; min-width: 0; }

/* ==========================================================================
   Tab shell
   ========================================================================== */
[x-cloak] { display: none !important; }

.tab-strip {
    display: flex;
    gap: 4px;
    padding: 12px 36px 0;
    background: var(--clr-bg-canvas);
    border-bottom: 1px solid var(--clr-border-soft);
    position: sticky;
    top: 76px;
    z-index: 4;
    overflow-x: auto;
    scrollbar-width: thin;
}
.tab-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-bottom: 0;
    background: transparent;
    color: var(--clr-text-muted);
    border-radius: 10px 10px 0 0;
    font-family: var(--bd-ff-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    max-width: 220px;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}
.tab-chip-title {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.tab-chip:hover {
    background: var(--clr-theme-soft);
    color: var(--clr-theme-primary-deep);
}
.tab-chip.is-active {
    background: var(--clr-bg-surface);
    color: var(--clr-text-secondary);
    border-color: var(--clr-border-soft);
}
.tab-chip.is-dirty .tab-chip-title::after {
    content: " •";
    color: var(--clr-theme-primary);
}
.tab-chip-close {
    opacity: .5;
    padding: 0 4px;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
}
.tab-chip-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, .06);
}

.tab-panes {
    padding: 32px 36px 60px;
}
.tab-pane {
    display: none;
}
.tab-pane.is-active {
    display: block;
}
.tab-loading {
    padding: 60px 0;
    text-align: center;
    color: var(--clr-text-muted);
    font-size: 14px;
}

.tab-toasts {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: grid;
    gap: 8px;
    z-index: 50;
    max-width: 420px;
}
.tab-toasts .flash {
    margin: 0;
    box-shadow: var(--shadow-card);
}

@media (max-width: 720px) {
    .tab-strip { padding: 8px 16px 0; top: 64px; }
    .tab-chip { max-width: 140px; padding: 6px 10px; }
    .tab-chip-title { max-width: 100px; }
    .tab-panes { padding: 20px 16px 40px; }
    .tab-toasts { right: 12px; bottom: 12px; left: 12px; }
}

/* Flash messages */
.flash {
    margin-bottom: 20px;
    padding: 14px 20px;
    border-radius: var(--radius-card);
    display: flex; align-items: center; gap: 10px;
    font-size: 14px;
    background: rgba(16,185,129,.08);
    color: #047857;
    border: 1px solid rgba(16,185,129,.2);
}
.flash.is-error { background: rgba(239,68,68,.08); color: #b91c1c; border-color: rgba(239,68,68,.2); }
.flash.is-warning { background: rgba(245,158,11,.08); color: #92400e; border-color: rgba(245,158,11,.25); }

/* ==========================================================================
   Surface / cards
   ========================================================================== */
.surface {
    background: var(--clr-bg-surface);
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}
.surface.is-padded { padding: 14px; }
.surface.is-padded-sm { padding: 12px 14px; }
.surface + .surface { margin-top: 12px; }

.surface h2, .surface h3, .surface h4, .surface h5, .surface h6 { margin-bottom: 6px; }

.surface-section-title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #666;
}
.surface-section-title.is-flush { margin: 0; }
.surface-section-title.is-positive { color: #1c8c1c; }
.surface-section-title.is-negative { color: #c0392b; }
.surface-section-title.is-neutral { color: #446; }

/* ==========================================================================
   Buttons (pill, with hover sweep — channel of .fill-btn)
   ========================================================================== */
.btn-fill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 30px;
    padding: 0 16px;
    border-radius: var(--radius-pill);
    font-family: var(--bd-ff-body);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: var(--clr-theme-primary);
    color: #fff;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
    z-index: 1;
    transition: color .25s ease, border-color .25s ease, transform .25s ease;
    cursor: pointer;
}
.crm-body a.btn-fill:not(.is-ghost) {
    color: #fff;
}
.btn-fill::before {
    content: "";
    position: absolute;
    top: 100%; left: 50%;
    width: 220%; height: 420px;
    background: var(--clr-theme-primary-deep);
    border-radius: 50%;
    transform: translateX(-50%);
    transition: transform .55s cubic-bezier(.19,1,.22,1);
    z-index: -1;
}
.btn-fill:hover { color: #fff; }
.crm-body a.btn-fill:not(.is-ghost):hover,
.crm-body a.btn-fill:not(.is-ghost):focus,
.crm-body a.btn-fill:not(.is-ghost):active {
    color: #fff;
}
.btn-fill:hover::before { transform: translate(-50%, -82%); }
.btn-fill:active { transform: translateY(1px); }

.btn-fill.is-ghost {
    background: transparent;
    color: var(--clr-text-secondary);
    border-color: var(--clr-border-strong);
}
.btn-fill.is-ghost::before { background: var(--clr-text-secondary); }
.btn-fill.is-ghost:hover { color: #fff; border-color: transparent; }

.btn-fill.is-dark {
    background: var(--clr-bg-dark);
}
.btn-fill.is-dark::before { background: var(--clr-theme-primary); }

.btn-fill.is-danger { background: #ef4444; }
.btn-fill.is-danger::before { background: #b91c1c; }

.btn-sm {
    height: 26px;
    padding: 0 12px;
    font-size: 10px;
}

.btn-fill-gray {
    border-radius: 20px;
    color: var(--clr-text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 500;
    padding-bottom: 2px;

    gap: 8px;
    height: 42px;
    padding: 0 22px;
    border-radius: var(--radius-pill);
    font-family: var(--bd-ff-body);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #333;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
    z-index: 1;
    transition: color .25s ease, border-color .25s ease, transform .25s ease;
    cursor: pointer;
}
.btn-fill-gray:hover { 
    color: var(--clr-theme-primary);
    border-color: currentColor;
}

.btn-link-quiet {
    color: var(--clr-text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 500;
    padding-bottom: 2px;
}
.btn-link-quiet:hover { 
    color: var(--clr-theme-primary);
    border-color: currentColor;
}

/* ==========================================================================
   Form controls
   ========================================================================== */
.crm-body .form-control,
.crm-body .form-select,
.crm-body input.form-control,
.crm-body select.form-select,
.crm-body textarea.form-control {
    background: #fff;
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-control);
    color: var(--clr-text-secondary);
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    font-family: var(--bd-ff-body);
    box-shadow: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.crm-body textarea.form-control { height: auto; padding: 8px 10px; line-height: 18px; }
.crm-body .form-control:focus,
.crm-body .form-select:focus {
    border-color: var(--clr-theme-primary);
    box-shadow: 0 0 0 3px rgba(245,134,52,.18);
    outline: none;
}
.crm-body .form-control-sm,
.crm-body .form-select-sm { height: 24px; padding: 0 8px; font-size: 11px; }

.crm-body .form-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    margin-bottom: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.crm-body .form-label.is-required::after {
    content: "*";
    color: #ef4444;
    font-size: 12px;
    line-height: 1;
    font-weight: 700;
    margin-left: 2px;
    letter-spacing: 0;
}

.required-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: .12em;
}
.required-legend::before {
    content: "*";
    color: #ef4444;
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.crm-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.crm-table thead th {
    background: var(--clr-theme-soft);
    color: var(--clr-theme-primary-deep);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--clr-border-soft);
}
.crm-table thead th.text-end { text-align: right; }
.crm-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--clr-border-soft);
    color: var(--clr-text-secondary);
    font-size: 12px;
    line-height: 1.4;
}
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table tbody tr:hover td { background: rgba(245,134,52,.03); }
.crm-table .text-end { text-align: right; }
.crm-table .muted { color: var(--clr-text-muted); }
.crm-table .num { font-variant-numeric: tabular-nums; }

.surface.has-table { padding: 0; overflow: visible; }
.surface.has-table .crm-table thead th:first-child { padding-left: 14px; }
.surface.has-table .crm-table thead th:last-child { padding-right: 14px; }
.surface.has-table .crm-table tbody td:first-child { padding-left: 14px; }
.surface.has-table .crm-table tbody td:last-child { padding-right: 14px; }
/* Explicit corner rounding for the header — replaces the clipping from overflow:hidden
   above, which had to be removed so that combobox / recent-prices popups inside line-item
   <td>s can escape past the surface border. */
.surface.has-table .crm-table thead tr:first-child th:first-child {
    border-top-left-radius: var(--radius-card);
}
.surface.has-table .crm-table thead tr:first-child th:last-child {
    border-top-right-radius: var(--radius-card);
}

/* Compact table variant — one notch denser than the new base, for ultra-tight tables. */
.crm-table.is-compact thead th { padding: 4px 8px; }
.crm-table.is-compact tbody td { padding: 3px 8px; }
.crm-table.is-compact tbody td code { font-size: inherit; }
.surface.has-table.is-compact .crm-table thead th:first-child,
.surface.has-table.is-compact .crm-table tbody td:first-child { padding-left: 12px; }
.surface.has-table.is-compact .crm-table thead th:last-child,
.surface.has-table.is-compact .crm-table tbody td:last-child { padding-right: 12px; }
.crm-table.is-compact thead tr.filter-row th { padding: 3px 5px; }
.crm-table.is-compact thead tr.filter-row th .form-control,
.crm-table.is-compact thead tr.filter-row th .form-select {
    height: 24px;
    padding: 0 6px;
    font-size: 11px;
    background: #fff;
}
.crm-table.is-compact thead tr.filter-row th .form-select { padding-right: 22px; }
.crm-table .btn-fill,
.crm-table .btn-fill.btn-sm {
    padding: 0 10px;
    font-size: 10px;
    line-height: 1.5;
    min-height: 0;
    height: 24px;
}

.empty-row {
    text-align: center;
    color: var(--clr-text-muted);
    padding: 28px 16px !important;
    font-size: 12px;
}

/* ==========================================================================
   Stage chips (pipeline)
   ========================================================================== */
.stage-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px 5px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    line-height: 1;
    background: rgba(85,85,85,.08);
    color: var(--clr-text-secondary);
    white-space: nowrap;
}
.stage-chip::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: .85;
}
.stage-chip.s-leads_masuk { background: #e0f2fe; color: #075985; }
.stage-chip.s-percakapan  { background: #fef3c7; color: #92400e; }
.stage-chip.s-penawaran   { background: #fed7aa; color: #9a3412; }
.stage-chip.s-closing     { background: #ccfbf1; color: #115e59; }
.stage-chip.s-launching   { background: var(--clr-theme-soft); color: var(--clr-theme-primary-deep); }

.flag-chip {
    display: inline-flex; align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 600;
    background: rgba(85,85,85,.08);
    color: var(--clr-text-muted);
}
.flag-chip.is-cancel { background: rgba(239,68,68,.1); color: #b91c1c; }
.flag-chip.is-hold   { background: rgba(245,158,11,.12); color: #b45309; }
.flag-chip.is-success { background: rgba(16,185,129,.12); color: #047857; }
.flag-chip.is-warning { background: rgba(245,158,11,.12); color: #b45309; }
.flag-chip.is-danger  { background: rgba(239,68,68,.1); color: #b91c1c; }

/* ==========================================================================
   KPI cards (analytics dashboard)
   ========================================================================== */
.kpi {
    background: #fff;
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-card);
    padding: 22px 22px 20px;
    position: relative;
    overflow: hidden;
    transition: transform .25s ease, box-shadow .25s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
.kpi .label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
}
.kpi .value {
    margin-top: 14px;
    font-size: 28px;
    font-weight: 600;
    color: var(--clr-text-secondary);
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}
.kpi .sub {
    margin-top: 6px;
    font-size: 12px;
    color: var(--clr-text-muted);
}
.kpi.is-feature {
    background: linear-gradient(140deg, var(--clr-bg-dark) 0%, #0f172a 100%);
    color: #fff;
    border-color: transparent;
}
.kpi.is-feature .label { color: rgba(255,255,255,.55); }
.kpi.is-feature .value { color: #fff; }
.kpi.is-feature .sub { color: rgba(255,255,255,.6); }
.kpi.is-feature::after {
    content: "";
    position: absolute;
    right: -50px; bottom: -60px;
    width: 180px; height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245,134,52,.55), transparent 60%);
    pointer-events: none;
}

/* Filter bar */
.filter-bar {
    background: #fff;
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-card);
    padding: 10px 12px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px 10px;
    align-items: end;
}
.filter-bar > div { min-width: 0; }
.crm-body .filter-bar .form-label {
    font-size: 9px;
    margin-bottom: 3px;
    letter-spacing: .1em;
}
.crm-body .filter-bar .form-control,
.crm-body .filter-bar .form-select {
    height: 28px;
    padding: 0 8px;
    font-size: 12px;
    border-radius: 8px;
}
.filter-bar .actions {
    grid-column: 1/-1;
    display: flex;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px solid var(--clr-border-soft);
    margin-top: 2px;
}

/* ==========================================================================
   Pipeline kanban
   ========================================================================== */
.pipeline-board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 300px;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 18px;
}
.pipeline-col {
    background: #fff;
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-card);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 480px;
}
.pipeline-col header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pipeline-col header .count {
    font-size: 12px;
    font-weight: 600;
    color: var(--clr-text-muted);
    background: var(--clr-bg-canvas);
    border-radius: var(--radius-pill);
    padding: 3px 12px;
}
.pipeline-list { display: flex; flex-direction: column; gap: 10px; flex: 1; }

.lead-card {
    background: var(--clr-bg-surface);
    border: 1px solid var(--clr-border-soft);
    border-radius: 12px;
    padding: 14px 14px 12px;
    cursor: grab;
    box-shadow: 0 1px 0 rgba(22,22,22,.03);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.lead-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-card-hover); border-color: var(--clr-theme-primary); }
.lead-card:active { cursor: grabbing; }
.lead-card .company { font-weight: 600; color: var(--clr-text-secondary); font-size: 14px; }
.lead-card .who { color: var(--clr-text-muted); font-size: 12px; margin-top: 2px; }
.lead-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 11px;
}
.lead-card .meta .owner {
    background: var(--clr-bg-canvas);
    border-radius: var(--radius-pill);
    padding: 3px 9px;
    color: var(--clr-text-secondary);
}
.lead-card .meta .deal {
    color: var(--clr-theme-primary-deep);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Login page (Breeze override)
   ========================================================================== */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    place-items: stretch;
    background: var(--clr-bg-canvas);
}
@media (min-width: 992px) {
    .auth-shell { grid-template-columns: 1fr 1fr; }
}
.auth-art {
    background:
        radial-gradient(circle at 80% 0%, rgba(245,134,52,.55), transparent 55%),
        radial-gradient(circle at 0% 100%, rgba(245,134,52,.35), transparent 55%),
        var(--clr-bg-dark);
    color: #fff;
    padding: 48px;
    position: relative;
    overflow: hidden;
    display: none;
}
@media (min-width: 992px) {
    .auth-art { display: flex; flex-direction: column; justify-content: space-between; }
}
.auth-art h2 {
    color: #fff;
    font-size: 44px;
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: -.01em;
    max-width: 460px;
}
.auth-art p { color: rgba(255,255,255,.7); max-width: 380px; }
.auth-art .footer { font-size: 12px; color: rgba(255,255,255,.5); letter-spacing: .12em; text-transform: uppercase; }

.auth-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}
.auth-form {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 36px 32px;
}
.auth-form h1 { font-size: 26px; margin-bottom: 6px; }
.auth-form .lede { font-size: 14px; color: var(--clr-text-muted); margin-bottom: 24px; }
.auth-form .field { margin-bottom: 16px; }
.auth-form .check-row {
    display: flex; justify-content: space-between; align-items: center;
    margin: 6px 0 22px;
    font-size: 13px; color: var(--clr-text-muted);
}

/* ==========================================================================
   Pagination (Bootstrap override)
   ========================================================================== */
.crm-body .pagination { gap: 4px; }
.crm-body .pagination .page-link {
    border: 1px solid var(--clr-border-soft);
    border-radius: 10px;
    color: var(--clr-text-secondary);
    padding: 6px 12px;
    font-size: 13px;
}
.crm-body .pagination .page-item.active .page-link {
    background: var(--clr-theme-primary);
    color: #fff;
    border-color: var(--clr-theme-primary);
}

/* ==========================================================================
   Misc
   ========================================================================== */
.dl-clean { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0; }
.dl-clean dt {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--clr-text-muted);
    font-weight: 500;
    align-self: center;
}
.dl-clean dd { margin: 0; color: var(--clr-text-secondary); font-size: 14px; }

.note-block { white-space: pre-wrap; line-height: 24px; color: var(--clr-text-secondary); }

.progress-bar-track {
    height: 8px;
    background: var(--clr-bg-canvas);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--clr-border-soft);
}
.progress-bar-track .fill {
    height: 100%;
    background: var(--clr-theme-primary);
    transition: width .4s ease;
}
.progress-bar-track .fill.is-success { background: #10b981; }
.progress-bar-track .fill.is-warning { background: #f59e0b; }
.progress-bar-track .fill.is-danger  { background: #ef4444; }

/* ==========================================================================
   Mobile drawer scaffolding (desktop hides these)
   ========================================================================== */
.crm-mobile-trigger,
.crm-mobile-backdrop,
.crm-sidebar-close { display: none; }

/* ===== Tablet + phone (≤991px) ===== */
@media (max-width: 991px) {
    .crm-shell { grid-template-columns: 1fr; }

    .crm-sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        width: 240px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 60;
        flex-direction: column;
        flex-wrap: nowrap;
        padding: 18px 14px 22px;
        gap: 14px;
    }
    .crm-sidebar.is-open {
        transform: translateX(0);
        box-shadow: 0 24px 60px -10px rgba(0,0,0,.4);
    }
    .crm-nav { flex-direction: column; flex-wrap: nowrap; }
    .crm-nav-section { display: block; }

    .crm-mobile-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 55;
    }
    .crm-mobile-trigger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px; height: 40px;
        background: #fff;
        border: 1px solid var(--clr-border-soft);
        border-radius: 10px;
        color: var(--clr-text-secondary);
        cursor: pointer;
        flex-shrink: 0;
    }
    .crm-mobile-trigger:hover { border-color: var(--clr-theme-primary); color: var(--clr-theme-primary); }
    .crm-sidebar-close {
        display: inline-flex;
        align-self: flex-end;
        background: transparent;
        border: 0;
        color: rgba(255,255,255,.7);
        font-size: 26px;
        line-height: 1;
        padding: 0 4px;
        cursor: pointer;
        margin-top: -8px;
    }

    .crm-topbar { padding: 0 16px; gap: 12px; }
    main.crm-main { padding: 24px 18px 60px; }
    .page-head h1 { font-size: 28px; }

    .surface.has-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .crm-table { min-width: 720px; }
}

/* ===== Phone (≤640px) ===== */
@media (max-width: 640px) {
    .crm-topbar { height: 64px; padding: 0 12px; gap: 8px; }
    .crm-topbar .crumbs { font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .topbar-actions { gap: 8px; }
    .user-chip { padding: 4px 8px 4px 4px; gap: 6px; }
    .user-chip .name-text { display: none; }
    .user-chip .role { font-size: 9px; padding: 2px 6px; margin-left: 0; }
    .bell-btn { width: 36px; height: 36px; }
    .btn-fill-gray { padding: 0 12px; height: 36px; font-size: 12px; }

    main.crm-main { padding: 14px 10px 40px; }
    .surface.is-padded { padding: 12px; }
    .surface.is-padded-sm { padding: 10px 12px; }

    .page-head { margin-bottom: 14px; }
    .page-head h1 { font-size: 20px; }
    .page-head .lede { font-size: 12px; line-height: 18px; }
    .page-head > div.d-flex { width: 100%; flex-wrap: wrap; }
    .page-head .btn-fill { height: 28px; padding: 0 12px; font-size: 11px; letter-spacing: .06em; }

    .crm-table thead th,
    .crm-table tbody td { padding: 6px 8px; font-size: 11px; }
    .surface.has-table .crm-table thead th:first-child,
    .surface.has-table .crm-table tbody td:first-child { padding-left: 12px; }
    .surface.has-table .crm-table thead th:last-child,
    .surface.has-table .crm-table tbody td:last-child { padding-right: 12px; }
    .crm-table { min-width: 520px; }
    .col-hide-sm { display: none !important; }

    .filter-bar { padding: 8px 10px; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }
}

/* ==========================================================================
   Profile page — forms, toggles, Quick Access picker
   ========================================================================== */
.profile-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.profile-section-head h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--clr-text-secondary);
}
.profile-section-head h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--clr-text-secondary);
}
.profile-section-head .muted,
.crm-body .surface .muted {
    color: var(--clr-text-muted);
    font-size: 13px;
    margin: 0;
    line-height: 1.5;
}

.prefs-saved-indicator {
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #047857;
    background: rgba(16,185,129,.1);
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    align-self: center;
}

/* Form helpers used by the profile + danger-zone forms */
.profile-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.form-hint { font-size: 13px; color: var(--clr-text-muted); }
.form-error { font-size: 12px; color: #b91c1c; margin-top: 6px; }
.link-button {
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--clr-theme-primary-deep);
    font-size: inherit;
    font-family: inherit;
    text-decoration: underline;
    cursor: pointer;
}
.link-button:hover { color: var(--clr-theme-primary); }

/* Toggle switches (used in app settings) */
.profile-toggle-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 8px;
}
.profile-switch {
    display: grid;
    grid-template-columns: 44px 1fr;
    align-items: start;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-control);
    cursor: pointer;
    background: var(--clr-bg-canvas);
    transition: border-color .15s ease, background .15s ease;
}
.profile-switch:hover { border-color: var(--clr-border-strong); }
.profile-switch input[type="checkbox"] {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
.switch-track {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    background: #d1d5db;
    border-radius: 999px;
    transition: background .2s ease;
    margin-top: 2px;
}
.switch-knob {
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: transform .2s ease;
}
.profile-switch input:checked ~ .switch-track {
    background: var(--clr-theme-primary);
}
.profile-switch input:checked ~ .switch-track .switch-knob {
    transform: translateX(18px);
}
.profile-switch input:focus-visible ~ .switch-track {
    box-shadow: 0 0 0 3px rgba(245,134,52,.25);
}
.switch-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.switch-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--clr-text-secondary);
    line-height: 1.3;
}
.switch-sub {
    font-size: 12.5px;
    color: var(--clr-text-muted);
    line-height: 1.45;
}

/* Quick Access picker */
.profile-quick-access {
    border-top: 1px dashed var(--clr-border-soft);
    margin-top: 18px;
    padding-top: 18px;
}
.quick-access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.quick-access-group {
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-control);
    padding: 12px 14px 14px;
    margin: 0;
    background: var(--clr-bg-canvas);
}
.quick-access-group legend {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    padding: 0 6px;
    margin-left: -6px;
}
.quick-access-item {
    display: grid;
    grid-template-columns: 18px 18px 1fr;
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--clr-text-secondary);
    transition: background .15s ease;
}
.quick-access-item:hover { background: rgba(245,134,52,.06); }
.quick-access-item input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--clr-theme-primary);
    cursor: pointer;
}
.quick-access-item .qa-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-text-muted);
}
.quick-access-item .qa-icon .ico {
    width: 16px; height: 16px;
    stroke: currentColor;
    stroke-width: 1.6;
    fill: none;
}
.quick-access-item input:checked ~ .qa-icon { color: var(--clr-theme-primary); }
.quick-access-item input:checked ~ .qa-label { color: var(--clr-theme-primary-deep); font-weight: 500; }
.qa-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.danger-zone {
    border-color: rgba(239,68,68,.25);
}
.danger-zone h2 { color: #b91c1c; }

/* Profile page mobile */
@media (max-width: 720px) {
    .profile-toggle-row { grid-template-columns: 1fr; }
    .profile-section-head { flex-direction: column; gap: 10px; }
    .profile-section-head .btn-fill { align-self: flex-start; }
}

/* ============================================================
   Styled combobox — replaces native <datalist> on line-item forms
   ============================================================ */
.combo-wrap {
    position: relative;
}
.combo-dropdown {
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--clr-bg-surface);
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-control);
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    margin-top: 4px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 50;
}
.combo-item {
    display: flex;
    gap: 10px;
    align-items: baseline;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--clr-border-soft);
    font-size: 12px;
    line-height: 1.4;
}
.combo-item:last-child { border-bottom: 0; }
.combo-item.is-active,
.combo-item:hover { background: var(--clr-theme-soft); }
.combo-code {
    font-weight: 600;
    color: var(--clr-theme-primary-deep);
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}
.combo-name {
    color: var(--clr-common-body-text);
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.combo-empty {
    padding: 12px;
    color: var(--clr-text-muted);
    font-size: 12px;
    text-align: center;
}

/* ============================================================
   Recent-prices popup — appears after a part/set is picked
   on Sales Invoice and Purchase Order forms
   ============================================================ */
.recent-prices-popup {
    position: absolute;
    top: 100%; left: 0;
    margin-top: 6px;
    min-width: 460px;
    max-width: 600px;
    background: var(--clr-bg-surface);
    border: 1px solid var(--clr-border-soft);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card-hover);
    z-index: 60;
    padding: 4px 0;
}
.recent-prices-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--clr-border-soft);
}
.recent-prices-head .eyebrow {
    margin: 0;
}
.recent-prices-close {
    background: transparent;
    border: 0;
    color: var(--clr-text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
}
.recent-prices-close:hover {
    background: var(--clr-theme-soft);
    color: var(--clr-theme-primary-deep);
}
.recent-prices-loading {
    padding: 18px;
    text-align: center;
    color: var(--clr-text-muted);
    font-size: 12px;
}
.recent-prices-row {
    display: grid;
    grid-template-columns: 92px 1fr 76px 116px auto;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    width: 100%;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--clr-border-soft);
    text-align: left;
    cursor: pointer;
    font-size: 12px;
    color: var(--clr-common-body-text);
    border-left: 3px solid transparent;
}
.recent-prices-row:last-child { border-bottom: 0; }
.recent-prices-row:hover { background: var(--clr-theme-soft); }
.recent-prices-row.is-current-contact {
    background: #fff5ed;
    border-left-color: var(--clr-theme-primary);
}
.recent-prices-row.is-current-contact:hover {
    background: #ffeacd;
}
.recent-prices-date {
    font-variant-numeric: tabular-nums;
    color: var(--clr-text-subtle);
}
.recent-prices-contact {
    color: var(--clr-common-heading);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recent-prices-qty,
.recent-prices-price {
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.recent-prices-price {
    font-weight: 600;
    color: var(--clr-theme-primary-deep);
}
.recent-prices-badge {
    display: inline-flex;
    align-items: center;
    background: var(--clr-theme-primary);
    color: #fff;
    border-radius: var(--radius-pill);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}
.recent-prices-empty {
    padding: 18px 14px;
    text-align: center;
    color: var(--clr-text-muted);
    font-size: 12px;
}

/* ============================================================
   Date input wrapper — DD/MM/YYYY text + hidden native picker.
   Drives Alpine's `dateInput()` component (see form-helpers.js).
   ============================================================ */
.date-input-wrap {
    position: relative;
}
.date-input-wrap .form-control {
    padding-right: 30px; /* room for the picker button */
}
.date-input-native {
    position: absolute;
    inset: 0 0 auto auto;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    border: 0;
}
.date-picker-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    color: var(--clr-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 6px;
}
.date-picker-btn:hover {
    background: var(--clr-theme-soft);
    color: var(--clr-theme-primary-deep);
}
