/* ============================================================================
   MME · Huawei B2B — design system
   Tokens first (light, then dark), then shell, components, pages.
   ========================================================================== */

@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-arabic-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-arabic-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* chart roles (validated: categorical adjacent CVD >= 9, ordinal monotone, vs white card) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --o1: #86b6ef; --o2: #5598e7; --o3: #2a78d6; --o4: #1c5cab; --o5: #104281;
  --grid: #ebeae6; --axisline: #c3c2b7; --ink-muted: #6f6e69; --up: #006300; --down: #d03b3b;

  /* surfaces & text */
  --bg: #f4f6f9; --card: #fff; --card-2: #f8fafc; --ink: #0f1c2e; --muted: #64748b; --line: #e4e9f0; --line-2: #eef2f6;
  /* brand: MME teal + deep navy */
  --brand: #00819e; --brand-2: #00a3b8; --accent: #0f5bb5; --accent-ink: #fff; --logo-bg: transparent;
  --ring: color-mix(in srgb, var(--accent) 28%, transparent);
  /* status */
  --ok: #15803d; --warn: #b45309; --bad: #c42b43; --info: #1d5fbf; --neutral: #64748b;
  /* sidebar is dark in both themes */
  --side: #0b1b2e; --side-2: #10243b; --side-ink: #d6e1ee; --side-muted: #8aa0b8; --side-line: rgba(255, 255, 255, .07);
  --side-active: rgba(0, 163, 184, .16);
  /* top navigation (soft blue bar, segmented page switcher) */
  --nav-bg: #eaf1f8; --nav-line: #d8e3ef; --nav-seg: #dde8f3; --nav-ink: #44566c; --nav-active: #fff;

  --radius: 12px; --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 28, 46, .05);
  --shadow: 0 1px 2px rgba(15, 28, 46, .04), 0 2px 8px rgba(15, 28, 46, .05);
  --shadow-lg: 0 12px 32px -8px rgba(15, 28, 46, .22), 0 4px 12px -4px rgba(15, 28, 46, .1);
  --font: "Plex Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
}
/* dark: follows Windows unless the user picked a theme (data-theme on <html>, see theme.js) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --o1: #1c5cab; --o2: #2a78d6; --o3: #5598e7; --o4: #86b6ef; --o5: #b7d3f6;
    --grid: #233041; --axisline: #344255; --ink-muted: #9aa8b8; --up: #22c55e; --down: #f07171;
    --bg: #0a111b; --card: #111a26; --card-2: #0e1621; --ink: #e7eef6; --muted: #8b9bb0; --line: #1f2b3b; --line-2: #18232f;
    --brand: #22b8cf; --brand-2: #4fd1e0; --accent: #3b8fea; --logo-bg: #fff;
    --ok: #34c873; --warn: #f0a63a; --bad: #f2667d; --info: #6aa8f5; --neutral: #8b9bb0;
    --side: #070e17; --side-2: #0c1622; --side-line: rgba(255, 255, 255, .06);
    --nav-bg: #0f1823; --nav-line: #1f2b3b; --nav-seg: #172333; --nav-ink: #9fb0c3; --nav-active: #24344a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 10px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6); }
}
:root[data-theme="dark"] { color-scheme: dark; --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --o1: #1c5cab; --o2: #2a78d6; --o3: #5598e7; --o4: #86b6ef; --o5: #b7d3f6;
    --grid: #233041; --axisline: #344255; --ink-muted: #9aa8b8; --up: #22c55e; --down: #f07171;
    --bg: #0a111b; --card: #111a26; --card-2: #0e1621; --ink: #e7eef6; --muted: #8b9bb0; --line: #1f2b3b; --line-2: #18232f;
    --brand: #22b8cf; --brand-2: #4fd1e0; --accent: #3b8fea; --logo-bg: #fff;
    --ok: #34c873; --warn: #f0a63a; --bad: #f2667d; --info: #6aa8f5; --neutral: #8b9bb0;
    --side: #070e17; --side-2: #0c1622; --side-line: rgba(255, 255, 255, .06);
    --nav-bg: #0f1823; --nav-line: #1f2b3b; --nav-seg: #172333; --nav-ink: #9fb0c3; --nav-active: #24344a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 10px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12.5px; }
::selection { background: color-mix(in srgb, var(--brand) 25%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; display: block; }
[dir="rtl"] svg.i.flip { transform: scaleX(-1); }

/* ---- scrollbars ---- */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 10px;
  border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--muted) 60%, transparent); }

/* ============================================================================
   Shell: dark top navigation bar + content
   ========================================================================== */
.shell { min-height: 100vh; }
.navbar { position: sticky; top: 0; z-index: 30; color: var(--ink); background: var(--nav-bg); border-bottom: 1px solid var(--nav-line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 22px; height: 62px; padding: 0 28px; }
.nb-brand { display: flex; align-items: center; gap: 11px; flex: none; }
.logo-tile { display: grid; place-items: center; width: 46px; height: 38px; border-radius: 10px; background: #fff;
  border: 1px solid var(--line); flex: none; }
.logo-tile .logo { width: 36px; height: auto; display: block; }
.nb-title { display: flex; flex-direction: column; line-height: 1.25; }
.nb-title strong { color: var(--ink); font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.nb-title small { color: var(--muted); font-size: 11px; letter-spacing: .04em; }

.tabs { display: flex; align-items: center; gap: 2px; flex: 0 1 auto; min-width: 0; padding: 4px; border-radius: 12px; background: var(--nav-seg); }
.tab, .tab-more { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border: 0; border-radius: 9px;
  background: transparent; color: var(--nav-ink); font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s; }
.tab svg.i, .tab-more svg.i { width: 17px; height: 17px; opacity: .85; }
.tab:hover, .tab-more:hover, .tab-more[aria-expanded="true"] { background: color-mix(in srgb, var(--nav-active) 60%, transparent); color: var(--ink); }
.tabs > .tab.active, .nav-more:has(.tab.active) > .tab-more { color: var(--accent); font-weight: 600; background: var(--nav-active);
  box-shadow: 0 1px 3px rgba(15, 28, 46, .14); }
.tabs > .tab.active svg.i, .nav-more:has(.tab.active) > .tab-more svg.i { color: var(--accent); opacity: 1; }
.tab-more .chev, .user-btn .chev { width: 14px !important; height: 14px !important; opacity: .7; transition: transform .15s; }
.tab-more[aria-expanded="true"] .chev, .user-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.nav-sep { width: 1px; height: 20px; background: var(--nav-line); margin: 0 6px; flex: none; }
.nav-sep:first-child, .tab.hidden + .tab.hidden + .nav-sep { display: none; }

.nav-count { margin-inline-start: 2px; min-width: 20px; height: 19px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums; background: color-mix(in srgb, var(--nav-ink) 18%, transparent); color: var(--ink); }
.nav-count.bad { background: #e5484d; color: #fff; }
.nav-count:empty { display: none; }

/* drop-down menus (Logs, user) */
.nav-more, .nb-user { position: relative; }
.menu { position: absolute; top: calc(100% + 14px); inset-inline-start: 0; z-index: 50; min-width: 220px; padding: 6px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); animation: dlg-in .14s ease-out; }
.nb-user .menu { inset-inline-start: auto; inset-inline-end: 0; }
.menu .tab, .menu-item { display: flex; width: 100%; height: 38px; gap: 10px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink); font: inherit; font-size: 13px; font-weight: 500; text-align: start; cursor: pointer; align-items: center; }
.menu .tab svg.i, .menu-item svg.i { width: 16px; height: 16px; color: var(--muted); opacity: 1; }
.menu .tab:hover, .menu-item:hover { background: var(--card-2); color: var(--ink); }
.menu .tab.active { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.menu .tab.active svg.i { color: var(--accent); }
.menu-item.danger:hover { color: var(--bad); }
.menu-item.danger:hover svg.i { color: var(--bad); }
.menu-label { padding: 10px 10px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  border-top: 1px solid var(--line-2); margin-top: 4px; }

/* user */
.nb-user { flex: none; }
.user-btn { display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 8px 0 4px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--muted); font: inherit; cursor: pointer; }
[dir="rtl"] .user-btn { padding: 0 4px 0 8px; }
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--card-2); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.me { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex: none; font-size: 12.5px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--brand-2), #1b6fd1); letter-spacing: .02em; }
.user-btn .who { display: none; }
.menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line-2); }
.menu-head b { display: block; font-size: 13px; font-weight: 600; }
.menu-head small { display: block; color: var(--muted); font-size: 11.5px; }
.who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; text-align: start; }
.who b { color: #fff; font-weight: 600; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.who small { color: var(--side-muted); font-size: 11px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 63px; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px 20px;
  flex-wrap: wrap; padding: 14px 28px; min-height: 72px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid transparent; }
.title { display: flex; flex-direction: column; min-width: 0; }
.crumb { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; direction: ltr; text-align: start; }
.crumb i { font-style: normal; opacity: .5; margin: 0 4px; }
.title h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; line-height: 1.35; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.actions > .muted { font-size: 12px; }
main { padding: 22px 28px 48px; }
.panel { animation: panel-in .25s ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel h3 { margin: 0; font-size: 15px; font-weight: 600; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 28px 2px 12px; }

/* ---- env badge / live light ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 4px 10px; border-radius: 999px;
  background: var(--line); font-weight: 700; letter-spacing: .06em; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge:empty { display: none; }
.badge.mock { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge.test { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.badge.prod { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.live-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .18), 0 0 8px 2px rgba(34, 197, 94, .55); flex: none; }
/* syncing: flashing red; idle: steady glowing green */
.live-dot.syncing { background: #ef4444; animation: live-blink-red 0.9s ease-in-out infinite; }
@keyframes live-blink-red {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 3px rgba(239, 68, 68, .2), 0 0 10px 3px rgba(239, 68, 68, .75); }
  50% { opacity: .2; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0), 0 0 0 0 rgba(239, 68, 68, 0); }
}
@media (prefers-reduced-motion: reduce) { .live-dot.syncing { animation-duration: 2.4s; } }

/* ============================================================================
   Buttons & form controls
   ========================================================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); padding: 7px 14px; min-height: 36px; border-radius: var(--radius-sm);
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s, transform .05s; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--card-2); }
.btn:active { transform: translateY(1px); }
.btn svg.i { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(11, 92, 173, .2); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: color-mix(in srgb, var(--accent) 88%, #000); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary.spinning svg.i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.primary.spinning svg.i { animation: none; } }
.btn.icon { padding: 0; width: 36px; min-width: 36px; }
.btn.icon svg { display: block; }
.btn.icon.lang { width: auto; padding: 0 12px; font-weight: 600; font-size: 12.5px; }

input, select, textarea { font: inherit; }
.toolbar input, .toolbar select, .field input, .field select, .field textarea, td input.qty, .users-role select {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink);
  transition: border-color .15s, box-shadow .15s; }
.toolbar input:focus, .toolbar select:focus, .field input:focus, .field select:focus, .field textarea:focus, td input.qty:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
select { cursor: pointer; }

/* ============================================================================
   Banners & notes
   ========================================================================== */
.banner { display: flex; align-items: center; gap: 10px; margin: 18px 28px 0; padding: 10px 16px; border-radius: 10px; font-size: 13px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-inline-start: 3px solid var(--warn); box-shadow: var(--shadow-sm); }
.banner svg.i { color: var(--warn); }
.banner.info { background: color-mix(in srgb, var(--accent) 8%, var(--card)); color: var(--ink); border-color: var(--line); }
.banner.err { display: block; background: color-mix(in srgb, var(--bad) 9%, var(--card)); color: color-mix(in srgb, var(--bad) 80%, var(--ink));
  border-color: color-mix(in srgb, var(--bad) 28%, transparent); white-space: pre-wrap; font-family: Consolas, monospace; font-size: 12px; }
.banner.err.hidden, .banner.hidden { display: none !important; }

/* ============================================================================
   Overview: action center, connection status, workflow pipeline, timeline
   ========================================================================== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head p { margin: 2px 0 0; }
.ov-top { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 18px; }
.ov-top .card { margin-bottom: 18px; }

.total-chip { min-width: 34px; height: 28px; padding: 0 10px; border-radius: 999px; display: inline-grid; place-items: center;
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.total-chip.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.total-chip.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.todo-list { display: flex; flex-direction: column; }
.todo { --tone: var(--neutral); display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  padding: 12px 4px; border-top: 1px solid var(--line-2); }
.todo:first-child { border-top: 0; padding-top: 2px; }
.todo.bad { --tone: var(--bad); } .todo.warn { --tone: var(--warn); } .todo.neutral { --tone: var(--info); }
.todo-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: color-mix(in srgb, var(--tone) 11%, transparent); color: var(--tone); }
.todo-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.todo-txt b { font-weight: 600; font-size: 13.5px; }
.todo-txt small { color: var(--muted); font-size: 12px; }
.todo-n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 40px; text-align: end; }
.todo.zero { --tone: var(--neutral); }
.todo.zero .todo-n { color: var(--muted); font-weight: 600; }
.all-clear { display: flex; align-items: center; gap: 10px; padding: 18px 4px; color: var(--ok); font-weight: 600; }

.kv { margin: 0; display: grid; gap: 0; }
.kv > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-2); }
.kv > div:first-child { border-top: 0; padding-top: 2px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; font-weight: 600; font-size: 13px; text-align: end; display: inline-flex; align-items: center; gap: 7px; }
.env-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--neutral); }
.env-dot.mock { background: var(--warn); } .env-dot.test { background: var(--info); }
.env-dot.prod { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
.stage { --tone: var(--neutral); position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: start;
  padding: 16px 18px; border: 1px solid var(--line); background: var(--card-2); color: var(--ink); font: inherit; cursor: pointer;
  margin-inline-end: -1px; transition: background .15s, border-color .15s, box-shadow .15s; }
.stage:first-child { border-start-start-radius: 10px; border-end-start-radius: 10px; }
.stage:last-child { border-start-end-radius: 10px; border-end-end-radius: 10px; margin-inline-end: 0; }
.stage:hover { background: var(--card); position: relative; z-index: 1; border-color: color-mix(in srgb, var(--tone) 45%, var(--line)); box-shadow: var(--shadow); }
.stage:not(:last-child)::after { content: ""; position: absolute; z-index: 2; top: 50%; inset-inline-end: -8px; width: 14px; height: 14px;
  background: var(--card-2); border-top: 1px solid var(--line); border-inline-end: 1px solid var(--line); transform: translateY(-50%) rotate(45deg); }
[dir="rtl"] .stage:not(:last-child)::after { transform: translateY(-50%) rotate(-45deg); }
.stage:hover::after { background: var(--card); }
.stage.bad { --tone: var(--bad); } .stage.warn { --tone: var(--warn); } .stage.info { --tone: var(--info); } .stage.ok { --tone: var(--ok); }
.stage-n { position: absolute; top: 14px; inset-inline-end: 18px; font-size: 11px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.stage-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; margin-bottom: 10px;
  background: color-mix(in srgb, var(--tone) 12%, transparent); color: var(--tone); }
.stage-ico svg.i { width: 18px; height: 18px; }
.stage-v { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stage-l { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stage-sub { margin-top: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 2px 8px; border-radius: 999px; background: var(--line-2); }
.stage-sub.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.stage-sub:hover { text-decoration: underline; }

.timeline { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow: auto; }
.tl { --tone: var(--neutral); position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding: 0 2px 16px; }
.tl:not(:last-child)::before { content: ""; position: absolute; top: 34px; bottom: 0; inset-inline-start: 18px; width: 1px; background: var(--line); }
.tl.ok { --tone: var(--ok); } .tl.bad { --tone: var(--bad); } .tl.warn { --tone: var(--warn); } .tl.info { --tone: var(--info); }
.tl-dot { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: color-mix(in srgb, var(--tone) 12%, var(--card)); color: var(--tone); border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent); }
.tl-dot svg.i { width: 16px; height: 16px; }
.tl-body { padding-top: 5px; min-width: 0; }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-head b { font-weight: 600; font-size: 13.5px; }
.tl-head code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 11.5px; padding: 1px 7px; border-radius: 6px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--ink); }
.tl-head time { margin-inline-start: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-body p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.tl-empty { color: var(--muted); padding: 24px; text-align: center; }

@media (max-width: 1200px) {
  .ov-top { grid-template-columns: 1fr; gap: 0; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
  .stage { border-radius: 10px !important; margin: 0; }
  .stage::after { display: none; }
}

/* ============================================================================
   Toolbars, segmented controls
   ========================================================================== */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { height: 38px; padding: 0 12px; font-size: 13px; }
.toolbar select { padding-inline-end: 8px; }
.toolbar input { min-width: 260px; flex: 1; max-width: 420px; padding-inline-start: 36px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat;
  background-position: left 12px center; }
[dir="rtl"] .toolbar input { background-position: right 12px center; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: color-mix(in srgb, var(--muted) 10%, var(--card));
  border: 1px solid var(--line); border-radius: 11px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 14px; cursor: pointer; font: inherit;
  font-size: 13px; font-weight: 500; border-radius: 8px; transition: background .15s, color .15s, box-shadow .15s; }
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--card); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 28, 46, .12), 0 0 0 1px var(--line); }

/* ============================================================================
   Tables
   ========================================================================== */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: 70vh;
  box-shadow: var(--shadow); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); text-align: start; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--card-2); color: var(--muted); font-weight: 600; font-size: 11.5px;
  letter-spacing: .02em; z-index: 1; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { font-variant-numeric: tabular-nums; text-align: end; }
td.wrap { white-space: normal; min-width: 220px; max-width: 360px; }
tbody tr { transition: background .12s; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--card-2) 70%, transparent); }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); cursor: pointer; }
td.empty { text-align: center; color: var(--muted); padding: 48px 20px; cursor: default; font-size: 13.5px; }

/* ---- status pills ---- */
.pill { --pc: var(--neutral); display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5; color: color-mix(in srgb, var(--pc) 88%, var(--ink));
  background: color-mix(in srgb, var(--pc) 12%, transparent); border: 1px solid color-mix(in srgb, var(--pc) 22%, transparent); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--pc); flex: none; }
.pill.new { --pc: var(--info); }
.pill.chg { --pc: var(--warn); }
.pill.cnl { --pc: var(--bad); }
.pill.ok { --pc: var(--ok); }
.pill.pend { --pc: var(--warn); }
.pill.bad { --pc: var(--bad); }
.pill.gray { --pc: var(--neutral); }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; color: var(--muted); font-size: 12.5px; }
.pager .btns { display: flex; gap: 6px; }

/* ============================================================================
   Dialogs
   ========================================================================== */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(760px, 94vw); background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-lg); }
dialog[open] { animation: dlg-in .18s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: rgba(8, 15, 26, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg-head strong { font-size: 15.5px; font-weight: 600; }
.dlg-head .btn { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); min-height: 32px; padding: 4px 10px; }
.dlg-head .btn:hover { background: var(--card-2); color: var(--ink); border-color: var(--line); }
dialog pre { margin: 0; padding: 18px 20px; max-height: 70vh; overflow: auto; direction: ltr; text-align: left; font-size: 12px;
  background: var(--card-2); font-family: Consolas, "Cascadia Mono", monospace; }

@media (max-width: 640px) {
  main { padding-left: 14px; padding-right: 14px; }
  .toolbar input { min-width: 0; width: 100%; max-width: none; }
}

/* ---- phase 2: actions ---- */
.btn.danger { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); color: var(--bad); }
.btn.danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.link { border: none; background: none; box-shadow: none; color: var(--accent); padding: 6px 8px; min-height: 0; }
.btn.link:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.btn.sm { padding: 3px 10px; min-height: 28px; font-size: 12px; border-radius: 7px; }
.actionbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 14px;
  background: color-mix(in srgb, var(--accent) 8%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 12px; box-shadow: var(--shadow); animation: panel-in .2s ease-out; }
.actionbar .count { font-weight: 600; margin-inline-end: auto; color: var(--accent); }
td.sel, th.sel { width: 40px; text-align: center; }
td.sel input, th.sel input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
tr.selected, tr.selected:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

dialog.wide { width: min(980px, 96vw); }
.dlg-body { padding: 18px 20px; max-height: 70vh; overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--card-2);
  border-end-start-radius: 16px; border-end-end-radius: 16px; }
form.dlg-body .dlg-foot { margin: 14px -20px -18px; }
.dlg-body table { font-size: 12.5px; }
.dlg-body .table-wrap { max-height: 38vh; margin: 8px 0 14px; box-shadow: none; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea, td input.qty { padding: 8px 11px; font-size: 13.5px; }
td input.qty { width: 110px; padding: 5px 8px; text-align: end; }
td input.qty.bad { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 14px; }
.msg { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; white-space: pre-wrap; }
.note { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--accent) 7%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); }
.note.warn { background: color-mix(in srgb, var(--warn) 9%, var(--card)); color: color-mix(in srgb, var(--warn) 70%, var(--ink));
  border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.note.ok { background: color-mix(in srgb, var(--ok) 9%, var(--card)); color: color-mix(in srgb, var(--ok) 70%, var(--ink));
  border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.files { list-style: none; padding: 0; margin: 6px 0 0; font-size: 12.5px; }
.files li { padding: 3px 0; }
.summary dt { color: var(--muted); font-size: 12px; margin-top: 8px; }
.summary dd { margin: 2px 0 0; font-weight: 600; }

/* ---- users ---- */
.temp-pw { font-family: Consolas, monospace; font-size: 18px; letter-spacing: 1px; padding: 10px 14px;
  background: var(--card-2); border: 1px dashed var(--accent); border-radius: 10px; display: inline-block; user-select: all; }
tr.inactive td { opacity: .5; }
#pwDlg .field { margin-bottom: 12px; }
#usersTable select { height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }

/* ---- column chooser ---- */
.cols-list { list-style: none; padding: 0; margin: 10px 0 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cols-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px;
  border-bottom: 1px solid var(--line-2); }
.cols-list li:last-child { border-bottom: 0; }
.cols-list li:hover { background: var(--card-2); }
.cols-list label { display: flex; align-items: center; gap: 10px; cursor: pointer; flex: 1; }
.cols-list input { accent-color: var(--accent); width: 16px; height: 16px; }
.cols-list span { display: flex; gap: 4px; }

/* ---- read-only local snapshot ---- */
.banner.snap { background: color-mix(in srgb, #6366f1 10%, var(--card)); color: var(--ink); border-color: color-mix(in srgb, #6366f1 28%, transparent); }
.live-dot.off { background: #94a3b8; box-shadow: none; animation: none; }

/* ============================================================================
   Analytics
   ========================================================================== */
.an-filters select { min-width: 160px; }
#tab-analytics.an-loading #anKpis, #tab-analytics.an-loading #anGrid { opacity: .55; transition: opacity .15s; }
.an-hero { position: relative; overflow: hidden; border-radius: var(--radius); padding: 22px 26px; margin-bottom: 16px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, rgba(0, 163, 184, .45), transparent 55%),
              linear-gradient(135deg, #0b2a4a 0%, #0b1b2e 100%);
  border: 1px solid rgba(255, 255, 255, .06); box-shadow: var(--shadow-lg); }
[dir="rtl"] .an-hero { background: radial-gradient(120% 140% at 0% 0%, rgba(0, 163, 184, .45), transparent 55%),
              linear-gradient(225deg, #0b2a4a 0%, #0b1b2e 100%); }
.an-hero .l { color: rgba(255, 255, 255, .72); font-size: 13px; font-weight: 500; }
.an-hero .v { font-size: 52px; font-weight: 700; line-height: 1.1; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.an-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 14px; margin-bottom: 20px; }
.an-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.an-tile .v { font-size: 23px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.an-tile .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; font-weight: 500; }
.an-tile .s { color: var(--muted); font-size: 12px; margin-top: 8px; border-top: 1px solid var(--line-2); padding-top: 7px; }
.an-delta { font-size: 12.5px; margin-top: 4px; font-weight: 600; }
.an-delta.up { color: var(--up); } .an-delta.down { color: var(--down); }
.an-delta span { color: var(--muted); font-weight: 400; }
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 16px; }
.an-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; box-shadow: var(--shadow); }
.an-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.an-head h4 { margin: 0; font-size: 14.5px; font-weight: 600; }
.an-head p { margin: 2px 0 0; font-size: 12px; }
.an-body { margin-top: 12px; min-height: 60px; }
.an-body svg { display: block; max-width: 100%; height: auto; }
.an-grid line.an-grid, svg .an-grid { stroke: var(--grid); stroke-width: 1; }
svg .an-base { stroke: var(--axisline); stroke-width: 1; }
svg .an-axis { fill: var(--ink-muted); font-size: 11px; font-family: var(--font); }
svg .an-val { fill: var(--ink); font-size: 11.5px; font-weight: 600; font-family: var(--font); }
svg .an-cross { stroke: var(--axisline); stroke-width: 1; }
svg .an-hit:hover { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.an-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.an-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }
.hb { display: flex; flex-direction: column; gap: 8px; }
.hb-row { display: grid; grid-template-columns: minmax(90px, 36%) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hb-label { min-width: 0; }
.hb-label span { display: block; overflow-wrap: anywhere; }
.hb-label small { display: block; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.hb-track { height: 14px; }
.hb-bar { height: 14px; border-start-end-radius: 4px; border-end-end-radius: 4px; min-width: 2px; }
.hb-val { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.hb-row:hover .hb-bar { filter: brightness(1.08); }
.an-table { max-height: 320px; }
.an-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font-size: 12px; box-shadow: var(--shadow-lg); min-width: 140px; }
.an-tip-title { font-weight: 600; margin-bottom: 4px; }
.an-tip-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.an-tip-row b { font-variant-numeric: tabular-nums; }
.an-tip-row span:last-child { color: var(--muted); }
.an-key { display: inline-block; width: 12px; height: 2px; border-radius: 1px; }
@media (max-width: 640px) { .an-hero .v { font-size: 38px; } .hb-row { grid-template-columns: minmax(70px, 40%) 1fr auto; } }

/* ---- theme toggle ---- */
.login .theme { position: absolute; inset-inline-start: 14px; top: 14px; width: auto; margin: 0; padding: 4px 8px; }

/* ---- hidden analytics code box ---- */
#anCodeDlg { width: min(260px, 90vw); }
.an-code input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  color: var(--ink); font: inherit; font-size: 18px; letter-spacing: 4px; text-align: center; }
.an-code .msg { text-align: center; }

@media (prefers-reduced-motion: reduce) { .panel, .kpi, dialog[open] { animation: none; transition: none; } }

/* ============================================================================
   Responsive top bar: labels give way to icons as the screen narrows
   ========================================================================== */
@media (max-width: 1560px) {
  .nb-title { display: none; }
}
@media (max-width: 1340px) {
  .tabs > .tab:not(.active) span, .tab-more span { display: none; }
  .tabs > .tab:not(.active) { padding: 0 10px; }
  .nav-count { position: absolute; top: 2px; inset-inline-end: 0; min-width: 17px; height: 16px; padding: 0 4px; font-size: 9.5px; }
  .tabs > .tab.active .nav-count { position: static; }
  .tabs > .tab:not(.active) .nav-count:not(.bad) { display: none; }
}
@media (max-width: 720px) {
  .nav-inner { gap: 10px; padding: 0 10px; height: 56px; }
  .top { top: 56px; position: static; padding: 12px 14px; }
  .logo-tile { width: 40px; height: 34px; }
  .logo-tile .logo { width: 30px; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs > .tab span { display: none; }
  .nav-sep { display: none; }
  .menu { position: fixed; top: 60px; inset-inline: 10px auto; }
  .nb-user .menu { inset-inline: auto 10px; }
  .banner { margin: 12px 14px 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { padding: 14px; }
  .stage-v { font-size: 22px; }
  .card { padding: 16px; }
  .todo { grid-template-columns: auto minmax(0, 1fr) auto; }
  .todo .btn { display: none; }
  .title h1 { font-size: 18px; }
}

/* ============================================================================
   Collections & cash flow
   ========================================================================== */
.cash-total { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; text-align: end; }
.cash-total b { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cash-total small { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; }
.cash-stages { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.cash-stage { --tone: var(--neutral); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--card-2);
  border-top: 3px solid var(--tone); }
.cash-stage.ok { --tone: var(--ok); } .cash-stage.warn { --tone: var(--warn); } .cash-stage.bad { --tone: var(--bad); } .cash-stage.info { --tone: var(--info); }
.cs-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cs-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: color-mix(in srgb, var(--tone) 12%, transparent); color: var(--tone); }
.cs-ico svg.i { width: 17px; height: 17px; }
.cs-share { font-size: 12px; font-weight: 700; color: var(--tone); font-variant-numeric: tabular-nums; }
.cs-v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.cs-l { font-weight: 600; font-size: 13px; margin-top: 4px; }
.cs-s { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.cash-bar { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; margin-top: 16px; background: var(--line-2); }
.cash-bar i { display: block; min-width: 3px; cursor: default; }
.cash-foot { margin: 10px 0 0; }

td.mini-bar { width: 160px; }
td.mini-bar span { display: flex; gap: 1px; height: 8px; border-radius: 999px; overflow: hidden; background: var(--line-2); }
td.mini-bar i { display: block; }
td.mini-bar em { display: none; }

.cash-aging { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.ag { --tone: var(--ok); display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 46px auto; gap: 4px 8px; align-items: end;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); }
.ag.warn { --tone: var(--warn); } .ag.bad { --tone: var(--bad); }
.ag-l { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-weight: 500; }
.ag-bar { grid-column: 1 / -1; display: flex; align-items: flex-end; height: 46px; }
.ag-bar i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--tone) 70%, transparent); }
.ag b { font-size: 20px; font-variant-numeric: tabular-nums; }
.ag small { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; text-align: end; }
#cashApprovers .table-wrap, .cash-acs { margin-bottom: 14px; box-shadow: none; }
.cash-acs { max-height: 420px; }
.cash-acs tr[data-ac] code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; color: var(--accent); }
.who-cell { display: inline-flex; align-items: center; gap: 8px; }
.avatar.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 11px; }

.assume { display: flex; gap: 10px; flex-wrap: wrap; }
.assume label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.assume input { width: 110px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink);
  font: inherit; font-variant-numeric: tabular-nums; }
.assume input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.fc-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.fc-tile { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card-2); }
.fc-tile i { width: 10px; height: 10px; border-radius: 3px; grid-row: 1 / 3; align-self: start; margin-top: 5px; }
.fc-tile span { font-size: 12px; color: var(--muted); }
.fc-tile b { font-size: 20px; font-variant-numeric: tabular-nums; }
#cashAssume { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }
#cashAssume b { color: var(--ink); }

@media (max-width: 1100px) {
  .cash-stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cash-aging { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fc-tiles { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .cash-stages, .cash-aging { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  td.mini-bar { display: none; }
}

/* ============================================================================
   Sync: header pill, details panel, toast
   ========================================================================== */
.sync-wrap { position: relative; }
.sync-wrap.snapshot .sp-ico { display: none; }
.sync-pill { position: relative; display: inline-flex; align-items: center; gap: 9px; height: 36px; padding: 0 12px 0 6px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font: inherit; font-size: 12.5px;
  cursor: pointer; box-shadow: var(--shadow-sm); overflow: hidden; transition: border-color .15s, background .15s; }
[dir="rtl"] .sync-pill { padding: 0 6px 0 12px; }
.sync-pill:hover, .sync-pill[aria-expanded="true"] { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--card-2); }
.sync-pill .badge { padding: 3px 9px; font-size: 10.5px; }
.sync-pill .live-dot { width: 9px; height: 9px; margin-inline: 6px 0; }
.sp-text { font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sp-ico { width: 15px !important; height: 15px !important; color: var(--muted); }
.sync-pill.running .sp-ico { color: var(--accent); animation: spin 1s linear infinite; }
.sync-pill.running .sp-text { color: var(--accent); }
.sync-pill.failed { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.sync-pill.failed .sp-text { color: var(--bad); }
.sp-line { position: absolute; inset: auto 0 0; height: 2px; }
.sp-line i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .6s ease; }
@media (prefers-reduced-motion: reduce) { .sync-pill.running .sp-ico { animation: none; } }

.sync-panel { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 40; width: 340px; max-width: calc(100vw - 24px);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); animation: dlg-in .16s ease-out; }
.spn-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.spn-head b { font-size: 14px; font-weight: 600; }
.spn-jobs { list-style: none; margin: 0; padding: 4px 16px 8px; display: grid; gap: 4px; }
.job { --tone: var(--muted); display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 4px 10px;
  padding: 8px 10px; border-radius: 9px; background: var(--card-2); font-size: 12.5px; }
.job-ico { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--tone); }
.job.done { --tone: var(--ok); } .job.done .job-ico { background: var(--ok); }
.job.done .job-ico::after { content: ""; width: 7px; height: 4px; border: 2px solid #fff; border-top: 0; border-inline-end: 0;
  transform: translateY(-1px) rotate(-45deg); }
[dir="rtl"] .job.done .job-ico::after { transform: translateY(-1px) rotate(-45deg) scaleX(-1); }
.job.running { --tone: var(--accent); } .job.running .job-ico { border-color: color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent); animation: spin .9s linear infinite; }
.job.error { --tone: var(--bad); } .job.error .job-val { color: var(--bad); font-weight: 600; }
.job.skipped .job-ico, .job.wait .job-ico, .job.none .job-ico { border-style: dashed; }
.job-name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
.job-bar { grid-column: 2 / -1; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; position: relative; }
.job-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .6s ease; }
.job-bar i.indet { position: absolute; animation: sp-indet 1.3s ease-in-out infinite; }
@keyframes sp-indet { 0% { inset-inline-start: -35%; } 100% { inset-inline-start: 100%; } }
.spn-meta { padding: 4px 16px 6px; }
.spn-meta > div { padding: 8px 0; }
.spn-meta dd { font-weight: 500; font-size: 12.5px; }
#syncErr { margin: 0 16px 10px; font-size: 12px; }
.spn-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line);
  background: var(--card-2); border-radius: 0 0 14px 14px; }

.toast { position: fixed; z-index: 60; bottom: 22px; inset-inline-end: 22px; display: flex; align-items: center; gap: 10px; max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 12px; background: var(--side); color: #fff; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  border-inline-start: 4px solid var(--ok); animation: toast-in .25s ease-out; }
.toast.bad { border-inline-start-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (max-width: 720px) {
  .sp-text { display: none; }
  .sync-pill { padding: 0 10px; }
}
