/* =========================================================
   CÃƒÂ´ng nÃ¡Â»Â£ v2 Ã¢â‚¬â€ Command workspace
   KhÃƒÂ¡c hoÃƒÂ n toÃƒÂ n v1: sidebar nav + 1 view / lÃ¡ÂºÂ§n, dark rail
   ========================================================= */

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

:root {
    --rail: #0f1419;
    --rail-2: #161b22;
    --rail-hover: #1c2330;
    --rail-active: #243044;
    --rail-text: #9aa4b2;
    --rail-text-on: #f0f3f7;
    --accent: #3b82f6;
    --accent-2: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.14);
    --bg: #e8ecf1;
    --surface: #ffffff;
    --surface-2: #f4f6f9;
    --line: #dce1e8;
    --line-soft: #e9edf2;
    --text: #111827;
    --text-2: #4b5563;
    --muted: #8b95a5;
    --ok: #059669;
    --ok-soft: #d1fae5;
    --bad: #dc2626;
    --bad-soft: #fee2e2;
    --warn: #d97706;
    --warn-soft: #fef3c7;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 16px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.14);
    --rail-w: 220px;
    --top-h: 52px;
    --font: "IBM Plex Sans", "Inter", system-ui, -apple-system, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --fs: 0.875rem;
}

html { height: 100%; }
body {
    font-family: var(--font);
    font-size: var(--fs);
    color: var(--text);
    background: var(--bg);
    min-height: 100%;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(1200px 600px at 10% -10%, #1e3a8a 0%, transparent 50%),
                radial-gradient(900px 500px at 100% 100%, #0f172a 0%, #020617 60%);
    padding: 24px;
}
.login-box {
    width: 100%;
    max-width: 400px;
    background: rgba(255,255,255,0.96);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.login-box h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.03em; }
.login-logo { width: 120px; height: 64px; object-fit: contain; object-position: left center; }
.login-box p { color: var(--text-2); font-size: 0.8125rem; }
.login-box input[type="password"] {
    height: 44px; border: 1px solid var(--line); border-radius: 10px;
    padding: 0 14px; font: inherit; outline: none;
}
.login-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 8px; font-size: 0.8125rem; font-weight: 600; }

.app-frame {
    display: grid;
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
    min-height: 100vh;
}

.rail {
    background: var(--rail);
    color: var(--rail-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid #1a2332;
    z-index: 30;
}
.rail-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.rail-logo {
    width: 60%;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
}
.rail-nav-group { display: flex; flex-direction: column; gap: 2px; }
.rail-nav-title { padding: 8px 12px; font-size: 0.7rem; font-weight: 600; color: var(--rail-text); }
.rail-brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rail-brand-text strong { color: var(--rail-text-on); font-size: 0.9rem; font-weight: 700; letter-spacing: -0.02em; }
.rail-brand-text span { font-size: 0.65rem; color: var(--rail-text); text-transform: uppercase; letter-spacing: 0.08em; }

.rail-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 10px;
    flex: 1;
}
.rail-nav button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--rail-text);
    font: inherit;
    font-weight: 550;
    font-size: 0.8125rem;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}
.rail-nav button:hover { background: var(--rail-hover); color: var(--rail-text-on); }
.rail-nav button.is-active {
    background: var(--rail-active);
    color: var(--rail-text-on);
    box-shadow: inset 3px 0 0 var(--accent);
}
.rail-ico {
    width: 20px; height: 20px; display: grid; place-items: center;
    font-size: 0.95rem; opacity: 0.9; flex-shrink: 0;
}
.rail-nav .rail-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-left: auto; padding: 0 5px; border-radius: 999px; background: #ddf6e9; color: #176348; font-size: .68rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.rail-nav .rail-count[hidden] { display: none; }
.rail-foot {
    padding: 12px 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rail-foot .meta {
    font-size: 0.65rem;
    color: #6b7280;
    line-height: 1.4;
}
.rail-foot a {
    color: var(--accent-2);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
}
.rail-foot a:hover { text-decoration: underline; }

.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.topbar {
    height: var(--top-h);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 18px;
    position: sticky;
    top: 0;
    z-index: 25;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.view-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.period-cluster {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.last-updated {
    font-size: 0.7rem;
    color: var(--muted);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.segmented {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px;
    gap: 1px;
}
.segmented button {
    border: none;
    background: transparent;
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 650;
    color: var(--text-2);
    cursor: pointer;
}
.segmented button.is-on {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(15,23,42,0.08);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border-radius: 9px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: 0.15s background, 0.15s border-color, 0.15s color;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-tiny { height: 28px; padding: 0 9px; font-size: 0.7rem; }
.btn-nav {
    width: 28px; height: 28px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--surface);
    cursor: pointer; color: var(--text-2); font-weight: 700;
}
.btn-nav:hover { background: var(--surface-2); color: var(--text); }

.spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.period-range {
    font-size: 0.75rem;
    font-weight: 650;
    min-width: 110px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.view-stack {
    flex: 1;
    padding: 16px 18px 28px;
    min-width: 0;
}
.view-panel { display: none; }
.view-panel.is-visible { display: block; }

.ov-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
}
.ov-kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ov-kpis-title { grid-column: 1 / -1; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; color: var(--text-2); }
.ov-signals { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ov-debtors { grid-column: 1 / 8; }
.ov-period { grid-column: 8 / -1; }
.ov-ix { grid-column: 1 / -1; }

.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.tile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-soft);
}
.tile-head h3 {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.tile-body { padding: 0; }

.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
    box-shadow: var(--shadow);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.metric:hover {
    border-color: #b6c4d8;
    box-shadow: 0 4px 18px rgba(15,23,42,0.08);
    transform: translateY(-1px);
}
.metric .m-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 6px;
}
.metric .m-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 750;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.metric .m-value.ok { color: var(--ok); }
.metric .m-value.bad { color: var(--bad); }

.signal {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    font: inherit;
    box-shadow: var(--shadow);
}
.signal:hover { border-color: #b6c4d8; }
.signal .s-label { font-size: 0.75rem; font-weight: 650; color: var(--text-2); }
.signal .s-value { font-size: 1.35rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.signal.bad .s-value { color: var(--bad); }
.signal.warn .s-value { color: var(--warn); }

.stat-list { display: flex; flex-direction: column; }
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 0.8125rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--text-2); }
.stat-row strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-row strong.ok { color: var(--ok); }
.stat-row strong.bad { color: var(--bad); }

.work-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--top-h) - 48px);
}
.payment-history-page { padding: 20px; gap: 10px; }
.payment-history-page h2 { margin: 0; font-size: 1.15rem; }
.payment-history-page .modal-summary { margin: 0 0 6px; }
.payment-history-table-wrap { max-height: none; min-width: 0; }
.payment-table.payment-history-table th:nth-child(3), .payment-table.payment-history-table td:nth-child(3) { text-align: left; }
.payment-table.payment-history-table th:nth-child(4), .payment-table.payment-history-table td:nth-child(4) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.payment-history-table th:nth-child(5), .payment-history-table .payment-status-cell { text-align: center; }
.payment-customer-cell strong, .payment-customer-cell small { display: block; }
.payment-customer-cell strong { font-weight: 750; }
.payment-customer-cell small {
    margin-top: 4px;
    color: var(--text-2);
    font-size: .75rem;
    font-weight: 400;
}
.payment-history-table .deal-ref-list > .payment-deal-link { border: 0; border-radius: 999px; padding: 5px 10px; background: #e5f0fc; color: #235d96; font: inherit; font-size: .72rem; font-weight: 750; text-decoration: none; cursor: pointer; }
.payment-history-table .deal-ref-list > .payment-deal-link.lead-won-deal { background: #ddf6e9; color: #176348; }
.payment-history-table .deal-ref-list > .payment-deal-link:hover, .payment-history-table .deal-ref-list > .payment-deal-link:focus-visible { outline: 2px solid #247b64; outline-offset: 2px; }
.payment-status { display: inline-block; padding: 5px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.payment-status-advance { color: #92400e; background: #fef3c7; }
.payment-status-payment { color: #1d4ed8; background: #dbeafe; }
.payment-status-settlement { color: #166534; background: #dcfce7; }
.payment-status-other { color: #475569; background: #e2e8f0; }
.work-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-soft);
    background: linear-gradient(180deg, #fff 0%, var(--surface-2) 100%);
}
.work-toolbar-left, .work-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.hint {
    padding: 8px 14px;
    font-size: 0.75rem;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--line-soft);
}
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-soft);
}
.chip {
    height: 28px;
    padding: 0 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 650;
    color: var(--text-2);
    cursor: pointer;
}
.chip:hover { border-color: #b6c4d8; color: var(--text); }
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: #1e40af; }
.chip.is-clear { color: var(--muted); }

.quick-search {
    height: 32px;
    min-width: 360px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    font: inherit;
    font-size: 0.8125rem;
    background: #fff;
    outline: none;
}
.quick-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-count { font-size: 0.7rem; color: var(--muted); font-weight: 650; }
select#topNSelect {
    height: 32px; border: 1px solid var(--line); border-radius: 8px;
    padding: 0 8px; font: inherit; font-size: 0.75rem; background: #fff;
}

.table-container { overflow: auto; flex: 1; max-height: calc(100vh - var(--top-h) - 160px); }
.top-debtors-table-wrap { max-height: none; overflow: visible; }
.prog-table-wrap { max-height: calc(100vh - var(--top-h) - 180px); }
.prog-table-wrap.is-enlarged { max-height: calc(100vh - var(--top-h) - 100px); }
.ix-table-wrap { max-height: calc(100vh - var(--top-h) - 180px); }

.payment-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.payment-table th {
    position: sticky; top: 0; z-index: 2;
    background: #f1f5f9;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.65rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-2);
    white-space: nowrap;
}
.payment-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
.payment-table tbody tr:hover { background: #f8fafc; }
.payment-table tfoot td {
    font-weight: 700;
    background: #f1f5f9;
    border-top: 1px solid var(--line);
}
.payment-table .num, .payment-table td.money {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: var(--mono);
    font-size: 0.78rem;
}

.payment-table td:nth-child(3), .payment-table th:nth-child(3) {
    text-align: right;
}

.payment-table td:nth-child(4), .payment-table th:nth-child(4) {
    text-align: center;
}

#paymentModal .payment-table td:nth-child(3),
#paymentModal .payment-table th:nth-child(3) { text-align: left; }
#paymentModal .payment-table td:nth-child(4),
#paymentModal .payment-table th:nth-child(4) { text-align: right; }

.prog-table th span {
    display: block; font-weight: 500; text-transform: none;
    letter-spacing: 0; color: var(--muted); margin-top: 2px;
}
.prog-sticky { position: sticky; left: 0; z-index: 3; background: #fff; }
.prog-table thead .prog-sticky { z-index: 4; background: #f1f5f9; }
.prog-hd-col { min-width: 88px; }
.prog-name-col { min-width: 200px; left: 0; }
.day-row td {
    background: #f1f5f9;
    font-weight: 750;
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-top: 12px !important;
}
#topDebtorsBody tr { cursor: pointer; }
#topDebtorsBody tr:hover { background: var(--accent-soft); }

.prog-input {
    width: 64px; height: 28px; border: 1px solid var(--line);
    border-radius: 6px; padding: 0 6px; font: inherit; font-size: 0.8rem; text-align: right;
}
.prog-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.board {
    display: flex;
    gap: 12px;
    padding: 14px;
    overflow-x: auto;
    align-items: flex-start;
    min-height: 320px;
    background: #eef2f7;
}
.column {
    flex: 1 0 272px;
    background: #e2e8f0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--top-h) - 200px);
    border: 1px solid #cbd5e1;
}
.column-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 10px;
    background: #f8fafc;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid #cbd5e1;
}
.column-header h2 {
    font-size: 0.75rem;
    font-weight: 750;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.column-header .count {
    font-size: 0.65rem;
    font-weight: 750;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 2px 7px;
    color: var(--text-2);
}
.col-toggle, .col-rename {
    width: 36px; height: 36px; flex-shrink: 0;
    display: inline-grid; place-items: center;
    border: 1px solid #cbd5e1; background: #fff; cursor: pointer;
    color: var(--text-2); font-size: 1.125rem; padding: 0; border-radius: 8px;
}
.col-toggle:focus-visible, .col-rename:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.col-toggle:hover, .col-rename:hover { background: #e2e8f0; color: var(--text); }
.column-content, .dropzone {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 80px;
    container-type: inline-size;
}
.dropzone.drag-over {
    background: var(--accent-soft);
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
}
.card {
    background: #fff;
    border: 1px solid #d0d7e2;
    border-radius: 10px;
    padding: 11px 12px;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(15,23,42,0.04);
    transition: box-shadow 0.15s, border-color 0.15s;
}
.card:hover { border-color: #94a3b8; box-shadow: 0 4px 12px rgba(15,23,42,0.08); }
.card.dragging { opacity: 0.55; }
.progress-wrap {
    height: 6px;
    background: #e2e8f0;
    border-radius: 4px;
    margin: 8px 0 4px;
    overflow: hidden;
}
.progress-bar { height: 100%; background: var(--ok); }
.card-overdue { border-left: 3px solid var(--bad); }
.card-aging-90 { border-left: 3px solid #7c3aed; }
.card-aging-60 { border-left: 3px solid var(--warn); }
.card-title { font-size: 0.8125rem; font-weight: 700; margin-bottom: 2px; line-height: 1.3; }
.card-subtitle { font-size: 0.72rem; color: var(--text-2); margin-bottom: 6px; }
.card-contract { font-size: 0.68rem; font-weight: 650; color: #64748b; margin-bottom: 6px; font-family: var(--mono); }
.card-field {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.72rem;
    margin-top: 3px;
    color: var(--text-2);
}
.card-field span:last-child { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.card-field-sales .card-field span:last-child { text-align: right; overflow-wrap: anywhere; }
.card-field.highlight span:last-child { color: var(--bad); }
.card-field.success span:last-child { color: var(--ok); }
.card-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.68rem;
    color: var(--muted);
    font-weight: 600;
}
.card-dates { font-size: 0.68rem; color: var(--muted); margin-top: 4px; }
.card-dates.highlight { color: var(--bad); font-weight: 650; }

@container (min-width: 420px) {
    .card-main {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(210px, 0.9fr);
        gap: 16px;
        align-items: start;
    }
    .card-details, .card-finance { min-width: 0; }
    .card-finance .card-field:first-child { margin-top: 0; }
}

.aging-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 750;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--warn-soft);
    color: var(--warn);
    text-transform: uppercase;
}
.channel-pill {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 750;
    padding: 2px 7px;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--text-2);
    border: 1px solid var(--line);
}
.channel-pill.zalo { background: var(--ok-soft); color: var(--ok); border-color: #a7f3d0; }
.channel-pill.call, .channel-pill.phone { background: var(--accent-soft); color: #1e40af; border-color: #bfdbfe; }
.ix-note {
    white-space: normal;
    word-break: break-word;
    color: var(--text-2);
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 550;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.toast.is-on { opacity: 1; pointer-events: auto; }
.live-banner {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 0.8125rem;
    font-weight: 550;
}
.live-banner.is-on { display: flex; }
.live-banner[hidden] { display: none !important; }
.toast[hidden] { display: none !important; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(15, 23, 42, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}
#dealDialog { z-index: 81; }
.modal.is-open,
.modal[style*="display: block"],
.modal[style*="display:flex"] {
    display: flex !important;
}
.modal-content {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow: auto;
    padding: 22px 24px 26px;
    position: relative;
    overflow: hidden;
}
.payment-modal {max-width: 80vw;}
.project-modal { max-width: 920px; }
.close-btn {
    position: absolute; top: 12px; right: 16px;
    font-size: 1.5rem; line-height: 1; color: var(--muted);
    cursor: pointer; border: none; background: none; padding: 4px 8px;
}
.close-btn:hover { color: var(--text); }
.modal-content h2 { font-size: 1.15rem; font-weight: 750; margin-bottom: 6px; padding-right: 32px; letter-spacing: -0.02em; }
.modal-summary { color: var(--text-2); font-size: 0.8125rem; margin-bottom: 14px; }
.modal-subhead { font-size: 0.875rem; font-weight: 700; margin: 16px 0 8px; }
.project-modal-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.kpi-value.success, .m-value.ok { color: var(--ok); }
.kpi-value.highlight, .m-value.bad { color: var(--bad); }

/* class aliases for app.js metric-card clicks */
.metric-card { }
.filter-chips { }

@media (max-width: 1100px) {
    .ov-debtors, .ov-period { grid-column: 1 / -1; }
    .ov-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
    .app-frame { grid-template-columns: 1fr; }
    .rail {
        position: sticky; top: 0; height: auto;
        flex-direction: row; flex-wrap: wrap;
        align-items: center;
    }
    .rail-brand { border-bottom: none; padding: 10px 12px; }
    .rail-nav {
        flex-direction: row; flex-wrap: wrap; padding: 6px 8px; flex: 1;
    }
    .rail-nav button { width: auto; padding: 8px 10px; }
    .rail-nav-group { flex-direction: row; flex-wrap: wrap; align-items: center; }
    .rail-nav-title { flex-basis: 100%; padding: 4px 10px; }
    .rail-nav button.is-active { box-shadow: none; background: var(--rail-active); }
    .rail-foot { display: none; }
    .ov-signals { grid-template-columns: 1fr; }
}

/* ===== Project modal v2 refinements ===== */
.project-modal-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 4px 0 16px;
}
.project-modal-stats > div {
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.project-modal-stats > div span {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
.project-modal-stats > div strong {
    font-size: 0.95rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}
.project-modal-stats .success { color: var(--ok); }
.project-modal-stats .highlight { color: var(--bad); }

.timeline-table td.tl-detail {
    white-space: normal;
    word-break: break-word;
    max-width: 420px;
    color: var(--text-2);
    line-height: 1.4;
}
.timeline-table tr.row-pay {
    background: #ecfdf5;
}
.timeline-table tr.row-pay:hover {
    background: #d1fae5;
}
.timeline-table tr.row-pay td:last-child {
    font-weight: 700;
    color: var(--ok);
    font-variant-numeric: tabular-nums;
    font-family: var(--mono);
    white-space: nowrap;
}
.timeline-table tr.row-ix td:last-child {
    white-space: normal;
}

@media (max-width: 640px) {
    .project-modal-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-row.stat-sep {
    border-top: 1px dashed var(--line);
    margin-top: 4px;
    padding-top: 12px;
}
.stat-row.stat-sep span { font-weight: 700; color: var(--text); }
.ov-debtors .table-container { max-height: none; }
.ov-period { align-self: start; }


/* Column collapse (PhÃƒÂ¢n loÃ¡ÂºÂ¡i) */
.column.is-collapsed {
    flex: 0 0 52px;
    width: 52px;
    min-width: 52px;
    max-width: 52px;
}
.column.is-collapsed .column-content,
.column.is-collapsed .dropzone {
    display: none !important;
}
.column.is-collapsed .col-rename {
    display: none;
}
.column.is-collapsed .column-header {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 6px;
    min-height: 120px;
}
.column.is-collapsed .column-header h2 {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.8rem;
    flex: 0 0 auto;
    max-height: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.column.is-collapsed .count {
    margin-top: 4px;
}
.column.is-collapsed .col-toggle {
    width: 36px;
    height: 36px;
}
.col-toggle {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}


/* Progress table Ã¢â‚¬â€ layout & input */
.prog-table thead th.prog-debt-group {
    text-align: center;
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #f6e05e;
}
.prog-table thead th.prog-debt-sub {
    background: #fffbeb;
}
.prog-table .prog-sticky.prog-name-col,
.prog-table td.prog-name {
    left: 0;
    min-width: 200px;
    max-width: 320px;
}
.prog-table td.prog-name {
    font-weight: 650;
    line-height: 1.35;
}
.prog-table .prog-sub {
    display: block;
    font-weight: 500;
    font-size: 0.72rem;
    color: #6b7280;
    margin-top: 2px;
}
.prog-table .prog-hd-sub {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #4b5563;
    font-weight: 600;
}
.prog-table .prog-edit-cell {
    padding: 6px 8px;
    text-align: center;
    vertical-align: middle;
}
.prog-pct-input {
    width: 64px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    background: #f8fafc;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 650;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: #1e3a8a;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.prog-pct-input:hover {
    background: #fff;
    border-color: #a5b4fc;
}
.prog-pct-input:focus {
    outline: none;
    background: #fff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.prog-pct-input::placeholder {
    color: #94a3b8;
    font-weight: 500;
}
/* hide number spinners for cleaner look */
.prog-pct-input::-webkit-outer-spin-button,
.prog-pct-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.prog-pct-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}



/* Interaction table */
.ix-content {
    min-width: 180px;
    max-width: 360px;
    line-height: 1.35;
    font-weight: 600;
}
.ix-sub {
    display: block;
    margin-top: 3px;
    font-size: 0.72rem;
    font-weight: 500;
    color: #6b7280;
}
.ix-note {
    white-space: normal !important;
    word-break: break-word;
    overflow: visible !important;
    text-overflow: unset !important;
    max-width: none;
    min-width: 200px;
    line-height: 1.4;
    color: #374151;
}


/* Progress table sticky header Ã¢â‚¬â€ 1 row (Ã¡Â»â€¢n Ã„â€˜Ã¡Â»â€¹nh khi scroll) */
.prog-table-wrap { position: relative; }
.prog-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f1f5f9;
    box-shadow: 0 1px 0 #dce1e8;
    text-align: center;
}
.prog-table thead th.prog-c1 { background: #e8f5ee; }
.prog-table thead th.prog-c2 { background: #eceaf5; }
.prog-table thead th.prog-c3 { background: #fdeceb; }
.prog-table thead th.prog-debt-col {
    background: #fef3c7;
    color: #92400e;
    border-bottom: 2px solid #f59e0b;
}
.prog-table thead th.prog-debt-col span { color: #b45309; }
.prog-table thead .prog-sticky {
    z-index: 7;
    left: 0;
    background: #f1f5f9;
}
.prog-table tbody td.prog-c3,
.prog-table tfoot td.prog-c3 {
    background: #fff5f5;
}

#progTableBody tr.prog-row-saved td {
    background: #ecfdf5 !important;
    transition: background 0.3s;
}

/* Sales and marketing KPI workspace */
.kpi-page { padding: 24px; margin: 20px; }
.kpi-page h2 { margin: 0 0 8px; }
.kpi-page p { color: var(--muted); margin: 0 0 20px; }
.kpi-table { width: 100%; min-width: 650px; }
.kpi-table th, .kpi-table td { padding: 12px; vertical-align: middle; }
.kpi-input { width: 100%; min-width: 90px; padding: 9px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; }
.kpi-table small { display: block; margin-top: 5px; color: var(--muted); }
#kpiSave { margin-top: 18px; }
#kpiSaveStatus { margin-left: 12px; }
.kpi-period { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.kpi-period select { padding: 8px 12px; border-radius: 8px; border: 1px solid #cbd5e1; }
.kpi-period input { width: 100px; padding: 8px 12px; border-radius: 8px; border: 1px solid #cbd5e1; font: inherit; }
.kpi-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi-card { padding: 20px; border: 1px solid #dbe3ec; border-radius: 12px; background: #fff; }
.kpi-card span { display: block; color: var(--muted); }
.kpi-card strong { display: block; font-size: 1.6rem; margin: 10px 0; }
.kpi-card strong small { font-size: .8rem; font-weight: normal; }
.kpi-card div { margin-top: 5px; }
.kpi-track { height: 8px; background: #e5eaf0; border-radius: 99px; overflow: hidden; }
.kpi-track i { display: block; height: 100%; background: #247b64; border-radius: inherit; }
@media (max-width: 860px) { .kpi-cards { grid-template-columns: 1fr; } .kpi-page { margin: 12px; padding: 16px; } }
#view-kpi-progress .kpi-page > h3 { margin: 34px 0 14px; }
#view-kpi-progress .kpi-page > h3:first-of-type { margin-top: 24px; }
#view-kpi-progress .kpi-page > p { margin-bottom: 12px; }
#view-kpi-progress .kpi-cards { margin-bottom: 30px; }
.kpi-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 34px 0 14px; }
.kpi-section-head h3 { margin: 0; }
.kpi-switch { min-width: 90px; }
.kpi-inline-progress { display: block; height: 6px; margin-top: 7px; border-radius: 10px; background: #e5eaf0; overflow: hidden; }
.kpi-inline-progress i { display: block; height: 100%; background: #247b64; }
.kpi-chart { display: grid; gap: 12px; padding: 18px; border: 1px solid #dbe3ec; border-radius: 12px; }
.kpi-chart[hidden], .table-container[hidden] { display: none; }
.kpi-chart-row { display: grid; grid-template-columns: 90px 1fr; gap: 12px; align-items: start; }
.kpi-chart-row > div { display: grid; gap: 4px; color: var(--muted); font-size: .75rem; }
.kpi-chart-track { height: 9px; background: #e5eaf0; border-radius: 10px; overflow: hidden; }
.kpi-chart-track i { display: block; height: 100%; background: #255e91; }
.kpi-chart-track.pkd i { background: #247b64; }
.kpi-chart-controls { display: flex; align-items: center; gap: 8px; }
.kpi-chart-type { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; font: inherit; }
.kpi-chart-type[hidden] { display: none; }
.kpi-chart.is-donut { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; border: 0; padding: 0; }
.kpi-donut-card { min-width: 0; position: relative; padding: 18px; border: 1px solid #dbe3ec; border-radius: 12px; background: #fff; }
.kpi-deal-card { text-align: left; cursor: pointer; font: inherit; color: inherit; border: 1px solid #dbe3ec; }
.kpi-deal-card:hover, .kpi-deal-card:focus-visible { border-color: #247b64; box-shadow: 0 0 0 2px #247b6426; }
.kpi-deal-link { border: 0; padding: 0; background: none; color: #196b5a; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.kpi-deal-link:focus-visible { outline: 2px solid #247b64; outline-offset: 2px; }
.deal-ref-list { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; max-width: 100%; vertical-align: middle; }
.deal-ref-list > button { flex: none; font-size: .75rem; line-height: 1.35; white-space: nowrap; }
.deal-ref-list > .kpi-deal-link { padding: 5px 0; }
.deals-controls { flex-wrap: wrap; }
.deals-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.deals-quick button { border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; color: var(--text-2); padding: 7px 10px; font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; }
.deals-quick button:hover, .deals-quick button:focus-visible { border-color: #247b64; color: #176348; }
.deals-quick button.is-active { background: #ddf6e9; border-color: #247b64; color: #176348; }
.deals-service-filter { display: grid; gap: 10px; margin: 12px 0; }
.deals-service-filter > span { display: block; font-weight: 700; color: var(--text-2); }
.deals-service-filter .deals-quick { width: 100%; }
.source-section { align-items: center; margin-left: 18px; }
.source-section[hidden], #periodSection[hidden] { display: none; }
.deals-search { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.deals-search label { white-space: nowrap; }
.deals-controls .deals-search input[type="search"] { width: 220px; min-width: 220px; }
@media (max-width: 760px) { .deals-search { width: 100%; justify-content: flex-end; } }
.deals-table-wrap { max-height: none; overflow-x: auto; }
.deals-summary-wrap { flex: none; max-height: none; margin: 4px 0 18px; padding: 14px 16px 16px; border: 1px solid #b8d9cd; border-radius: 14px; background: linear-gradient(135deg, #effaf4, #f5f9ff); box-shadow: 0 5px 16px #194f3d12; }
.deals-summary-wrap[hidden] { display: none; }
.deals-summary-wrap h3 { margin: 0 0 12px; color: #176348; font-size: .9rem; }
.deals-summary-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.deals-summary-metrics > div { border: 1px solid #d8e9e0; border-radius: 10px; background: #fff; padding: 11px 13px; }
.deals-summary-metrics span { display: block; color: #46665b; font-size: .82rem; }
.deals-summary-metrics strong { display: block; margin-top: 5px; color: #173d31; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.deals-status-chart { display: grid; gap: 10px; }
.deals-status-track { display: flex; height: 20px; overflow: hidden; border-radius: 999px; background: #dfeae5; }
.deals-status-fill { height: 100%; flex: none; }
.deals-status-fill.won { background: #2a9d70; }
.deals-status-fill.pending { background: #e9a740; }
.deals-status-fill.lost { background: #d76a6a; }
.deals-status-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; color: #355b4c; font-size: .85rem; }
.deals-status-legend span { display: inline-flex; align-items: center; gap: 5px; }
.deals-status-legend i { width: 10px; height: 10px; border-radius: 50%; }
.deals-status-legend i.won { background: #2a9d70; }
.deals-status-legend i.pending { background: #e9a740; }
.deals-status-legend i.lost { background: #d76a6a; }
.deals-status-legend strong { color: #173d31; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .deals-summary-metrics { grid-template-columns: 1fr; } }
.deals-table { width: max-content; min-width: 100%; }
.deals-table th, .deals-table td { min-width: 120px; max-width: 360px; white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.deals-table thead th { position: sticky; top: 0; z-index: 1; background: #f8fafc; }
.deals-table .deal-list-row { cursor: pointer; }
.deals-table .deal-list-row.is-selected td { background: #e4f3ec; box-shadow: inset 0 2px #247b64, inset 0 -2px #247b64; }
.deals-table .deal-list-row:focus-visible { outline: 2px solid #247b64; outline-offset: -2px; background: #edf7f3; }
.deals-table .deal-main { font-weight: 750; }
.deals-table .deal-status-cell, .deals-table th:nth-child(3), .deals-table .deal-source-cell, .deals-table th:nth-child(4) { text-align: center; }
.deals-table .num { text-align: right; }
#view-leads .deals-table-wrap { min-width: 0; overflow-x: hidden; }
.leads-table { width: 100%; min-width: 0; table-layout: fixed; }
.leads-table th, .leads-table td { min-width: 0; max-width: none; overflow-wrap: anywhere; }
.leads-table th:nth-child(1) { width: 10%; }
.leads-table th:nth-child(2) { width: 22%; }
.leads-table th:nth-child(3) { width: 16%; }
.leads-table th:nth-child(4) { width: 13%; }
.leads-table th:nth-child(5) { width: 13%; }
.leads-table th:nth-child(6) { width: 11%; }
.leads-table th:nth-child(7) { width: 15%; }
.leads-table .deal-ref-list > button { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.leads-table .lead-customer {
    font-weight: 750;
    color: var(--text);
    font-size: 1.1em;
}
.leads-table .lead-code {
    font-weight: 750;
    color: var(--text);
    font-size: 1.1em;
    letter-spacing: 0px;
}
.leads-table tr.is-selected td { background: #edf7f3; }
.leads-table .lead-phone { display: block; margin-top: 3px; color: var(--text-2); font-size: .75rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.leads-table :is(th, td):is(:nth-child(3), :nth-child(4), :nth-child(5), :nth-child(7)) { text-align: center; }
.leads-table td:nth-child(6) {
    font-variant-numeric: tabular-nums;
    font-family: var(--mono);
    font-size: 0.78rem;
    text-align: center;
}

.leads-table :is(th, td):nth-child(6) {
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.lead-chip { display: inline-block; max-width: 100%; padding: 5px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.lead-value-tone, #leadsServices button.lead-value-tone { color: var(--lead-ink); background: var(--lead-bg); border-color: var(--lead-border); }
.lead-chip.lead-status-failed { text-decoration: line-through; }
.deal-overview strong.lead-chip { display: inline-block; font-size: .72rem; font-weight: 700; }
#leadsServices button.lead-value-tone.is-active { box-shadow: 0 0 0 2px var(--lead-border); }
:is(.leads-table, #ixTable, #leadDialog) .lead-won-deal { border: 0; border-radius: 999px; background: #ddf6e9; color: #176348; padding: 5px 10px; font: inherit; font-size: .72rem; font-weight: 750; text-decoration: none; cursor: pointer; }
:is(.leads-table, #ixTable, #leadDialog) .lead-won-deal:hover, :is(.leads-table, #ixTable, #leadDialog) .lead-won-deal:focus-visible { background: #c4ebd7; outline: 2px solid #247b64; outline-offset: 2px; }
.deal-ref-list > .lead-won-deal { font-size: .75rem; }
.leads-table tr[data-lead-id] { cursor: pointer; }
.leads-table tr[data-lead-id]:focus-visible { outline: 2px solid #247b64; outline-offset: -2px; }
@media (max-width: 1100px) {
    .leads-table { display: block; width: 100%; min-width: 0; }
    .leads-table thead { display: none; }
    .leads-table tbody { display: grid; gap: 10px; }
    .leads-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
    .leads-table tbody tr.is-selected { border-color: #247b64; background: #edf7f3; }
    .leads-table td, .leads-table td:nth-child(3), .leads-table td:nth-child(4), .leads-table td:nth-child(6), .leads-table td:nth-child(7) { display: block; min-width: 0; max-width: none; padding: 0; border: 0; text-align: left; }
    .leads-table td::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--text-2); font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
    .leads-table td.lead-customer, .leads-table td:nth-child(7), .leads-table td[colspan] { grid-column: 1 / -1; }
    .leads-table td[colspan]::before { content: none; }
}
@media (max-width: 480px) {
    .leads-table tbody tr { grid-template-columns: minmax(0, 1fr); }
    .leads-table tbody tr > td { grid-column: 1 / -1; }
}
.deal-badge { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.deal-badge.status-won { color: #176348; background: #ddf6e9; }
.deal-badge.status-consult { color: #235d96; background: #e5f0fc; }
.deal-badge.status-quote { color: #81520a; background: #fff0c9; }
.deal-badge.status-info { color: #594a98; background: #eee9fb; }
.deal-badge.status-lost { color: #a23434; background: #fde6e6; }
.deal-badge.status-delay { color: #795018; background: #f8e5cc; }
.deal-badge.status-other { color: #526071; background: #edf0f4; }
.deal-badge.source-pkd { color: #176348; background: #ddf6e9; }
.deal-badge.source-bod { color: #235d96; background: #e5f0fc; }
:is(#dealDialog, #leadDialog) .modal-content { overflow-y: auto; }
:is(#dealDialog, #leadDialog) > .modal-content > .table-container { max-height: none; }
.deal-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 16px 0; }
.deal-overview > div { padding: 10px 12px; background: #f5f8fb; border-radius: 8px; min-width: 0; }
#dealDialogOverview > .deal-overview > div:nth-child(7) { grid-column: span 2; }
.deal-overview span { display: block; color: var(--muted); font-size: .75rem; font-weight: 700; }
.deal-overview strong { display: block; margin: 4px 0 0; overflow-wrap: anywhere; font-size: .86rem; font-weight: 650; }
.deal-overview strong.deal-badge { display: inline-block; padding: 5px 9px; font-size: .72rem; }
.deal-overview label { display: block; color: var(--muted); font-size: .75rem; font-weight: 700; }
.deal-overview select { width: 100%; margin-top: 5px; padding: 7px; border: 1px solid #b9c8d5; border-radius: 6px; background: #fff; }
.deal-overview small { display: block; margin-top: 5px; color: var(--muted); }
@media (max-width: 600px) { .deal-overview { grid-template-columns: 1fr; } #dealDialogOverview > .deal-overview > div:nth-child(7) { grid-column: span 1; } }
.kpi-donut-card h4 { margin: 0 0 14px; font-size: .95rem; }
.kpi-donut-outer { width: 150px; height: 150px; margin: 0 auto 16px; border-radius: 50%; background: conic-gradient(#255e91 0 var(--ring-value), #e5eaf0 var(--ring-value) 100%); display: grid; place-items: center; }
.kpi-donut-inner { width: 112px; height: 112px; border: 10px solid #fff; border-radius: 50%; background: conic-gradient(#247b64 0 var(--ring-value), #e5eaf0 var(--ring-value) 100%); display: grid; place-items: center; }
.kpi-donut-center { width: 72px; height: 72px; padding: 10px 4px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; font-size: .8rem; font-weight: 700; }
.kpi-donut-outer, .kpi-donut-inner { transition: transform .18s ease; }
.kpi-donut-outer:hover:not(:has(.kpi-donut-inner:hover)), .kpi-donut-outer:focus-visible:not(:has(.kpi-donut-inner:focus-visible)) { transform: scale(1.045); }
.kpi-donut-inner:hover, .kpi-donut-inner:focus-visible { transform: scale(1.06); }
.kpi-donut-legend { display: grid; gap: 9px; font-size: .82rem; }
.kpi-donut-legend > div { display: flex; align-items: flex-start; gap: 8px; }
.kpi-donut-legend i { width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; flex: none; }
.kpi-donut-legend i.company { background: #255e91; }
.kpi-donut-legend i.pkd { background: #247b64; }
.kpi-donut-legend strong, .kpi-donut-legend small { display: block; }
.kpi-donut-legend small { color: var(--muted); }
#kpiMonthlyChart.is-donut { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
#kpiMonthlyChart .kpi-donut-card { padding: 12px; position: relative; }
#kpiMonthlyChart .kpi-donut-outer { width: 118px; height: 118px; }
#kpiMonthlyChart .kpi-donut-inner { width: 88px; height: 88px; border-width: 8px; }
#kpiMonthlyChart .kpi-donut-center { width: 58px; height: 58px; font-size: .7rem; }
#kpiMonthlyChart .kpi-donut-legend { font-size: .72rem; overflow-wrap: anywhere; }
.kpi-ring-tip { display: none; position: absolute; z-index: 20; left: 8px; right: 8px; bottom: calc(100% - 6px); padding: 10px; border-radius: 8px; color: #fff; background: #233247; box-shadow: 0 8px 18px #0002; font-size: .76rem; line-height: 1.5; text-align: left; }
.kpi-ring-tip span { display: block; }
.kpi-donut-outer:hover > .outer-tip, .kpi-donut-outer:focus-visible > .outer-tip, .kpi-donut-inner:hover > .inner-tip, .kpi-donut-inner:focus-visible > .inner-tip { display: block; }
.kpi-donut-outer:has(.kpi-donut-inner:hover) > .outer-tip { display: none; }
.kpi-donut-outer:has(.kpi-donut-inner:focus-visible) > .outer-tip { display: none; }
@media (prefers-reduced-motion: reduce) { .kpi-donut-outer, .kpi-donut-inner { transition: none; } }
@media (max-width: 1100px) { #kpiMonthlyChart.is-donut { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { #kpiMonthlyChart.is-donut { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { #kpiMonthlyChart.is-donut { grid-template-columns: 1fr; } }
.kpi-funnel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 18px; margin: 24px 0 36px; }
.kpi-funnel-card { border: 1px solid #b8d9cd; border-radius: 14px; padding: 20px; background: linear-gradient(135deg, #effaf4, #f5f9ff); box-shadow: 0 5px 16px #194f3d12; }
.kpi-funnel-card h3 { margin: 0 0 16px; color: #176348; }
.kpi-funnel-steps { display: grid; gap: 10px; }
.kpi-funnel-steps > div { background: #fff; border: 1px solid #d8e9e0; padding: 12px 16px; border-radius: 10px; }
.kpi-funnel-steps strong { display: block; font-size: 1.25rem; }
.kpi-funnel-steps small { color: var(--muted); }
@media (max-width: 860px) { .kpi-funnel-grid { grid-template-columns: 1fr; } .kpi-section-head { margin-top: 26px; } }

.sync-status-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 16px; background: #102033aa; }
.report-controls { flex-wrap: wrap; }
.report-page h3 { margin: 28px 0 14px; }
.report-insights { padding: 4px 20px; border: 1px solid #dbe3ec; border-radius: 12px; background: #f5f8fb; line-height: 1.6; }
.report-insights li { margin: 10px 0; }
.report-page .report-note { margin-top: 22px; font-size: .85rem; }
.report-funnel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.report-funnel > div { padding: 18px; border: 1px solid #dbe3ec; border-radius: 12px; background: #f5f8fb; }
.report-funnel span, .report-funnel small { display: block; color: var(--muted); }
.report-funnel strong { display: block; font-size: 1.4rem; margin: 8px 0; }
.report-breakdowns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.report-breakdowns > div { min-width: 0; padding: 16px; border: 1px solid #dbe3ec; border-radius: 12px; }
.report-breakdowns h4 { margin: 0 0 12px; }
.report-breakdowns ul { list-style: none; margin: 0; padding: 0; }
.report-breakdowns li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid #e5eaf0; }
@media (max-width: 860px) { .report-funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); } .report-breakdowns { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .report-funnel { grid-template-columns: 1fr; } }
.sync-status-overlay[hidden] { display: none; }
.sync-status-panel { width: min(520px, 100%); max-height: 85vh; overflow: auto; padding: 24px; border-radius: 14px; background: #fff; box-shadow: 0 20px 55px #0003; }
.sync-status-panel h2 { margin: 0 0 8px; font-size: 1.15rem; }
.sync-status-panel p { margin: 0 0 16px; color: #526174; }
.sync-status-rows { display: grid; gap: 8px; margin-bottom: 18px; }
.sync-status-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid #dbe3ec; border-radius: 8px; }
.sync-status-row span { text-align: right; }
.sync-status-row strong { min-width: 88px; }
.sync-status-row span { flex: 1; }
.sync-status-row button { flex: none; }
.sync-status-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 560px) { .sync-status-row { flex-wrap: wrap; } .sync-status-row span { flex-basis: calc(100% - 110px); text-align: left; } }
