/* Layout: fixed app chrome — sticky header + scrolling single column + bottom tab bar on phones, left rail from 820px.
   Palette: Ecomaster brand (primary #9B1E22, accent #ECA533, success #2A9D8F) on warm-neutral paper. */

:root {
  --paper: #FAFAF9;
  --surface: #FFFFFF;
  --surface-2: #F2F0F0;
  --surface-3: #E7E4E4;
  --ink: #121010;
  --ink-2: #555555;
  --ink-3: #888888;
  --line: #DDDDDD;
  --line-strong: #C9C5C5;

  --brand: #9B1E22;
  --brand-ink: #FFFFFF;
  --brand-text: #9B1E22;
  --brand-soft: #FDEAEA;
  --brand-soft-ink: #7A181B;

  --up: #9B1E22;
  --up-soft: #FDEAEA;
  --down: #22786D;
  --down-soft: #DDF1EE;
  --warn: #8A6016;
  --warn-soft: #FCEFD6;
  --info: #4A4A4A;
  --info-soft: #EDEBEB;

  --c-cost: #9B1E22;
  --c-profit: #2A9D8F;
  --c-grid: #E8E4E4;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.08), 0 18px 40px rgba(0,0,0,.16);

  --font-display: 'Readex Pro', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'IBM Plex Sans Arabic', 'Readex Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-num: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-xl: 26px;
  --tab-h: 62px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121010;
    --surface: #1C1919;
    --surface-2: #272222;
    --surface-3: #332C2C;
    --ink: #F3F0F0;
    --ink-2: #A09999;
    --ink-3: #807878;
    --line: #322B2B;
    --line-strong: #453D3D;
    --brand: #C2383E;
    --brand-ink: #FFFFFF;
    --brand-text: #E8898D;
    --brand-soft: #38191B;
    --brand-soft-ink: #F0A8AB;
    --up: #E8898D;
    --up-soft: #38191B;
    --down: #5BC4B4;
    --down-soft: #16332F;
    --warn: #E3B058;
    --warn-soft: #332A17;
    --info: #B5AEAE;
    --info-soft: #262222;
    --c-cost: #CE4047;
    --c-profit: #39A594;
    --c-grid: #2E2727;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lift: 0 2px 6px rgba(0,0,0,.5), 0 18px 40px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121010;
  --surface: #1C1919;
  --surface-2: #272222;
  --surface-3: #332C2C;
  --ink: #F3F0F0;
  --ink-2: #A09999;
  --ink-3: #807878;
  --line: #322B2B;
  --line-strong: #453D3D;
  --brand: #C2383E;
  --brand-ink: #FFFFFF;
  --brand-text: #E8898D;
  --brand-soft: #38191B;
  --brand-soft-ink: #F0A8AB;
  --up: #E8898D;
  --up-soft: #38191B;
  --down: #5BC4B4;
  --down-soft: #16332F;
  --warn: #E3B058;
  --warn-soft: #332A17;
  --info: #B5AEAE;
  --info-soft: #262222;
  --c-cost: #CE4047;
  --c-profit: #39A594;
  --c-grid: #2E2727;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.5), 0 18px 40px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; border-radius: 6px; }
h1,h2,h3,h4 { margin: 0; font-family: var(--font-display); font-weight: 600; text-wrap: balance; letter-spacing: -0.01em; }
.num, .tnum { font-variant-numeric: tabular-nums; }

/* ---------- brand mark ---------- */
.logo { display: block; width: 100%; height: 100%; }
.logochip {
  width: 34px; height: 30px; flex: none; border-radius: 9px; background: #FFFFFF;
  display: grid; place-items: center; box-shadow: 0 0 0 1px var(--line);
  padding: 3px;
}
:root[data-theme="dark"] .logochip, :root:not([data-theme="light"]) .logochip { box-shadow: none; }

/* ---------- app shell ---------- */
#app { display: flex; flex-direction: column; min-height: 100%; }

.appbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar-in {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; min-height: 54px;
  max-width: 1100px; margin: 0 auto;
}
.appbar h1 { font-size: 19px; flex: 1; min-width: 0; }
.appbar .sub { display: block; font-family: var(--font-body); font-size: 11.5px; font-weight: 400; color: var(--ink-2); letter-spacing: 0; }

.iconbtn {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.iconbtn:active { background: var(--surface-2); }
.iconbtn.ghost { border-color: transparent; background: transparent; }
.iconbtn svg { width: 19px; height: 19px; }

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 14px 16px calc(var(--tab-h) + 86px); }

.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar button {
  border: 0; background: none; padding: 8px 1px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--ink-3); font-size: 9.5px; font-weight: 500; min-height: var(--tab-h);
  overflow: hidden;
}
.tabbar button span:not(.tdot) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar button svg { width: 21px; height: 21px; }
.tabbar button[aria-current="page"] { color: var(--brand-text); }
.tabbar button[aria-current="page"] .tdot { opacity: 1; }
.tdot { width: 16px; height: 2.5px; border-radius: 2px; background: var(--brand-text); opacity: 0; }

.fab {
  position: fixed; inset-inline-end: 18px; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom, 0px));
  z-index: 45; height: 54px; min-width: 54px; padding: 0 20px;
  border: 0; border-radius: 18px; background: var(--brand); color: var(--brand-ink);
  font-family: var(--font-display); font-weight: 600; font-size: 14.5px;
  display: inline-flex; align-items: center; gap: 8px; box-shadow: var(--shadow-lift);
}
.fab:active { transform: scale(.97); }
.fab svg { width: 20px; height: 20px; }

@media (min-width: 820px) {
  :root { --tab-h: 0px; }
  #app { flex-direction: row; }
  .tabbar {
    position: sticky; top: 0; bottom: auto; inset-inline: auto;
    height: 100dvh; width: 212px; flex: none;
    grid-template-columns: 1fr; grid-auto-rows: max-content;
    align-content: start; gap: 2px; padding: 16px 12px;
    border-top: 0; border-inline-end: 1px solid var(--line);
    background: var(--surface);
  }
  .tabbar button {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 14px; border-radius: 12px; font-size: 14px; min-height: 0;
  }
  .tabbar button svg { width: 20px; height: 20px; }
  .tabbar button[aria-current="page"] { background: var(--brand-soft); color: var(--brand-soft-ink); }
  .tdot { display: none; }
  .shellcol { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  main { padding-bottom: 120px; }
  .fab { bottom: 28px; }
}

/* ---------- primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; }
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric .lab { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.metric .big { font-family: var(--font-display); font-size: 27px; font-weight: 600; line-height: 1.12; font-variant-numeric: tabular-nums; }
.metric .big small { font-size: 13px; font-weight: 400; color: var(--ink-2); }
.metric .sub { font-size: 12.5px; color: var(--ink-3); }
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13.5px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv .k { color: var(--ink-2); min-width: 0; }
.kv .v { flex: none; font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack.sm { gap: 7px; }
.stack.lg { gap: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; }
.sectionhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 2px 8px; }
.sectionhead:first-child { margin-top: 4px; }
.minitabs { display: flex; gap: 4px; }
.minitabs button {
  border: 0; background: none; padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3);
}
.minitabs button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); }
.sectionhead h2 { font-size: 13px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.sectionhead .link { font-size: 12.5px; color: var(--ink-2); background: none; border: 0; padding: 2px 0; font-weight: 600; }
.sectionhead .link:active { color: var(--brand-text); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-family: var(--font-display); font-weight: 600; font-size: 14.5px;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand-soft-ink); }
.btn.good { background: var(--down-soft); border-color: transparent; color: var(--down); }
.btn.danger { background: var(--up-soft); border-color: transparent; color: var(--up); }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 13px; font-size: 13.5px; border-radius: 11px; }
.btn:disabled { opacity: .45; }
.btn:active { transform: scale(.985); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.pill.brand { background: var(--brand-soft); color: var(--brand-soft-ink); }
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.down { background: var(--down-soft); color: var(--down); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }

.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 16px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips::after, .stagerail::after { content: ''; flex: none; inline-size: 6px; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.seg { display: flex; background: var(--surface-2); border-radius: 13px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 10px; background: none; color: var(--ink-2); font-weight: 600; font-size: 13.5px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  padding: 12px 14px; min-height: 62px; border: 0; background: none; color: inherit;
  border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item:active { background: var(--surface-2); }
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 13px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-soft-ink);
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
}
.item .main { flex: 1; min-width: 0; display: block; }
.item .name { display: block; font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.item .meta { display: block; font-size: 12.5px; color: var(--ink-2); line-height: 1.4; margin-top: 1px; }
.item .tail { text-align: end; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.item .tail .num { font-size: 14px; }
bdi { unicode-bidi: isolate; }
.dot { color: var(--ink-3); padding: 0 2px; }
.chev { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
:root[dir="rtl"] .chev { transform: scaleX(-1); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding-inline-start: 2px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1px solid var(--line-strong); border-radius: 13px;
  background: var(--surface); color: var(--ink); font-size: 16px;
}
textarea.input { min-height: 84px; resize: vertical; line-height: 1.45; }
.input::placeholder { color: var(--ink-3); }
.input:focus { border-color: var(--brand-text); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.input.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

.search { position: relative; }
.search svg { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-inline-start: 40px; }

.stepper { display: inline-flex; align-items: center; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.stepper button { width: 36px; height: 36px; border: 0; border-radius: 9px; background: var(--surface); color: var(--ink); font-size: 19px; line-height: 1; display: grid; place-items: center; box-shadow: var(--shadow); }
.stepper button:disabled { opacity: .35; box-shadow: none; }
.stepper input { width: 52px; border: 0; background: none; text-align: center; font-family: var(--font-num); font-size: 15px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(10,8,8,.5); backdrop-filter: blur(2px); animation: fade .18s ease; }
@keyframes fade { from { opacity: 0 } }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 61;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  max-height: 92dvh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lift); animation: rise .24s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { transform: translateY(14px); opacity: .6 } }
@media (prefers-reduced-motion: reduce) { .sheet, .scrim { animation: none } }
.sheet-head { padding: 12px 18px 10px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.sheet-head h2 { font-size: 17px; flex: 1; min-width: 0; }
.grab { position: absolute; top: 7px; inset-inline-start: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 4px; background: var(--line-strong); }
.sheet-body { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; overscroll-behavior: contain; }
.sheet-foot { padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
@media (min-width: 820px) {
  .sheet { inset-inline: auto; inset-inline-end: 50%; transform: translateX(50%); bottom: 24px; width: min(620px, 94vw); border-radius: var(--r-xl); max-height: 86dvh; }
  :root[dir="rtl"] .sheet { transform: translateX(-50%); }
  .grab { display: none; }
}

/* ---------- stage rail ---------- */
.stagerail { display: flex; gap: 6px; overflow-x: auto; padding: 2px 18px; margin: 0 -18px; scrollbar-width: none; }
.stagerail::-webkit-scrollbar { display: none; }
.stagerail button {
  flex: none; padding: 9px 13px; border-radius: 11px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.stagerail button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow); }
.stagerail button.done { background: var(--surface-2); border-color: transparent; color: var(--ink-2); }
.stagerail button.done::before { content: '✓'; margin-inline-end: 5px; color: var(--down); font-weight: 700; }

/* ---------- metrics ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
@media (min-width: 620px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 4px;
  background-image: linear-gradient(180deg, var(--brand-soft) 0%, transparent 62%);
}
.hero .k { font-size: 12px; font-weight: 600; color: var(--brand-soft-ink); letter-spacing: .04em; text-transform: uppercase; }
.hero .v { font-family: var(--font-display); font-size: 38px; font-weight: 600; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hero .v small { font-size: 14px; font-weight: 400; color: var(--ink-2); }
.hero .d { font-size: 12.5px; color: var(--ink-2); }
.profitline { color: var(--ink-2); }
.profitline strong { color: var(--down); font-family: var(--font-display); font-size: 15px; font-variant-numeric: tabular-nums; }
.profitline .pct {
  display: inline-block; margin-inline-start: 4px; padding: 1px 7px; border-radius: 999px;
  background: var(--down-soft); color: var(--down); font-size: 11.5px; font-weight: 600;
}
.metric .sub.profitline { font-size: 13px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 13px 14px; display: flex; flex-direction: column; gap: 3px; }
.kpi .k { font-size: 11.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .03em; }
.kpi .v { font-family: var(--font-display); font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .d { font-size: 11.5px; color: var(--ink-3); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.bar .lab { font-size: 13px; }
.bar .val { font-family: var(--font-num); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bar .track { grid-column: 1 / -1; display: block; height: 8px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar .fill { display: block; height: 100%; border-radius: 5px; background: var(--brand); opacity: .9; }
.share { display: block; height: 4px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: 8px 0 2px; max-width: 220px; }
.share > span { display: block; height: 100%; border-radius: 3px; background: color-mix(in srgb, var(--brand) 55%, transparent); }

/* ---------- price update ---------- */
.priceitem { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--line); }
.priceitem:first-child { border-top: 0; }
.priceitem .main { flex: 1; min-width: 0; }
.priceitem .nm { font-weight: 600; font-size: 14px; }
.priceitem .sub { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.priceitem .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.priceinput {
  width: 104px; flex: none; text-align: center; min-height: 44px; padding: 8px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface);
  font-family: var(--font-num); font-size: 16px; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.priceinput::-webkit-outer-spin-button, .priceinput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.priceinput:focus { border-color: var(--brand-text); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.priceinput.changed { border-color: var(--brand-text); background: var(--brand-soft); }


/* ---------- consumption basket ---------- */
.basket { display: flex; flex-direction: column; gap: 0; }
.brow { padding: 11px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.brow:first-child { border-top: 0; }
.brow .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brow .nm { flex: 1 1 auto; min-width: 45%; font-weight: 600; font-size: 14px; }
.brow .ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brow .ctl .mini { display: flex; flex-direction: column; gap: 3px; }
.brow .ctl .mini span { font-size: 10.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .03em; }
.minin {
  width: 84px; min-height: 40px; padding: 6px 10px; text-align: center;
  border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface);
  font-family: var(--font-num); font-size: 15px; font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.minin.wide { width: 100%; min-width: 96px; text-align: start; font-family: var(--font-body); font-size: 14px; }
.brow .ctl .mini span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brow .ctl .mini.grow { min-width: 96px; }
.minin::-webkit-outer-spin-button, .minin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.minin:focus { border-color: var(--brand-text); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.minsel { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface); font-size: 14px; }

/* ---------- quote ---------- */
.qline { padding: 11px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.qline:first-child { border-top: 0; }
.qline .top { display: flex; align-items: center; gap: 10px; }
.qline .nm { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.qline .calc { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.qline .calc .op { color: var(--ink-3); font-weight: 600; }
.qline .calc .unitprice { font-family: var(--font-num); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.markin {
  width: 78px; min-height: 40px; padding: 5px 8px; text-align: center;
  border: 1.5px solid var(--line-strong); border-radius: 11px; background: var(--surface); color: var(--ink);
  font-family: var(--font-num); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.markin:focus { border-color: var(--brand-text); box-shadow: 0 0 0 3px var(--brand-soft); }
.markin::-webkit-outer-spin-button, .markin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.markin:focus { outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.qtotal { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.qtotal.grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.qtotal .v { font-variant-numeric: tabular-nums; }
.previewwrap { background: var(--surface-2); border-radius: var(--r); padding: 10px; overflow-x: auto; }
.previewwrap canvas { display: block; width: 100%; max-width: 100%; height: auto; border-radius: 6px; box-shadow: var(--shadow); }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 38px 20px; color: var(--ink-2); }
.empty .ico { width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 15px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3); }
.empty .ico svg { width: 24px; height: 24px; }
.empty h3 { font-size: 16px; color: var(--ink); margin-bottom: 5px; }
.empty p { margin: 0 auto; max-width: 34ch; font-size: 13.5px; }

.toast {
  position: fixed; inset-inline: 16px; bottom: calc(var(--tab-h) + 22px + env(safe-area-inset-bottom, 0px)); z-index: 90;
  margin: 0 auto; max-width: 420px; padding: 13px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lift); animation: rise .2s ease;
}
.toast.bad { background: var(--brand); color: #fff; }

.banner { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.banner svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sh 1.3s linear infinite; border-radius: 10px; }
@keyframes sh { to { background-position: -200% 0 } }

.divider { height: 1px; background: var(--line); border: 0; margin: 4px 0; }


/* ---------- reports & charts ---------- */
.chartcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; }
.chartcard > figure { margin: 0; }
.charthead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.charthead h3 { font-size: 15px; }
.charthead .sub { font-size: 12px; color: var(--ink-2); }
.chartcard .toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 3px 11px; font-size: 11.5px; font-weight: 600; flex: none;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0 2px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chartsvg { display: block; width: 100%; height: auto; overflow: visible; }
.chartsvg .grid { stroke: var(--c-grid); stroke-width: 1; }
.chartsvg .axis { fill: var(--ink-3); font-size: 10px; font-family: var(--font-num); }
.chartsvg .lab { fill: var(--ink-2); font-size: 11px; }
.chartsvg .val { fill: var(--ink); font-size: 11px; font-weight: 600; font-family: var(--font-num); }
.chartsvg .hit { fill: transparent; cursor: pointer; }
.chartsvg .hit:focus-visible { outline: 2px solid var(--brand-text); }
.readout {
  min-height: 34px; margin-top: 8px; padding: 7px 11px; border-radius: 10px;
  background: var(--surface-2); font-size: 12.5px; color: var(--ink-2);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.readout strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.dtable { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.dtable th, .dtable td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: start; }
.dtable th { color: var(--ink-2); font-weight: 600; font-size: 11.5px; }
.dtable td.n { font-variant-numeric: tabular-nums; text-align: end; font-family: var(--font-num); }
.tablewrap { overflow-x: auto; }

.hbar { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; align-items: center; padding: 7px 0; }
.hbar + .hbar { border-top: 1px solid var(--line); }
.hbar .lab { font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .val { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.hbar .track { grid-column: 1 / -1; display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.hbar .seg { height: 100%; }
.hbar .seg.cost { background: var(--c-cost); border-radius: 5px 0 0 5px; }
.hbar .seg.profit { background: var(--c-profit); border-radius: 0 5px 5px 0; }
:root[dir="rtl"] .hbar .seg.cost { border-radius: 0 5px 5px 0; }
:root[dir="rtl"] .hbar .seg.profit { border-radius: 5px 0 0 5px; }

.insight { display: flex; gap: 11px; align-items: flex-start; width: 100%; text-align: start; padding: 12px 14px; border: 0; background: none; color: inherit; border-top: 1px solid var(--line); }
.insight:first-child { border-top: 0; }
.insight:active { background: var(--surface-2); }
.insight .ic { width: 30px; height: 30px; flex: none; border-radius: 10px; display: grid; place-items: center; }
.insight .ic svg { width: 16px; height: 16px; }
.insight .ic.good { background: var(--down-soft); color: var(--down); }
.insight .ic.bad { background: var(--up-soft); color: var(--up); }
.insight .ic.warn { background: var(--warn-soft); color: var(--warn); }
.insight .ic.info { background: var(--surface-2); color: var(--ink-2); }
.insight .tx { flex: 1; min-width: 0; }
.insight .tt { display: block; font-weight: 600; font-size: 14px; }
.insight .dd { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }

/* ---------------- sign in ---------------- */
.authwrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.authcard {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}
.authlogo { display: flex; justify-content: center; }
.authlogo .logo { width: 56px; height: 48px; }
.authcard h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}
.authsub { margin: -8px 0 4px; font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.authcard .stack { text-align: start; }
.authcard .btn.primary { min-height: 48px; margin-top: 4px; }
.autherr {
  font-size: 13px;
  line-height: 1.5;
  color: var(--up);
  background: var(--up-soft);
  border-radius: 10px;
  padding: 9px 12px;
  text-align: start;
}
.linkbtn {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  padding: 6px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.linkbtn:hover { color: var(--brand); }
.pendingmark { display: flex; justify-content: center; padding: 8px 0 4px; }
.pendingmark svg { width: 40px; height: 40px; color: var(--ink-3); stroke-width: 1.4; }
