/* CaisseTech distributor dashboard (P9 item 2).
   Phone first: one column, 44 px targets, readable at 360 px wide. Dark mode
   follows the phone. All spacing is logical, so Arabic (rtl) needs no rule. */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --accent: #16a34a;
  --accent-ink: #ffffff;
  --warn-bg: #fef3c7;
  --warn-line: #f59e0b;
  --warn-ink: #78350f;
  --error: #b91c1c;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #111a2e;
    --ink: #e2e8f0;
    --muted: #94a3b8;
    --line: #1e293b;
    --accent: #22c55e;
    --accent-ink: #04210f;
    --warn-bg: #2a2205;
    --warn-line: #a16207;
    --warn-ink: #fde68a;
    --error: #fca5a5;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Tahoma, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.pwa { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-block-start)) 16px 10px;
  background: var(--card);
  border-block-end: 1px solid var(--line);
}
.brand { font-weight: 800; color: var(--accent); letter-spacing: .2px; }
.brand-sub { font-weight: 500; color: var(--muted); font-size: .85rem; }
.lang {
  min-width: 44px; min-height: 40px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
  font: inherit; font-size: .85rem; padding: 8px 14px;
}
.lang:active { background: var(--line); }
.screen { padding: 14px 14px calc(24px + env(safe-area-inset-block-end)); display: grid; gap: 12px; }
.screen-center { align-content: start; justify-items: center; padding-block-start: 60px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 14px;
}
.card h1 { font-size: 1.2rem; margin: 0 0 6px; }
.card h2 { font-size: 1.02rem; margin: 0 0 4px; }
.card p { margin: 0 0 8px; }
.card.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.hint { color: var(--muted); font-size: .92rem; }
.small { font-size: .86rem; color: var(--muted); }
.warn-text { color: var(--warn-ink); font-weight: 600; }
.error { color: var(--error); font-weight: 600; }
.notice {
  margin: 0; padding: 12px 16px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; text-align: center;
}
/* ---- the figures of one seller ---- */
.seller-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chip {
  flex: none;
  font-size: .8rem; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.chip-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-block: 12px; }
.figure {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 76px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  text-align: start; font: inherit; color: inherit;
}
.figure:active { border-color: var(--accent); }
.figure-value { font-size: 1.08rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.figure-label { font-size: .8rem; color: var(--muted); }
.figure-sub { font-size: .72rem; color: var(--muted); }
.seller-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* ---- forms ---- */
.field { display: grid; gap: 4px; margin-block-end: 10px; }
.field > span { font-size: .86rem; color: var(--muted); }
.field input, .field textarea, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 16px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink);
  font: inherit; font-weight: 700; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 40px; font-size: .88rem; }
.btn.ghost { background: transparent; font-weight: 600; }
.btn:disabled { opacity: .6; }
.form { display: grid; gap: 4px; }
.form .btn { margin-block-start: 6px; }
.expense { display: grid; gap: 8px; padding-block: 10px; border-block-end: 1px solid var(--line); }
.sum { font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.9; }
/* ---- the sheet that opens under a figure ---- */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(15 23 42 / 55%); z-index: 9; }
.sheet {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 10;
  max-height: 86dvh; display: flex; flex-direction: column;
  background: var(--card); color: var(--ink);
  border-radius: 20px 20px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-block-end));
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-block-end: 10px; }
.sheet-head h2 { margin: 0; font-size: 1.05rem; }
.sheet-body { overflow: auto; }
/* ---- the rows behind a figure ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 8px 8px; text-align: start; border-block-end: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td { font-variant-numeric: tabular-nums; }
.total { margin-block: 10px 0; font-weight: 700; }
.thread-last, .notes { font-size: .9rem; }
.notes { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; gap: 8px; }
.notes li { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); }
.note-support { background: var(--bg); }
.note-client { border-color: var(--accent); }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-block-start-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
@media (min-width: 420px) {
  .screen { max-width: 560px; margin-inline: auto; width: 100%; }
  .figures { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}
/* E3: seller phones */
.phone-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--line, #ddd); }
.phone-row .btn { margin-inline-start: auto; }
.big-code { font-size: 2.2rem; font-weight: 700; letter-spacing: .3rem; text-align: center; margin: .5rem 0; }
