/* =========================================================
   TOLLA DESIGN SYSTEM
   Dark-first, premium operations/analytics SaaS tokens.
   Layered surfaces (bg -> surface -> elevated -> interactive),
   restrained saturation, semantic color only. RTL + Persian
   numerals throughout. Light theme is generated from the same
   token set for parity.
   ========================================================= */
:root{
  /* brand ramp (light) */
  --brand-shade:#0B4A82;
  --brand-hover:#0D5FA3;
  --brand:#1170CC;
  --brand-tint:#EAF2FC;
  --brand-tint2:#E3EEFB;
  --brand-soft:#DCEAFA;

  /* layered neutral surfaces: bg -> card -> elevated -> interactive */
  --nb1:#FFFFFF;   /* card / surface */
  --nb2:#F4F6F9;   /* app background */
  --nb3:#ECF0F5;   /* elevated surface / hover */
  --nb4:#E3E8EF;   /* interactive / pressed */

  /* strokes */
  --stroke1:#E4E8EE; --stroke2:#D6DCE5; --stroke-strong:#98A2B3;

  /* foreground */
  --fg1:#111826; --fg2:#5B6472; --fg3:#8A93A3; --fg-on-brand:#FFFFFF;

  /* semantic */
  --success-bg:#E4F6EA; --success-fg:#1A7F42; --success-border:#B3E3C4;
  --warning-bg:#FFF3D9; --warning-fg:#93650A; --warning-border:#F3D089;
  --danger-bg:#FCE8E8;  --danger-fg:#C42B2B;  --danger-border:#F3B4B4;

  /* chart palette — desaturated, dark-safe hues shared across themes */
  --chart-blue:#2E7BD6; --chart-blue-fill:rgba(46,123,214,.16);
  --chart-green:#2FA463; --chart-green-fill:rgba(47,164,99,.16);
  --chart-amber:#C97A1F; --chart-amber-fill:rgba(201,122,31,.16);
  --chart-red:#D24B4B;  --chart-red-fill:rgba(210,75,75,.16);
  --chart-teal:#1F9AA3; --chart-teal-fill:rgba(31,154,163,.16);
  --chart-grid:rgba(17,24,38,.08);
  --chart-tick:#8A93A3;

  /* elevation */
  --shadow-color:0,0,0;
  --shadow2: 0 1px 2px rgba(var(--shadow-color),.06), 0 1px 1px rgba(var(--shadow-color),.08);
  --shadow4: 0 2px 6px rgba(var(--shadow-color),.07), 0 1px 2px rgba(var(--shadow-color),.06);
  --shadow8: 0 6px 16px rgba(var(--shadow-color),.09), 0 2px 6px rgba(var(--shadow-color),.06);
  --shadow16:0 12px 28px rgba(var(--shadow-color),.11), 0 4px 10px rgba(var(--shadow-color),.07);
  --shadow28:0 22px 48px rgba(var(--shadow-color),.16), 0 8px 18px rgba(var(--shadow-color),.08);

  /* radius */
  --r-sm:6px; --r-md:9px; --r-lg:14px; --r-xl:18px;

  /* 8px spacing scale */
  --sp-xs:4px; --sp-s:8px; --sp-m:12px; --sp-l:16px; --sp-xl:24px; --sp-xxl:32px;

  /* motion */
  --dur:160ms; --dur-slow:260ms; --curve: cubic-bezier(.33,0,.2,1);

  /* type */
  --font-ui: 'Vazirmatn', -apple-system, 'SF Pro Text', 'Segoe UI', 'Inter', system-ui, sans-serif;

  color-scheme: light;
}

/* ---------------- Dark theme: the hero surface ---------------- */
:root[data-theme="dark"]{
  color-scheme: dark;
  --brand-shade:#8FC1F5; --brand-hover:#5FA3EA; --brand:#4C96E8; --brand-tint:#152B42; --brand-tint2:#122538; --brand-soft:#1B3450;

  /* background -> surface -> elevated -> interactive */
  --nb2:#0F1115;   /* app background */
  --nb1:#181B20;   /* card / surface */
  --nb3:#1D2128;   /* elevated surface / hover */
  --nb4:#252A32;   /* interactive / pressed */

  --stroke1:#262B33; --stroke2:#333944; --stroke-strong:#4A515C;

  --fg1:#F1F3F6; --fg2:#A6ADBB; --fg3:#6C7382; --fg-on-brand:#0B1016;

  --success-bg:#132A1E; --success-fg:#4FCC85; --success-border:#1E4430;
  --warning-bg:#2E2410; --warning-fg:#E3AC4E; --warning-border:#4A3A17;
  --danger-bg:#301719;  --danger-fg:#E8807F;  --danger-border:#4C2224;

  --chart-blue:#5B9FE8; --chart-blue-fill:rgba(91,159,232,.16);
  --chart-green:#4FCC85; --chart-green-fill:rgba(79,204,133,.14);
  --chart-amber:#E3AC4E; --chart-amber-fill:rgba(227,172,78,.16);
  --chart-red:#E8807F;  --chart-red-fill:rgba(232,128,127,.16);
  --chart-teal:#4FC3CC; --chart-teal-fill:rgba(79,195,204,.14);
  --chart-grid:rgba(255,255,255,.06);
  --chart-tick:#6C7382;

  --shadow-color:0,0,0;
  --shadow2: 0 1px 2px rgba(0,0,0,.32), 0 1px 1px rgba(0,0,0,.24);
  --shadow4: 0 2px 8px rgba(0,0,0,.34), 0 1px 2px rgba(0,0,0,.28);
  --shadow8: 0 8px 20px rgba(0,0,0,.38), 0 2px 6px rgba(0,0,0,.28);
  --shadow16:0 16px 36px rgba(0,0,0,.42), 0 4px 12px rgba(0,0,0,.3);
  --shadow28:0 26px 56px rgba(0,0,0,.5), 0 10px 22px rgba(0,0,0,.32);
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0; overflow-x:hidden;}
body{
  background:var(--nb2);
  color:var(--fg1);
  font-family:var(--font-ui);
  font-size:14px;
  line-height:20px;
  min-height:100vh;
  transition:background-color var(--dur-slow) var(--curve), color var(--dur-slow) var(--curve);
  -webkit-font-smoothing:antialiased;
}
.num{ font-variant-numeric:tabular-nums; direction:ltr; unicode-bidi:isolate; }
::selection{ background:var(--brand-tint); color:var(--brand-shade); }
:focus-visible{ outline:2px solid var(--brand); outline-offset:2px; border-radius:4px; }
a{ color:var(--brand); }

/* subtle themed scrollbars */
::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{ background:var(--stroke2); border-radius:999px; border:2px solid var(--nb2); }
::-webkit-scrollbar-thumb:hover{ background:var(--stroke-strong); }
*{ scrollbar-color:var(--stroke2) transparent; scrollbar-width:thin; }

/* ---------------- App bar ---------------- */
.appbar{
  background:var(--nb1); border-bottom:1px solid var(--stroke1);
  padding:9px clamp(16px,3vw,32px); display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap;
  position:sticky; top:0; z-index:40; backdrop-filter:saturate(1.1);
}
.brand{ display:flex; align-items:center; gap:9px; }
.brand-mark{ width:24px; height:24px; }
.brand h1{ font-size:15.5px; line-height:20px; font-weight:700; margin:0; color:var(--fg1); letter-spacing:-.2px; }
.brand p{ margin:0; color:var(--fg3); font-size:11px; line-height:14px; }
.appbar-actions{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.filename-chip{
  font-size:11.5px; color:var(--fg2); background:var(--nb3); border:1px solid var(--stroke1);
  padding:4px 10px 4px 8px; border-radius:999px; max-width:240px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  display:inline-flex; align-items:center; gap:6px;
}
.filename-chip::before{ content:''; width:6px; height:6px; border-radius:999px; background:var(--fg3); flex:none; }
.filename-chip.backup-ok::before{ background:var(--success-fg); }
.filename-chip.backup-warn::before{ background:var(--warning-fg); }
.filename-chip.backup-danger::before{ background:var(--danger-fg); }

/* ---------------- Compact header theme switch (segmented) ---------------- */
.header-theme-switch{
  display:inline-flex; align-items:center; gap:1px; background:var(--nb2); border:1px solid var(--stroke1);
  border-radius:999px; padding:2px; margin-inline-end:2px;
}
.header-theme-switch .theme-swatch{
  all:unset; box-sizing:border-box; cursor:pointer; width:28px; height:26px; border-radius:999px; display:flex;
  align-items:center; justify-content:center; color:var(--fg3); transition:background var(--dur) var(--curve), color var(--dur) var(--curve);
}
.header-theme-switch .theme-swatch svg{ width:14px; height:14px; }
.header-theme-switch .theme-swatch:hover{ color:var(--fg1); }
.header-theme-switch .theme-swatch.active{ background:var(--nb1); color:var(--brand); box-shadow:var(--shadow2); }

/* ---------------- Buttons ---------------- */
.btn{
  font-family:inherit; cursor:pointer; border:1px solid var(--stroke2); background:var(--nb1);
  color:var(--fg1); padding:0 13px; height:32px; border-radius:var(--r-md); font-size:13.5px; font-weight:600;
  transition:background var(--dur) var(--curve), border-color var(--dur) var(--curve), transform var(--dur) var(--curve), box-shadow var(--dur) var(--curve);
  display:inline-flex; align-items:center; gap:6px; white-space:nowrap;
}
.btn svg{ width:16px; height:16px; flex:none; }
.btn:hover{ background:var(--nb3); border-color:var(--stroke-strong); }
.btn:active{ background:var(--nb4); transform:translateY(.5px); }
.btn:disabled{ opacity:.4; cursor:not-allowed; }
.btn.primary{ background:var(--brand); border-color:var(--brand); color:var(--fg-on-brand); }
.btn.primary:hover{ background:var(--brand-hover); border-color:var(--brand-hover); box-shadow:0 0 0 3px var(--brand-tint); }
.btn.primary:active{ background:var(--brand-shade); border-color:var(--brand-shade); }
.btn.subtle{ background:var(--nb2); border-color:transparent; }
.btn.subtle:hover{ background:var(--nb3); border-color:var(--stroke1); }
.btn.ghost{ background:transparent; border-color:transparent; }
.btn.ghost:hover{ background:var(--nb3); }
.btn.danger-text{ color:var(--danger-fg); }
.btn.danger-text:hover{ background:var(--danger-bg); border-color:var(--danger-border); }
.btn.small{ height:28px; padding:0 10px; font-size:12.5px; }
.icon-btn{
  width:28px; height:28px; padding:0; display:inline-flex; align-items:center; justify-content:center;
  border-radius:var(--r-md); border:1px solid transparent; background:transparent; cursor:pointer; color:var(--fg2);
  transition:background var(--dur) var(--curve), color var(--dur) var(--curve);
}
.icon-btn svg{ width:16px; height:16px; }
.icon-btn:hover{ background:var(--nb3); color:var(--fg1); }
.icon-btn.danger:hover{ background:var(--danger-bg); color:var(--danger-fg); }

.dirty-dot{ width:8px; height:8px; border-radius:999px; background:var(--danger-fg); display:none; margin-inline-start:2px; }
.dirty-dot.show{ display:inline-block; }
.filename-chip.backup-ok{ color:var(--success-fg); background:var(--success-bg); border-color:var(--success-border); }
.filename-chip.backup-warn{ color:var(--warning-fg); background:var(--warning-bg); border-color:var(--warning-border); }
.filename-chip.backup-danger{ color:var(--danger-fg); background:var(--danger-bg); border-color:var(--danger-border); cursor:pointer; }
.filename-chip[data-clickable="1"]{ cursor:pointer; }
.backup-banner{ display:flex; align-items:center; gap:10px; padding:9px 16px; background:var(--warning-bg); color:var(--warning-fg); border-bottom:1px solid var(--warning-border); font-size:13px; }
.backup-banner-icon{ width:18px; height:18px; flex-shrink:0; }
.backup-banner-text{ flex:1; line-height:1.5; }
.backup-banner .btn.small{ flex-shrink:0; padding:5px 12px; font-size:12.5px; }
.backup-banner .icon-btn{ flex-shrink:0; color:inherit; }
#moreMenu .btn{ text-align:start; }
.hint-dot{ color:var(--muted-fg, #8a8a8a); font-size:11px; cursor:help; margin-inline-start:4px; }

/* ---- CRM tab ---- */
.crm-layout{ display:grid; grid-template-columns:280px 1fr; gap:16px; align-items:start; }
.crm-list-panel{ padding:0; overflow:hidden; }
.crm-list-panel .table-toolbar{ padding:12px; border-bottom:1px solid var(--stroke1); }
.crm-customer-list{ max-height:70vh; overflow-y:auto; }
.crm-customer-row{ display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%; text-align:start; padding:11px 14px; border:none; border-bottom:1px solid var(--stroke1); background:var(--nb1); cursor:pointer; font-family:inherit; }
.crm-customer-row:hover{ background:var(--nb2); }
.crm-customer-row.active{ background:var(--brand-tint); border-inline-start:3px solid var(--brand); }
.crm-customer-row .name{ font-weight:600; font-size:13px; color:var(--fg1); }
.crm-customer-row .meta{ font-size:11px; color:var(--fg3); margin-top:2px; }
.crm-followup-dot{ width:9px; height:9px; border-radius:999px; background:var(--danger-fg); flex-shrink:0; }
.crm-detail-panel{ min-height:70vh; }
.crm-empty-state{ display:flex; align-items:center; justify-content:center; height:60vh; color:var(--fg3); font-size:13px; text-align:center; padding:0 40px; }
.crm-detail-header{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:14px; }
.crm-detail-header h3{ margin:0 0 4px; }
.crm-detail-sub{ font-size:12px; color:var(--fg3); }
.crm-stats{ display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-bottom:18px; }
.crm-stats .cs{ background:var(--nb2); border:1px solid var(--stroke1); border-radius:var(--r-md); padding:10px 12px; }
.crm-stats .cs .lbl{ font-size:11px; color:var(--fg3); }
.crm-stats .cs .val{ font-size:15px; font-weight:700; margin-top:2px; }
.crm-section-title{ font-size:13px; color:var(--fg2); margin:0 0 10px; }
.crm-timeline{ display:flex; flex-direction:column; gap:2px; max-height:52vh; overflow-y:auto; padding-inline-start:4px; }
.crm-tl-item{ display:flex; gap:10px; padding:10px 4px; border-bottom:1px solid var(--stroke1); }
.crm-tl-icon{ width:28px; height:28px; border-radius:999px; display:flex; align-items:center; justify-content:center; flex-shrink:0; background:var(--nb3); color:var(--fg2); }
.crm-tl-icon.call{ background:var(--brand-tint); color:var(--brand); }
.crm-tl-icon.order{ background:var(--success-bg); color:var(--success-fg); }
.crm-tl-icon.delivery{ background:var(--warning-bg); color:var(--warning-fg); }
.crm-tl-body{ flex:1; min-width:0; }
.crm-tl-top{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.crm-tl-title{ font-size:13px; font-weight:600; color:var(--fg1); }
.crm-tl-date{ font-size:11px; color:var(--fg3); white-space:nowrap; }
.crm-tl-desc{ font-size:12.5px; color:var(--fg2); margin-top:3px; }
.crm-tl-followup{ display:inline-block; margin-top:5px; font-size:11px; padding:2px 8px; border-radius:999px; background:var(--warning-bg); color:var(--warning-fg); border:1px solid var(--warning-border); }
.crm-tl-del{ flex-shrink:0; }
@media (max-width:900px){ .crm-layout{ grid-template-columns:1fr; } .crm-stats{ grid-template-columns:repeat(2,1fr); } }

/* ---- Settings dialog ---- */
.settings-body{ display:grid; grid-template-columns:170px 1fr; gap:0; padding:0 !important; min-height:420px; }
.settings-nav{ border-inline-end:1px solid var(--stroke1); padding:10px; display:flex; flex-direction:column; gap:2px; background:var(--nb2); }
.settings-nav-item{ display:block; width:100%; text-align:start; padding:9px 12px; border:none; border-radius:var(--r-md); background:none; color:var(--fg2); font-size:13px; font-family:inherit; cursor:pointer; }
.settings-nav-item:hover{ background:var(--nb3); color:var(--fg1); }
.settings-nav-item.active{ background:var(--brand-tint); color:var(--brand); font-weight:600; }
.settings-panels{ padding:18px 20px; overflow-y:auto; }
.settings-panel{ display:none; }
.settings-panel.active{ display:block; }
.settings-panel h4{ margin:0 0 4px; font-size:14px; }
.settings-panel .settings-desc{ font-size:12px; color:var(--fg3); margin:0 0 16px; }
.theme-options{ display:flex; gap:10px; flex-wrap:wrap; }
.theme-swatch{ flex:1; min-width:110px; border:1.5px solid var(--stroke1); border-radius:var(--r-md); padding:10px; cursor:pointer; background:var(--nb1); display:flex; flex-direction:column; align-items:center; gap:8px; font-family:inherit; }
.theme-swatch.active{ border-color:var(--brand); background:var(--brand-tint); }
.theme-swatch .swatch-preview{ width:100%; height:34px; border-radius:var(--r-sm); border:1px solid var(--stroke1); }
.theme-swatch .swatch-preview.light{ background:linear-gradient(135deg,#fff 50%,#F3F2F1 50%); }
.theme-swatch .swatch-preview.dark{ background:linear-gradient(135deg,#201F1E 50%,#181716 50%); }
.theme-swatch .swatch-preview.system{ background:linear-gradient(135deg,#fff 50%,#201F1E 50%); }
.theme-swatch span{ font-size:12.5px; color:var(--fg2); }
.settings-panel select{ height:32px; }

.backup-method-card{
  border:1px solid var(--stroke1); border-radius:var(--r-md); padding:14px 16px; margin-bottom:12px; background:var(--nb2);
}
.backup-method-head{ display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.backup-method-icon{ width:22px; height:22px; flex-shrink:0; color:var(--fg2); }
.backup-method-head strong{ font-size:13.5px; color:var(--fg1); }
.backup-method-actions{ display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.backup-method-actions .btn{ font-size:12.5px; padding:6px 12px; }
.ai-enable-row{ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--fg2); cursor:pointer; }
.ai-enable-row input{ width:16px; height:16px; }
.ai-provider-fields{ margin-top:10px; padding-top:10px; border-top:1px dashed var(--stroke1); }
body.no-financial .financial-only{ display:none !important; }

/* ---- AI assistant floating widget ---- */
.ai-fab{
  position:fixed; bottom:20px; right:20px; z-index:60; width:44px; height:44px; border-radius:50%;
  border:1px solid var(--stroke1); background:var(--nb1); color:var(--brand); display:flex; align-items:center;
  justify-content:center; cursor:pointer; box-shadow:var(--shadow8); transition:transform var(--dur) var(--curve), box-shadow var(--dur) var(--curve);
}
.ai-fab:hover{ transform:translateY(-1px); box-shadow:var(--shadow16); background:var(--brand-tint); }
.ai-fab svg{ width:19px; height:19px; }
.ai-panel{ position:fixed; bottom:74px; right:20px; z-index:60; width:380px; max-width:calc(100vw - 32px); height:520px; max-height:calc(100vh - 130px); background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-lg); box-shadow:var(--shadow28); display:none; flex-direction:column; overflow:hidden; }
.ai-panel.show{ display:flex; }
.ai-panel-header{ display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--stroke1); font-weight:700; font-size:13.5px; }
.ai-panel-body{ flex:1; overflow-y:auto; padding:12px 14px; display:flex; flex-direction:column; gap:10px; }
.ai-msg{ max-width:88%; padding:8px 11px; border-radius:12px; font-size:13px; line-height:1.6; white-space:pre-wrap; }
.ai-msg.user{ align-self:flex-end; background:var(--brand); color:#fff; border-bottom-right-radius:4px; }
html[dir="rtl"] .ai-msg.user{ border-bottom-right-radius:12px; border-bottom-left-radius:4px; }
.ai-msg.assistant{ align-self:flex-start; background:var(--nb3); color:var(--fg1); border-bottom-left-radius:4px; }
html[dir="rtl"] .ai-msg.assistant{ border-bottom-left-radius:12px; border-bottom-right-radius:4px; }
.ai-msg.system{ align-self:center; background:none; color:var(--fg3); font-size:11.5px; }
.ai-card{ align-self:stretch; background:var(--nb2); border:1px solid var(--stroke1); border-radius:var(--r-md); padding:10px 12px; font-size:12.5px; }
.ai-card-title{ font-weight:700; margin-bottom:6px; font-size:13px; }
.ai-card-row{ display:flex; justify-content:space-between; gap:8px; padding:2px 0; color:var(--fg2); }
.ai-card-actions{ display:flex; gap:8px; margin-top:10px; }
.ai-card-actions .btn{ flex:1; padding:7px; font-size:12.5px; }
.ai-typing{ align-self:flex-start; color:var(--fg3); font-size:12px; }
.ai-panel-input{ display:flex; gap:8px; padding:10px 12px; border-top:1px solid var(--stroke1); }
.ai-panel-input textarea{ flex:1; resize:none; height:38px; max-height:100px; border-radius:var(--r-md); border:1px solid var(--stroke1); background:var(--nb2); color:var(--fg1); padding:8px 10px; font-family:inherit; font-size:13px; }
.ai-panel-input button{ width:38px; height:38px; border-radius:var(--r-md); border:none; background:var(--brand); color:#fff; cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.ai-setup-note{ text-align:center; color:var(--fg3); font-size:12.5px; padding:18px 8px; }
.ai-setup-note .btn{ margin-top:10px; }
.settings-soon{ font-size:11px; color:var(--fg3); margin-inline-start:6px; }
@media (max-width:640px){ .settings-body{ grid-template-columns:1fr; } .settings-nav{ flex-direction:row; overflow-x:auto; border-inline-end:none; border-bottom:1px solid var(--stroke1); } }

/* ---- invoice export modal ---- */
.invoice-mode-tabs{ display:flex; gap:8px; margin-bottom:14px; }
.invoice-mode-tabs button{ flex:1; padding:9px; border-radius:var(--r-md); border:1px solid var(--stroke1); background:var(--nb2); font-weight:600; cursor:pointer; color:var(--fg2); }
.invoice-mode-tabs button.active{ background:var(--brand); border-color:var(--brand); color:#fff; }
.lock-bar{ display:flex; align-items:center; gap:8px; padding:10px 12px; background:var(--warning-bg); border:1px solid var(--warning-border); border-radius:var(--r-md); margin-bottom:14px; flex-wrap:wrap; }
.lock-bar label{ display:flex; align-items:flex-start; gap:6px; font-size:13px; font-weight:600; color:var(--warning-fg); cursor:pointer; }
.lock-bar .sub{ font-size:12px; color:var(--fg2); font-weight:400; margin-inline-start:auto; }
@media (max-width:600px){
  .lock-bar .sub{ margin-inline-start:0; flex-basis:100%; }
}
.invoice-controls .form-grid{ margin-bottom:12px; }
.invoice-controls h4{ margin:0 0 8px; font-size:13px; color:var(--fg2); }
.dialog-body fieldset{ border:1px solid var(--stroke1); border-radius:var(--r-md); padding:14px 14px 12px; margin:0 0 14px; }
.dialog-body fieldset legend{ font-size:12px; font-weight:700; color:var(--brand-shade); padding:0 8px; }
.invoice-items-edit{ display:flex; flex-direction:column; gap:6px; margin-bottom:8px; }
.invoice-item-edit-row{ display:grid; grid-template-columns:1.6fr .8fr .9fr .9fr; gap:8px; align-items:center; }
.invoice-item-edit-row > *{ min-width:0; }
.invoice-item-edit-row .inv-line-total{ font-size:12.5px; font-weight:600; text-align:center; color:var(--fg2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.invoice-item-edit-row input{ height:32px; width:100%; box-sizing:border-box; }
@media (max-width:600px){
  .invoice-item-edit-row{ grid-template-columns:1fr 1fr; row-gap:6px; }
}
.vat-row{ display:flex; align-items:center; gap:10px; }
.vat-row label{ display:flex; align-items:center; gap:6px; font-size:13px; font-weight:600; }
.vat-row input[type="text"]{ width:90px; }

#invoicePrintArea{ background:#fff; color:#1a1a1a; border:1px solid var(--stroke1); border-radius:var(--r-lg); padding:32px; font-size:13px; line-height:1.7; }
.inv-head{ display:flex; justify-content:space-between; align-items:flex-start; border-bottom:3px solid var(--brand); padding-bottom:16px; margin-bottom:20px; }
.inv-head .inv-brand{ font-size:20px; font-weight:800; color:var(--brand-shade); }
.inv-head .inv-brand-sub{ font-size:12px; color:#666; margin-top:2px; }
.inv-head .inv-type{ text-align:end; }
.inv-head .inv-type-badge{ display:inline-block; padding:6px 18px; border-radius:999px; font-weight:800; font-size:15px; background:var(--brand-tint); color:var(--brand-shade); border:1px solid var(--brand); }
.inv-head .inv-meta{ margin-top:8px; font-size:12px; color:#555; }
.inv-parties{ margin-bottom:20px; }
.inv-party{ background:var(--nb2); border:1px solid var(--stroke1); border-radius:var(--r-md); padding:14px 16px; max-width:560px; }
.inv-party h5{ margin:0 0 10px; font-size:12px; color:var(--brand-shade); font-weight:700; }
.inv-subheading{ margin:22px 0 8px; font-size:12px; color:var(--brand-shade); font-weight:700; }
.inv-party-grid{ display:grid; grid-template-columns:1fr 1fr; gap:4px 24px; }
.inv-party .row{ display:flex; justify-content:space-between; font-size:12.5px; padding:3px 0; color:#333; }
.inv-party .row.full{ grid-column:1/-1; }
.inv-party .row b{ color:#111; font-weight:600; }
.inv-table{ width:100%; border-collapse:collapse; margin-bottom:16px; }
.inv-table th{ background:var(--brand-shade); color:#fff; font-size:12px; padding:9px 10px; text-align:center; }
.inv-table td{ padding:8px 10px; text-align:center; border-bottom:1px solid var(--stroke1); font-size:12.5px; }
.inv-table tr:nth-child(even) td{ background:var(--nb2); }
.inv-totals{ display:flex; justify-content:flex-start; }
.inv-totals table{ min-width:280px; border-collapse:collapse; }
.inv-totals td{ padding:6px 12px; font-size:13px; }
.inv-totals td:first-child{ color:#555; }
.inv-totals td:last-child{ font-weight:700; text-align:end; }
.inv-totals tr.grand td{ border-top:2px solid var(--brand-shade); font-size:15px; padding-top:10px; }
.inv-totals tr.grand td:last-child{ color:var(--brand-shade); }
.inv-notes{ margin-top:18px; font-size:12px; color:#555; background:var(--nb2); border-radius:var(--r-md); padding:10px 12px; }
.inv-footer{ margin-top:28px; display:flex; justify-content:space-between; font-size:12px; color:#666; border-top:1px dashed var(--stroke2); padding-top:14px; }
.inv-sign{ text-align:center; width:150px; }
.inv-sign .line{ margin-top:36px; border-top:1px solid #999; padding-top:4px; }

#ordersReportPrintArea{ background:#fff; color:#1a1a1a; border:1px solid var(--stroke1); border-radius:var(--r-lg); padding:32px; font-size:13px; line-height:1.7; }
.report-filters{ font-size:12px; color:#555; background:var(--nb2); border-radius:var(--r-md); padding:8px 12px; margin-bottom:16px; }
.report-summary{ display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:10px; margin-bottom:20px; }
.report-summary .rs-tile{ background:var(--nb2); border:1px solid var(--stroke1); border-inline-start:3px solid var(--stroke-strong); border-radius:var(--r-md); padding:9px 12px; }
.report-summary .rs-tile.brand{ border-inline-start-color:var(--brand); }
.report-summary .rs-tile.success{ border-inline-start-color:#0E5C0E; }
.report-summary .rs-tile.danger{ border-inline-start-color:#C50F1F; }
.report-summary .rs-lbl{ font-size:10.5px; color:#666; margin-bottom:3px; }
.report-summary .rs-val{ font-size:15px; font-weight:700; color:#1a1a1a; }
.rpt-sub{ font-size:10.5px; color:#777; font-weight:400; margin-top:1px; }
tr.rpt-group-item td{ color:#555; }
tr.rpt-total-row td{ border-top:2px solid var(--brand-shade); font-weight:700; background:var(--nb2) !important; }
tr.rpt-total-row td:first-child{ text-align:start; }

.order-group-header td{ background:var(--nb3); font-weight:600; }
.order-group-header:hover td{ background:var(--nb4); }
.order-group-item td{ background:var(--nb2); color:var(--fg2); font-size:13px; }
.order-group-item td:nth-child(4){ color:var(--fg1); }
.group-toggle{ display:inline-flex; align-items:center; gap:6px; background:none; border:none; cursor:pointer; padding:0; font:inherit; color:inherit; }
.group-toggle svg{ width:14px; height:14px; transition:transform var(--dur) var(--curve); flex:none; }
.group-toggle.open svg{ transform:rotate(90deg); }
.item-indent{ padding-inline-start:20px; color:var(--fg3); }

/* ---------------- Supplier ledger ---------------- */
.supplier-detail-row td{ background:var(--nb2); padding:14px 16px; }
.supplier-detail-cols{ display:grid; grid-template-columns:1fr 1.3fr; gap:20px; }
@media (max-width:900px){ .supplier-detail-cols{ grid-template-columns:1fr; } }
.supplier-detail-cols h4{ margin:0 0 8px; font-size:13px; font-weight:600; color:var(--fg2); }
.detail-subtotal-row td{ border-top:1px solid var(--stroke1); color:var(--fg2); font-size:12px; }
.detail-total-row td{ border-top:1px solid var(--stroke2); font-weight:700; }
.supplier-detail-cols table{ background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-md); overflow:hidden; }
.supplier-detail-cols thead th{ background:var(--nb3); }
.balance-owed{ color:var(--danger-fg); font-weight:700; }
.balance-clear{ color:var(--success-fg); font-weight:700; }

main{ padding: var(--sp-l) clamp(16px,3vw,32px) 60px; max-width:1400px; margin:0 auto; }

/* ---------------- Empty state (dropzone) ---------------- */
.dropzone{
  margin-top:32px; border:1.5px dashed var(--stroke2); border-radius:var(--r-lg);
  padding:56px 24px; text-align:center; background:var(--nb1);
}
.dropzone.drag{ border-color:var(--brand); background:var(--brand-tint); }
.dropzone-inner{ max-width:640px; margin:0 auto; }
.dropzone h2{ font-size:20px; line-height:26px; font-weight:600; margin:16px 0 6px; }
.dropzone p{ color:var(--fg2); font-size:14px; margin:0 0 22px; }
.dz-icon{ width:48px; height:48px; margin:0 auto; display:block; color:var(--brand); }
.welcome-choice-grid{ display:flex; gap:14px; flex-wrap:wrap; }
.welcome-choice-card{
  flex:1; min-width:200px; background:var(--nb1); border:1.5px solid var(--stroke1); border-radius:var(--r-lg);
  padding:20px 16px; cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:8px;
  font-family:inherit; text-align:center; transition:border-color .15s, background .15s;
}
.welcome-choice-card:hover{ border-color:var(--brand); background:var(--brand-tint); }
.welcome-choice-card svg{ width:26px; height:26px; color:var(--brand); }
.welcome-choice-card strong{ font-size:14.5px; }
.welcome-choice-card span{ font-size:12.5px; color:var(--fg3); line-height:1.6; }
.welcome-import-options{ max-width:340px; margin:20px auto 0; display:flex; flex-direction:column; gap:10px; }

/* ---------------- Setup wizard ---------------- */
.wizard-dialog{ max-width:560px; }
.wizard-progress{ display:flex; gap:6px; padding:14px 24px 0; }
.wizard-progress-dot{ flex:1; height:4px; border-radius:999px; background:var(--stroke1); }
.wizard-progress-dot.active{ background:var(--brand); }
.wizard-progress-dot.done{ background:var(--brand-tint); }
.wizard-step{ display:none; }
.wizard-step.active{ display:block; }
.wizard-step-title{ font-size:16px; font-weight:700; margin:0 0 4px; }
.wizard-step-desc{ font-size:13px; color:var(--fg3); margin:0 0 16px; }
.wizard-choice-row{ display:flex; gap:10px; flex-wrap:wrap; }
.wizard-choice-btn{
  flex:1; min-width:110px; background:var(--nb1); border:1.5px solid var(--stroke1); border-radius:var(--r-md);
  padding:12px 10px; cursor:pointer; font-family:inherit; font-size:13px; color:var(--fg1); text-align:center;
}
.wizard-choice-btn.active{ border-color:var(--brand); background:var(--brand-tint); color:var(--brand); font-weight:700; }
.wizard-data-card{
  border:1.5px solid var(--stroke1); border-radius:var(--r-md); padding:12px 14px; cursor:pointer;
  display:flex; flex-direction:column; gap:2px;
}
.wizard-data-card.active{ border-color:var(--brand); background:var(--brand-tint); }
.wizard-data-card strong{ font-size:13.5px; }
.wizard-data-card span{ font-size:12px; color:var(--fg3); }
.wizard-data-card em{ font-style:normal; font-size:11px; color:var(--brand); margin-top:2px; }
.wizard-backup-status{ font-size:12.5px; color:var(--success-fg); margin-top:8px; display:none; }
.wizard-backup-status.show{ display:block; }
.wizard-template-gallery{ margin-top:16px; border-top:1px solid var(--stroke1); padding-top:14px; }
.wizard-template-search input{ width:100%; height:34px; border-radius:var(--r-md); border:1px solid var(--stroke1); background:var(--nb2); color:var(--fg1); padding:0 12px; font-family:inherit; font-size:13px; margin-bottom:10px; box-sizing:border-box; }
.wizard-template-categories{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.wizard-template-cat-chip{ padding:5px 12px; border-radius:999px; border:1px solid var(--stroke1); background:var(--nb2); color:var(--fg2); font-size:12px; cursor:pointer; }
.wizard-template-cat-chip.active{ border-color:var(--brand); background:var(--brand-tint); color:var(--brand); font-weight:700; }
.wizard-template-grid{ display:flex; flex-direction:column; gap:8px; max-height:240px; overflow-y:auto; }
.wizard-template-empty{ text-align:center; color:var(--fg3); font-size:12.5px; padding:22px 0; }

/* ---------------- Navigation (TabList) ---------------- */
.tabs-wrap{ position:relative; }
.tabs{ display:flex; gap:2px; margin:24px 0 20px; border-bottom:1px solid var(--stroke1); overflow-x:auto; scrollbar-width:none; padding-bottom:1px; }
.tabs::-webkit-scrollbar{ display:none; }
.tab{
  font-family:inherit; cursor:pointer; background:none; border:none; color:var(--fg2);
  padding:8px 12px; margin-bottom:6px; font-size:13.5px; font-weight:600; position:relative;
  border-radius:999px; transition:color var(--dur) var(--curve), background var(--dur) var(--curve);
  display:inline-flex; align-items:center; gap:6px; flex:none; white-space:nowrap;
}
.tab svg{ width:15px; height:15px; flex-shrink:0; opacity:.75; transition:opacity var(--dur) var(--curve); }
.tab:hover{ color:var(--fg1); background:var(--nb3); }
.tab.active{ color:var(--brand); background:var(--brand-tint); }
.tab.active svg{ opacity:1; }
.tab.active::after{ content:none; }
.tab .count{ font-size:11.5px; color:var(--fg3); margin-inline-start:2px; }
.tab.active .count{ color:var(--brand); opacity:.8; }

/* Mobile tab switcher: a compact "current tab" pill that expands into a dropdown list */
.tabs-mobile-trigger{ display:none; }
.tabs-mobile-backdrop{ display:none; }
@media (max-width:760px){
  .tabs-mobile-trigger{
    width:100%; margin:16px 0 0; font-family:inherit; cursor:pointer; background:var(--nb1); border:1px solid var(--stroke1);
    border-radius:var(--r-lg); box-shadow:var(--shadow2); padding:10px 14px; display:flex; align-items:center; gap:10px;
    font-size:14px; font-weight:600; color:var(--fg1);
  }
  .tabs-mobile-icon{ width:16px; height:16px; flex:none; display:inline-flex; color:var(--brand); }
  .tabs-mobile-icon svg{ width:16px; height:16px; }
  .tabs-mobile-label{ flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:start; }
  .tabs-mobile-chev{ width:16px; height:16px; flex:none; color:var(--fg3); transition:transform var(--dur) var(--curve); }
  .tabs-wrap.open .tabs-mobile-chev{ transform:rotate(180deg); }
  .tabs-wrap.open .tabs-mobile-trigger{ border-color:var(--brand); box-shadow:0 0 0 1px var(--brand); }

  .tabs{
    display:none; position:absolute; top:calc(100% + 4px); right:0; left:0; z-index:70; margin:0;
    background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-lg); box-shadow:var(--shadow8);
    padding:6px; flex-direction:column; gap:0; overflow-x:visible; max-height:70vh; overflow-y:auto;
  }
  .tabs-wrap.open .tabs{ display:flex; }
  .tab{ margin-inline-end:0; padding:10px 8px; border-radius:var(--r-md); white-space:normal; }
  .tab:hover{ background:var(--nb3); }
  .tab.active{ background:var(--brand-tint); }
  .tab.active::after{ content:none; }

  .tabs-mobile-backdrop{ position:fixed; inset:0; z-index:65; }
  .tabs-wrap.open .tabs-mobile-backdrop{ display:block; }
}

/* ---------------- Cards / Panels ---------------- */
.panel{
  background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-lg); padding:var(--sp-xl) var(--sp-l);
  box-shadow:var(--shadow2); transition:border-color var(--dur) var(--curve), box-shadow var(--dur) var(--curve);
}
.panel h3{ margin:0 0 4px; font-size:15px; line-height:22px; font-weight:700; letter-spacing:-.1px; }
.panel .hint{ font-size:12.5px; color:var(--fg3); margin:0 0 16px; }
.grid2{ display:grid; grid-template-columns:1.3fr 1fr; gap:16px; margin-bottom:20px; }
@media (max-width:900px){ .grid2{ grid-template-columns:1fr; } }
.grid3{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; margin-bottom:20px; }
@media (max-width:1100px){ .grid3{ grid-template-columns:1fr 1fr; } }
@media (max-width:700px){ .grid3{ grid-template-columns:1fr; } }
.chart-wrap{ position:relative; height:270px; }
.chart-wrap.tall{ height:320px; }

/* ---------------- Overview: "Today" operational widgets ---------------- */
.today-actions{ display:flex; gap:10px; margin-bottom:16px; }
.today-actions .btn svg{ width:15px; height:15px; }
.today-grid{ margin-bottom:20px; }
.today-panel{ display:flex; flex-direction:column; border-top:3px solid transparent; }
.today-panel-head{ display:flex; align-items:center; gap:9px; margin-bottom:2px; }
.today-panel-head h3{ margin:0; }
.today-panel-icon{
  width:27px; height:27px; border-radius:9px; display:flex; align-items:center; justify-content:center; flex:none;
}
.today-panel-icon svg{ width:14px; height:14px; }
/* Deliveries = things that already happened, good news — green. */
.today-panel-deliveries{ border-top-color:var(--success-fg); }
.today-panel-deliveries .today-panel-icon{ background:var(--success-bg); color:var(--success-fg); }
/* Open orders = work still pending — amber. */
.today-panel-orders{ border-top-color:var(--warning-fg); }
.today-panel-orders .today-panel-icon{ background:var(--warning-bg); color:var(--warning-fg); }
.today-panel-orders .today-row-btn{ border-color:var(--warning-border); color:var(--warning-fg); }
.today-panel-orders .today-row-btn:hover{ background:var(--warning-bg); border-color:var(--warning-fg); }
/* Follow-ups = people/contacts — brand blue, avatar-style rows. */
.today-panel-followups{ border-top-color:var(--brand); }
.today-panel-followups .today-panel-icon{ background:var(--brand-tint); color:var(--brand); }

.today-panel .hint{ margin-bottom:10px; }
.today-list{ display:flex; flex-direction:column; gap:2px; flex:1; }
.today-row{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:9px 4px; border-bottom:1px solid var(--stroke1); text-align:start;
  background:none; border-inline:none; border-top:none; width:100%; font:inherit; color:inherit; cursor:default;
}
.today-list .today-row:last-child{ border-bottom:none; }
button.today-row{ cursor:pointer; transition:background var(--dur) var(--curve); border-radius:var(--r-sm); }
button.today-row:hover{ background:var(--nb2); }
.tr-main{ min-width:0; }
.tr-main-avatar{ display:flex; align-items:center; gap:9px; min-width:0; }
.tr-main-avatar .tr-text{ min-width:0; }
.tr-avatar{
  width:27px; height:27px; border-radius:999px; background:var(--brand-tint); color:var(--brand);
  display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; flex:none;
}
.tr-title{ font-size:13.5px; font-weight:600; color:var(--fg1); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tr-sub{ font-size:11.5px; color:var(--fg3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:1px; }
.tr-side{ display:flex; align-items:center; gap:8px; flex:none; }
.tr-val{ font-size:14px; font-weight:700; color:var(--fg1); font-variant-numeric:tabular-nums; }
.tr-date{ font-size:11.5px; color:var(--fg3); white-space:nowrap; }
.tr-chip{ font-size:12px; font-weight:700; padding:3px 10px; border-radius:999px; font-variant-numeric:tabular-nums; white-space:nowrap; }
.tr-chip-success{ background:var(--success-bg); color:var(--success-fg); }
.tr-chip-warning{ background:var(--warning-bg); color:var(--warning-fg); }
.today-row-btn{
  font-size:11.5px; font-weight:600; padding:4px 10px; border-radius:var(--r-sm); border:1px solid var(--stroke-strong);
  background:var(--nb2); color:var(--fg1); cursor:pointer; white-space:nowrap; transition:background var(--dur) var(--curve);
}
.today-row-btn:hover{ background:var(--nb3,var(--nb2)); border-color:var(--brand); }
.today-empty{ padding:14px 4px; font-size:12.5px; color:var(--fg3); text-align:center; }
.today-viewall{
  margin-top:10px; align-self:flex-start; background:none; border:none; padding:2px 0; cursor:pointer;
  font-size:12px; font-weight:600; color:var(--brand);
}
.today-viewall:hover{ text-decoration:underline; }

/* ---------------- Overview: collapsible full reports ---------------- */
details.full-reports{ margin-top:4px; }
details.full-reports > summary{
  cursor:pointer; list-style:none; user-select:none; font-size:14px; font-weight:700; color:var(--fg1);
  padding:12px 14px; background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-lg);
  box-shadow:var(--shadow2); display:flex; align-items:center; gap:8px; margin-bottom:16px;
}
details.full-reports > summary::-webkit-details-marker{ display:none; }
details.full-reports > summary::before{
  content:''; width:8px; height:8px; border-inline-start:2px solid var(--fg2); border-bottom:2px solid var(--fg2);
  transform:rotate(-45deg); transition:transform var(--dur) var(--curve); flex:none;
}
details.full-reports[open] > summary::before{ transform:rotate(45deg); }
details.full-reports > summary:hover{ border-color:var(--stroke-strong); }

/* ---------------- Filter bar ---------------- */
.filterbar{
  display:flex; flex-wrap:wrap; gap:8px; align-items:flex-end;
  background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-lg);
  padding:var(--sp-m) var(--sp-l); margin-bottom:16px; box-shadow:var(--shadow2);
}
.filterbar-top, .filterbar-extra{ display:contents; }
.field{ display:flex; flex-direction:column; gap:4px; min-width:150px; }
.field.grow{ flex:1 1 220px; }
.field label{ font-size:12px; color:var(--fg2); font-weight:600; }
.filterbar-toggle{ display:none; }
.filter-badge{
  display:inline-flex; align-items:center; justify-content:center; min-width:16px; height:16px; padding:0 4px;
  border-radius:999px; background:var(--brand); color:#fff; font-size:11px; font-weight:700; line-height:16px;
}
@media (max-width:760px){
  .filterbar{ flex-direction:column; align-items:stretch; }
  .filterbar-top{ display:flex; gap:8px; align-items:flex-end; width:100%; }
  .filterbar-top .field.grow{ flex:1 1 auto; min-width:0; }
  .filterbar-toggle{
    display:inline-flex; align-items:center; gap:6px; flex:none; height:32px; white-space:nowrap;
  }
  .filterbar-toggle svg{ width:15px; height:15px; }
  .filterbar.open .filterbar-toggle{ border-color:var(--brand); color:var(--brand); }
  .filterbar-extra{
    display:none; flex-direction:column; gap:10px; width:100%; margin-top:12px; padding-top:12px;
    border-top:1px solid var(--stroke1);
  }
  .filterbar.open .filterbar-extra{ display:flex; }
  .filterbar-extra .field{ min-width:0; width:100%; }
  .filterbar-extra .btn{ width:100%; justify-content:center; }
}
input[type=text], input[type=search]{
  font-family:inherit; background:var(--nb2); border:1px solid var(--stroke1); color:var(--fg1);
  padding:0 10px; height:32px; border-radius:var(--r-md); font-size:13.5px; outline:none;
  transition:border-color var(--dur) var(--curve), box-shadow var(--dur) var(--curve), background-color var(--dur) var(--curve);
}
input[type=text]:hover, input[type=search]:hover{ border-color:var(--stroke-strong); }
input[type=text]:focus, input[type=search]:focus{ background:var(--nb1); border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-tint); outline:none; }
input[type=text][readonly], input[type=text]:disabled{ background:var(--nb4); color:var(--fg2); }
select{
  font-family:inherit; background:var(--nb2); border:1px solid var(--stroke1); color:var(--fg1);
  padding:0 10px; height:32px; border-radius:var(--r-md); font-size:13.5px; outline:none; cursor:pointer;
  transition:border-color var(--dur) var(--curve), box-shadow var(--dur) var(--curve), background-color var(--dur) var(--curve);
}
select:hover{ border-color:var(--stroke-strong); }
select:focus{ background:var(--nb1); border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-tint); outline:none; }
.filterbar .btn{ flex:0 0 auto; }
.active-filters{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:14px; }
.chip{
  font-size:12px; background:var(--brand-tint); border:1px solid var(--brand); color:var(--brand-shade);
  padding:3px 8px; border-radius:var(--r-sm); display:flex; align-items:center; gap:6px; font-weight:600;
}
.chip button{ background:none; border:none; color:inherit; cursor:pointer; font-size:14px; line-height:1; padding:0; display:flex; }

/* ---------------- Multi-select (Fluent Dropdown / Listbox) ---------------- */
.ms{ position:relative; }
.ms-trigger{
  font-family:inherit; cursor:pointer; width:100%; min-width:160px; height:32px; background:var(--nb3);
  border:1px solid var(--stroke2); border-radius:var(--r-md); padding:0 8px 0 10px; display:flex; align-items:center;
  justify-content:space-between; gap:8px; font-size:14px; color:var(--fg1); transition:border-color var(--dur) var(--curve), background-color var(--dur) var(--curve);
}
.ms-trigger:hover{ border-color:var(--stroke-strong); }
.ms-trigger.open{ background:var(--nb1); border-color:var(--brand); box-shadow:0 0 0 1px var(--brand); }
.ms-trigger-value{ color:var(--fg2); font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ms-trigger .chev{ width:14px; height:14px; flex:none; color:var(--fg3); transition:transform var(--dur) var(--curve); }
.ms-trigger.open .chev{ transform:rotate(180deg); }
.ms-panel{
  position:absolute; top:calc(100% + 4px); right:0; left:0; min-width:220px; background:var(--nb1);
  border:1px solid var(--stroke1); border-radius:var(--r-lg); box-shadow:var(--shadow8); z-index:60; padding:6px;
}
.ms-panel[hidden]{ display:none; }
.ms-search{ padding:4px; }
.ms-search input{ width:100%; }
.ms-actions{ display:flex; gap:4px; padding:4px 6px; border-bottom:1px solid var(--stroke1); margin-bottom:4px; }
.ms-actions button{
  font-family:inherit; background:none; border:none; color:var(--brand); font-size:12px; font-weight:600;
  cursor:pointer; padding:4px 6px; border-radius:var(--r-sm);
}
.ms-actions button:hover{ background:var(--brand-tint); }
.ms-list{ max-height:220px; overflow-y:auto; }
.ms-item{
  display:flex; align-items:center; gap:8px; padding:6px 8px; border-radius:var(--r-sm); cursor:pointer; font-size:13px;
}
.ms-item:hover{ background:var(--nb3); }
.ms-item input[type=checkbox]{ width:16px; height:16px; accent-color:var(--brand); flex:none; }
.ms-empty{ padding:14px; text-align:center; color:var(--fg3); font-size:12px; }

/* ---------------- KPI cards ---------------- */
.kpis{ display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:12px; margin-bottom:24px; }
.kpi{
  position:relative; background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-lg);
  padding:var(--sp-l); box-shadow:var(--shadow2); min-width:0;
  opacity:0; transform:translateY(4px); animation:rise var(--dur-slow) var(--curve) forwards;
  transition:border-color var(--dur) var(--curve), box-shadow var(--dur) var(--curve), transform var(--dur) var(--curve);
}
.kpi:hover{ border-color:var(--stroke-strong); box-shadow:var(--shadow4); transform:translateY(-1px); }
.kpi:nth-child(1){ animation-delay:0ms; } .kpi:nth-child(2){ animation-delay:20ms; }
.kpi:nth-child(3){ animation-delay:40ms; } .kpi:nth-child(4){ animation-delay:60ms; }
.kpi:nth-child(5){ animation-delay:80ms; } .kpi:nth-child(6){ animation-delay:100ms; }
@keyframes rise{ to{ opacity:1; transform:none; } }
.kpi-top{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.kpi .lbl{ font-size:12px; color:var(--fg2); font-weight:600; letter-spacing:.1px; }
.kpi-dot{ width:7px; height:7px; border-radius:999px; background:var(--stroke-strong); flex:none; }
.kpi.kpi-brand .kpi-dot{ background:var(--brand); }
.kpi.kpi-success .kpi-dot{ background:var(--success-fg); }
.kpi.kpi-danger .kpi-dot{ background:var(--danger-fg); }
.kpi .val{ font-size:25px; line-height:30px; font-weight:700; margin-top:8px; color:var(--fg1); letter-spacing:-.3px; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.kpi .sub{ font-size:12px; color:var(--fg3); margin-top:3px; display:flex; align-items:center; gap:4px; }
.kpi.kpi-brand .val{ color:var(--fg1); }
.kpi.kpi-success .val{ color:var(--fg1); }
.kpi.kpi-danger .val{ color:var(--fg1); }
.kpi.kpi-success .sub{ color:var(--success-fg); }
.kpi.kpi-danger .sub{ color:var(--danger-fg); }
.kpi-progress{ height:5px; border-radius:999px; background:var(--nb3); margin-top:12px; overflow:hidden; }
.kpi-progress-fill{ height:100%; border-radius:999px; background:linear-gradient(90deg, var(--brand), var(--success-fg)); transition:width var(--dur-slow) var(--curve); }
.kpi.kpi-hero{ background:linear-gradient(165deg, var(--nb1) 0%, var(--brand-tint2) 145%); }
.kpi.kpi-hero .val{ font-size:30px; }
@media (prefers-reduced-motion: reduce){ .kpi{ animation:none; opacity:1; transform:none; } }

/* ---------------- Financial summary panel (Overview tab) ---------------- */
.financial-panel{ margin-bottom:24px; background:var(--nb1); border-color:var(--stroke1); }
.financial-panel h3{ display:flex; align-items:center; gap:8px; font-size:14.5px; }
.financial-panel h3::before{ content:''; width:7px; height:7px; border-radius:50%; background:var(--success-fg); flex:none; }
.financial-kpis{ margin-bottom:0; }
.financial-kpis .kpi{ background:var(--nb2); border-top:2px solid var(--stroke-strong); border-radius:var(--r-md); box-shadow:none; }
.financial-kpis .kpi:hover{ box-shadow:none; transform:none; border-color:var(--stroke-strong); }
.financial-kpis .kpi.kpi-brand{ border-top-color:var(--brand); }
.financial-kpis .kpi.kpi-success{ border-top-color:var(--success-fg); }
.financial-kpis .kpi.kpi-danger{ border-top-color:var(--danger-fg); }
.financial-kpis .kpi .val{ font-size:25px; }

/* ---------------- Tables ---------------- */
.table-toolbar{ display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:16px; flex-wrap:wrap; }
table{ width:100%; border-collapse:collapse; font-size:13.5px; }
thead th{
  text-align:start; font-size:11px; color:var(--fg3); font-weight:700; background:var(--nb2);
  padding:11px 12px; border-bottom:1px solid var(--stroke1); cursor:pointer; white-space:nowrap; user-select:none;
  letter-spacing:.4px; text-transform:uppercase; transition:color var(--dur) var(--curve);
}
thead th:hover{ color:var(--fg1); }
thead th .arrow{ color:var(--brand); margin-inline-start:3px; font-size:10px; }
thead th.no-sort{ cursor:default; }
tbody td{ padding:10px 12px; border-bottom:1px solid var(--stroke1); color:var(--fg1); }
tbody tr{ transition:background var(--dur) var(--curve); }
tbody tr:hover{ background:var(--nb2); }
.row-actions{ display:flex; gap:2px; justify-content:flex-end; }
.row-actions [data-add-delivery-order]{ color:var(--brand); }
.row-actions [data-add-delivery-order]:hover{ background:var(--brand-tint); }
.bar-cell{ display:flex; align-items:center; gap:8px; }
.bar-track{ flex:1; height:6px; background:var(--nb3); border-radius:4px; overflow:hidden; min-width:50px; }
.bar-fill{ height:100%; background:var(--brand); border-radius:4px; }

/* Table container: rounded card with contained header/rows */
.table-scroll{ border:1px solid var(--stroke1); border-radius:var(--r-lg); background:var(--nb1); }
.table-scroll table{ border-radius:inherit; }
.table-scroll thead th:first-child{ border-start-start-radius:var(--r-lg); }
.table-scroll thead th:last-child{ border-start-end-radius:var(--r-lg); }
.table-scroll tbody tr:last-child td{ border-bottom:none; }

/* Primary/secondary column emphasis on desktop rows */
#ordersTable tbody td:nth-child(1), #deliveriesTable tbody td:nth-child(1){ color:var(--fg3); font-size:12.5px; }
#ordersTable tbody td:nth-child(2), #deliveriesTable tbody td:nth-child(2){ font-weight:700; color:var(--fg1); }
#ordersTable tbody td:nth-child(5), #ordersTable tbody td:nth-child(6){ font-weight:700; font-variant-numeric:tabular-nums; }
#customerLedgerTable tbody td:nth-child(2), #supplierLedgerTable tbody td:nth-child(2){ font-weight:700; color:var(--fg1); }
#customersTable tbody td:nth-child(1), #productsTable tbody td:nth-child(1), #suppliersTable tbody td:nth-child(1){ font-weight:700; color:var(--fg1); }
.rem-warn{ color:var(--warning-fg); font-weight:700; }
.rem-zero{ color:var(--success-fg); font-weight:700; }

/* Badge (Fluent Badge, "tint" appearance, rounded shape) */
.badge{ font-size:12px; padding:2px 8px; border-radius:var(--r-sm); font-weight:600; display:inline-block; border:1px solid transparent; }
.badge.success{ background:var(--success-bg); color:var(--success-fg); border-color:var(--success-border); }
.badge.warning{ background:var(--warning-bg); color:var(--warning-fg); border-color:var(--warning-border); }
.badge.danger{ background:var(--danger-bg); color:var(--danger-fg); border-color:var(--danger-border); }

.table-scroll{ overflow-x:auto; }

/* ---------------- Responsive tables -> cards on mobile ---------------- */
@media (max-width:760px){
  .table-scroll{ overflow-x:visible; border:none; border-radius:0; background:none; box-shadow:none; }
  .rc-table{ border-collapse:separate; margin:6px 0; }
  .rc-table thead{ display:none; }
  .rc-table, .rc-table tbody, .rc-table tr{ display:block; width:100%; }
  .rc-table tbody tr{
    background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-lg);
    padding:4px 14px; box-shadow:var(--shadow4); margin-bottom:10px;
  }
  .rc-table tbody tr:last-child{ margin-bottom:0; }
  .rc-table tbody tr.empty-row, .rc-table tbody tr.rc-full{
    background:none; border:none; box-shadow:none; padding:0;
  }
  .rc-table tbody tr.rc-full td{ padding:12px 2px; display:block; }
  .rc-table tbody tr.empty-row td{ text-align:center; }
  .rc-table tbody tr.order-group-header:has(+ tr.order-group-item){
    margin-bottom:0; border-end-start-radius:0; border-end-end-radius:0;
  }
  .rc-table tbody tr.order-group-item{
    margin-top:0; border-top:none; border-start-start-radius:0; border-start-end-radius:0;
    background:var(--nb2) !important;
  }
  .rc-table tbody tr.order-group-item:has(+ tr.order-group-item){
    margin-bottom:0; border-end-start-radius:0; border-end-end-radius:0;
  }
  .rc-table td{
    display:flex; justify-content:space-between; align-items:center; gap:14px;
    padding:7px 2px; background:none !important;
    text-align:end; min-height:20px;
  }
  .rc-table td:empty{ display:none; }
  .rc-table td[data-label]::before{
    content:attr(data-label); font-size:11.5px; font-weight:500; color:var(--fg3); text-align:start; flex:none;
  }
  .rc-table td:not([data-label]){ justify-content:flex-start; padding-inline-start:0; }
  .rc-table td.num{ flex-direction:row-reverse; font-weight:600; color:var(--fg1); }
  .rc-table .row-actions{ width:100%; }
  .rc-table .group-toggle{ font-size:13px; font-weight:600; }

  /* ---- Bespoke rich mobile cards (any .rc-table with an order-card-cell) ---- */
  .rc-table tr:has(> td.order-card-cell) > td:not(.order-card-cell){ display:none !important; }
  .rc-table td.order-card-cell{ display:block !important; background:none !important; border:none !important; padding:0 !important; }
  .rc-table tbody tr:has(> td.order-card-cell){ padding:12px 14px 10px; }

  .oc{ display:flex; flex-direction:column; gap:10px; }
  .oc-top{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
  .oc-date{ display:block; font-size:11px; color:var(--fg3); font-weight:500; margin-bottom:2px; }
  .oc-customer{ margin:0; font-size:16px; font-weight:700; color:var(--fg1); line-height:1.3; }
  .oc-badge-main{ flex:none; margin-top:1px; }
  .oc-single-metric{ flex:none; align-items:flex-end; }
  .oc-single-metric .oc-metric-val{ font-size:19px; color:var(--brand); }
  .oc-status-row{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
  .oc-city{ font-size:12px; color:var(--fg3); }

  .oc-metrics{ display:flex; align-items:stretch; background:var(--nb2); border-radius:var(--r-md); padding:10px 4px; }
  .oc-metric{ flex:1; display:flex; flex-direction:column; align-items:center; gap:2px; min-width:0; }
  .oc-metric-val{ font-size:18px; font-weight:800; color:var(--fg1); font-variant-numeric:tabular-nums; letter-spacing:-.2px; }
  .oc-metric-lbl{ font-size:10.5px; color:var(--fg3); font-weight:500; }
  .oc-metric.warn .oc-metric-val{ color:var(--warning-fg); }
  .oc-metric.zero .oc-metric-val{ color:var(--success-fg); }
  .oc-metric-sep{ width:1px; background:var(--stroke1); margin:2px 0; }

  .oc-details{ display:flex; flex-direction:column; gap:5px; padding:0 2px; }
  .oc-detail-row{ display:flex; justify-content:space-between; align-items:center; gap:10px; font-size:12.5px; }
  .oc-detail-lbl{ color:var(--fg3); flex:none; }
  .oc-detail-val{ color:var(--fg1); font-weight:600; text-align:end; }
  .oc-group-toggle{ color:var(--brand); }
  .oc-group-toggle svg{ transform:rotate(90deg); }
  .oc-group-toggle.open svg{ transform:rotate(-90deg); }

  .oc-financial{
    display:flex; align-items:center; justify-content:space-between; background:var(--brand-tint);
    border-radius:var(--r-md); padding:9px 12px;
  }
  .oc-financial-lbl{ font-size:12px; color:var(--fg2); font-weight:600; }
  .oc-financial-val{ font-size:19px; font-weight:800; color:var(--fg1); font-variant-numeric:tabular-nums; letter-spacing:-.2px; }
  .oc-financial-val.pos{ color:var(--success-fg); }
  .oc-financial-val.neg{ color:var(--danger-fg); }

  .oc-actions{ display:flex; justify-content:flex-end; gap:2px; background:var(--nb2); border-radius:var(--r-md); padding:4px; }
  .oc-actions .row-actions{ width:auto; }
  .oc-actions .icon-btn{ width:34px; height:34px; }
  .oc-actions [data-add-delivery-order]{ color:var(--brand); background:var(--brand-tint2); }
  .oc-actions [data-add-delivery-order]:hover{ background:var(--brand-tint); }
}
.empty-row td{ text-align:center; color:var(--fg3); padding:28px; }
.pagination{ display:flex; justify-content:center; align-items:center; gap:14px; margin-top:14px; font-size:12.5px; color:var(--fg2); }
.pagination button{ background:var(--nb1); border:1px solid var(--stroke2); color:var(--fg1); border-radius:var(--r-sm); padding:4px 10px; cursor:pointer; font-family:inherit; }
.pagination button:hover:not(:disabled){ background:var(--nb3); }
.pagination button:disabled{ opacity:.4; cursor:default; }

/* ---------------- Dialog / Modal (Fluent Dialog) ---------------- */
.overlay{ position:fixed; inset:0; background:rgba(0,0,0,.4); display:none; align-items:center; justify-content:center; z-index:100; padding:20px; }
.overlay.open{ display:flex; }
.dialog{
  background:var(--nb1); border-radius:var(--r-lg); box-shadow:var(--shadow28); width:100%; max-width:520px;
  max-height:88vh; display:flex; flex-direction:column; animation:dialogIn var(--dur) var(--curve);
}
.dialog.wide{ max-width:760px; }
.dialog.xwide{ max-width:980px; }
@media print{
  body > header, body > main, body > footer, body > .toast-region{ display:none !important; }
  .overlay{ display:none !important; }
  .overlay.open{ position:static !important; background:none !important; padding:0 !important; display:block !important; inset:auto !important; }
  .overlay.open .dialog{ max-height:none !important; box-shadow:none !important; max-width:none !important; margin:0 !important; animation:none !important; }
  .overlay.open .dialog-body{ overflow:visible !important; padding:0 !important; }
  .overlay.open .dialog-header, .overlay.open .dialog-footer, .invoice-controls{ display:none !important; }
  .print-doc{ margin:0 auto !important; box-shadow:none !important; border:none !important; max-width:720px !important; padding:18px !important; font-size:12px !important; }
  .print-doc .inv-head{ padding-bottom:10px !important; margin-bottom:14px !important; }
  .print-doc .inv-parties{ margin-bottom:14px !important; }
  .print-doc .inv-party{ max-width:460px !important; padding:10px 12px !important; }
  .print-doc .inv-table{ margin-bottom:12px !important; }
  .print-doc .inv-table th, .print-doc .inv-table td{ padding:6px 8px !important; }
  .print-doc .inv-notes{ margin-top:12px !important; }
  .print-doc .inv-footer{ margin-top:18px !important; }
  .print-doc.wide-report{ max-width:1040px !important; padding:22px !important; }
  .print-doc.wide-report .report-table th, .print-doc.wide-report .report-table td{ padding:5px 6px !important; font-size:10.5px !important; }
}
@keyframes dialogIn{ from{ opacity:0; transform:scale(.98) translateY(4px); } to{ opacity:1; transform:none; } }
.dialog-header{ display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--stroke1); }
.dialog-header h2{ font-size:18px; font-weight:600; margin:0; }
.dialog-body{ padding:16px 20px; overflow-y:auto; overflow-x:hidden; }
.dialog-footer{ display:flex; justify-content:flex-end; gap:8px; padding:14px 20px; border-top:1px solid var(--stroke1); flex-wrap:wrap; }
.form-grid{ display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:12px; }
.form-grid .full{ grid-column:1/-1; }
@media (max-width:600px){
  .dialog-footer{ flex-direction:column-reverse; align-items:stretch; }
  .dialog-footer .btn{ width:100%; justify-content:center; }
  .form-grid{ grid-template-columns:1fr; }
}
.form-field{ display:flex; flex-direction:column; gap:4px; min-width:0; }
.form-field label{ font-size:12px; font-weight:600; color:var(--fg2); }
.form-field input, .form-field select, .form-field textarea{ height:32px; width:100%; box-sizing:border-box; min-width:0; }
.form-field .req{ color:var(--danger-fg); }
.form-field input[readonly]{ background:var(--nb4); color:var(--fg2); cursor:not-allowed; }
.form-field input:disabled{ background:var(--nb4); color:var(--fg2); cursor:not-allowed; }

/* ---------------- Drive backup picker ---------------- */
.drive-backup-list{ display:flex; flex-direction:column; gap:8px; }
.drive-backup-row{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:var(--nb2); border:1px solid var(--stroke1); border-radius:var(--r-md); padding:10px 12px;
}
.drive-backup-row-info{ min-width:0; }
.drive-backup-row-info strong{ display:block; font-size:13.5px; font-weight:600; color:var(--fg1); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.drive-backup-row-info span{ display:block; font-size:11.5px; color:var(--fg3); margin-top:2px; }
.drive-backup-row .btn{ flex:none; }
.drive-backup-empty{ font-size:12.5px; color:var(--fg3); text-align:center; padding:14px 0; }
.drive-backup-new{ border-top:1px solid var(--stroke1); padding-top:10px; }
.order-info-box{ display:none; background:var(--brand-tint); border:1px solid var(--stroke1); border-radius:var(--r-md); padding:10px 14px; margin-bottom:14px; font-size:13px; }
.order-info-box.show{ display:block; }
.order-info-box .oi-row{ display:flex; justify-content:space-between; gap:10px; padding:2px 0; color:var(--fg1); }
.order-info-box .oi-row b{ color:var(--fg2); font-weight:600; }
.order-info-box .oi-remaining{ margin-top:6px; padding-top:6px; border-top:1px dashed var(--stroke2); font-weight:700; color:var(--brand-shade); }
.order-items-section{ margin-top:0; border:1px solid var(--stroke1); border-radius:var(--r-md); padding:14px; }
.oi-section-header{ display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.oi-section-header h4{ margin:0; font-size:12px; font-weight:700; color:var(--brand-shade); }
.order-item-row{ background:var(--nb2); border:1px solid var(--stroke1); border-radius:var(--r-md); padding:12px; margin-bottom:10px; }
.order-item-row:last-child{ margin-bottom:0; }
.order-item-row .oi-line1{ display:grid; grid-template-columns:minmax(0,1.5fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) 28px; gap:8px; align-items:end; margin-bottom:8px; }
.order-item-row .oi-line2{ display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr); gap:8px; align-items:end; }
.order-item-row .form-field label{ font-size:11px; }
.order-item-row .oi-remove{ margin-bottom:2px; }
.single-item .oi-remove{ visibility:hidden; }
.row-muted{ opacity:.55; }
.row-muted td{ text-decoration:line-through; text-decoration-color:var(--stroke-strong); }
.row-muted td:last-child, .row-muted .badge{ text-decoration:none; }
.profit-pos{ color:var(--success-fg); font-weight:700; }
.profit-neg{ color:var(--danger-fg); font-weight:700; }
.oi-profit.positive{ color:var(--success-fg); font-weight:600; }
.oi-profit.negative{ color:var(--danger-fg); font-weight:600; }
.oi-total-profit{ margin-top:12px; padding:10px 14px; border-radius:var(--r-md); background:var(--nb2); font-size:13px; font-weight:700; text-align:end; }
.oi-total-profit.positive{ color:var(--success-fg); }
.oi-total-profit.negative{ color:var(--danger-fg); }
@media (max-width:640px){
  .order-item-row .oi-line1{ grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
  .order-item-row .oi-line1 .oi-remove{ grid-column:2; justify-self:end; }
  .order-item-row .oi-line2{ grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
}
.confirm-text{ font-size:14px; color:var(--fg1); line-height:20px; }

/* ---------------- Toast (Fluent MessageBar/Toast) ---------------- */
.toast-region{ position:fixed; bottom:20px; left:20px; display:flex; flex-direction:column; gap:8px; z-index:200; }
.toast{
  display:flex; align-items:center; gap:10px; background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-md);
  box-shadow:var(--shadow8); padding:10px 14px; font-size:13px; min-width:260px; animation:toastIn var(--dur) var(--curve);
  border-inline-start:3px solid var(--brand);
}
.toast.success{ border-inline-start-color:var(--success-fg); }
.toast.warning{ border-inline-start-color:var(--warning-fg); }
.toast.danger{ border-inline-start-color:var(--danger-fg); }
@keyframes toastIn{ from{ opacity:0; transform:translateY(6px); } to{ opacity:1; transform:none; } }

/* ---------------- Install guide (post-wizard coachmark) ---------------- */
.install-guide{ position:fixed; inset:0; z-index:300; display:none; }
.install-guide.open{ display:block; }
.install-guide-backdrop{ position:absolute; inset:0; background:rgba(0,0,0,.5); animation:igFadeIn .25s ease; }
@keyframes igFadeIn{ from{ opacity:0; } to{ opacity:1; } }

.install-guide-card{
  position:absolute; box-sizing:border-box; width:330px; max-width:calc(100vw - 28px);
  background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-lg);
  box-shadow:var(--shadow28); padding:18px 20px; text-align:start;
  animation:igCardIn .32s cubic-bezier(.2,.8,.2,1);
}
@keyframes igCardIn{ from{ opacity:0; transform:scale(.96) translateY(6px); } to{ opacity:1; transform:none; } }

/* Positions are physical (screen-relative), not logical/RTL-aware — they
   target real browser chrome (address bar, menu bar, share sheet), which
   sits in the same place regardless of the page's own text direction. */
.install-guide-card.ig-pos-top-right{ top:74px; right:16px; left:auto; }
.install-guide-card.ig-pos-top-left{ top:74px; left:16px; right:auto; }
.install-guide-card.ig-pos-bottom-center{ bottom:92px; left:50%; transform:translateX(-50%); }
.install-guide-card.ig-pos-center{ top:50%; left:50%; transform:translate(-50%,-50%); }

.install-guide-icon{
  width:38px; height:38px; border-radius:11px; background:var(--brand-tint); color:var(--brand);
  display:flex; align-items:center; justify-content:center; margin-bottom:10px; flex-shrink:0;
}
.install-guide-icon svg{ width:20px; height:20px; }
.install-guide-title{ font-size:15px; font-weight:700; margin:0 0 6px; color:var(--fg1); }
.install-guide-text{ font-size:13px; line-height:1.9; color:var(--fg2); margin:0 0 16px; }
.install-guide-actions{ display:flex; gap:8px; }
.install-guide-actions .btn{ flex:1; justify-content:center; }

/* The bouncing pointer that points off-card toward real browser UI */
.install-guide-pointer{ position:absolute; width:44px; height:60px; pointer-events:none; filter:drop-shadow(0 4px 8px rgba(0,0,0,.4)); }
.install-guide-pointer svg{ width:100%; height:100%; }
.install-guide-pointer.ig-dir-up{ animation:igBounceUp 1.3s ease-in-out infinite; }
.install-guide-pointer.ig-dir-down{ animation:igBounceDown 1.3s ease-in-out infinite; }
@keyframes igBounceUp{ 0%,100%{ transform:translateY(0); } 50%{ transform:translateY(-9px); } }
@keyframes igBounceDown{ 0%,100%{ transform:translateY(0); } 50%{ transform:translateY(9px); } }
.install-guide-pointer.ig-pos-above-right{ top:8px; right:26px; }
.install-guide-pointer.ig-pos-above-left{ top:8px; left:26px; }
.install-guide-pointer.ig-pos-below-center{ bottom:26px; left:50%; transform:translateX(-50%); }

/* Pulsing ring used to highlight the in-card install button itself, for the
   native-prompt variant where there's no external browser UI to point at. */
.install-guide-pulse-wrap{ position:relative; flex:1; border-radius:var(--r-md); }
.install-guide-pulse-wrap::after{
  content:''; position:absolute; inset:-4px; border-radius:inherit; border:2px solid var(--brand);
  animation:igPulseRing 1.7s ease-out infinite; pointer-events:none;
}
@keyframes igPulseRing{ 0%{ opacity:.85; transform:scale(1); } 100%{ opacity:0; transform:scale(1.28); } }

@media (max-width:640px){
  .install-guide-card.ig-pos-top-right, .install-guide-card.ig-pos-top-left{
    top:auto; bottom:92px; left:50%; right:auto; transform:translateX(-50%);
  }
  .install-guide-pointer.ig-pos-above-right, .install-guide-pointer.ig-pos-above-left{ display:none; }
}

/* ---------------- Section tour (post-wizard, points at real UI) ---------------- */
.section-tour-backdrop{
  position:fixed; inset:0; z-index:285; background:rgba(0,0,0,.55);
  animation:igFadeIn .2s ease; display:none;
}
.section-tour-backdrop.open{ display:block; }
.section-tour-highlight{
  position:fixed; z-index:286; border-radius:12px; pointer-events:none;
  box-shadow:0 0 0 4px var(--brand), 0 0 0 9999px rgba(0,0,0,.55);
  transition:top .28s cubic-bezier(.2,.8,.2,1), left .28s cubic-bezier(.2,.8,.2,1),
             width .28s cubic-bezier(.2,.8,.2,1), height .28s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
}
.section-tour-highlight::after{
  content:''; position:absolute; inset:-4px; border-radius:inherit; border:2px solid var(--brand);
  animation:igPulseRing 1.7s ease-out infinite; pointer-events:none;
}
.section-tour-card{
  position:fixed; z-index:287; width:300px; max-width:calc(100vw - 32px); box-sizing:border-box;
  background:var(--nb1); border:1px solid var(--stroke1); border-radius:var(--r-lg);
  box-shadow:var(--shadow28); padding:16px 18px;
  transition:top .28s cubic-bezier(.2,.8,.2,1), left .28s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
}
.section-tour-step{ font-size:11.5px; font-weight:700; color:var(--brand); margin:0 0 4px; letter-spacing:.02em; }
.section-tour-title{ font-size:14.5px; font-weight:700; margin:0 0 6px; color:var(--fg1); }
.section-tour-text{ font-size:13px; line-height:1.85; color:var(--fg2); margin:0 0 14px; }
.section-tour-actions{ display:flex; align-items:center; gap:8px; }
.section-tour-skip{
  background:none; border:none; cursor:pointer; font-family:inherit; font-size:12.5px; color:var(--fg3);
  padding:6px 4px; margin-inline-end:auto;
}
.section-tour-skip:hover{ color:var(--fg1); }
.section-tour-actions .btn{ padding:6px 14px; font-size:12.5px; }

.section-tour-arrow{ position:fixed; z-index:287; width:30px; height:40px; pointer-events:none; filter:drop-shadow(0 3px 6px rgba(0,0,0,.35)); }
.section-tour-arrow svg{ width:100%; height:100%; }
.section-tour-arrow.dir-up{ animation:igBounceUp 1.3s ease-in-out infinite; }
.section-tour-arrow.dir-down{ animation:igBounceDown 1.3s ease-in-out infinite; }

footer{ text-align:center; color:var(--fg3); font-size:12px; padding:30px 0 10px; }

/* ---------------- General mobile polish ---------------- */
@media (max-width:520px){
  .brand p{ display:none; }
  .filename-chip{ max-width:120px; }
  .table-toolbar{ align-items:stretch; }
  .table-toolbar > div{ flex-wrap:wrap; }
  .table-toolbar h3{ flex:1 1 100%; }
}

/* =========================================================
   MOBILE-FIRST DASHBOARD PASS
   Tighter header, denser KPI grid, lighter panels/filter bar,
   so the important numbers are visible without scrolling.
   ========================================================= */
@media (max-width:640px){

  /* ---- Page rhythm: less dead air before content ---- */
  main{ padding-top:10px; padding-bottom:44px; }

  /* ---- Compact top bar ---- */
  .appbar{ padding:7px 12px; gap:8px; }
  .brand{ gap:6px; }
  .brand-mark{ width:20px; height:20px; }
  .brand h1{ font-size:14px; line-height:18px; }
  .appbar-actions{ gap:4px; }
  /* Theme is still changeable from Settings — no need for 3 swatches in the bar */
  .header-theme-switch{ display:none; }
  /* Icon-only "more options" trigger instead of an icon+label button */
  #moreMenuBtn{ width:32px; height:32px; padding:0; justify-content:center; }
  #moreMenuBtn .btn-label{ display:none; }
  #moreMenu{ min-width:220px; }
  /* Backup/sync status becomes a small subtle pill instead of a long sentence */
  .filename-chip{ max-width:118px; font-size:10.5px; padding:3px 8px 3px 6px; }
  .dirty-dot{ width:7px; height:7px; }

  /* ---- Mobile tab switcher sits closer to the header ---- */
  .tabs-mobile-trigger{ margin-top:10px; padding:8px 12px; font-size:13.5px; }

  /* ---- Filter bar: lighter shell, no wasted padding ---- */
  .filterbar{ padding:8px 10px; border-radius:var(--r-md); margin-bottom:10px; }
  .filterbar-extra{ margin-top:10px; padding-top:10px; }
  .active-filters{ margin-bottom:10px; }

  /* ---- KPI cards: 2-column grid, compact height, number-first hierarchy ---- */
  .kpis{ grid-template-columns:repeat(2,1fr); gap:8px; margin-bottom:14px; }
  .kpi{ display:flex; flex-direction:column; padding:10px 12px; border-radius:var(--r-md); }
  .kpi:hover{ transform:none; box-shadow:var(--shadow2); } /* no hover lift on touch */
  /* Reorder so the number leads, the label follows, then the supporting trend —
     the primary number becomes the strongest, most immediate element. */
  .kpi .val{ order:1; font-size:20px; line-height:24px; margin-top:0; }
  .kpi-top{ order:2; margin-top:4px; gap:6px; }
  .kpi .lbl{ font-size:10.5px; }
  .kpi .sub{ order:3; font-size:10.5px; margin-top:2px; color:var(--fg2); }
  .kpi.kpi-success .sub, .kpi.kpi-danger .sub{ color:inherit; }
  .kpi-dot{ display:none; } /* color is already carried by the value/sub text */
  .kpi-progress{ order:4; }
  .kpi-progress{ margin-top:8px; height:4px; }
  /* The completion/hero metric reads as the headline number, full-width */
  .kpi.kpi-hero{ grid-column:1 / -1; padding:12px 14px; }
  .kpi.kpi-hero .val{ font-size:26px; }
  /* .financial-kpis .kpi .val is 3 classes deep (higher specificity than the
     rules above), so it needs its own mobile override or it wins and blows
     out the 2-col grid — that was the clipped-header/overflow bug. */
  .financial-kpis .kpi .val{ font-size:18px; line-height:22px; }
  .financial-kpis .kpi.kpi-hero .val{ font-size:22px; }

  /* ---- Panels: less internal padding, shorter charts, tighter gaps ---- */
  .panel{ padding:14px; border-radius:var(--r-md); }
  .panel h3{ font-size:14px; }
  .panel .hint{ font-size:11.5px; margin-bottom:10px; }
  .grid2, .grid3{ gap:10px; margin-bottom:12px; }
  .chart-wrap{ height:220px; }
  .chart-wrap.tall{ height:240px; }
  .financial-panel{ margin-bottom:14px; }

  /* ---- Floating AI button: stay clear of the safe area, don't crowd content ---- */
  .ai-fab{ bottom:calc(14px + env(safe-area-inset-bottom)); left:14px; right:auto; width:46px; height:46px; }
  html[dir="rtl"] .ai-fab{ left:auto; right:14px; }
  .ai-panel{ bottom:calc(66px + env(safe-area-inset-bottom)); left:10px; right:10px; width:auto; max-width:none; height:min(70vh,520px); }
  html[dir="rtl"] .ai-panel{ left:10px; right:10px; }

  /* ---- Today widgets: this is the primary daily-use screen, so it gets
     the tightest treatment of all ---- */
  .today-actions{ margin-bottom:12px; }
  .today-actions .btn{ flex:1; justify-content:center; }
  .today-grid{ margin-bottom:12px; }
  .today-panel-icon{ width:23px; height:23px; border-radius:7px; }
  .today-panel-icon svg{ width:12px; height:12px; }
  .tr-avatar{ width:23px; height:23px; font-size:11px; }
  .today-row{ padding:8px 2px; }
  .tr-title{ font-size:13px; }
  .tr-sub{ font-size:11px; }
  .today-row-btn{ font-size:11px; padding:4px 8px; }
  details.full-reports > summary{ padding:11px 12px; font-size:13.5px; margin-bottom:12px; }
}
