/* ============================================================
   Next Era — global styles
   ============================================================ */

:root {
  --bg: #0b1220;
  --bg-2: #0f172a;
  --panel: #111a2e;
  --panel-2: #1a2540;
  --line: #223056;
  --muted: #94a3b8;
  --text: #e6edf9;
  --accent: #6c5ce7;
  --accent-2: #845ef7;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #3b82f6;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html, body { overflow-x: hidden; }
body {
  font-family: 'Noto Kufi Arabic','Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #1c2a55 0, #0b1220 50%) fixed, var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  max-width: 100vw;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; color: inherit; }

/* ----- boot splash ----- */
.boot-splash {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
}
.boot-logo { font-size: 64px; }
.boot-title { font-size: 28px; font-weight: 800; }
.boot-sub   { color: var(--muted); }

/* ----- layout ----- */
.app {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, #101a33, #0b1220);
  border-inline-start: 1px solid var(--line);
  padding: 14px 10px;
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow: auto;
}
.sb-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 4px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  cursor: pointer;
  color: inherit; text-decoration: none;
  transition: opacity .15s ease;
  min-height: 70px;   /* reserve space so the brand doesn't flicker between emoji and logo */
}
.sb-brand:hover { opacity: 0.85; }
.sb-brand .logo { font-size: 22px; }
.sb-brand .title { font-weight: 800; font-size: 15px; }
.sb-brand .sub   { color: var(--muted); font-size: 11px; }

/* Logo-only mode: large centered logo replaces the text block */
.sb-brand-logo-only {
  flex-direction: column;
  padding: 10px 6px 16px;
  justify-content: center;
}
.sb-brand .sb-logo-hero {
  width: 100%;
  max-width: 170px;
  max-height: 90px;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

/* ===== Animated RGB ring around app logos ===== */
.logo-rgb {
  position: relative;
  display: inline-flex;
  align-items: center; justify-content: center;
  padding: 4px;
  border-radius: 18px;
  isolation: isolate;
  overflow: hidden;
}
.logo-rgb::before {
  content: '';
  position: absolute;
  inset: -100%;
  background: conic-gradient(
    from 0deg,
    #ff0080 0%,
    #ff8800 12%,
    #ffee00 25%,
    #00ff88 37%,
    #00eeff 50%,
    #0080ff 62%,
    #8000ff 75%,
    #ff00ee 87%,
    #ff0080 100%
  );
  animation: rgb-ring-spin 3s linear infinite;
  z-index: 0;
  pointer-events: none;
}
.logo-rgb::after {
  /* inner mask so only a thin rainbow ring shows around the edge */
  content: '';
  position: absolute; inset: 4px;
  background: var(--rgb-center, #0b1220);
  border-radius: 14px;
  z-index: 1;
}
.logo-rgb > * {
  position: relative;
  z-index: 2;
}
@keyframes rgb-ring-spin {
  to { transform: rotate(360deg); }
}

/* Compact ring for the page-title inline logo */
.logo-rgb-inline {
  padding: 3px;
  border-radius: 14px;
}
.logo-rgb-inline::after {
  inset: 3px;
  border-radius: 11px;
}

.sb-user {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 8px 0;
  font-size: 12px;
}
.sb-user .role { color: var(--muted); font-size: 10px; }
.sb-user .name { font-weight: 700; margin-top: 2px; font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  color: #cbd5ee; font-size: 13px;
  transition: background .15s ease;
}
.nav-item:hover { background: var(--panel); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(108,92,231,.28), rgba(108,92,231,.05));
  color: #fff;
  border: 1px solid rgba(108,92,231,.35);
}
.nav-icon { font-size: 14px; width: 20px; text-align: center; }

.logout-btn {
  margin-top: 10px; width: 100%;
  background: transparent; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; color: #ffb4b4; cursor: pointer;
  font-size: 13px;
}
.logout-btn:hover { border-color: var(--err); color: #ff8080; }

/* ----- main area ----- */
.main {
  padding: 16px 16px;
  max-width: 100%;
  min-width: 0;          /* critical for flex/grid children to shrink */
}
.main > * { min-width: 0; }
.page-title {
  display: flex; align-items: center; gap: 12px;
  font-size: 22px; font-weight: 800; margin: 0 0 4px;
}
.page-sub { color: var(--muted); margin-bottom: 20px; }

/* ----- cards + grids ----- */
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }

/* Staggered card-in delay for grids — each card appears slightly after the previous */
.grid > .card:nth-child(1)  { animation-delay: .04s; }
.grid > .card:nth-child(2)  { animation-delay: .09s; }
.grid > .card:nth-child(3)  { animation-delay: .14s; }
.grid > .card:nth-child(4)  { animation-delay: .19s; }
.grid > .card:nth-child(5)  { animation-delay: .24s; }
.grid > .card:nth-child(6)  { animation-delay: .29s; }
.grid > *:nth-child(1)  { animation-delay: .04s; }
.grid > *:nth-child(2)  { animation-delay: .09s; }
.grid > *:nth-child(3)  { animation-delay: .14s; }
.grid > *:nth-child(4)  { animation-delay: .19s; }
.grid > *:nth-child(5)  { animation-delay: .24s; }
.grid > *:nth-child(6)  { animation-delay: .29s; }

/* Stagger for non-.grid containers that hold card-like children */
.branch-map-grid > *:nth-child(1),
.top-cats-grid   > *:nth-child(1),
.centers-grid    > *:nth-child(1) { animation-delay: .04s; }
.branch-map-grid > *:nth-child(2),
.top-cats-grid   > *:nth-child(2),
.centers-grid    > *:nth-child(2) { animation-delay: .09s; }
.branch-map-grid > *:nth-child(3),
.top-cats-grid   > *:nth-child(3),
.centers-grid    > *:nth-child(3) { animation-delay: .14s; }
.branch-map-grid > *:nth-child(4),
.top-cats-grid   > *:nth-child(4),
.centers-grid    > *:nth-child(4) { animation-delay: .19s; }
.branch-map-grid > *:nth-child(5),
.top-cats-grid   > *:nth-child(5),
.centers-grid    > *:nth-child(5) { animation-delay: .24s; }
.branch-map-grid > *:nth-child(6),
.top-cats-grid   > *:nth-child(6),
.centers-grid    > *:nth-child(6) { animation-delay: .29s; }
@media (max-width: 1380px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  animation: card-in .4s cubic-bezier(.22,1,.36,1) both;
  transition: box-shadow .22s ease, transform .22s ease;
  will-change: transform;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 36px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.25);
}

/* Clickable cards get a stronger lift */
a.card:hover,
.card[style*="cursor:pointer"]:hover,
.card[style*="cursor: pointer"]:hover,
.center-card:hover,
.branch-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 44px rgba(0,0,0,.52), 0 4px 12px rgba(0,0,0,.3);
}

/* Static wrapper cards (tables, forms) — keep shadow but no lift */
.card .card { transform: none !important; box-shadow: none !important; }
.card.period-card:hover { transform: none; box-shadow: var(--shadow); }

/* ── All non-.card elements that share the card-in animation ── */
.branch-map-card,
.top-cat-card,
.type-card,
.partner-card,
.pc-q-card,
.center-card {
  animation: card-in .4s cubic-bezier(.22,1,.36,1) both;
  will-change: transform;
  transition: box-shadow .22s ease, transform .22s ease, border-color .22s ease;
}
.card-title {
  font-weight: 700; font-size: 14px;
  margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center;
}

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .k { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.kpi .sub { color: var(--muted); font-size: 12px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: rgba(108,92,231,.15); color: #c7bbff;
}
.pill.ok   { background: rgba(16,185,129,.15); color: #6ee7b7; }
.pill.warn { background: rgba(245,158,11,.15); color: #fcd34d; }
.pill.err  { background: rgba(239,68,68,.15);  color: #fca5a5; }

/* ----- tables ----- */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); }
table.t th, table.t td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); }
table.t th { background: var(--panel-2); font-weight: 600; color: #cbd5ee; }
table.t tbody tr:hover { background: rgba(255,255,255,.02); }
table.t .num { text-align: end; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ----- forms ----- */
.form-row { display: grid; gap: 14px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: repeat(3,1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4,1fr); }
@media (max-width: 900px) { .form-row.cols-2,.form-row.cols-3,.form-row.cols-4 { grid-template-columns: 1fr; } }

label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #cbd5ee; }
label.f .hint { color: var(--muted); font-size: 11px; }
.f-input, .f-select, textarea.f-input {
  background: #0b1326;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  width: 100%;
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.f-input:focus, .f-select:focus, textarea.f-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,.2);
}
textarea.f-input { min-height: 80px; resize: vertical; }

.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: 0; border-radius: 10px;
  padding: 10px 16px; cursor: pointer; font-weight: 600;
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.btn.ok     { background: linear-gradient(135deg, #10b981, #059669); }
.btn.warn   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 12px;
}
.toolbar .spacer { flex: 1; }

/* ----- login ----- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 10% 10%, rgba(108,92,231,.15) 0, transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(16,185,129,.12) 0, transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card .lead { color: var(--muted); margin-bottom: 20px; }

/* ----- modals ----- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 6, 18, .6);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  width: 100%; max-width: 640px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
  max-height: 90vh; overflow: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ----- toasts ----- */
.toasts {
  position: fixed; bottom: 20px; inset-inline-start: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px;
  min-width: 260px; animation: slide-in .2s ease-out;
}
.toast.ok  { border-color: rgba(16,185,129,.5); }
.toast.err { border-color: rgba(239,68,68,.5); }
.toast.warn{ border-color: rgba(245,158,11,.5); }
@keyframes slide-in {
  from { transform: translateX(-20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ----- misc ----- */
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; border: 1px solid var(--line); background: var(--panel-2);
}
.branch-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line);
}
.muted { color: var(--muted); }
.num   { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.row   { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.empty {
  text-align: center; color: var(--muted);
  padding: 40px 20px; border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.loader {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.1); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hr { border-top: 1px solid var(--line); margin: 16px 0; }

/* ============================================================
   Mobile top bar (hidden on desktop, shown on mobile)
   ============================================================ */
.mobile-topbar { display: none; }
.sb-close       { display: none; }
.sb-overlay     { display: none; }

@media (max-width: 900px) {
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px;
    height: 58px;                   /* fixed height — no layout shift on logo load */
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 80;
  }
  .mt-burger {
    background: transparent; border: 0;
    display: inline-flex; flex-direction: column; gap: 4px;
    padding: 8px; cursor: pointer;
    flex-shrink: 0;
  }
  .mt-burger span {
    width: 22px; height: 2px;
    background: var(--text);
    border-radius: 2px;
  }
  .mt-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 15px;
  }
  .mt-logo { font-size: 22px; }
  .mt-brand {
    flex: 1;
    height: 100%;                   /* fill topbar height — never shifts */
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: opacity .15s ease;
  }
  .mt-brand:hover { opacity: 0.8; }
  /* logo-rgb inside topbar: keep it contained */
  .mt-brand .logo-rgb {
    padding: 3px;
    border-radius: 12px;
  }
  .mt-brand .logo-rgb img,
  .mt-brand img {
    height: 34px;                   /* fixed height — no shift */
    max-width: 130px;
    object-fit: contain;
    background: transparent;
    display: block;
  }

  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; right: 0; left: auto;  /* RTL: attach to right */
    width: 280px; max-width: 85vw;
    height: 100vh;
    z-index: 100;
    transform: translateX(110%);               /* hide to the right (RTL) */
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.6);
    border-inline-start: 1px solid var(--line);
  }
  html[dir="ltr"] .sidebar {
    right: auto; left: 0;
    transform: translateX(-110%);
  }
  .sidebar.open,
  html[dir="ltr"] .sidebar.open,
  html[dir="rtl"] .sidebar.open {
    transform: translateX(0) !important;
  }

  .sb-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99;
    animation: fadein .15s ease;
  }
  @keyframes fadein { from { opacity: 0 } to { opacity: 1 } }

  .sb-close {
    display: inline-flex; align-items: center; justify-content: center;
    margin-inline-start: auto;
    background: transparent; border: 0; color: var(--muted);
    font-size: 18px; cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px;
  }
  .sb-close:hover { background: var(--panel-2); color: var(--text); }

  .main { padding: 16px 14px; max-width: 100%; }
  .page-title { font-size: 18px; }
  .page-sub   { font-size: 12px; margin-bottom: 14px; }
  .toolbar    { gap: 6px; }
  .toolbar .f-input, .toolbar .f-select { font-size: 13px; padding: 8px 10px; }
  .btn        { padding: 8px 12px; font-size: 13px; }
  .card       { padding: 12px; border-radius: 12px; }
  .card-title { font-size: 13px; }
  .kpi .v     { font-size: 17px; }
  .kpi .k     { font-size: 11px; }
  .mk-value   { font-size: 15px; }
  .mk-label   { font-size: 10px; }
  table.t     { font-size: 12px; }
  table.t th, table.t td { padding: 8px 10px; }
}

@media (max-width: 640px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); gap: 10px; }
  .grid-3 { grid-template-columns: 1fr; gap: 10px; }
  .grid-2 { grid-template-columns: 1fr; gap: 10px; }
  .grid   { gap: 10px; }

  .main { padding: 12px 10px; }
  .page-title { font-size: 17px; }

  /* Stack branch header contents */
  .branch-header-main { flex-direction: column; align-items: stretch; gap: 10px; }
  .branch-switcher    { width: 100% !important; }
  .branch-icon-box    { width: 44px; height: 44px; }
  .branch-name        { font-size: 16px; }

  /* Compact KPI cards */
  .kpi .v { font-size: 15px; }
  .mini-kpi { padding: 10px; }

  /* Period selector wraps and fits */
  .period-selector { justify-content: flex-start; }
  .period-btn { padding: 6px 12px; font-size: 12px; }

  /* Wizard steps compact */
  .wiz-steps { flex-direction: column; gap: 6px; padding: 10px; }
  .ws-line   { display: none; }
  .ws-step   { width: 100%; }

  /* Branch cards full-width */
  .branch-map-grid { grid-template-columns: 1fr; }
  .branch-grid     { grid-template-columns: 1fr; }
  .type-picker     { grid-template-columns: 1fr; }

  /* Quarter cards 2 per row */
  .quarter-card .v { font-size: 16px; }

  /* Distribution chart: stacked */
  .expense-dist-wrap { grid-template-columns: 1fr; gap: 12px; }
  .expense-dist-list { max-height: none; }

  /* Toolbar and filters - wrap into 2 rows */
  .toolbar { flex-wrap: wrap; }
  .toolbar .f-select, .toolbar .f-input {
    min-width: 44%; flex: 1 1 44%;
  }
  .toolbar .spacer { display: none; }

  /* Tables: horizontal scroll preserved */
  .table-wrap { border-radius: 10px; }
  table.t th, table.t td { padding: 6px 8px; white-space: nowrap; }
  .branch-chip { font-size: 11px; padding: 3px 6px; }

  /* Modal full-height */
  .modal { border-radius: 14px 14px 0 0; max-height: 95vh; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 {
    grid-template-columns: 1fr !important;
  }

  /* Login card */
  .login-card { padding: 22px 18px; }
}

/* ============================================================
   Branch Header — persistent branch context on every page
   ============================================================ */
.branch-header {
  background: linear-gradient(90deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-inline-start: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.branch-header-main {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.branch-icon-box {
  width: 56px; height: 56px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 14px;
  flex-shrink: 0;
}
.branch-name {
  font-size: 20px; font-weight: 800; letter-spacing: -.01em;
}
.branch-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.branch-switcher {
  width: 200px; min-width: 180px;
  border-width: 1.5px;
}
.branch-header-extra {
  border-top: 1px dashed var(--line);
  margin-top: 12px; padding-top: 10px;
  font-size: 13px;
}
.branch-header-extra .row > div { white-space: nowrap; }

/* ============================================================
   KPI / mini-KPI
   ============================================================ */
.kpi-card {
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  /* Subtle color-accent fade (driven by the --kc var set inline by React) */
  background:
    linear-gradient(135deg, var(--kc-fade, rgba(255,255,255,0.02)) 0%, transparent 60%),
    var(--panel);
}
.kpi-card::before {
  /* Colored accent bar on the top inline-start edge (RTL = right) */
  content: ''; position: absolute; top: 0; bottom: 0;
  inset-inline-start: 0;
  width: 3px;
  background: var(--kc, transparent);
  opacity: 0.6;
}
.kpi-card > .row { flex: 1; min-height: 0; }
.kpi-card:hover { transform: translateY(-2px); border-color: var(--kc, var(--accent)); }
.kpi-card.kpi-clickable::after {
  content: ''; position: absolute; top: 10px; left: 10px;
  width: 6px; height: 6px; border-radius: 50%;
  background: #60a5fa; box-shadow: 0 0 8px #60a5fa;
  opacity: 0.8; animation: bw-pulse-sm 1.8s ease-in-out infinite;
}
.kpi-card.kpi-clickable:hover {
  box-shadow: 0 6px 20px rgba(59,130,246,0.25);
  border-color: rgba(96,165,250,0.6);
}
/* The wrapper grid stretches cards to same height */
.grid { align-items: stretch; }
@keyframes bw-pulse-sm {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1.3); }
}
.kpi .trend {
  font-size: 11px; font-weight: 700; margin-top: 2px;
  display: inline-block; padding: 2px 8px; border-radius: 999px;
}
.kpi .trend.up   { color: #6ee7b7; background: rgba(16,185,129,.12); }
.kpi .trend.down { color: #fca5a5; background: rgba(239,68,68,.12); }

.mini-kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.mk-label { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.mk-value { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.mk-trend {
  font-size: 11px; margin-top: 4px;
  display: inline-block; padding: 2px 8px; border-radius: 999px;
}
.mk-trend.up   { color: #6ee7b7; background: rgba(16,185,129,.12); }
.mk-trend.down { color: #fca5a5; background: rgba(239,68,68,.12); }

/* ============================================================
   Section heading separator
   ============================================================ */
.section-head {
  margin: 24px 0 12px;
  padding: 4px 0;
  border-inline-start: 4px solid var(--accent);
  padding-inline-start: 12px;
}
.section-title { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.section-head .muted { font-size: 12px; margin-top: 2px; display: block; }

/* ============================================================
   Branch cards grid (Admin Dashboard "branch map")
   ============================================================ */
.branch-grid { gap: 14px; }
.branch-card {
  padding: 0; cursor: pointer; overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.branch-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(0,0,0,.4);
}
.branch-card-head {
  padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--line);
}
.branch-card-title { display: flex; align-items: center; gap: 10px; }
.branch-card-body  { padding: 14px 16px; }

.bc-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  font-size: 13px;
}
.bc-kpis > div { display: flex; flex-direction: column; }
.bc-kpis .lbl  { color: var(--muted); font-size: 11px; }
.bc-kpis b     { font-size: 14px; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.trend-pill {
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
}
.trend-pill.up   { color: #6ee7b7; background: rgba(16,185,129,.15); }
.trend-pill.down { color: #fca5a5; background: rgba(239,68,68,.15); }
.trend-pill.tiny { font-size: 10px; padding: 2px 6px; }

/* ============================================================
   Bar in tables (top categories with %)
   ============================================================ */
.bar-wrap {
  display: inline-block; vertical-align: middle;
  width: 80px; height: 8px; background: var(--panel-2);
  border-radius: 4px; overflow: hidden; margin-inline-end: 6px;
}
.bar {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 4px;
}

/* ============================================================
   إدارة المراكز — Centers Management (big branch cards)
   ============================================================ */
/* ── Sub-branch picker summary cards (السنة + الشهر) ── */
.sub-picker-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.sub-sum-card {
  padding: 18px 20px;
}
.sub-sum-card .cc-col-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.sub-sum-card .cc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: 13px;
}
.sub-sum-card .cc-row .lbl { color: var(--muted); }
.sub-sum-card .cc-row .val { font-weight: 700; font-size: 14px; }

.centers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.centers-grid.centers-stacked { grid-template-columns: 1fr; }
.centers-stacked .center-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr);
}
.centers-stacked .cc-header {
  border-bottom: 0;
  border-inline-end: 1px solid var(--line);
  padding: 20px;
}
.centers-stacked .cc-body {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.centers-stacked .cc-two-cols {
  flex: 1 1 460px;
  min-width: 320px;
}
.centers-stacked .cc-enter {
  flex: 0 0 auto;
  margin-top: 0;
  margin-inline-start: auto;
  padding: 10px 18px;
  white-space: nowrap;
}
@media (max-width: 900px) {
  .centers-stacked .center-card { grid-template-columns: 1fr; }
  .centers-stacked .cc-header {
    border-inline-end: 0;
    border-bottom: 1px solid var(--line);
  }
  .centers-stacked .cc-body { padding: 12px; gap: 10px; }
  .centers-stacked .cc-two-cols { flex: 1 1 100%; min-width: 0; }
  .centers-stacked .cc-enter { flex: 1 1 100%; margin-inline-start: 0; }
}
.center-card {
  display: block;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  cursor: pointer;
}
.center-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 56px rgba(0,0,0,.48), 0 0 20px rgba(108,92,231,.2);
}
.cc-header {
  padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
  color: #fff;
  position: relative;
}
.cc-icon { font-size: 42px; }
.cc-icon-xl {
  font-size: 76px;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.35));
  display: block;
}

/* When branch has a logo: stack logo big on top, name below — NO white background */
.cc-header-logo {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px 16px;
  gap: 12px;
  text-align: center;
}
.cc-logo-big {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  min-height: 140px;
}
.cc-logo-big img {
  max-height: 130px;
  max-width: 100%;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}
.cc-header-logo .cc-title {
  text-align: center;
}
.cc-header-logo .cc-arrow {
  position: absolute; top: 12px; inset-inline-start: 14px;
  font-size: 22px;
}
.cc-title { flex: 1; min-width: 0; }
.cc-name-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.cc-name  { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.cc-code  { font-size: 12px; opacity: .85; margin-top: 2px; }
.cc-subbranches-pill {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.22);
  color: #fff;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.25);
  white-space: nowrap;
}
.cc-arrow { font-size: 28px; opacity: .75; }
.cc-body  { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.cc-kpi-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.cc-kpi .lbl { color: var(--muted); font-size: 11px; }
.cc-kpi .val { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* Two columns with vertical separator — year | month */
.cc-two-cols {
  display: grid;
  grid-template-columns: 1fr 2px 1fr;
  gap: 14px;
  align-items: stretch;
  width: 100%;
}
.cc-sep {
  background: linear-gradient(180deg, transparent 0%, var(--line) 20%, var(--line) 80%, transparent 100%);
  width: 2px;
  align-self: stretch;
  border-radius: 2px;
}
.cc-col {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(255,255,255,.015) 0%, transparent 100%);
  border-radius: 10px;
  border-inline-start: 3px solid rgba(255,255,255,.1);
  min-width: 0;
}
.cc-col-year   { border-inline-start-color: rgba(52,211,153,0.5); background: linear-gradient(135deg, rgba(52,211,153,0.05) 0%, transparent 100%); }
.cc-col-month  { border-inline-start-color: rgba(167,139,250,0.5); background: linear-gradient(135deg, rgba(167,139,250,0.06) 0%, transparent 100%); }
.cc-col:nth-child(3) {
  border-inline-start-color: rgba(167,139,250,.5);
  background: linear-gradient(135deg, rgba(167,139,250,.06) 0%, transparent 100%);
}
.cc-col-title {
  font-size: 13px;
  font-weight: 800;
  color: #cbd5ee;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 2px;
  letter-spacing: .01em;
  white-space: nowrap;
}
.cc-col-title-month { color: #a78bfa; border-bottom-color: rgba(167,139,250,.3); }
.cc-col-subtitle {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
  margin-bottom: 6px;
  font-weight: 500;
}

/* Uniform stacked row — label above value — works at any width */
.cc-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255,255,255,.04);
}
.cc-row:last-child { border-bottom: 0; padding-bottom: 2px; }
.cc-row .lbl {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
}
.cc-row .val {
  font-weight: 800;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}

@media (max-width: 640px) {
  .cc-two-cols { grid-template-columns: 1fr; }
  .cc-sep { display: none; }
  .cc-col { padding: 10px 12px; }
  .cc-row .lbl { font-size: 11px; }
  .cc-row .val { font-size: 13px; }
}

/* === Medal badges on top-3 center cards === */
.cc-medal {
  position: absolute; top: 12px; inset-inline-end: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px;
  border-radius: 999px;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  z-index: 5;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.55));
  animation: cc-medal-pulse 2.2s ease-in-out infinite;
  transform-origin: center;
}
.cc-medal::before {
  /* Shiny ring around the medal */
  content: '';
  position: absolute; inset: -4px;
  border-radius: inherit;
  background: conic-gradient(from 0deg, transparent 0deg, var(--ring, #fff) 90deg, transparent 180deg, var(--ring, #fff) 270deg, transparent 360deg);
  opacity: 0.4;
  animation: cc-medal-ring 3s linear infinite;
  z-index: -1;
}
.cc-medal.gold   {
  background: radial-gradient(circle at 30% 30%, #fef08a 0%, #facc15 40%, #ca8a04 100%);
  color: #422006;
  --ring: #fcd34d;
  box-shadow: 0 4px 18px rgba(250,204,21,0.65), 0 0 0 3px rgba(250,204,21,0.85) inset;
}
.cc-medal.silver {
  background: radial-gradient(circle at 30% 30%, #f8fafc 0%, #cbd5e1 40%, #64748b 100%);
  color: #1e293b;
  --ring: #e2e8f0;
  box-shadow: 0 4px 18px rgba(203,213,225,0.6), 0 0 0 3px rgba(226,232,240,0.85) inset;
}
.cc-medal.bronze {
  background: radial-gradient(circle at 30% 30%, #fef3c7 0%, #f59e0b 40%, #92400e 100%);
  color: #451a03;
  --ring: #fbbf24;
  box-shadow: 0 4px 18px rgba(217,119,6,0.6), 0 0 0 3px rgba(251,191,36,0.85) inset;
}

/* One-time entry pop (only the first time the badge appears) */
.cc-medal {
  animation: cc-medal-pop 0.7s cubic-bezier(.34,1.56,.64,1) both,
             cc-medal-pulse 2.2s ease-in-out 0.7s infinite;
}
@keyframes cc-medal-pop {
  0%   { transform: scale(0) rotate(-200deg); opacity: 0; }
  70%  { transform: scale(1.25) rotate(15deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes cc-medal-pulse {
  0%, 100% { transform: scale(1) rotate(0); }
  50%      { transform: scale(1.08) rotate(-5deg); }
}
@keyframes cc-medal-ring {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 480px) {
  .cc-medal { width: 44px; height: 44px; font-size: 24px; top: 10px; inset-inline-end: 10px; }
}

/* === Per-branch monthly drilldown summary — stacks on mobile === */
.bmr-rows {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.bmr-row {
  display: flex; flex-direction: column;
  padding: 6px 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
}
.bmr-lbl { font-size: 11px; color: var(--muted); font-weight: 600; }
.bmr-val { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }

@media (max-width: 640px) {
  .bmr-rows { grid-template-columns: 1fr; gap: 4px; }
  .bmr-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
  }
  .bmr-val { font-size: 14px; margin-top: 0; }
}

/* Hide the navigation arrow when a medal occupies the same corner */
.cc-medal ~ .cc-header .cc-arrow { visibility: hidden; }

.cc-enter {
  margin-top: 4px;
  padding: 9px 14px;
  background: var(--panel-2);
  border-radius: 10px;
  text-align: center;
  font-weight: 700; font-size: 13px;
  color: var(--accent);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line);
  transition: all .15s ease;
}
.center-card:hover .cc-enter {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================================
   Branch Workspace banner + tabs
   ============================================================ */
.branch-workspace-banner {
  padding: 18px 22px;
  border-radius: 16px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;        /* allow pills row to wrap below on narrow screens */
  color: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  position: relative;
}

/* Left column: back button(s) + doc pills */
.bwb-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  flex-shrink: 0;
}
.bwb-back {
  background: rgba(0,0,0,.2);
  padding: 6px 12px; border-radius: 999px;
  color: #fff; font-size: 12px;
  white-space: nowrap;
  transition: background .15s ease;
}
.bwb-back:hover { background: rgba(0,0,0,.35); }

/* When branch has a logo — show bigger, no background, drop shadow for visibility */
.bwb-icon-logo {
  background: transparent;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 120px; min-height: 90px;
}
.bwb-icon-logo img {
  max-height: 90px;
  max-width: 180px;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.45));
}
.bwb-icon { font-size: 44px; }
.bwb-text { flex: 1; }
.bwb-sub  { font-size: 12px; opacity: .85; }
.bwb-name { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.bwb-code {
  background: rgba(0,0,0,.22);
  padding: 6px 12px; border-radius: 8px;
  font-size: 12px; font-family: monospace;
}

.branch-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 6px;
  background: rgba(17, 26, 46, 0.85);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.branch-tabs::-webkit-scrollbar { height: 4px; }
.branch-tabs::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
.branch-tabs::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.branch-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: #b4c0d8;
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .18s ease;
  position: relative;
}
.branch-tab:hover {
  background: rgba(255,255,255,.04);
  color: var(--text);
}
.branch-tab.active {
  background: linear-gradient(135deg, rgba(108,92,231,.25) 0%, rgba(132,94,247,.15) 100%);
  border-color: rgba(108,92,231,.5);
  color: #fff;
  box-shadow: 0 4px 12px rgba(108,92,231,.2);
}
.branch-tab.active::after {
  content: '';
  position: absolute;
  bottom: -6px; left: 50%;
  transform: translateX(-50%);
  width: 20px; height: 3px;
  background: var(--accent);
  border-radius: 2px;
}
.branch-tab > span:first-child { font-size: 15px; }

@media (max-width: 900px) {
  .branch-workspace-banner { padding: 14px 16px; }
  .bwb-icon { font-size: 32px; }
  .bwb-name { font-size: 18px; }
  .branch-tabs {
    padding: 5px;
    border-radius: 12px;
    top: 60px; /* below mobile topbar */
  }
  .branch-tab { padding: 7px 11px; font-size: 12px; }
  .branch-tab > span:first-child { font-size: 14px; }
}

@media (max-width: 640px) {
  /* Banner: pills move to a full-width row below the main info */
  .branch-workspace-banner {
    padding: 12px 14px;
    gap: 10px;
    align-items: flex-start;
  }
  .bwb-left {
    order: 9;              /* push after all other children */
    flex: 0 0 100%;        /* full-width row */
    max-width: 100%;
  }
  .bwb-icon { order: 1; font-size: 28px; }
  .bwb-icon-logo {
    order: 1;
    min-width: 54px !important;
    min-height: 44px !important;
  }
  .bwb-icon-logo img {
    max-height: 54px !important;
    max-width: 100px !important;
  }
  .bwb-text {
    order: 2;
    flex: 1;
    min-width: 0;
  }
  .bwb-name { font-size: 15px; }
  .bwb-sub  { font-size: 11px; }
  .bwb-code { order: 3; align-self: flex-start; font-size: 11px; padding: 4px 8px; }
}

/* ============================================================
   Expense / Revenue distribution donut + list
   ============================================================ */
.expense-dist-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: center;
}
@media (max-width: 1100px) { .expense-dist-wrap { grid-template-columns: 1fr; } }
.expense-dist-chart { position: relative; }
.expense-dist-center {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
  text-align: center;
}
.expense-dist-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 340px; overflow-y: auto;
  padding-inline-end: 6px;
}
.expense-dist-list::-webkit-scrollbar { width: 6px; }
.expense-dist-list::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.edl-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.edl-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.edl-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edl-bar-wrap { width: 100%; height: 4px; background: rgba(255,255,255,.05); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.edl-bar { height: 100%; border-radius: 2px; transition: width .3s ease; }
.edl-value { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.edl-pct { font-size: 11px; color: var(--muted); margin-top: 2px; }
.edl-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
  border-top: 1px dashed var(--line);
  margin-top: 6px;
  font-size: 14px; font-weight: 700;
}

/* ============================================================
   Expense Category Cards (clickable, colored borders + glow)
   ============================================================ */
.ecc-summary {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; margin-bottom: 12px;
  background: linear-gradient(135deg, rgba(248,113,113,.06), rgba(108,92,231,.04));
  border: 1px solid rgba(248,113,113,.18);
  border-radius: 10px;
  font-size: 13px;
}
.exp-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.exp-cat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
  user-select: none;
}
.exp-cat-card:hover {
  transform: translateY(-2px) !important;
  filter: brightness(1.08);
}
.ecc-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.ecc-dot {
  display: inline-block; width: 9px; height: 9px;
  border-radius: 50%; flex-shrink: 0;
}
.ecc-name {
  font-weight: 700; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #e2e8f0;
}
.ecc-value {
  font-size: 18px; font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.3px;
}
.ecc-bar-wrap {
  width: 100%; height: 5px;
  background: rgba(255,255,255,.04);
  border-radius: 3px; overflow: hidden;
}
.ecc-bar {
  height: 100%; border-radius: 3px;
  transition: width .4s ease;
}
.ecc-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px;
}
.ecc-pct { font-weight: 800; }
.ecc-cnt { color: var(--muted); }
@media (max-width: 700px) {
  .exp-cat-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
  .exp-cat-card { padding: 12px; }
  .ecc-value { font-size: 16px; }
}

/* ============================================================
   Branch Map Grid (Revenues / Expenses quick-select strip)
   ============================================================ */
.branch-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.branch-map-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  display: flex; flex-direction: column;
}
.branch-map-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 36px rgba(0,0,0,.42), 0 0 12px rgba(108,92,231,.18);
  border-color: rgba(167,139,250,.4);
}
.branch-map-card.selected {
  box-shadow: 0 0 0 3px rgba(108,92,231,.22);
}
.bmc-head {
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.bmc-icon {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  font-size: 20px;
}
.bmc-name { font-weight: 800; font-size: 14px; }
.bmc-body {
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px; flex: 1;
}
.bmc-kpi .k   { color: var(--muted); font-size: 11px; }
.bmc-kpi .v   { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.bmc-kpi .sub { margin-top: 2px; }
.bmc-add {
  margin-top: auto;
  padding: 8px 12px; font-size: 12px;
  border-radius: 10px;
}

/* ============================================================
   Advanced PeriodBar (Year/Month/Quarters/Calendar)
   ============================================================ */
/* ---- PeriodBar — slim, polished, mobile-friendly ---- */
.period-bar {
  display: flex; flex-direction: column; gap: 8px;
}
.pb-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.pb-group {
  display: inline-flex; align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
}
.pb-group:hover { border-color: rgba(167,139,250,0.25); }
.pb-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  padding-inline: 2px;
}
.pb-group .f-select {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  background: var(--panel-2);
  border-color: rgba(255,255,255,0.06);
}
.pb-group.pb-range-pill {
  background: linear-gradient(135deg, rgba(108,92,231,0.12), rgba(52,211,153,0.08));
  border-color: rgba(108,92,231,0.25);
  padding: 5px 10px;
  color: #c4b5fd;
}

/* Slimmer wrapper around the PeriodBar */
.card.period-card {
  padding: 10px 12px;
  margin-bottom: 14px;
  background: linear-gradient(180deg, var(--panel) 0%, rgba(15,23,42,0.6) 100%);
}
@media (max-width: 480px) {
  .card.period-card { padding: 8px 10px; margin-bottom: 10px; }
}

/* Branch summary strip */
.branch-summary-strip {
  display: flex; flex-wrap: wrap; gap: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 13px;
}

/* Channels horizontal bars */
.channels-bars { display: flex; flex-direction: column; gap: 10px; padding: 6px 2px; }
.cb-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 12px;
}
.cb-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.cb-bar-wrap {
  background: var(--panel-2);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.cb-bar {
  height: 100%;
  border-radius: 999px;
  min-width: 2px;
  transition: width .3s ease;
}
.cb-value { font-weight: 700; font-size: 13px; white-space: nowrap; }
.cb-pct   { color: var(--muted); font-size: 11px; margin-inline-start: 4px; }
.cb-total {
  border-top: 1px dashed var(--line);
  padding-top: 8px; margin-top: 4px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px;
}

/* Top categories improved grid */
.top-cats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.top-cat-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
}
.top-cat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  border-color: rgba(167,139,250,.35);
}
.tcc-head {
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.tcc-rank {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  flex-shrink: 0;
}
.tcc-name {
  font-weight: 700; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.tcc-body { padding: 12px; }
.tcc-value {
  font-size: 18px; font-weight: 800; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.tcc-bar-wrap {
  background: var(--panel-2);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  margin-top: 10px;
}
.tcc-bar {
  height: 100%;
  border-radius: 999px;
  transition: width .3s ease;
}
.tcc-pct { color: var(--muted); font-size: 11px; margin-top: 6px; }

@media (max-width: 640px) {
  .cb-row { grid-template-columns: 100px 1fr auto; gap: 8px; }
  .cb-label { font-size: 12px; }
  .cb-value { font-size: 12px; }
  .period-bar { gap: 6px; }
  .pb-row { gap: 6px; }
  .pb-group {
    padding: 2px 4px;
    gap: 4px;
    background: rgba(255,255,255,0.02);
  }
  .pb-label { font-size: 10px; }
  .period-btn { padding: 4px 10px; font-size: 11px; }
  .pb-group .f-select { height: 28px; font-size: 11px; padding: 0 8px; }
}

/* ============================================================
   Period Selector (quick period buttons)
   ============================================================ */
.period-selector {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.period-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: all .12s ease;
  letter-spacing: 0.1px;
}
.period-btn:hover {
  background: rgba(167,139,250,0.1);
  border-color: rgba(167,139,250,0.4);
  color: #ddd6fe;
}
.period-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(108,92,231,0.35);
}
.period-btn.active:hover { transform: translateY(-1px); }

/* ============================================================
   CSS rev/exp paired bars (fallback for ChartMonthlyRE)
   ============================================================ */
.rev-exp-row {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 4px;
  border-bottom: 1px dashed rgba(255,255,255,.05);
}
.rev-exp-row:last-child { border-bottom: 0; }
.rex-label {
  width: 80px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rex-bar-wrap {
  background: var(--panel-2);
  height: 20px;
  border-radius: 6px;
  overflow: hidden;
}
.rex-bar {
  height: 100%;
  border-radius: 6px;
  display: flex; align-items: center;
  padding-inline-start: 8px;
  min-width: 2px;
  opacity: .9;
  transition: width .3s ease;
}
.rex-val {
  color: #fff; font-size: 11px; font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.rev-exp-legend {
  display: flex; justify-content: center; gap: 20px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.rev-exp-legend .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-inline-end: 6px;
}

/* ============================================================
   Daily bars (CSS-only, Recharts-free)
   ============================================================ */
.daily-bars {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 500px;
  overflow-y: auto;
  padding: 6px 4px;
}
.db-row {
  display: grid;
  grid-template-columns: 80px 1fr 60px;
  gap: 10px;
  align-items: center;
}
.db-date {
  font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.db-bar-wrap {
  background: var(--panel-2);
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.db-bar {
  height: 100%;
  border-radius: 6px;
  display: flex; align-items: center;
  padding-inline-start: 8px;
  min-width: 2px;
  transition: width .3s ease;
  opacity: .85;
}
.db-bar-label {
  color: #fff; font-size: 11px; font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.db-cnt {
  text-align: end;
  color: var(--muted); font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Reports wizard — 3-step stepper
   ============================================================ */
.wiz-steps {
  display: flex; align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  gap: 10px;
}
.ws-step {
  flex: 1; display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 12px;
  cursor: pointer;
  transition: background .15s ease;
}
.ws-step:hover { background: var(--panel-2); }
.ws-num {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--muted);
  font-weight: 800; flex-shrink: 0;
}
.ws-step.done .ws-num   { background: var(--accent); color: #fff; }
.ws-step.active .ws-num { box-shadow: 0 0 0 4px rgba(108,92,231,.25); }
.ws-label { font-size: 12px; color: var(--muted); }
.ws-value { font-size: 14px; font-weight: 700; margin-top: 2px; }
.ws-step > div:nth-child(2) {
  display: flex; flex-direction: column;
}
.ws-line {
  flex: 0 0 30px; height: 2px; background: var(--line); align-self: center;
  border-radius: 2px;
}

/* type picker cards */
.type-picker { gap: 16px; }
.type-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px;
  cursor: pointer;
  text-align: center;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.type-card:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(0,0,0,.4); }
.type-card.rev:hover { border-color: #10b981; }
.type-card.exp:hover { border-color: #ef4444; }
.tp-icon  { font-size: 56px; margin-bottom: 12px; }
.tp-title { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.tp-sub   { color: var(--muted); font-size: 13px; line-height: 1.6; }
.tp-btn   {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(108,92,231,.15);
  color: var(--accent);
  font-weight: 700; font-size: 13px;
}
.type-card.rev .tp-btn { background: rgba(16,185,129,.15); color: #34d399; }
.type-card.exp .tp-btn { background: rgba(239,68,68,.15); color: #f87171; }

.rep-branch-card .branch-card-body { display: flex; flex-direction: column; }

/* ============================================================
   Tax Report (click inputs + alert card)
   ============================================================ */
.click-input {
  width: 80px !important;
  text-align: center;
  padding: 4px 8px !important;
  font-size: 12px !important;
}
.tax-alert {
  border-color: rgba(239,68,68,.5) !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.15);
}

/* ============================================================
   Partner Breakdown Cards (Profits page)
   ============================================================ */
.partner-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.partner-card:hover {
  transform: translateY(-3px);
  border-color: rgba(167,139,250,.5);
  box-shadow: 0 12px 36px rgba(0,0,0,.42), 0 0 14px rgba(108,92,231,.18);
}
.pc-head {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.pc-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c5ce7 0%, #a78bfa 100%);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800;
  flex-shrink: 0;
}
.pc-ident { flex: 1; min-width: 180px; }
.pc-name { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.pc-meta {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-top: 4px;
  font-size: 12px; color: var(--muted);
}
.pc-pct {
  text-align: center;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(108,92,231,.15) 0%, rgba(167,139,250,.1) 100%);
  border: 1px solid rgba(167,139,250,.35);
  border-radius: 14px;
}
.pc-pct-big {
  font-size: 26px; font-weight: 900;
  color: #a78bfa;
  letter-spacing: -.02em;
}
.pc-pct-label { font-size: 10px; color: var(--muted); }

.pc-totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 2fr;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.pc-total .lbl { color: var(--muted); font-size: 11px; }
.pc-total .val {
  font-size: 18px; font-weight: 800; letter-spacing: -.01em;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.pc-progress {
  display: flex; flex-direction: column; gap: 6px; justify-content: center;
}
.pc-progress-track {
  background: var(--panel-2);
  height: 10px; border-radius: 999px;
  overflow: hidden;
}
.pc-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #34d399 0%, #10b981 100%);
  border-radius: 999px;
  transition: width .3s ease;
}
.pc-progress-label {
  font-size: 11px; color: var(--muted);
  text-align: center;
}

.pc-months-toggle {
  cursor: pointer; padding: 10px 0; margin-top: 6px;
  font-weight: 700; color: var(--accent); font-size: 13px;
  list-style: none;
}
.pc-months-toggle::-webkit-details-marker { display: none; }
.pc-months-toggle::before {
  content: '▸';
  margin-inline-end: 6px;
  transition: transform .15s ease;
  display: inline-block;
}
details[open] .pc-months-toggle::before { transform: rotate(90deg); }

.pc-months-table td { font-size: 12px; }
.pc-month-empty { opacity: .4; }
.pc-totals-row {
  background: var(--panel-2);
  font-size: 13px !important;
}

/* ===== Quarters grid inside partner card ===== */
.pc-quarters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 900px) { .pc-quarters { grid-template-columns: 1fr; } }

.pc-q-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  position: relative;
  transition: border-color .15s ease, transform .15s ease;
}
.pc-q-card:hover { transform: translateY(-2px); border-color: var(--qc); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.pc-q-card.current {
  border-color: var(--qc);
  box-shadow: 0 0 0 1px var(--qc), 0 6px 20px rgba(0,0,0,.25);
}
.pc-q-card::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; inset-inline-start: 0;
  width: 4px;
  background: var(--qc);
  border-radius: 4px 0 0 4px;
  opacity: 0.6;
}

.pc-q-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 10px;
}
.pc-q-title { font-size: 14px; font-weight: 800; color: var(--qc); }
.pc-q-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.pc-q-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 8px;
}
.pc-q-summary > div { text-align: center; }
.pc-q-summary .lbl { font-size: 10px; color: var(--muted); }
.pc-q-summary .val { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }

.pc-q-bar {
  height: 4px; background: rgba(255,255,255,.05); border-radius: 2px;
  overflow: hidden; margin-bottom: 12px;
}
.pc-q-fill { height: 100%; transition: width .3s ease; }

.pc-q-months {
  display: flex; flex-direction: column; gap: 8px;
}
.pc-q-month {
  background: rgba(255,255,255,.02);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  transition: border-color .15s;
}
.pc-q-month:hover { border-color: var(--qc); }
.pc-q-month-empty { opacity: .5; }
.pc-q-month-done  { border-color: rgba(52,211,153,.3); background: rgba(52,211,153,.04); }
.pc-q-month-owed  { border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.04); }

.pc-qm-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; margin-bottom: 4px;
}
.pc-qm-main {
  font-size: 16px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}
.pc-qm-rows {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255,255,255,.06);
  margin-bottom: 6px;
}
.pc-qm-row {
  display: flex; justify-content: space-between;
}
.pc-qm-action { margin-top: 4px; }

@media (max-width: 900px) {
  .pc-totals {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .pc-progress { grid-column: 1 / -1; }
  .pc-pct { padding: 8px 12px; }
  .pc-pct-big { font-size: 22px; }
  .pc-avatar { width: 48px; height: 48px; font-size: 22px; }
  .pc-name { font-size: 18px; }
}

/* ============================================================
   Quarter cards (Profits page)
   ============================================================ */
.quarter-card {
  position: relative;
  transition: transform .15s ease, border-color .15s ease;
}
.quarter-card:hover { transform: translateY(-2px); }
.quarter-card.active {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, .18);
}
.quarter-card.active::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 3px; height: 100%; background: #a78bfa;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ============================================================
   Print — hide sidebar/toolbars, keep only content
   ============================================================ */

/* ============================================================
   PHONE-specific overrides (≤ 480px) — make every page fit
   ============================================================ */
@media (max-width: 480px) {
  /* Global compactness */
  html, body { font-size: 14px; }
  .main { padding: 12px 10px !important; }
  .card { padding: 12px; border-radius: 12px; }
  .page-title { font-size: 20px !important; }
  .page-sub   { font-size: 12px; }
  .section-title { font-size: 15px !important; }

  /* Layout grids — stack everything */
  .grid         { gap: 10px; }
  .grid-2,
  .grid-3,
  .grid-4       { grid-template-columns: 1fr !important; }

  /* KPI cards — tighter padding, smaller values */
  .kpi-card     { padding: 12px; }
  .kpi .v       { font-size: 16px !important; }
  .kpi .k       { font-size: 11px; }
  .kpi .sub     { font-size: 11px; }

  /* Toolbars — buttons full-width, stacked */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
  }
  .toolbar .btn,
  .toolbar .f-select,
  .toolbar .f-input { width: 100%; }
  .toolbar .spacer { display: none; }

  /* Branch header / switcher */
  .branch-header { padding: 12px; flex-direction: column; }
  .branch-header-main { flex-direction: column; align-items: flex-start; gap: 8px; }
  .branch-switcher { min-width: 0; width: 100%; }
  .branch-name { font-size: 18px; }

  /* Tables — allow horizontal scroll + smaller cells */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table.t { font-size: 11px; }
  table.t th, table.t td { padding: 6px 6px; }

  /* Modal — full width + small padding */
  .modal {
    max-width: 100vw !important;
    margin: 0;
    border-radius: 0;
    height: 100vh;
    max-height: 100vh;
  }
  .modal-body { padding: 14px; }
  .modal-head { padding: 12px 14px; }
  .form-row.cols-2,
  .form-row.cols-3 { grid-template-columns: 1fr !important; }

  /* Center cards */
  .centers-grid { grid-template-columns: 1fr !important; gap: 10px; }
  .cc-two-cols  { flex: 1 1 100%; min-width: 0 !important; }
  .cc-body      { flex-direction: column !important; gap: 10px; }
  .center-card .cc-value { font-size: 18px !important; }

  /* Partner cards */
  .partner-card { padding: 14px; }
  .pc-head { flex-wrap: wrap; gap: 10px; }
  .pc-ident { min-width: 0 !important; flex: 1 1 100%; }
  .pc-avatar { width: 40px; height: 40px; font-size: 18px; }
  .pc-pct { align-self: flex-start; padding: 6px 10px; }
  .pc-pct-big { font-size: 18px; }
  .pc-totals {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    padding: 10px !important;
  }
  .pc-progress { grid-column: 1 / -1; }
  .pc-total .val { font-size: 14px; }
  .pc-quarters { grid-template-columns: 1fr !important; gap: 10px; }
  .pc-q-card { padding: 10px; }
  .pc-q-summary { gap: 4px; }
  .pc-q-summary .val { font-size: 12px; }

  /* Tax balance cards */
  .tax-balance-card { padding: 12px; }

  /* Branch map cards on Revenue/Expense */
  .bmc-grid { grid-template-columns: 1fr !important; }

  /* Reports wizard */
  .rep-branch-card { flex: 1 1 100%; }

  /* Quarter cards in profits page */
  .quarter-card { padding: 10px; }

  /* Holiday awareness card pills */
  .holiday-pills { flex-direction: column; align-items: stretch; }

  /* Hide non-essential icons on very narrow screens */
  .page-sub { margin-bottom: 10px; }
  .branch-summary-strip {
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    font-size: 12px;
  }

  /* Prevent horizontal overflow everywhere */
  .card, .section-head, .pc-q-card, .partner-card { max-width: 100%; overflow-x: hidden; }
  .app { overflow-x: hidden; }

  /* Make sure pill/chip rows don't force overflow */
  .row, .toolbar, .form-row { flex-wrap: wrap; }
}

/* Even tighter (≤ 360px) — cheap android phones */
@media (max-width: 360px) {
  html, body { font-size: 13px; }
  .kpi .v { font-size: 15px !important; }
  .main { padding: 10px 8px !important; }
  .card { padding: 10px; }
  .pc-totals { grid-template-columns: 1fr !important; }
}

@media print {
  .sidebar, .toolbar, .branch-switcher, .btn { display: none !important; }
  .app  { grid-template-columns: 1fr; }
  .main { padding: 0; }
  .card { box-shadow: none; border-color: #ddd; }
  body  { background: #fff; color: #000; }
  .card, .branch-header, table.t, table.t th, table.t td {
    background: #fff !important; color: #000 !important; border-color: #ddd !important;
  }
}
