/* v2-core (design-v2 section 1): shared v2 components. No inline styles: widths come from data-* via JS. */

/* ---- sidebar additions (3.5, 4.1) ---- */
.nav-badge--warn { background: var(--warning-solid); color: #1C2117; }
.nav-new { margin-inline-start: auto; padding: 0 6px; height: 18px; display: inline-flex; align-items: center; border-radius: var(--r-pill);
  border: 1px solid var(--brass-light); color: var(--brass-light); font-size: var(--fs-11); line-height: 1; }
.nav-new + .nav-badge, .nav-new + .nav-dot { margin-inline-start: 6px; }
.app.is-rail .nav-new { display: none; }
@media (max-width: 1279px) and (min-width: 1024px) { .app:not(.nav-open) .nav-new { display: none; } }
.nav-link.is-new-flash { animation: nav-flash 1.2s var(--ease-out) 1; }
@keyframes nav-flash { from { background: var(--sidebar-active-bg); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .nav-link.is-new-flash { animation: none; } }

/* ---- module-off (1.11) ---- */
.module-off .empty-text { max-width: 52ch; }
.module-off-note { margin-block-end: 16px; }

/* ---- numbers ---- */
.unit { color: var(--text-3); font-size: var(--fs-12); }
.is-warn { color: var(--warning); }

/* ---- quantity / rate / foreign inputs (1.3) ---- */
.qty-input { text-align: end; font-variant-numeric: tabular-nums; width: 88px; }
.qty-input.input--grid { width: 100%; }
.money--fc .money-suffix { font-variant-numeric: normal; }
.rate-wrap { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rate-input { width: 160px; text-align: end; font-variant-numeric: tabular-nums; }
.rate-suffix { font-size: var(--fs-12); color: var(--text-3); }
.month-input { width: 160px; }

/* ---- foreign amount (1.8) ---- */
.fx-amt { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.fx-amt .fx-base { font-size: var(--fs-12); color: var(--text-3); }
.fx-sub { display: block; font-size: var(--fs-12); color: var(--text-3); }

/* ---- meter (1.9) ---- */
.meter { display: inline-flex; align-items: center; gap: 8px; min-width: 110px; }
.meter-bar { position: relative; flex: 1 1 60px; height: 6px; border-radius: var(--r-pill); background: var(--meter-track); overflow: hidden; }
.meter-fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; border-radius: var(--r-pill); background: var(--primary); }
.meter--warn .meter-fill { background: var(--warning-solid); }
.meter--over .meter-fill { background: var(--negative); }
.meter-text { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-12); color: var(--text-2); font-variant-numeric: tabular-nums; }
.meter--over .meter-text { color: var(--negative); }
.meter-text .ic { width: 12px; height: 12px; }

/* ---- item / project picker options (1.4, 1.5) ---- */
.picker-opt--item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; }
.picker-unit { margin-inline-start: 6px; font-size: var(--fs-12); color: var(--text-3); }
.picker-stock { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-12); color: var(--text-2); white-space: nowrap; }
.picker-stock.is-warn { color: var(--warning); }
.picker-stock.is-neg { color: var(--negative); }
.picker-stock .ic { width: 14px; height: 14px; }
.picker-none { font-style: normal; }
@media (max-width: 640px) { .picker-opt--item { grid-template-columns: auto 1fr; } .picker-opt--item .picker-bal, .picker-opt--item .picker-stock { grid-column: 2; } }

/* ---- wide grid editor (1.10) ---- */
.grid-ed { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.grid-ed th, .grid-ed td { white-space: nowrap; }
.grid-ed thead th { position: sticky; inset-block-start: 0; z-index: 3; background: var(--surface-2); }
.grid-ed .gcol-first { position: sticky; inset-inline-start: 0; z-index: 2; background: var(--surface); min-width: var(--grid-first-w); max-width: var(--grid-first-w);
  border-inline-end: 1px solid var(--line-strong); white-space: normal; }
.grid-ed thead .gcol-first { z-index: 4; background: var(--surface-2); }
.grid-ed .gcol-end { position: sticky; inset-inline-end: 0; z-index: 2; background: var(--surface-2); border-inline-start: 1px solid var(--line-strong); }
.grid-ed thead .gcol-end { z-index: 4; }
.grid-ed tfoot td, .grid-ed tfoot th { position: sticky; inset-block-end: 0; z-index: 3; background: var(--surface-2); border-block-start: 1px solid var(--line-strong); }
.grid-ed tfoot .gcol-first, .grid-ed tfoot .gcol-end { z-index: 5; }
.grid-ed td.gcell { padding: 2px 4px; }
.grid-ed td.gcell .money, .grid-ed td.gcell .qty-input { width: var(--grid-cell-w); }
.grid-ed td.gcell .money-input, .grid-ed td.gcell .qty-input { height: var(--h-sm); }
@media (pointer: coarse) { .grid-ed td.gcell .money-input, .grid-ed td.gcell .qty-input { height: var(--h-lg); } }
.grid-ed td.gcalc { background: var(--surface-2); color: var(--text-2); text-align: end; min-width: var(--grid-cell-w); }
.grid-ed td.gcalc.is-strong { color: var(--text); font-weight: var(--fw-semibold); }
.grid-ed input.dirty { box-shadow: inset 0 -2px 0 var(--brass); }
.grid-ed .grow-head th, .grid-ed .grow-head td { background: var(--surface-2); font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; }
.grid-ed .grow-total th, .grid-ed .grow-total td { font-weight: var(--fw-semibold); background: var(--surface-2); }
.grid-ed .gsub { display: block; font-size: var(--fs-12); color: var(--text-3); font-weight: var(--fw-regular); }
.grid-ed .ghint { display: block; font-size: 11px; color: var(--text-3); text-align: end; padding-inline: 4px; }
.grid-hint-line { font-size: var(--fs-12); color: var(--text-3); margin-block: 8px 0; }
.grid-wrap { max-height: calc(100vh - 260px); overflow: auto; }
@media (max-width: 860px) { .grid-ed .gcol-first { min-width: 140px; max-width: 160px; } }

/* sticky summary bar for grids (payroll) */
.grid-summary { position: sticky; inset-block-end: 0; z-index: var(--z-sticky); margin-block-start: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: var(--fs-13); box-shadow: var(--shadow-1); }
.grid-summary strong { font-variant-numeric: tabular-nums; }

/* ---- choice card (1.12) ---- */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.choice-card { position: relative; display: flex; flex-direction: column; gap: 8px; min-height: 132px; padding: 16px; border: 1px solid var(--line-strong);
  border-radius: var(--r-md); background: var(--surface); cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1); }
.choice-card:hover { border-color: var(--text-3); }
.choice-card input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.choice-card:focus-within { box-shadow: var(--focus-ring); }
.choice-card.is-checked { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-soft); }
.choice-card.is-checked:focus-within { box-shadow: inset 0 0 0 1px var(--primary), var(--focus-ring); }
.choice-check { position: absolute; inset-block-start: 12px; inset-inline-end: 12px; color: var(--primary); display: none; }
.choice-card.is-checked .choice-check { display: block; }
.choice-check .ic { width: 18px; height: 18px; }
.choice-ic { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; }
.choice-ic .ic { width: 22px; height: 22px; }
.choice-card.is-checked .choice-ic { background: var(--primary); color: var(--primary-ink); }
.choice-name { font-size: 15px; font-weight: var(--fw-semibold); padding-inline-end: 24px; }
.choice-desc { font-size: var(--fs-13); color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.choice-starts { font-size: var(--fs-12); color: var(--text-3); margin-block-start: auto; }

/* ---- small shared bits ---- */
.tab-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-block-end: 12px; }
.chip--pos { color: var(--positive); border-color: var(--positive); }
.chip--neg { color: var(--negative); border-color: var(--negative); }
.chip--warn { color: var(--warning); border-color: var(--warning-solid); }
.chip .ic { width: 14px; height: 14px; }
.dt tr.is-low td.num.qty-cell { color: var(--warning); }
.hint-line { display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--warning); }
.hint-line .ic { width: 14px; height: 14px; }
.kpi-grid--4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.signed-pos { color: var(--positive); }

@media print {
  .module-off, .fx-block .btn, .stepper, .wizard-actions, .module-card .module-toggle { display: none !important; }
  .meter-bar { display: none; }
  .fx-amt .fx-base { color: #333 !important; }
  .grid-ed { page: report-landscape; }
  .grid-ed input { border: 0 !important; background: none !important; padding: 0; text-align: end; }
  .grid-ed th, .grid-ed td { position: static !important; }
  .grid-ed .dirty { box-shadow: none; }
  .grid-summary { position: static; box-shadow: none; }
}

/* ---- setup wizard (design-v2 2) ---- */
.wizard { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.wizard-head { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.wizard-head .brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.wizard-body { width: 100%; max-width: var(--wizard-max); margin: 0 auto; padding: 24px 16px 96px; flex: 1; }
.wizard-title { font-size: var(--fs-22); margin: 0; }
.wizard-intro { color: var(--text-2); margin: 6px 0 20px; }
.wizard-card { padding: 24px 28px; }
@media (max-width: 640px) { .wizard-card { padding: 18px 16px; } }
.wizard-h2 { font-size: var(--fs-18); margin: 0 0 8px; }
.wizard-h2-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wizard-hint { margin-block-end: 16px; }
.wizard-actions { position: sticky; inset-block-end: 0; background: var(--surface); border-block-start: 1px solid var(--line); z-index: var(--z-sticky); }
.wizard-actions-inner { max-width: var(--wizard-max); margin: 0 auto; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; }
.wizard-count { font-size: var(--fs-12); color: var(--text-3); }
.stepper { list-style: none; display: flex; margin: 0 0 20px; padding: 0; }
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.stepper li + li::before { content: ""; position: absolute; inset-block-start: 14px; inset-inline-end: calc(50% + 18px); width: calc(100% - 36px); height: 2px; background: var(--line); }
.stepper li.is-done + li::before, .stepper li.is-current::before { background: var(--primary); }
.stepper-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line-strong); color: var(--text-3); background: var(--surface); font-size: var(--fs-13); font-weight: var(--fw-semibold); padding: 0; }
button.stepper-dot { cursor: pointer; }
.stepper li.is-done .stepper-dot { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.stepper li.is-current .stepper-dot { border-color: var(--primary); color: var(--primary); }
.stepper-dot .ic { width: 16px; height: 16px; }
.stepper-label { font-size: var(--fs-13); color: var(--text-2); text-align: center; }
.stepper-compact { display: none; margin-block-end: 16px; }
.stepper-compact p { margin: 0 0 6px; font-size: var(--fs-13); color: var(--text-2); }
.stepper-bar { height: 4px; border-radius: var(--r-pill); background: var(--meter-track); overflow: hidden; }
.stepper-bar span { display: block; height: 100%; background: var(--primary); }
@media (max-width: 640px) { .stepper { display: none; } .stepper-compact { display: block; } }
.mode-callout { margin-block-start: 16px; }
.mode-set { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.mode-set legend, .radio-set legend { font-weight: var(--fw-semibold); margin-block-end: 6px; padding: 0; }
.radio-set { border: 0; padding: 0; margin: 0 0 12px; }
.radio-row.is-disabled { color: var(--text-3); }
.radio-row .hint { display: block; }
.always-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-block-end: 12px; }
.always-label { font-size: var(--fs-13); color: var(--text-2); }
.always-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.mod-list { list-style: none; margin: 0 0 12px; padding: 0; }
.mod-row + .mod-row { border-block-start: 1px solid var(--line); }
.mod-row-label { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; min-height: 64px; cursor: pointer; }
.mod-ic, .module-ic { width: 36px; height: 36px; flex: none; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-3); display: grid; place-items: center; }
.mod-ic.is-on, .module-card.is-on .module-ic { background: var(--primary); color: var(--primary-ink); }
.mod-row-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.mod-row-name { font-weight: var(--fw-semibold); }
.mod-row-desc { font-size: var(--fs-13); color: var(--text-2); }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-block-end: 16px; }
.review-block { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 16px; }
.review-block--wide { grid-column: 1 / -1; }
.review-head { display: flex; align-items: center; justify-content: space-between; }
.review-head h3 { margin: 0; font-size: var(--fs-14); }
.review-type { display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) { .review-grid { grid-template-columns: 1fr; } }
.setup-wait { min-height: 100vh; justify-content: center; }

/* ---- modules dashboard (design-v2 3) ---- */
.mods-title-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.mods-intro { max-width: 70ch; color: var(--text-2); margin: 0; }
.mods-count { color: var(--text-2); font-variant-numeric: tabular-nums; }
.mods-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-block-end: 24px; }
@media (max-width: 400px) { .mods-grid { grid-template-columns: 1fr; } }
.module-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 20px; }
.module-card.is-on { border-color: var(--line-strong); }
.module-head { display: flex; align-items: center; gap: 10px; }
.module-ic { width: 40px; height: 40px; }
.module-name { flex: 1; font-size: var(--fs-16); margin: 0; }
.module-state { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-12); color: var(--text-3); }
.module-card.is-on .module-state { color: var(--positive); }
.module-state .ic { width: 12px; height: 12px; }
/* The On/Off text and the switch are one big target (min 44px tall). */
.module-toggle { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 6px 4px 12px; margin-inline-end: -6px;
  border-radius: var(--r-pill); cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
[dir="rtl"] .module-toggle { padding: 4px 12px 4px 6px; }
.module-toggle:hover { background: var(--line); }
.module-toggle:has(input:disabled) { cursor: progress; }
.module-toggle .module-state { font-size: var(--fs-13); font-weight: 600; }
.switch--lg { width: 48px; height: 28px; }
.switch--lg .switch-track::after { width: 22px; height: 22px; }
.switch--lg input:checked + .switch-track::after { transform: translateX(20px); }
[dir="rtl"] .switch--lg input:checked + .switch-track::after { transform: translateX(-20px); }
.module-desc { font-size: var(--fs-13); color: var(--text-2); margin: 0; }
.module-get { border-block-start: 1px solid var(--line); padding-block-start: 10px; }
.module-get-title { font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-3); margin: 0 0 6px; }
.module-bullets { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: var(--fs-13); }
.module-bullets li { display: flex; gap: 6px; align-items: flex-start; }
.module-bullets .ic { width: 14px; height: 14px; color: var(--positive); flex: none; margin-block-start: 3px; }
.module-foot { margin-block-start: auto; border-block-start: 1px solid var(--line); padding-block-start: 10px; }
.module-usage { font-size: var(--fs-12); color: var(--text-2); margin: 0 0 6px; }
.module-links { display: flex; justify-content: space-between; }
.callout--compact { padding: 8px 10px; font-size: var(--fs-13); }
.always-tiles { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.always-tile { height: 40px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); font-size: var(--fs-13); }
.always-tile .ic { width: 16px; height: 16px; }
.always-tile .always-lock { width: 12px; height: 12px; color: var(--text-3); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ---- business setup / settings nav ---- */
.biz-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-block: 8px; }
.biz-row + .biz-row { border-block-start: 1px solid var(--line); }
.biz-row .field-label { min-width: 140px; }
.biz-value { flex: 1; display: inline-flex; align-items: center; gap: 8px; }
.biz-row--link { justify-content: space-between; }
.settings-nav-label { font-size: var(--fs-11); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 14px 12px 4px; }
.choice-grid--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .choice-grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .choice-grid--3 { grid-template-columns: 1fr; } }

/* ---- dashboard widgets (design-v2 4.3) ---- */
.widget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-block-start: 16px; }
@media (max-width: 400px) { .widget-grid { grid-template-columns: 1fr; } }
.widget { min-height: 220px; display: flex; flex-direction: column; }
.widget-empty { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.widget-dl > div { display: flex; justify-content: space-between; gap: 8px; }
.bva-row { margin-block-end: 12px; }
.bva-head { display: flex; justify-content: space-between; font-size: var(--fs-13); gap: 8px; }
.bva-bar { position: relative; height: 8px; margin-block: 6px; border-radius: var(--r-pill); background: var(--meter-track); }
.bva-fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: var(--r-pill); background: var(--primary); }
.bva-mark { position: absolute; inset-block: -3px; width: 2px; background: var(--chart-budget); }
.bva-var { display: flex; align-items: center; gap: 4px; font-size: var(--fs-12); margin: 0; }
.bva-var .ic { width: 14px; height: 14px; }
.mod-hint-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mod-hint-list li { display: flex; gap: 10px; align-items: flex-start; }
.mod-hint-list li > span { display: flex; flex-direction: column; font-size: var(--fs-13); }
