/* =====================================================================
   CRM & Sales Lab - look and feel on top of Bootstrap 5.3
   Light and dark mode: Bootstrap switches on <html data-bs-theme="dark">
   ===================================================================== */
:root {
    --app-font: "Inter", "Segoe UI", system-ui, -apple-system, "Noto Sans Thai", Roboto, sans-serif;
    --brand: #0f766e;
    --brand-2: #0ea5e9;
    --brand-grad: linear-gradient(135deg, #0f766e 0%, #0d9488 45%, #0ea5e9 100%);
    --accent: #f59e0b;
    --page-bg: #f3f6f8;
    --card-bg: #ffffff;
    --card-border: rgba(15, 23, 42, .07);
    --card-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
    --sidebar-w: 256px;
    --sidebar-bg: linear-gradient(180deg, #042f2e 0%, #0b2440 100%);
    --muted-bg: #eef2f5;
    --ring: rgba(13, 148, 136, .25);
    --good: #059669;
    --bad: #e11d48;
}

[data-bs-theme="dark"] {
    --brand: #2dd4bf;
    --page-bg: #0a1220;
    --card-bg: #101b2d;
    --card-border: rgba(148, 163, 184, .13);
    --card-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --muted-bg: #16233a;
    --bs-body-bg: #0a1220;
    --bs-secondary-bg: #101b2d;
    --bs-tertiary-bg: #16233a;
    --good: #34d399;
    --bad: #fb7185;
}

html, body { height: 100%; }
body { font-family: var(--app-font); background: var(--page-bg); font-size: .9375rem; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
.min-w-0 { min-width: 0; }
.text-good { color: var(--good) !important; }
.text-bad { color: var(--bad) !important; }
.fw-600 { font-weight: 600; }
.small-caps { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--bs-secondary-color); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- shell */
.app-shell { display: flex; min-height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--sidebar-w); }
.content { flex: 1; padding: 1.6rem 2rem 2rem; max-width: 1560px; width: 100%; }
.app-footer { padding: 1rem 2rem 1.5rem; font-size: .8rem; color: var(--bs-secondary-color); }

.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040; background: var(--sidebar-bg); color: #cbd5e1;
    display: flex; flex-direction: column; padding: 1rem .8rem; transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: .25rem .5rem 1rem; color: #fff; text-decoration: none; }
.brand strong { display: block; font-size: 1.02rem; letter-spacing: -.01em; }
.brand small { display: block; color: #5eead4; font-size: .7rem; text-transform: uppercase; letter-spacing: .18em; }
.side-nav { flex: 1; overflow-y: auto; margin: 0 -.25rem; padding: 0 .25rem; scrollbar-width: thin; }
.nav-section { font-size: .66rem; text-transform: uppercase; letter-spacing: .14em; color: #64748b; margin: 1rem .75rem .4rem; font-weight: 600; }
.nav-item {
    display: flex; align-items: center; gap: .7rem; padding: .48rem .75rem; margin-bottom: 1px; border-radius: .6rem;
    color: #cbd5e1; text-decoration: none; font-weight: 500; font-size: .9rem; position: relative; transition: background .15s, color .15s;
}
.nav-item i { font-size: 1.02rem; width: 1.2rem; text-align: center; opacity: .85; }
.nav-item .nav-no { margin-left: auto; font-size: .66rem; color: #64748b; font-weight: 600; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(45, 212, 191, .32), rgba(45, 212, 191, .07)); color: #fff; }
.nav-item.active .nav-no { color: #99f6e4; }
.nav-item.active::before { content: ""; position: absolute; left: -.8rem; top: .4rem; bottom: .4rem; width: 4px; border-radius: 0 4px 4px 0; background: #5eead4; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding: .8rem .6rem 0; margin-top: .5rem; font-size: .8rem; }

.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .65rem 2rem;
    background: color-mix(in srgb, var(--page-bg) 82%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--card-border);
}
.global-search { position: relative; max-width: 360px; flex: 1; }
.global-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); }
.global-search input { padding-left: 2.2rem; border-radius: 999px; background: var(--card-bg); }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: .7rem; color: var(--bs-body-color); }
.btn-icon:hover { background: var(--muted-bg); }
.user-chip { display: flex; align-items: center; gap: .6rem; border-radius: 999px; padding: .25rem .8rem .25rem .25rem; border: 1px solid var(--card-border); background: var(--card-bg); }
[data-bs-theme="dark"] .theme-icon-dark, [data-bs-theme="light"] .theme-icon-light { display: none; }

.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .main-col { margin-left: 0; }
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1030; }
    .content { padding: 1.1rem 1rem 1.5rem; }
    .topbar { padding: .55rem 1rem; }
}

/* ---------------------------------------------------------------- page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-title { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: .6rem; }
.feature-no { font-size: .7rem; font-weight: 700; padding: .2rem .5rem; border-radius: .45rem; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); letter-spacing: .03em; }
.page-sub { color: var(--bs-secondary-color); margin: .25rem 0 0; }
.crumbs { font-size: .8rem; color: var(--bs-secondary-color); margin-bottom: .35rem; }
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--brand); }

/* ---------------------------------------------------------------- cards and KPIs */
.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 1rem; box-shadow: var(--card-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--card-border); padding: .9rem 1.2rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-header .sub { font-weight: 400; color: var(--bs-secondary-color); font-size: .83rem; }
.card-body { padding: 1.2rem; }

.kpi { padding: 1.05rem 1.2rem; height: 100%; display: flex; flex-direction: column; gap: .25rem; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; color: #fff; flex: none; }
.kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--bs-secondary-color); font-size: .83rem; font-weight: 500; }
.kpi-foot { font-size: .8rem; color: var(--bs-secondary-color); }
.delta-up { color: var(--good); font-weight: 600; }
.delta-down { color: var(--bad); font-weight: 600; }
.g-teal { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.g-sky { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.g-violet { background: linear-gradient(135deg, #6366f1, #a855f7); }
.g-amber { background: linear-gradient(135deg, #f59e0b, #f97316); }
.g-rose { background: linear-gradient(135deg, #e11d48, #f472b6); }
.g-green { background: linear-gradient(135deg, #059669, #22c55e); }
.g-slate { background: linear-gradient(135deg, #475569, #1e293b); }

.hero {
    border-radius: 1.2rem; padding: 1.4rem 1.6rem; color: #fff; background: var(--brand-grad); position: relative; overflow: hidden;
    box-shadow: 0 10px 30px rgba(13, 148, 136, .25);
}
.hero::after { content: ""; position: absolute; right: -70px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.hero h2 { font-weight: 700; letter-spacing: -.02em; }
.hero .chip { background: rgba(255, 255, 255, .18); border-radius: 999px; padding: .25rem .7rem; font-size: .8rem; display: inline-flex; align-items: center; gap: .35rem; color: #fff; text-decoration: none; }
.hero .chip:hover { background: rgba(255, 255, 255, .28); }

/* ---------------------------------------------------------------- avatars and people */
.avatar { border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; flex: none; letter-spacing: .02em; }
.avatar-xs { width: 24px; height: 24px; font-size: .62rem; }
.avatar-sm { width: 32px; height: 32px; font-size: .74rem; }
.avatar-md { width: 40px; height: 40px; font-size: .85rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-sq { border-radius: 12px; background: linear-gradient(135deg, #0f766e, #0ea5e9); }
.person { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.person .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person small { color: var(--bs-secondary-color); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- badges */
.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; padding: .22rem .6rem; border-radius: 999px; white-space: nowrap; }
.pill-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-soft { background: color-mix(in srgb, var(--c, #64748b) 14%, transparent); color: var(--c, #64748b); }
[data-bs-theme="dark"] .pill-soft { color: color-mix(in srgb, var(--c, #94a3b8) 70%, #fff); }
.st-NEW, .st-DRAFT, .st-OPEN { --c: #64748b; }
.st-CONTACTED, .st-SENT, .st-CONFIRMED { --c: #0284c7; }
.st-QUALIFIED, .st-ACCEPTED, .st-DELIVERED, .st-APPROVED { --c: #7c3aed; }
.st-CONVERTED, .st-ORDERED, .st-PAID, .st-DONE, .st-WON, .st-ACTIVE, .st-POSITIVE, .st-CONNECTED { --c: #059669; }
.st-UNQUALIFIED, .st-REJECTED, .st-CANCELLED, .st-LOST, .st-INACTIVE, .st-NEGATIVE, .st-WRONG_NUMBER { --c: #e11d48; }
.st-NO_ANSWER, .st-BUSY, .st-VOICEMAIL, .st-NEUTRAL, .st-EXPIRED { --c: #d97706; }
.st-HOT { --c: #e11d48; } .st-WARM { --c: #d97706; } .st-COLD { --c: #0284c7; }
.st-HIGH { --c: #e11d48; } .st-NORMAL { --c: #0284c7; } .st-LOW { --c: #64748b; }
.st-EARN { --c: #059669; } .st-REDEEM { --c: #7c3aed; } .st-ADJUST { --c: #d97706; }
.code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .78rem; background: var(--muted-bg); padding: .12rem .42rem; border-radius: .4rem; color: var(--bs-body-color); }
.score { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; font-weight: 700; font-size: .82rem;
    background: conic-gradient(var(--c, #0d9488) calc(var(--v) * 1%), var(--muted-bg) 0); position: relative; }
.score span { position: relative; z-index: 1; }
.score::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--card-bg); }

/* ---------------------------------------------------------------- tables */
.table-modern { margin: 0; --bs-table-bg: transparent; }
.table-modern thead th {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--bs-secondary-color); font-weight: 600;
    border-bottom: 1px solid var(--card-border); padding: .7rem 1rem; white-space: nowrap; background: var(--muted-bg);
}
.table-modern tbody td { padding: .72rem 1rem; vertical-align: middle; border-color: var(--card-border); }
.table-modern tbody tr:hover td { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.table-modern tbody tr:last-child td { border-bottom: 0; }
.table-modern tfoot td { padding: .75rem 1rem; font-weight: 700; background: var(--muted-bg); border: 0; }
.table-wrap { border-radius: 1rem; overflow: hidden; }
.row-link { color: inherit; text-decoration: none; font-weight: 600; }
.row-link:hover { color: var(--brand); }
.row-actions { display: flex; gap: .25rem; justify-content: flex-end; }
.row-actions .btn { --bs-btn-padding-y: .22rem; --bs-btn-padding-x: .5rem; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link.active { color: var(--brand); }

/* ---------------------------------------------------------------- forms */
.form-label { font-weight: 500; font-size: .86rem; margin-bottom: .3rem; }
.form-control, .form-select { border-radius: .6rem; padding: .5rem .75rem; border-color: var(--card-border); background-color: var(--card-bg); }
[data-bs-theme="light"] .form-control, [data-bs-theme="light"] .form-select { border-color: #dbe2e8; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .22rem var(--ring); }
.form-control-color { width: 3rem; padding: .3rem; }
.form-section { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--bs-secondary-color); font-weight: 600; margin: 1.4rem 0 .8rem; display: flex; align-items: center; gap: .5rem; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--card-border); }
.btn { border-radius: .6rem; font-weight: 500; }
.btn-primary { --bs-btn-bg: #0f766e; --bs-btn-border-color: #0f766e; --bs-btn-hover-bg: #115e59; --bs-btn-hover-border-color: #115e59; --bs-btn-active-bg: #134e4a; --bs-btn-disabled-bg: #0f766e; --bs-btn-disabled-border-color: #0f766e; }
.btn-gradient { background: var(--brand-grad); color: #fff; border: 0; box-shadow: 0 6px 16px rgba(13, 148, 136, .3); }
.btn-gradient:hover, .btn-gradient:focus { color: #fff; filter: brightness(1.06); }
.btn-soft { background: var(--muted-bg); border: 1px solid var(--card-border); color: var(--bs-body-color); }
.btn-soft:hover { background: color-mix(in srgb, var(--brand) 10%, var(--muted-bg)); color: var(--bs-body-color); }
.filter-bar { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.filter-bar .form-control, .filter-bar .form-select { width: auto; min-width: 150px; }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); }
.search-box input { padding-left: 2.2rem; width: 100%; }
.seg-tabs { display: flex; gap: .35rem; flex-wrap: wrap; }
.seg-tabs a { padding: .38rem .8rem; border-radius: 999px; text-decoration: none; color: var(--bs-body-color); font-size: .85rem; font-weight: 500; border: 1px solid var(--card-border); background: var(--card-bg); }
.seg-tabs a .count { color: var(--bs-secondary-color); margin-left: .25rem; font-size: .78rem; }
.seg-tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.seg-tabs a.active .count { color: rgba(255, 255, 255, .8); }
.check-card { display: flex; gap: .6rem; align-items: flex-start; padding: .65rem .8rem; border: 1px solid var(--card-border); border-radius: .75rem; cursor: pointer; height: 100%; }
.check-card:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, transparent); }
.choice-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.choice-row label { flex: 1; min-width: 90px; text-align: center; padding: .5rem; border: 1px solid var(--card-border); border-radius: .65rem; cursor: pointer; font-size: .85rem; font-weight: 500; }
.choice-row input { display: none; }
.choice-row label:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, transparent); color: var(--brand); }

/* ---------------------------------------------------------------- learn tips */
.learn-tip { display: flex; gap: .8rem; padding: .8rem 1rem; border-radius: .85rem; font-size: .86rem;
    background: color-mix(in srgb, var(--brand) 7%, var(--card-bg)); border: 1px dashed color-mix(in srgb, var(--brand) 40%, transparent); }
.learn-tip > i { color: var(--brand); font-size: 1.15rem; }
.learn-tip code { color: #7c3aed; }
[data-bs-theme="dark"] .learn-tip code { color: #c4b5fd; }

/* ---------------------------------------------------------------- progress bars */
.progress-thin { height: 8px; border-radius: 999px; background: var(--muted-bg); overflow: hidden; }
.progress-thin > div { height: 100%; border-radius: 999px; background: var(--brand-grad); }
.progress-thin.over > div { background: linear-gradient(90deg, #059669, #22c55e); }
.progress-thin.under > div { background: linear-gradient(90deg, #f59e0b, #f97316); }
.progress-thin.bad > div { background: linear-gradient(90deg, #e11d48, #f472b6); }
.hbar { display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto; gap: .75rem; align-items: center; margin-bottom: .65rem; font-size: .86rem; }
.hbar-track { height: 10px; border-radius: 999px; background: var(--muted-bg); overflow: hidden; display: flex; }
.hbar-fill { height: 100%; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: middle; }

/* ---------------------------------------------------------------- 449 pipeline board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: start; }
.board-col { background: var(--muted-bg); border-radius: 1rem; padding: .75rem; min-height: 360px; border: 2px dashed transparent; transition: border-color .15s, background .15s; }
.board-col.drag-over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--muted-bg)); }
.board-head { display: flex; align-items: center; gap: .5rem; padding: .2rem .25rem .6rem; }
.board-head .dot { width: 10px; height: 10px; border-radius: 50%; }
.board-head .meta { font-size: .78rem; color: var(--bs-secondary-color); padding: 0 .25rem .7rem; display: flex; justify-content: space-between; }
.deal-card { background: var(--card-bg); border: 1px solid var(--card-border); border-left: 4px solid var(--c, var(--brand)); border-radius: .8rem; padding: .7rem .8rem;
    margin-bottom: .6rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .05); cursor: grab; transition: transform .12s, box-shadow .12s; }
.deal-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow); }
.deal-card.dragging { opacity: .45; }
.deal-card .title { font-weight: 600; font-size: .88rem; color: var(--bs-body-color); text-decoration: none; display: block; line-height: 1.3; }
.deal-card .title:hover { color: var(--brand); }
.deal-card .cust { font-size: .78rem; color: var(--bs-secondary-color); }
.deal-card .amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.deal-card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: .5rem; font-size: .76rem; }
.close-zone { border: 2px dashed var(--card-border); border-radius: 1rem; padding: 1rem; text-align: center; font-weight: 600; transition: all .15s; }
.close-zone.won { color: var(--good); }
.close-zone.lost { color: var(--bad); }
.close-zone.drag-over { background: color-mix(in srgb, currentColor 10%, transparent); border-color: currentColor; }

/* ---------------------------------------------------------------- stage stepper (deal page) */
.stepper { display: flex; gap: 4px; }
.stepper .step { flex: 1; padding: .55rem .4rem; text-align: center; font-size: .78rem; font-weight: 600; background: var(--muted-bg); color: var(--bs-secondary-color);
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); border: 0; }
.stepper .step:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: .5rem 0 0 .5rem; }
.stepper .step.done { background: color-mix(in srgb, var(--brand) 22%, var(--muted-bg)); color: var(--brand); }
.stepper .step.current { background: var(--brand); color: #fff; }
.stepper .step.won { background: #059669; color: #fff; }
.stepper .step.lost { background: #e11d48; color: #fff; }
.stepper button.step:hover:not(.current) { filter: brightness(.95); cursor: pointer; }

/* ---------------------------------------------------------------- timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { display: flex; gap: .8rem; padding: .55rem 0; position: relative; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 2.3rem; bottom: -.4rem; width: 2px; background: var(--card-border); }
.tl-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .9rem; color: #fff; }
.tl-body { min-width: 0; flex: 1; }
.tl-body .when { font-size: .76rem; color: var(--bs-secondary-color); }

/* ---------------------------------------------------------------- activities */
.act-col .card-header { position: sticky; top: 60px; z-index: 2; background: var(--card-bg); border-radius: 1rem 1rem 0 0; }
.act-item { display: flex; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--card-border); }
.act-item:last-child { border-bottom: 0; }
.act-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--muted-bg); color: var(--brand); }
.act-item.overdue .act-icon { background: rgba(225, 29, 72, .12); color: var(--bad); }
.act-item.closed { opacity: .7; }
.act-item.closed .subject { text-decoration: line-through; }

/* ---------------------------------------------------------------- 450/451 documents */
.lines-table input, .lines-table select { min-width: 0; }
.lines-table td { padding: .45rem .4rem !important; }
.lines-table .col-product { width: 30%; }
.lines-table .col-qty { width: 9%; }
.lines-table .col-price { width: 14%; }
.lines-table .col-disc { width: 9%; }
.lines-table .col-total { width: 14%; text-align: right; font-weight: 600; }
.totals { max-width: 360px; margin-left: auto; }
.totals .row-t { display: flex; justify-content: space-between; padding: .35rem 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--card-border); margin-top: .35rem; padding-top: .6rem; font-size: 1.2rem; font-weight: 700; }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.flow { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .8rem; }
.flow .f { padding: .3rem .65rem; border-radius: 999px; background: var(--muted-bg); color: var(--bs-secondary-color); font-weight: 600; }
.flow .f.on { background: var(--brand); color: #fff; }
.flow .f.bad { background: #e11d48; color: #fff; }
.flow i { color: var(--bs-secondary-color); }

/* print page (A4) */
.paper { background: #fff; color: #0f172a; max-width: 820px; margin: 1.5rem auto; padding: 2.5rem 2.75rem; border-radius: .5rem; box-shadow: 0 10px 40px rgba(15, 23, 42, .15); font-size: .9rem; }
.paper h1 { font-size: 1.6rem; letter-spacing: .12em; color: #0f766e; margin: 0; }
.paper table { width: 100%; border-collapse: collapse; margin-top: 1.2rem; }
.paper th { background: #0f766e; color: #fff; font-weight: 600; padding: .5rem .6rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.paper td { padding: .5rem .6rem; border-bottom: 1px solid #e2e8f0; }
.paper .r { text-align: right; }
.paper .muted { color: #64748b; }
.paper .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; margin-top: 3.5rem; text-align: center; }
.paper .sign div { border-top: 1px solid #94a3b8; padding-top: .4rem; color: #64748b; font-size: .82rem; }
.print-bar { max-width: 820px; margin: 1rem auto 0; display: flex; gap: .5rem; justify-content: flex-end; }
@media print {
    .print-bar { display: none; }
    body { background: #fff !important; }
    .paper { box-shadow: none; margin: 0; max-width: none; padding: 0; }
}

/* ---------------------------------------------------------------- 456 targets */
.grid-table input { text-align: right; padding: .3rem .4rem; font-size: .82rem; min-width: 84px; font-variant-numeric: tabular-nums; }
.grid-table td, .grid-table th { padding: .45rem .5rem !important; }
.grid-scroll { overflow-x: auto; }
.cell-pct { font-size: .72rem; font-weight: 700; }
.heat { border-radius: .45rem; padding: .3rem .35rem; text-align: center; font-size: .78rem; font-variant-numeric: tabular-nums; }
.heat small { display: block; font-size: .66rem; opacity: .8; }
.heat-0 { background: var(--muted-bg); color: var(--bs-secondary-color); }
.heat-1 { background: rgba(225, 29, 72, .14); color: #be123c; }
.heat-2 { background: rgba(245, 158, 11, .16); color: #b45309; }
.heat-3 { background: rgba(16, 185, 129, .16); color: #047857; }
.heat-4 { background: rgba(5, 150, 105, .28); color: #065f46; }
[data-bs-theme="dark"] .heat-1 { color: #fda4af; } [data-bs-theme="dark"] .heat-2 { color: #fcd34d; }
[data-bs-theme="dark"] .heat-3 { color: #6ee7b7; } [data-bs-theme="dark"] .heat-4 { color: #a7f3d0; }

/* ---------------------------------------------------------------- 455 segments / 458 tiers */
.seg-card { border-top: 4px solid var(--c); height: 100%; }
.seg-card .big { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; }
.rule-chip { display: inline-block; font-size: .76rem; padding: .2rem .55rem; border-radius: .5rem; background: var(--muted-bg); margin: .15rem .2rem 0 0; }
.tier-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; color: #fff; background: var(--c, #94a3b8); }
.tier-card { border-radius: 1rem; padding: 1.1rem 1.2rem; color: #fff; background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #0f172a)); position: relative; overflow: hidden; height: 100%; }
.tier-card::after { content: ""; position: absolute; right: -30px; bottom: -40px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.tier-card .count { font-size: 1.7rem; font-weight: 800; }
.points-card { border-radius: 1rem; padding: 1.25rem; color: #fff; background: linear-gradient(135deg, var(--c, #0f766e), color-mix(in srgb, var(--c, #0f766e) 50%, #0f172a)); }
.points-card .pts { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }
.reward { display: flex; align-items: center; gap: .8rem; padding: .65rem .8rem; border: 1px solid var(--card-border); border-radius: .8rem; }
.reward .cost { font-weight: 700; color: var(--brand); white-space: nowrap; }

/* ---------------------------------------------------------------- customer 360 */
.c360-head { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: .45rem 1rem; font-size: .88rem; }
.kv dt { color: var(--bs-secondary-color); font-weight: 500; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.tabs-line { border-bottom: 1px solid var(--card-border); display: flex; gap: .25rem; overflow-x: auto; }
.tabs-line a { padding: .7rem 1rem; text-decoration: none; color: var(--bs-secondary-color); font-weight: 600; font-size: .88rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs-line a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs-line a .count { font-size: .72rem; background: var(--muted-bg); border-radius: 999px; padding: .05rem .45rem; margin-left: .25rem; }
.mini-stat { padding: .8rem 1rem; border-radius: .85rem; background: var(--muted-bg); height: 100%; }
.mini-stat .v { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-stat .l { font-size: .76rem; color: var(--bs-secondary-color); font-weight: 500; }

/* ---------------------------------------------------------------- login */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--page-bg); }
.login-art { background: var(--sidebar-bg); color: #e2e8f0; padding: 3rem; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.login-art::before { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, rgba(45, 212, 191, .35), transparent 65%); right: -160px; top: -140px; }
.login-art::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(14, 165, 233, .3), transparent 65%); left: -140px; bottom: -160px; }
.login-art > * { position: relative; z-index: 1; }
.login-art h1 { font-size: 2.3rem; font-weight: 800; letter-spacing: -.03em; color: #fff; }
.feature-list { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1.25rem; font-size: .88rem; }
.feature-list span { display: flex; gap: .45rem; align-items: center; color: #cbd5e1; }
.feature-list b { color: #5eead4; font-size: .72rem; min-width: 2rem; }
.login-form-col { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.login-card { width: 100%; max-width: 440px; }
.demo-account { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .5rem .7rem; border: 1px solid var(--card-border); border-radius: .75rem; background: var(--card-bg); text-align: left; transition: border-color .15s, transform .15s; color: var(--bs-body-color); }
.demo-account:hover { border-color: var(--brand); transform: translateY(-1px); }
@media (max-width: 991.98px) { .login-page { grid-template-columns: 1fr; } .login-art { display: none; } }

/* ---------------------------------------------------------------- misc */
.confirm-icon { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; font-size: 2rem; color: #e11d48; background: rgba(225, 29, 72, .12); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.3rem; display: block; margin-bottom: .5rem; opacity: .5; }
.flash { border: 0; border-radius: .85rem; box-shadow: var(--card-shadow); }
.list-tight > * + * { border-top: 1px solid var(--card-border); }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.error-page { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.error-code { font-size: 5rem; font-weight: 800; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.learn-table td:first-child { white-space: nowrap; }
.learn-table code { font-size: .78rem; }
