/* fitbandweb demo — RTL Hebrew UI, light + dark */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --meter-track: #cde2fb;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --shadow: 0 1px 3px rgba(11, 11, 11, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text-1: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.16);
    --meter-track: #184f95;
    --good-text: #0ca30c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --text-1: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-wash: rgba(57, 135, 229, 0.16);
  --meter-track: #184f95;
  --good-text: #0ca30c;
  --shadow: none;
}

html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
}

.app { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 224px; flex-shrink: 0;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  padding: 20px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 0 10px 16px; }
.logo .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.logo .name { font-weight: 700; font-size: 16px; }
.logo .sub { font-size: 11px; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--accent-wash); }
.nav a.active { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.nav .icon { width: 20px; text-align: center; }
.nav hr { border: 0; border-top: 1px solid var(--border); margin: 8px 4px; }
.sidebar .foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }

/* ---------- main / topbar ---------- */
main { flex: 1; min-width: 0; padding: 0 28px 48px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0 12px; margin-bottom: 16px;
  background: var(--page); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.menu-btn { display: none; font-size: 16px; }
.menu-backdrop { display: none; }
.topbar .spacer { flex: 1; }
.sync-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
  background: var(--surface);
}
.sync-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }

/* ---------- generic ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.card .card-sub { font-size: 12px; color: var(--muted); margin-top: -10px; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: minmax(0, 1fr); } }
.mt { margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right-ltr { direction: ltr; unicode-bidi: embed; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid transparent; border-radius: 9px;
  padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--surface); color: var(--text-1); border-color: var(--border); }
.btn.ghost:hover { background: var(--accent-wash); filter: none; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.danger { background: var(--critical); }
.btn[disabled] { opacity: 0.5; cursor: default; }

input[type="text"], input[type="number"], input[type="date"], input[type="email"],
select, textarea {
  font-family: inherit; font-size: 13px; color: var(--text-1);
  background: var(--surface); border: 1px solid var(--baseline);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
label.fld { display: block; font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 12px; }
label.fld > span { display: block; margin-bottom: 4px; }
.fld-row { display: flex; gap: 12px; }
.fld-row > * { flex: 1; }

/* ---------- stat tiles ---------- */
.tile .label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.tile .value { font-size: 27px; font-weight: 650; margin-top: 4px; }
.tile .delta { font-size: 12px; margin-top: 3px; color: var(--text-2); }
.tile .delta.up { color: var(--good-text); }
.tile .delta.down { color: var(--critical); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: right; font-size: 11.5px; font-weight: 600; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
.tbl td { padding: 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.rowlink { cursor: pointer; }
.tbl tr.rowlink:hover td { background: var(--accent-wash); }
.tbl .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .actions { white-space: nowrap; }
a.lnk { color: var(--accent); text-decoration: none; font-weight: 600; }
a.lnk:hover { text-decoration: underline; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; border-radius: 999px;
  padding: 3px 10px; white-space: nowrap; color: var(--text-1);
  border: 1px solid transparent;
}
.chip .ic { font-weight: 700; }
.chip.ok      { background: rgba(12, 163, 12, 0.13); }
.chip.ok .ic  { color: var(--good); }
.chip.warn    { background: rgba(250, 178, 25, 0.16); }
.chip.warn .ic{ color: #a86e00; }
.chip.crit    { background: rgba(208, 59, 59, 0.13); }
.chip.crit .ic{ color: var(--critical); }
.chip.open    { background: var(--accent-wash); }
.chip.open .ic{ color: var(--accent); }
.chip.neutral { background: transparent; border-color: var(--baseline); color: var(--text-2); }

/* ---------- meter ---------- */
.meter { height: 8px; border-radius: 999px; background: var(--meter-track); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter > i.done { background: var(--good); }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-row .meter { flex: 1; }
.meter-row .pct { font-size: 12px; font-weight: 700; min-width: 38px; }

/* ---------- chart ---------- */
.chart-box { direction: ltr; position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-box .bar { cursor: pointer; }
.chart-tip {
  position: absolute; pointer-events: none; display: none;
  background: var(--text-1); color: var(--page);
  font-size: 12px; padding: 5px 9px; border-radius: 7px; white-space: nowrap;
  transform: translate(-50%, -110%); direction: rtl; z-index: 3;
}

/* ---------- banner ---------- */
.banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent-wash); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px;
}

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; width: min(640px, 100%); max-height: 88vh;
  overflow-y: auto; padding: 22px;
}
.modal h3 { font-size: 16px; margin-bottom: 4px; }
.modal .modal-sub { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.modal .msg-preview {
  background: var(--page); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; white-space: pre-wrap; font-size: 13px; margin-bottom: 14px;
}
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- pipeline (new order simulation) ---------- */
.pipe { list-style: none; }
.pipe li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--grid); }
.pipe li:last-child { border-bottom: 0; }
.pipe .st { width: 22px; text-align: center; flex-shrink: 0; }
.pipe .st.done { color: var(--good); font-weight: 700; }
.pipe .desc .d2 { font-size: 12px; color: var(--text-2); margin-top: 2px; white-space: pre-wrap; }
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--grid); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text-1); color: var(--page);
  border-radius: 10px; padding: 10px 16px; font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- activity ---------- */
.feed { list-style: none; }
.feed li { display: flex; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--grid); }
.feed li:last-child { border-bottom: 0; }
.feed .fic {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; background: var(--accent-wash); font-size: 14px;
}
.feed .fts { font-size: 11.5px; color: var(--muted); }

/* ---------- portal ---------- */
.portal-head {
  background: linear-gradient(120deg, var(--accent), #4a3aa7);
  color: #fff; border-radius: 14px; padding: 22px; margin-bottom: 14px;
}
.portal-head h2 { font-size: 20px; }
.portal-head p { opacity: 0.9; font-size: 13px; }

/* ---------- new order items ---------- */
.item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.item-row select { flex: 3; }
.item-row input { flex: 1; }
.item-row .line-total { min-width: 84px; text-align: left; font-variant-numeric: tabular-nums; font-size: 13px; }
.item-row .rm { background: none; border: none; color: var(--critical); cursor: pointer; font-size: 15px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 500; }

@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  /* Sidebar becomes an off-canvas drawer, opened by the ☰ button in the top bar. */
  .sidebar {
    position: fixed; top: 0; right: 0; height: 100vh; z-index: 60;
    transform: translateX(100%); transition: transform 0.22s ease;
  }
  body.menu-open .sidebar { transform: translateX(0); box-shadow: 0 0 32px rgba(0, 0, 0, 0.35); }
  .menu-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 55; }
  body.menu-open .menu-backdrop { display: block; }
  .topbar { flex-wrap: wrap; }
  main { padding: 0 14px 40px; }
  .cols-4, .cols-2 { grid-template-columns: minmax(0, 1fr); }
}
