/* Fasa 4C: notifications, site-visit schedule, CSV import, commission. Uses --fx-* tokens only. */
html[data-ui="fortress"] .fx-4c-panel { grid-column: 1 / -1; }
.fx-4c-prefs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.fx-4c-pref { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--fx-edge); border-radius: var(--fx-radius-2); cursor: pointer; min-height: 44px; }
.fx-4c-pref input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--fx-gold); flex: none; }
.fx-4c-pref span { display: grid; gap: 2px; }
.fx-4c-pref small, .fx-4c-dialog .panel-note small { color: var(--fx-muted); font-size: var(--fx-type-2); }

.fx-4c-visit-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.fx-4c-visit-row label { display: grid; gap: 4px; font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-4c-visit-row input { min-height: 40px; }

.fx-4c-dialog { width: min(980px, calc(100vw - 24px)); max-height: min(88vh, 900px); padding: 18px; border: 1px solid var(--fx-edge); border-radius: var(--fx-radius-3); background: var(--fx-panel); color: var(--fx-ink); }
.fx-4c-dialog::backdrop { background: rgb(0 0 0 / .5); }
.fx-4c-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.fx-4c-dialog-head h2 { margin: 0; font: 600 var(--fx-type-6) var(--fx-display); }
#csvImportBody { display: grid; gap: 14px; }
.fx-4c-steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.fx-4c-steps li { counter-increment: step; padding: 4px 10px; border: 1px solid var(--fx-edge); border-radius: var(--fx-pill); color: var(--fx-muted); font-size: var(--fx-type-2); }
.fx-4c-steps li::before { content: counter(step) ". "; }
.fx-4c-steps li.is-on { border-color: var(--fx-gold); color: var(--fx-gold); }
.fx-4c-file { display: grid; gap: 8px; padding: 18px; border: 1px dashed var(--fx-edge); border-radius: var(--fx-radius-2); font-weight: 600; }
.fx-4c-map, .fx-4c-choices, .fx-4c-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; align-items: end; }
.fx-4c-map label, .fx-4c-choices label, .fx-4c-filters label { display: grid; gap: 4px; font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-4c-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.fx-4c-summary li { padding: 6px 10px; border: 1px solid var(--fx-edge); border-radius: var(--fx-radius-1); font-size: var(--fx-type-2); }
.fx-4c-summary li.warn { border-color: var(--fx-warn); }
.fx-4c-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.fx-4c-error { color: var(--fx-danger); }
.fx-4c-empty { padding: 12px; border: 1px dashed var(--fx-edge); border-radius: var(--fx-radius-2); color: var(--fx-muted); }
.fx-4c-progress { height: 10px; border-radius: var(--fx-pill); background: var(--fx-glass); overflow: hidden; }
.fx-4c-progress span { display: block; height: 100%; background: var(--fx-gold); transition: width var(--fx-base) var(--fx-ease); }

.fx-4c-table-wrap { overflow-x: auto; border: 1px solid var(--fx-edge); border-radius: var(--fx-radius-2); }
html body .fx-4c-table { display: table; width: 100%; min-width: 640px; border-collapse: collapse; font-size: var(--fx-type-2); }
html body .fx-4c-table thead { display: table-header-group; }
html body .fx-4c-table tbody { display: table-row-group; }
html body .fx-4c-table tr { display: table-row; margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent; }
html body .fx-4c-table th, html body .fx-4c-table td { display: table-cell; padding: 7px 10px; border: 0; border-bottom: 1px solid var(--fx-edge); text-align: left; vertical-align: top; }
html body .fx-4c-table td:nth-child(n)::before, html body .fx-4c-table th:nth-child(n)::before { content: none; display: none; }
.fx-4c-table thead th { font-size: var(--fx-type-1); letter-spacing: .06em; text-transform: uppercase; color: var(--fx-muted); }
.fx-4c-table td.num, .fx-4c-table th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fx-4c-table td small { display: block; color: var(--fx-muted); }
.fx-4c-table tr.has-problem td { color: var(--fx-warn); }
.fx-4c-pay { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fx-4c-pay input { min-height: 34px; max-width: 150px; }

.fx-scheme-threshold { display: grid; gap: 4px; max-width: 360px; margin-bottom: 12px; font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-scheme-threshold input, .fx-4c-table input[type="number"] { min-height: 38px; max-width: 160px; }

html[data-ui="fortress"] .fx-4c-commission { margin-top: 16px; display: grid; gap: 12px; scroll-margin-top: 100px; }

@media (max-width: 767px) {
  .fx-4c-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .fx-4c-actions button { flex: 1; min-height: 44px; }
}

/* ---------- Goals & commission (monthly 10-lot target) ---------- */
.fx-goal-bar { position: relative; height: 8px; border-radius: var(--fx-pill); background: var(--fx-glass); border: 1px solid var(--fx-edge); overflow: visible; }
.fx-goal-bar.is-large { height: 14px; }
.fx-goal-fill { position: absolute; inset: 0 auto 0 0; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--fx-earth), var(--fx-gold)); transition: width 900ms var(--fx-ease); }
.fx-goal-bar.is-full .fx-goal-fill { background: linear-gradient(90deg, var(--fx-gold), var(--fx-ok)); box-shadow: 0 0 12px rgb(var(--fx-ok-rgb) / .45); }
.fx-goal-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -2px; background: var(--fx-ink); opacity: .35; border-radius: 2px; }

html[data-ui="fortress"] .fx-goals { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#p4cGoalsBody { flex: 1; min-height: 0; overflow: hidden auto; display: grid; align-content: start; gap: 6px; }
.fx-goal-me { display: flex; align-items: center; gap: 14px; }
.fx-goal-ring { width: 78px; height: 78px; flex: none; }
.fx-ring-track { fill: none; stroke: var(--fx-glass); stroke-width: 12; }
.fx-ring-fill { fill: none; stroke: var(--fx-gold); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1100ms var(--fx-ease); }
.fx-goal-ring.is-full .fx-ring-fill { stroke: var(--fx-ok); filter: drop-shadow(0 0 6px rgb(var(--fx-ok-rgb) / .6)); }
.fx-ring-value { fill: var(--fx-ink); font: 600 30px var(--fx-display); text-anchor: middle; }
.fx-ring-label { fill: var(--fx-muted); font: 12px var(--fx-body); text-anchor: middle; }
.fx-goal-copy { display: grid; gap: 2px; min-width: 0; font-size: var(--fx-type-2); line-height: 1.35; }
.fx-goal-copy p { margin: 0; color: var(--fx-muted); }
.fx-goal-copy b { color: var(--fx-ink); font-variant-numeric: tabular-nums; }
.fx-goal-head { font: 600 var(--fx-type-4, 16px) var(--fx-display); color: var(--fx-ink); }
.fx-goal-uplift span { color: var(--fx-ok); font-weight: 600; }
.fx-goal-note { font-size: var(--fx-type-1, 11px); }

.fx-leaderboard { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0; padding: 0; list-style: none; align-content: start; }
.fx-leaderboard li { display: grid; grid-template-columns: 14px minmax(54px, 80px) minmax(40px, 1fr) 22px; align-items: center; gap: 8px; font-size: var(--fx-type-2); min-height: 16px; line-height: 16px; }
.fx-leaderboard li.is-me { padding: 1px 6px; border-radius: var(--fx-radius-1); background: var(--fx-glass); outline: 1px solid var(--fx-gold); }
.fx-lb-rank { color: var(--fx-muted); font-variant-numeric: tabular-nums; }
.fx-lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-leaderboard b { text-align: right; font-variant-numeric: tabular-nums; }

.fx-comm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.fx-comm-card { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--fx-edge); border-radius: var(--fx-radius-3); background: var(--fx-glass); transition: transform var(--fx-base) var(--fx-ease), border-color var(--fx-base); animation: fx-enter var(--fx-slow) var(--fx-ease) both; }
.fx-comm-card:hover { transform: translateY(-2px); border-color: var(--fx-gold); }
.fx-comm-card.is-full { border-color: rgb(var(--fx-ok-rgb) / .6); }
.fx-comm-card header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.fx-comm-card header span { font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-comm-card.is-full header span { color: var(--fx-ok); font-weight: 600; }
.fx-comm-lots { margin: 0; font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-comm-lots b { color: var(--fx-ink); font: 600 20px var(--fx-display); }
.fx-comm-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.fx-comm-card dt { font-size: var(--fx-type-1, 11px); color: var(--fx-muted); }
.fx-comm-card dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.fx-comm-card dd small { color: var(--fx-ok); font-weight: 600; }
.fx-comm-paid { margin: 0; font-size: var(--fx-type-2); color: var(--fx-muted); }

.fx-confetti { position: fixed; inset: 0; z-index: 9999; pointer-events: none; }

/* Dashboard entrance: bars grow, KPI cards rise, numbers count up (JS). Plays once per visit. */
.p3-dashboard.fx-animate .p3-kpis button { animation: fx-rise 520ms var(--fx-ease) both; }
.p3-dashboard.fx-animate .p3-kpis button:nth-child(2) { animation-delay: 60ms; }
.p3-dashboard.fx-animate .p3-kpis button:nth-child(3) { animation-delay: 120ms; }
.p3-dashboard.fx-animate .p3-kpis button:nth-child(4) { animation-delay: 180ms; }
.p3-dashboard.fx-animate .p3-card { animation: fx-rise 600ms var(--fx-ease) both; animation-delay: 140ms; }
.p3-dashboard.fx-animate .p3-bar { transform-box: fill-box; transform-origin: left center; animation: fx-grow-x 800ms var(--fx-ease) both; animation-delay: calc(200ms + var(--i, 0) * 70ms); }
.p3-dashboard.fx-animate .p3-bar.p3-col { transform-origin: center bottom; animation-name: fx-grow-y; }
.p3-bar { transition: opacity var(--fx-fast); }
.p3-sales:hover .p3-bar:not(:hover) { opacity: .55; }

/* Buttons and cards respond to touch: lift on hover, press down on click. */
html[data-ui="fortress"] .p3-kpis button { transition: transform var(--fx-base) var(--fx-ease), border-color var(--fx-base), box-shadow var(--fx-base); }
html[data-ui="fortress"] .p3-kpis button:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgb(0 0 0 / .22); }
html[data-ui="fortress"] :is(.primary-button, .ghost-button, .p3-card-head button, .p3-task button, .p3-pager button, .fx-small-button, .fx-icon-button, .p3-kpis button):not(:disabled):active { transform: scale(.96); }
html[data-ui="fortress"] :is(.primary-button, .ghost-button, .p3-card-head button, .p3-task button, .p3-pager button, .fx-small-button, .fx-icon-button) { transition: transform var(--fx-fast) var(--fx-ease), border-color var(--fx-base), background-color var(--fx-base), box-shadow var(--fx-base); }
html[data-ui="fortress"] :is(.primary-button, .p3-card-head button):not(:disabled):hover { transform: translateY(-1px); }

@keyframes fx-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fx-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes fx-grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes fx-badge-pop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }

.fx-goal-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.fx-goal-me { align-items: flex-start; }
.fx-comm-team { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--fx-edge); border-radius: var(--fx-radius-3); background: var(--fx-glass); }
.fx-comm-team > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; align-items: baseline; }
.fx-comm-team span { font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-comm-team.is-full span { color: var(--fx-ok); font-weight: 600; }
.fx-comm-team b { font-variant-numeric: tabular-nums; }

@media (max-width: 700px) {
  .fx-goal-layout { grid-template-columns: minmax(0, 1fr); }
  .fx-comm-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .p3-dashboard.fx-animate *, .fx-comm-card { animation: none !important; }
  .fx-goal-fill, .fx-ring-fill, html[data-ui="fortress"] .p3-kpis button { transition: none; }
}
html body .fx-4c-table tbody th { text-transform: none; letter-spacing: 0; font-size: var(--fx-type-2); font-weight: 600; color: var(--fx-ink); background: transparent; }

/* Dashboard container: legacy styles gave it a border, shadow and white backdrop with no padding,
   so the KPI and card borders sat on top of that frame line. In Fortress the cards are the frame. */
html[data-ui="fortress"] #dashboardAnalytics.dashboard-analytics { border: 0 !important; box-shadow: none !important; background: none !important; border-radius: 0 !important; padding: 0 !important; } /* legacy rules use !important */
html[data-ui="fortress"] #dashboardAnalytics.dashboard-analytics::before { display: none; content: none; }
/* Ring and goal tracks need a visible colour in the light theme (glass is near white there). */
.fx-ring-track { stroke: var(--fx-edge); }
.fx-goal-bar { background: var(--fx-edge); }

/* Jualan & Bayaran (sales from the Tasha portal) */
.fx-sl { display: grid; gap: 14px; }
.fx-sl-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.fx-sl-kpis article { display: grid; gap: 6px; padding: 16px; border: 1px solid var(--fx-edge); border-radius: var(--fx-radius-3); background: var(--fx-panel); }
.fx-sl-kpis span, .fx-sl-kpis small { font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-sl-kpis strong { font: 600 22px var(--fx-display); font-variant-numeric: tabular-nums; }
.fx-sl-body { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.fx-sl-detail { position: sticky; top: 92px; }
.fx-sl-orders tbody tr { cursor: pointer; }
.fx-sl-orders tbody tr:hover, .fx-sl-orders tbody tr.is-selected { background: var(--fx-glass); }
.fx-sl-orders td b { display: block; }
.fx-4c-table tr.is-void td { color: var(--fx-muted); text-decoration: line-through; }
.fx-sl-review { padding: 10px 12px; border: 1px solid var(--fx-warn); border-radius: var(--fx-radius-2); font-size: var(--fx-type-2); }
.fx-sl-review ul { margin: 6px 0 0; padding-left: 18px; }
.fx-sl-pending { margin: 0; padding-left: 18px; font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-sl-admin { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--fx-edge); }
.fx-sl-admin label { display: grid; gap: 4px; font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-sl-detail h4 { margin: 4px 0 0; font: 600 14px var(--fx-display); }
@media (max-width: 1000px) { .fx-sl-body { grid-template-columns: minmax(0, 1fr); } .fx-sl-detail { position: static; } .fx-sl-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
html body .fx-sl-orders, html body .fx-sl-detail .fx-4c-table { min-width: 0; }
.fx-sl-orders td:nth-child(2) { max-width: 240px; }
.fx-sl-orders td small, .fx-sl-detail td small { white-space: normal; overflow-wrap: anywhere; }
.fx-sl-orders td.num, .fx-sl-detail td.num { white-space: nowrap; }
.fx-sl-detail dd small { display: block; color: var(--fx-muted); font-weight: 400; }

/* Jadual Live TikTok */
.fx-lv { display: grid; gap: 14px; }
.fx-lv-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 18px; }
.fx-lv-bar label { display: grid; gap: 4px; font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-lv-bar .fx-lv-mine { display: flex; align-items: center; gap: 8px; min-height: 40px; color: var(--fx-ink); }
.fx-lv-bar .panel-note { flex: 1 1 320px; margin: 0; }
.fx-lv-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-lv-stat { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--fx-edge); border-radius: var(--fx-pill); font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-lv-stat i { width: 10px; height: 10px; border-radius: 50%; background: var(--lv); }
.fx-lv-stat b { color: var(--fx-ink); }
.fx-lv-stat em { color: var(--fx-danger); font-style: normal; }
.fx-lv-stat.is-me { border-color: var(--fx-gold); }
.fx-lv-week { display: grid; gap: 6px; }
.fx-lv-week h3 { margin: 0; padding: 6px 12px; border-radius: var(--fx-radius-1); background: var(--fx-ink); color: var(--fx-bg); font: 700 13px var(--fx-display); letter-spacing: .08em; text-align: center; }
.fx-lv-table { display: grid; border: 1px solid var(--fx-edge); border-radius: var(--fx-radius-2); overflow: hidden; }
.fx-lv-row { display: grid; grid-template-columns: 120px repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--fx-edge); }
.fx-lv-row:first-child { border-top: 0; }
.fx-lv-head { background: var(--fx-glass); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--fx-muted); }
.fx-lv-head span, .fx-lv-date { padding: 8px 10px; }
.fx-lv-date { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fx-muted); }
.fx-lv-date b { font: 600 18px var(--fx-display); color: var(--fx-ink); }
.fx-lv-row.is-today { background: color-mix(in srgb, var(--fx-gold) 10%, transparent); box-shadow: inset 3px 0 0 var(--fx-gold); }
.fx-lv-row.is-off .fx-lv-date { color: var(--fx-danger); }
.fx-lv-cell { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 48px; padding: 6px 8px; border-left: 1px solid var(--fx-edge); transition: background-color 160ms; }
.fx-lv-cell small { flex-basis: 100%; font-size: 11px; color: var(--fx-muted); }
.fx-lv-cell.is-over { background: color-mix(in srgb, var(--fx-gold) 22%, transparent); outline: 2px dashed var(--fx-gold); outline-offset: -3px; }
.fx-lv-off { color: var(--fx-danger); font-weight: 700; letter-spacing: .08em; }
.fx-lv-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 4px 12px; border: 2px solid transparent; border-radius: var(--fx-pill); background: var(--lv); color: #1b1406; font: 700 12px var(--fx-body); cursor: pointer; transition: transform 160ms var(--fx-ease), box-shadow 160ms; }
.fx-lv-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgb(0 0 0 / .18); }
.fx-lv-chip[draggable="true"] { cursor: grab; }
.fx-lv-chip.is-me { border-color: var(--fx-ink); }
.fx-lv-chip.is-done { background: var(--fx-ok); color: #0f2a19; }
.fx-lv-chip.is-late { background: transparent; border: 2px dashed var(--fx-danger); color: var(--fx-danger); }
.fx-lv-chip.is-dragging { opacity: .4; }
.fx-lv-add { width: 30px; height: 30px; border: 1px dashed var(--fx-edge); border-radius: 50%; background: transparent; color: var(--fx-muted); font-size: 18px; cursor: pointer; opacity: .55; }
.fx-lv-cell:hover .fx-lv-add { opacity: 1; }
.fx-lv-dialog { width: min(520px, calc(100vw - 24px)); }
.fx-lv-dialog form { display: grid; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--fx-edge); }
.fx-lv-dialog form h3 { margin: 0; font: 600 15px var(--fx-display); }
.fx-lv-dialog label { display: grid; gap: 4px; font-size: var(--fx-type-2); color: var(--fx-muted); }
.fx-lv-donenote { color: var(--fx-ok); font-weight: 700; }
.fx-lv-actions { justify-content: flex-start; }
@media (max-width: 760px) {
  .fx-lv-head { display: none; }
  .fx-lv-row { grid-template-columns: minmax(0, 1fr); }
  .fx-lv-cell { border-left: 0; border-top: 1px dashed var(--fx-edge); }
  .fx-lv-cell::before { content: attr(data-label); flex-basis: 100%; font-size: 11px; color: var(--fx-muted); }
  .fx-lv-chip { min-height: 40px; padding: 6px 14px; }
}

/* Add lead: source as five simple chips (the select stays for validation) */
.fx-src-select { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; }
.fx-src-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.fx-src-chips button { min-height: 40px; padding: 8px 14px; border: 1px solid var(--fx-edge); border-radius: var(--fx-pill); background: var(--fx-glass); color: var(--fx-ink); font: 600 13px var(--fx-body); cursor: pointer; transition: background-color 160ms, border-color 160ms, transform 120ms; }
.fx-src-chips button:hover { border-color: var(--fx-gold); }
.fx-src-chips button:active { transform: scale(.97); }
.fx-src-chips button[aria-checked="true"] { background: var(--fx-gold); border-color: var(--fx-gold); color: var(--fx-gold-ink); }
.fx-src-chips button.is-live[aria-checked="false"] { border-style: dashed; }
#reportCentreBoard > #p3-live { grid-column: 1 / -1; }
