/* =====================================================================
   Theme tokens — dark (default) and light. Toggled via [data-theme] on
   <html> (see the inline script in index.html <head> that sets it before
   first paint, and app.js's toggleTheme()). Every rule below reads colors
   from these tokens so both themes stay in sync automatically; only a
   handful of structural properties (gradients vs. flat fills, shadow
   depth) are branched explicitly where the two themes intentionally look
   different in kind, not just in color.
   ===================================================================== */
:root, [data-theme="dark"] {
  --primary: #5b8cff;
  --primary-mid: #3563d6;
  --primary-dark: #142452;
  --primary-hover: #4a7cf2;
  --primary-soft: rgba(91, 140, 255, .16);
  --primary-soft-strong: rgba(91, 140, 255, .26);
  --primary-line: rgba(91, 140, 255, .38);

  /* Lifted off true black and pulled text back from pure white -- the old
     #0a0e18/#eef1f8 pairing measured fine on paper but read as glare over a
     full day of use. Panels keep the same relative steps, just on a softer
     base. */
  --bg: #12151d;
  --panel: #1a2032;
  --panel-muted: #161b29;
  --panel-elevated: #202739;
  --text: #e3e7f0;
  --text-2: #b0bacf;
  --muted: #8791a9;
  --muted-2: #6c7690;
  --line: #29314a;
  --line-strong: #3a4460;

  --green: #34d399;
  --green-bg: rgba(52, 211, 153, .15);
  --green-line: rgba(52, 211, 153, .36);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, .15);
  --red-line: rgba(248, 113, 113, .36);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, .15);
  --amber-line: rgba(251, 191, 36, .36);
  --violet: #a78bfa;
  --violet-bg: rgba(167, 139, 250, .16);
  --violet-line: rgba(167, 139, 250, .38);
  --rose: #e2a4bb;
  --rose-bg: rgba(217, 155, 176, .14);
  --rose-line: rgba(217, 155, 176, .32);
  --rose-panel: #1c1520;
  --teal: #2dd4bf;
  --teal-bg: rgba(45, 212, 191, .15);
  --teal-line: rgba(45, 212, 191, .36);
  --carrot: #fb923c;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px rgba(0, 0, 0, .38);
  --shadow-md: 0 16px 36px rgba(0, 0, 0, .5), 0 4px 14px rgba(0, 0, 0, .4);
  --shadow-lg: 0 32px 80px rgba(0, 0, 0, .62), 0 10px 30px rgba(0, 0, 0, .45);

  --btn-primary-bg: linear-gradient(155deg, #7fabff, var(--primary) 68%);
  --btn-primary-bg-hover: linear-gradient(155deg, #6fa0ff, var(--primary-hover) 68%);
  --btn-primary-text: #0b1730;
  --btn-primary-shadow: 0 6px 16px rgba(91, 140, 255, .22);
  --btn-primary-shadow-hover: 0 8px 20px rgba(91, 140, 255, .28);

  --nav-active-bg: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
  --nav-active-shadow: 0 6px 16px -4px rgba(53, 99, 214, .4), inset 0 0 0 1px rgba(255, 255, 255, .08);

  --sidebar-bg-1: #070b16;
  --sidebar-bg-2: #020408;
  --sidebar-line: rgba(255, 255, 255, .06);
  --sidebar-shadow: 18px 0 46px -28px rgba(0, 0, 0, .7);
  --sidebar-text: #97a5c2;
  --sidebar-text-hover: #ffffff;
  --sidebar-hover-bg: rgba(255, 255, 255, .07);
  --sidebar-chip-bg: rgba(255, 255, 255, .03);
  --sidebar-chip-line: rgba(255, 255, 255, .08);
  --sidebar-muted: #8592af;
  --sidebar-icon-btn: #9aa7c2;

  --login-hero-bg:
    radial-gradient(680px 460px at 14% -6%, rgba(91, 140, 255, .32), transparent 60%),
    radial-gradient(620px 520px at 105% 18%, rgba(52, 211, 153, .14), transparent 55%),
    linear-gradient(165deg, #142c5c 0%, #0b1730 46%, #05070f 100%);
  --login-bg-solid: #060a14;
  --login-dot-color: rgba(255, 255, 255, .07);
}

[data-theme="light"] {
  --primary: #2f66ea;
  --primary-mid: #1e4fc7;
  --primary-dark: #163a99;
  --primary-hover: #2657d1;
  --primary-soft: rgba(47, 102, 234, .10);
  --primary-soft-strong: rgba(47, 102, 234, .16);
  --primary-line: rgba(47, 102, 234, .34);

  /* The old bg/panel/line trio all sat within a couple of points of each
     other, so cards and dividers nearly vanished against the page. Panels
     stay white; the page ground and lines are pulled down enough to read
     as actual edges instead of a flat wash. */
  --bg: #e9edf3;
  --panel: #ffffff;
  --panel-muted: #eef1f6;
  --panel-elevated: #ffffff;
  --text: #14171d;
  --text-2: #3c4453;
  --muted: #5b6373;
  --muted-2: #7c8496;
  --line: #d7dde6;
  --line-strong: #b9c1d1;

  --green: #148a52;
  --green-bg: rgba(20, 138, 82, .10);
  --green-line: rgba(20, 138, 82, .3);
  --red: #d1332f;
  --red-bg: rgba(209, 51, 47, .09);
  --red-line: rgba(209, 51, 47, .3);
  --amber: #b3690a;
  --amber-bg: rgba(179, 105, 10, .1);
  --amber-line: rgba(179, 105, 10, .3);
  --violet: #6d3fd6;
  --violet-bg: rgba(109, 63, 214, .1);
  --violet-line: rgba(109, 63, 214, .3);
  --rose: #ad5c76;
  --rose-bg: rgba(173, 92, 118, .09);
  --rose-line: rgba(173, 92, 118, .28);
  --rose-panel: #fdf4f7;
  --teal: #0e8a7c;
  --teal-bg: rgba(14, 138, 124, .1);
  --teal-line: rgba(14, 138, 124, .3);
  --carrot: #c2570b;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 0 rgba(16, 24, 40, .03);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, .07);
  --shadow-lg: 0 24px 55px rgba(16, 24, 40, .16);

  --btn-primary-bg: var(--primary);
  --btn-primary-bg-hover: var(--primary-hover);
  --btn-primary-text: #ffffff;
  --btn-primary-shadow: 0 4px 12px rgba(47, 102, 234, .22);
  --btn-primary-shadow-hover: 0 6px 16px rgba(47, 102, 234, .28);

  --nav-active-bg: var(--primary);
  --nav-active-shadow: 0 4px 14px rgba(47, 102, 234, .28);

  --sidebar-bg-1: #f7f7f9;
  --sidebar-bg-2: #eef0f4;
  --sidebar-line: #e5e8ee;
  --sidebar-shadow: 1px 0 0 rgba(16, 24, 40, .04);
  --sidebar-text: #5a6272;
  --sidebar-text-hover: #16181d;
  --sidebar-hover-bg: rgba(16, 24, 40, .05);
  --sidebar-chip-bg: rgba(16, 24, 40, .035);
  --sidebar-chip-line: rgba(16, 24, 40, .08);
  --sidebar-muted: #757e8e;
  --sidebar-icon-btn: #6b7280;

  --login-hero-bg:
    radial-gradient(680px 460px at 14% -6%, rgba(47, 102, 234, .12), transparent 60%),
    radial-gradient(620px 520px at 105% 18%, rgba(20, 138, 82, .1), transparent 55%),
    linear-gradient(165deg, #f4f7ff 0%, #ffffff 46%, #fbfbfd 100%);
  --login-bg-solid: #ffffff;
  --login-dot-color: rgba(16, 24, 40, .05);
}

:root {
  --radius-sm: 11px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --sidebar: 268px;
  --control-h: 44px;
  --ease: cubic-bezier(.22, .7, .24, 1);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans Georgian", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .2s var(--ease), color .2s var(--ease);
}
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a, button, input, select, textarea { outline: none; }
:focus-visible { outline: 3px solid var(--primary-line); outline-offset: 2px; border-radius: 4px; }
.hidden { display: none !important; }
::selection { background: var(--primary-soft-strong); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ===================== Icon system ===================== */
/* One inline SVG sprite (see index.html <symbol> defs) referenced everywhere
   via <svg class="icon"><use href="#ic-name"/></svg> — crisp at any size,
   colored with currentColor, no external icon font / CDN dependency. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 19px; height: 19px;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: -5px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-icon .icon { width: 20px; height: 20px; stroke-width: 1.8; }
.kpi-icon .icon { width: 21px; height: 21px; stroke-width: 1.9; }
.qa-icon .icon { width: 19px; height: 19px; }
.qa-chevron { color: var(--muted-2); display: inline-flex; }
.qa-chevron .icon { width: 15px; height: 15px; transform: rotate(-90deg); }
.icon-btn .icon { width: 19px; height: 19px; }
.month-chip .icon { width: 16px; height: 16px; color: var(--primary); }
.btn .icon { width: 16px; height: 16px; }
.btn.small .icon { width: 14px; height: 14px; }
.modal-close .icon, .company-menu-close .icon { width: 17px; height: 17px; }
.row-action .icon { width: 17px; height: 17px; }
.search-box .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--muted); pointer-events: none; }
.text-link { display: inline-flex; align-items: center; gap: 3px; }
.text-link .icon { width: 14px; height: 14px; transform: rotate(-90deg); }
.sort-arrow-icon { width: 13px; height: 13px; transition: transform .15s var(--ease); }
.sort-arrow-icon.is-asc { transform: rotate(180deg); }
.sort-arrow-icon.neutral { opacity: .55; }
.company-action-menu > button[role="menuitem"] > span .icon { width: 18px; height: 18px; }
.inline-action .icon { width: 15px; height: 15px; }
.user-card button .icon { width: 18px; height: 18px; }

/* ===================== Status-by-color company names ===================== */
/* Applied to company name links/headings wherever a subscriber's financial
   status is known, so the name itself carries the same color as its badge. */
.st-paid { color: var(--green) !important; }
.st-due { color: var(--amber) !important; }
.st-debt { color: var(--red) !important; }
.st-advance { color: #A855F7 !important; }

/* Real money already sitting as advance for the CURRENT (still in-progress)
   month, with no service invoice sent for it yet -- worth a harder-to-miss
   flag than the calm violet "paid ahead" badge, since it's the one advance
   case that needs an action (send the invoice), not just information. Wins
   over .st-advance above by appearing later in the cascade (both use
   !important at equal specificity) -- opacity carries the blink so it
   doesn't fight that color rule the way animating color itself would. */
.needs-invoice { color: var(--red) !important; animation: invoice-blink 1.1s ease-in-out infinite; }
@keyframes invoice-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.status-badge.invoice-alert { background: var(--red-bg); color: var(--red); animation: invoice-blink 1.1s ease-in-out infinite; }

/* ===================== Login ===================== */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: var(--login-hero-bg);
  background-color: var(--login-bg-solid);
}
.login-screen::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(var(--login-dot-color) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(700px 500px at 50% 15%, #000 0%, transparent 75%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(440px, 100%);
  padding: 42px 40px 36px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel-elevated);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.brand-mark {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: grid; place-items: center;
  flex: 0 0 auto;
  color: #fff;
  font-family: Inter, "Noto Sans Georgian", sans-serif;
  font-size: 20px; font-weight: 800;
  background: linear-gradient(150deg, #7fabff 0%, var(--primary) 55%, var(--primary-mid) 100%);
  box-shadow: 0 10px 24px rgba(91, 140, 255, .35);
}
.brand-mark.large { width: 66px; height: 66px; margin: 0 auto 20px; border-radius: 20px; font-size: 30px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.brand-mark.has-logo { background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.12); padding: 6px; }
.profile-logo-row { display: flex; align-items: center; gap: 18px; }
.profile-logo-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.login-card h1 { margin: 0; font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 31px; line-height: 1.2; font-weight: 700; letter-spacing: .06em; color: var(--text); }
.login-subtitle { margin: 6px 0 22px; color: var(--primary); font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 13px; font-weight: 600; letter-spacing: .17em; text-transform: uppercase; }
.login-copy { margin-bottom: 27px; color: var(--text-2); font-size: 14px; }
.login-card form { text-align: left; }
.login-card label, .field label { display: block; margin-bottom: 7px; color: var(--text-2); font-size: 13px; font-weight: 650; }
.login-card input, .field input, .field select, .field textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--panel-muted);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
.login-card input { margin-bottom: 15px; }
.login-card input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--muted-2); }
.login-card input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--muted-2); }
.login-card input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.login-card small { display: block; margin-top: 23px; color: var(--muted-2); font-size: 12.5px; }
.form-error { min-height: 20px; margin-top: 10px; color: var(--red); font-size: 13px; font-weight: 600; text-align: center; }

/* ===================== Shell ===================== */
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar);
  overflow-x: hidden; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  color: var(--sidebar-text);
  background: linear-gradient(178deg, var(--sidebar-bg-1) 0%, var(--sidebar-bg-2) 100%);
  border-right: 1px solid var(--sidebar-line);
  box-shadow: var(--sidebar-shadow);
  transition: background .2s var(--ease), width .2s var(--ease), padding .2s var(--ease);
}
/* Collapsed sidebar — icon-only rail. Toggled via #sidebarToggleBtn (app.js
   toggleSidebar()), persisted in localStorage, applied pre-paint in <head>
   to avoid a flash of the expanded sidebar on load. */
.sidebar-toggle-btn { width: 30px; height: 30px; flex: 0 0 auto; margin-left: auto; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--sidebar-icon-btn); cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease); }
.sidebar-toggle-btn .icon { width: 17px; height: 17px; }
.sidebar-toggle-btn:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-hover); }
:root[data-sidebar="collapsed"] .sidebar { width: 76px; padding: 22px 10px 16px; }
:root[data-sidebar="collapsed"] .brand { flex-direction: column; justify-content: center; padding: 4px 0 26px; gap: 10px; }
:root[data-sidebar="collapsed"] .sidebar-toggle-btn { margin-left: 0; }
:root[data-sidebar="collapsed"] .brand-text,
:root[data-sidebar="collapsed"] .nav-item span:not(.nav-icon),
:root[data-sidebar="collapsed"] .user-card strong,
:root[data-sidebar="collapsed"] .user-card small { display: none; }
:root[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 10px; gap: 0; }
:root[data-sidebar="collapsed"] .user-card { grid-template-columns: 1fr; justify-items: center; gap: 8px; }
:root[data-sidebar="collapsed"] .workspace { width: calc(100% - 76px); margin-left: 76px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 26px; }
.brand-link { appearance: none; border: 0; margin: 0; padding: 0; background: transparent; display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; cursor: pointer; border-radius: 10px; transition: opacity .15s var(--ease); }
.brand-link:hover { opacity: .85; }
.brand-text strong { display: block; font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 19px; font-weight: 700; letter-spacing: .045em; color: var(--sidebar-text-hover); }
.brand-text small { display: block; margin-top: 2px; color: var(--primary); font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 11px; font-weight: 600; letter-spacing: .14em; }
.sidebar nav { display: grid; gap: 4px; }
.nav-item {
  position: relative;
  width: 100%; min-height: 46px;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 13px;
  border: 0; border-radius: 12px;
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  text-align: left;
  font-size: 14.5px; font-weight: 610;
  letter-spacing: .002em;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-item:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-hover); }
.nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.nav-item.active {
  background: var(--nav-active-bg);
  color: #fff;
  box-shadow: var(--nav-active-shadow);
}
.nav-icon { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; color: currentColor; opacity: .95; }
.nav-item[data-view="dashboard"] .nav-icon { color: var(--primary); }
.nav-item[data-view="subscribers"] .nav-icon { color: var(--violet); }
.nav-item[data-view="packages"] .nav-icon { color: var(--amber); }
.nav-item[data-view="disconnected"] .nav-icon { color: var(--rose); }
.nav-item[data-view="payments"] .nav-icon { color: var(--green); }
.nav-item[data-view="unmatched"] .nav-icon { color: var(--amber); }
.nav-item[data-view="debts"] .nav-icon { color: var(--red); }
.nav-item[data-view="invoices"] .nav-icon { color: var(--primary); }
.nav-item[data-view="reports"] .nav-icon { color: var(--violet); }
.nav-item[data-view="accounting"] .nav-icon { color: var(--green); }
.nav-item[data-view="expenses"] .nav-icon { color: var(--teal); }
.nav-item[data-view="calculators"] .nav-icon { color: var(--green); }
.nav-item[data-view="analytics"] .nav-icon { color: var(--carrot); }
.nav-item[data-view="audit"] .nav-icon { color: var(--rose); }
.nav-item[data-view="profile"] .nav-icon { color: var(--primary); }
.nav-item[data-view="settings"] .nav-icon { color: var(--violet); }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { color: currentColor; }
.sidebar-spacer { flex: 1; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; background: #33d18b; box-shadow: 0 0 0 4px rgba(51, 209, 139, .18); }
.db-status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-muted); }
.db-status-row strong { display: block; font-size: 13px; font-weight: 650; color: var(--text); }
.db-status-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.user-card { display: grid; grid-template-columns: 38px 1fr 34px; gap: 9px; align-items: center; padding: 9px 10px; border: 1px solid var(--sidebar-chip-line); border-radius: 13px; background: var(--sidebar-chip-bg); }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(150deg, #4a7cf2, #223a86); color: #fff; font-size: 14.5px; font-weight: 650; }
.user-card strong { display: block; font-size: 13px; font-weight: 650; color: var(--sidebar-text-hover); }
.user-card small { display: block; margin-top: 2px; color: var(--sidebar-muted); font-size: 11px; }
.user-card button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--sidebar-icon-btn); cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease); }
.user-card button:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-hover); }

.workspace { width: calc(100% - var(--sidebar)); min-width: 0; margin-left: var(--sidebar); transition: width .2s var(--ease), margin-left .2s var(--ease); }
.topbar {
  position: sticky; top: 0; z-index: 12;
  height: 76px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
}
.page-heading { min-width: 0; }
.page-heading h1 { margin: 0 0 3px; font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -.016em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.month-chip { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--text-2); font-size: 13.5px; font-weight: 550; box-shadow: var(--shadow-xs); }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--text-2); cursor: pointer; transition: border-color .15s var(--ease), color .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease); box-shadow: var(--shadow-xs); }
.icon-btn:hover { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.small { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.small .icon { width: 15px; height: 15px; }

.content { width: 100%; max-width: 2000px; margin: 0 auto; padding: 26px 30px 44px; }
.view { display: none; }
.view.active { display: block; animation: view-in .22s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.welcome-row, .section-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.export-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.welcome-row h2, .section-header h2 { margin: 0 0 4px; font-size: 23px; line-height: 1.3; font-weight: 650; letter-spacing: -.013em; color: var(--text); }
.welcome-row p, .section-header p { margin: 0; color: var(--muted); font-size: 13px; }
.legend-note { min-height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text-2); font-size: 12.5px; white-space: nowrap; box-shadow: var(--shadow-xs); }

/* ===================== Buttons ===================== */
.btn {
  min-height: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13.5px; font-weight: 650;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease);
}
.btn:hover { border-color: var(--muted-2); background: var(--panel-elevated); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--primary); background: var(--btn-primary-bg); color: var(--btn-primary-text); box-shadow: var(--btn-primary-shadow); }
.btn.primary:hover { border-color: var(--primary-hover); background: var(--btn-primary-bg-hover); box-shadow: var(--btn-primary-shadow-hover); }
.btn.ghost { background: var(--panel-muted); }
.btn.ghost.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.btn.wide { width: 100%; margin-top: 4px; }
.text-link { min-height: 32px; padding: 4px 2px; border: 0; background: transparent; color: var(--primary); cursor: pointer; font-size: 12.5px; font-weight: 650; }
.text-link:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 2px; }

/* ===================== KPI cards ===================== */
.kpi-grid { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.expenses-kpi-grid { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
.kpi-card {
  position: relative;
  overflow: hidden;
  min-height: 126px;
  display: flex; align-items: flex-start; gap: 14px;
  padding: 19px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.kpi-card.blue::before { background: var(--primary); }
.kpi-card.green::before { background: var(--green); }
.kpi-card.red::before { background: var(--red); }
.kpi-card.amber::before { background: var(--amber); }
.kpi-card.violet::before { background: var(--violet); }
.kpi-card.rose::before { background: var(--rose); }
.kpi-card.teal::before { background: var(--teal); }
.kpi-icon { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 14px; box-shadow: var(--shadow-xs); }
.blue .kpi-icon { background: var(--primary-soft); color: var(--primary); }
.green .kpi-icon { background: var(--green-bg); color: var(--green); }
.red .kpi-icon { background: var(--red-bg); color: var(--red); }
.amber .kpi-icon { background: var(--amber-bg); color: var(--amber); }
.violet .kpi-icon { background: var(--violet-bg); color: var(--violet); }
.rose .kpi-icon { background: var(--rose-bg); color: var(--rose); }
.teal .kpi-icon { background: var(--teal-bg); color: var(--teal); }
.kpi-card span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi-card strong { display: block; font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 25px; line-height: 1.2; font-weight: 680; letter-spacing: -.025em; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi-card small { display: block; margin-top: 7px; color: var(--muted-2); font-size: 12px; }

/* ===================== Panels / dashboard ===================== */
.dashboard-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.primary-grid { grid-template-columns: minmax(0, 1.55fr) minmax(285px, .82fr) minmax(250px, .72fr); }
.secondary-grid { grid-template-columns: minmax(0, 1.2fr) minmax(260px, .72fr) minmax(290px, .9fr); }
.expenses-charts-grid { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); }
.panel, .table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.panel-head { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0 0 3px; font-size: 15px; line-height: 1.35; font-weight: 620; color: var(--text); }
.panel-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.soft-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 11px; border-radius: 8px; font-size: 12px; font-weight: 620; }
.soft-badge.blue { background: var(--primary-soft); color: var(--primary); }
.finance-chart { height: 282px; padding: 18px 18px 14px; position: relative; display: flex; flex-direction: column; gap: 6px; }
.finance-chart.large { height: 372px; }
.chart-svg { width: 100%; flex: 1 1 auto; min-height: 0; display: block; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis-text { fill: var(--muted); font-size: 11.5px; font-family: Inter, "Noto Sans Georgian", sans-serif; }
.area-billed, .area-paid, .area-outstanding { opacity: .9; }
.line-billed, .line-paid, .line-outstanding { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.line-billed { stroke: var(--primary); stroke-width: 2.4; filter: drop-shadow(0 0 6px rgba(91, 140, 255, .3)); }
.line-paid { stroke: var(--green); stroke-width: 2.6; filter: drop-shadow(0 0 6px rgba(52, 211, 153, .3)); }
.line-outstanding { fill: none; stroke: var(--red); stroke-width: 2.1; stroke-dasharray: 5 4; }
.chart-dot-billed { fill: var(--primary); stroke: var(--panel); stroke-width: 1.6; }
.chart-dot-paid { fill: var(--green); stroke: var(--panel); stroke-width: 1.6; }
.chart-dot-outstanding { fill: var(--red); stroke: var(--panel); stroke-width: 1.6; }
.yearly-line-cur, .yearly-line-prev { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.yearly-line-cur { stroke: var(--primary); stroke-width: 2.6; filter: drop-shadow(0 0 6px rgba(91, 140, 255, .3)); }
.yearly-line-prev { stroke: var(--muted-2); stroke-width: 2.1; stroke-dasharray: 5 4; }
.yearly-dot-cur { fill: var(--primary); stroke: var(--panel); stroke-width: 1.6; }
.yearly-dot-prev { fill: var(--muted-2); stroke: var(--panel); stroke-width: 1.6; }
.yearly-hover-line { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; transition: opacity .12s var(--ease); }
.yearly-hover-dot { stroke: var(--panel); stroke-width: 2; pointer-events: none; transition: opacity .12s var(--ease); }
.yearly-hover-dot-cur { fill: var(--primary); filter: drop-shadow(0 0 6px rgba(91, 140, 255, .6)); }
.yearly-hover-dot-prev { fill: var(--muted-2); }
.yearly-hover-capture { cursor: crosshair; }
.chart-tooltip { position: absolute; left: 0; top: 0; transform: translate(-50%, calc(-100% - 14px)); background: var(--panel-elevated); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.5; white-space: nowrap; pointer-events: none; z-index: 5; }
.chart-tooltip-month { font-weight: 660; color: var(--text); margin-bottom: 3px; }
.chart-tooltip-row { display: flex; align-items: center; gap: 7px; }
.chart-tooltip-row span:nth-child(2) { color: var(--muted); flex: 1 1 auto; }
.chart-tooltip-row b { font-variant-numeric: tabular-nums; margin-left: 10px; }
.chart-tooltip-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.chart-tooltip-dot.cur { background: var(--primary); }
.chart-tooltip-dot.prev { background: var(--muted-2); }
.chart-tooltip-delta { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); font-weight: 660; font-size: 11.5px; }
.chart-tooltip-delta.up { color: var(--green); }
.chart-tooltip-delta.down { color: var(--red); }
.bar-billed { fill: var(--primary); }
.bar-paid { fill: var(--green); }
.bar-outstanding { fill: var(--red); }
.bar-expenses { fill: #4285F4; transition: opacity .12s var(--ease); cursor: default; }
.bar-expenses:hover { opacity: .82; }
.chart-bar-value { fill: var(--text-2); font-size: 11.5px; font-weight: 650; font-family: Inter, "Noto Sans Georgian", sans-serif; font-variant-numeric: tabular-nums; }

.ai-chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; margin-bottom: 14px; }
.ai-chat-msg { padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.6; max-width: 88%; white-space: pre-wrap; }
.ai-chat-msg.user { align-self: flex-end; background: var(--primary-soft); color: var(--text); }
.ai-chat-msg.ai { align-self: flex-start; background: var(--panel-muted); color: var(--text); border: 1px solid var(--line); }
.ai-chat-input-row { display: flex; gap: 8px; }
.ai-chat-input-row input { flex: 1 1 auto; min-height: var(--control-h); padding: 8px 13px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel-muted); color: var(--text); font-size: 14px; }
.ai-chat-input-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); outline: none; }
.expense-group-row td { background: var(--panel-muted); font-weight: 640; color: var(--text); border-top: 1px solid var(--line); }
.expense-group-row td:first-child { text-align: left; }
.expense-group-row td.money { color: var(--carrot); }
.expense-group-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.expense-grand-total-row td { background: var(--panel-elevated); font-weight: 700; color: var(--primary); border-top: 2px solid var(--line-strong); font-size: 14.5px; }
.expense-grand-total-row td:first-child { text-align: left; }
.spectrum-line-billed, .spectrum-line-paid, .spectrum-line-outstanding { fill: none; stroke-linejoin: round; stroke-linecap: round; stroke-width: 2; }
.spectrum-line-billed { stroke: #c9862a; }
.spectrum-line-paid { stroke: #22c3a0; }
.spectrum-line-outstanding { stroke: #e79aa0; }
.spectrum-dot-billed { fill: #c9862a; stroke: var(--panel); stroke-width: 1.4; }
.spectrum-dot-paid { fill: #22c3a0; stroke: var(--panel); stroke-width: 1.4; }
.spectrum-dot-outstanding { fill: #e79aa0; stroke: var(--panel); stroke-width: 1.4; }
.chart-legend.spectrum .billed:before { background: #c9862a; }
.chart-legend.spectrum .paid:before { background: #22c3a0; }
.chart-legend.spectrum .outstanding:before { background: #e79aa0; }
.chart-legend { flex: 0 0 auto; display: flex; gap: 18px; color: var(--text-2); font-size: 12.5px; font-weight: 550; }
.chart-legend span:before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; }
.chart-legend .billed:before { background: var(--primary); }
.chart-legend .paid:before { background: var(--green); }
.chart-legend .outstanding:before { background: var(--red); }

.donut-wrap { display: grid; grid-template-columns: 150px minmax(120px, 1fr); align-items: center; gap: 14px; padding: 30px 17px 25px; }
.donut { width: 140px; height: 140px; display: grid; place-items: center; position: relative; border-radius: 50%; background: conic-gradient(var(--green) 0 25%, var(--amber) 25% 50%, var(--red) 50% 75%, var(--primary) 75% 100%); box-shadow: 0 0 0 1px var(--line), var(--shadow-md); }
.donut:before { content: ""; position: absolute; width: 92px; height: 92px; border-radius: 50%; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.donut-center { position: relative; text-align: center; }
.donut-center strong { display: block; font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 26px; line-height: 1.2; font-weight: 680; color: var(--text); }
#expensesCategoryDonut .donut-center strong { font-size: 17px; white-space: nowrap; }
.donut-center small { color: var(--muted); font-size: 12px; }
.status-legend { display: grid; gap: 12px; }
.status-legend > div { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 9px; color: var(--text-2); font-size: 13px; }
.status-legend b { color: var(--text); font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 13px; font-variant-numeric: tabular-nums; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-dot.green { background: var(--green); }
.legend-dot.amber { background: var(--amber); }
.legend-dot.red { background: var(--red); }
.legend-dot.blue { background: var(--primary); }
.legend-dot.muted { background: var(--muted-2); }
.legend-dot.violet { background: #A855F7; }
.status-legend-inline { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.status-legend-inline .legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.yearly-panel { margin-bottom: 20px; }
.yearly-summary { display: flex; gap: 22px; }
.yearly-summary > div { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.yearly-summary b { font-family: Inter, "Noto Sans Georgian", sans-serif; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

.quick-actions { padding: 7px 10px 10px; }
.quick-actions button { width: 100%; min-height: 62px; display: grid; grid-template-columns: 40px 1fr 16px; gap: 12px; align-items: center; padding: 8px 8px; border: 0; border-radius: 12px; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; text-align: left; transition: background .14s var(--ease); }
.quick-actions button:last-child { border-bottom: 0; }
.quick-actions button:hover { background: var(--primary-soft); }
.quick-actions b { display: block; font-size: 13px; font-weight: 660; }
.quick-actions small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.qa-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; box-shadow: var(--shadow-xs); }
.qa-icon.blue { background: var(--primary-soft); color: var(--primary); }
.qa-icon.green { background: var(--green-bg); color: var(--green); }
.qa-icon.amber { background: var(--amber-bg); color: var(--amber); }
.qa-icon.violet { background: var(--violet-bg); color: var(--violet); }

/* Compact dashboard lists injected by app.js */
.mini-table, .rank-list, .payment-list { min-height: 214px; }
.mini-row, .rank-row, .payment-row { min-height: 58px; display: grid; align-items: center; gap: 10px; padding: 9px 17px; border-bottom: 1px solid var(--line); transition: background .13s var(--ease); }
.mini-row:hover, .rank-row:hover, .payment-row:hover { background: var(--panel-muted); }
.mini-row:last-child, .rank-row:last-child, .payment-row:last-child { border-bottom: 0; }
.mini-row { grid-template-columns: minmax(0,1fr) auto auto auto; }
.rank-row { grid-template-columns: minmax(0,1fr) auto; }
.payment-row { grid-template-columns: minmax(0,1fr) auto; }
.company-sub, .cell-sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.cell-main { font-size: 14px; font-weight: 660; }

/* ===================== Tables ===================== */
.table-toolbar { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.search-box { width: min(470px, 62%); position: relative; }
.search-box input, .table-toolbar select { min-height: 42px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel-muted); color: var(--text); font-size: 13.5px; }
.search-box input::placeholder { color: var(--muted-2); }
.search-box input { width: 100%; padding: 8px 12px 8px 42px; }
.table-toolbar select { min-width: 175px; padding: 8px 32px 8px 13px; }
.search-box input:focus, .table-toolbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.table-scroll { width: 100%; overflow: auto; }
/* Cards with a toolbar (subscribers/disconnected/unmatched) get a viewport-relative
   bounded height so .table-scroll becomes a REAL internal scroll container — not just
   a horizontal one. That's what makes thead's position:sticky actually work: sticky only
   tracks its nearest ancestor that truly scrolls, and an unbounded .table-scroll never
   did (it just grew to fit content, letting the page scroll instead). The toolbar itself
   no longer needs position:sticky at all — it now sits outside the scrolling area, so it's
   simply always visible. */
.table-toolbar + .table-scroll { max-height: min(1200px, calc(100vh - 260px)); overflow-y: auto; }
table { width: 100%; min-width: 930px; border-collapse: separate; border-spacing: 0; }
thead th { position: sticky; top: 0; z-index: 1; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel-muted); color: var(--muted); font-size: 12px; font-weight: 630; letter-spacing: .02em; text-align: center; white-space: nowrap; }
thead th:first-child { text-align: left; }
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line); color: var(--text-2); font-size: 14px; vertical-align: middle; text-align: center; }
tbody td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-muted); }
.money { font-family: Inter, "Noto Sans Georgian", sans-serif; font-weight: 660; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text); }
.money.green { color: var(--green); }
.money.red { color: var(--red); }
.status-badge { min-height: 26px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 660; white-space: nowrap; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.status-badge.paid { background: var(--green-bg); color: var(--green); }
.status-badge.due { background: var(--amber-bg); color: var(--amber); }
.status-badge.debt { background: var(--red-bg); color: var(--red); }
.status-badge.advance { background: rgba(168, 85, 247, .15); color: #A855F7; }
.status-badge.period { background: linear-gradient(150deg, #4a7cf2, #223a86); color: #fff; }
.status-badge.bank { background: var(--primary-soft); color: var(--primary); }
.status-badge-btn { border: 0; cursor: pointer; font: inherit; transition: filter .12s var(--ease); }
.status-badge-btn:hover { filter: brightness(1.18); }
.status-badge.invoiced { background: var(--primary-soft); color: var(--primary); }
.row-action { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 10px; background: var(--panel-muted); color: var(--text-2); cursor: pointer; transition: border-color .14s var(--ease), background .14s var(--ease), color .14s var(--ease); }
.row-action:hover { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary); }
.table-footer { min-height: 44px; display: flex; align-items: center; padding: 8px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }

/* ===================== Debt/reports ===================== */
.kpi-strip { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-bottom: 15px; }
.kpi-strip div, .report-grid article { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); box-shadow: var(--shadow-sm); }
.kpi-strip span, .report-grid span { display: block; color: var(--muted); font-size: 13px; }
.kpi-strip b { display: block; margin-top: 6px; font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 22px; font-variant-numeric: tabular-nums; color: var(--text); }
.report-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.report-grid strong { display: block; margin: 9px 0 5px; font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 27px; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--text); }
.report-grid small { color: var(--muted-2); font-size: 12px; }
.report-chart-panel { margin-top: 12px; }

/* ===================== Modals ===================== */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; background: rgba(2, 5, 10, .68); backdrop-filter: blur(4px); animation: backdrop-in .16s var(--ease); }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(550px, 100%); max-height: 92vh; overflow: auto; border: 1px solid var(--line); border-radius: 20px; background: var(--panel-elevated); box-shadow: var(--shadow-lg); animation: modal-in .2s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.wide-modal { width: min(750px, 100%); }
.extra-wide-modal { width: min(950px, 100%); }
.detail-modal { width: min(790px, 100%); }
.modal-head { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0 0 3px; font-size: 18px; line-height: 1.3; font-weight: 630; color: var(--text); }
.modal-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.modal-close { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 11px; background: var(--panel-muted); color: var(--text-2); cursor: pointer; transition: background .14s var(--ease), color .14s var(--ease); }
.modal-close:hover { background: var(--line-strong); color: var(--text); }
.modal-body { padding: 21px 22px; }
.field { margin-bottom: 14px; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.calc-triple { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 13px; margin: 6px 0 14px; }
.money-input { position: relative; }
.money-input span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money-input input { padding-left: 32px; }
.payment-preview { display: grid; gap: 0; padding: 12px 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-muted); }
.payment-preview > div { display: flex; justify-content: space-between; gap: 18px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.payment-preview > div:last-child { border-bottom: 0; }
.payment-preview span { color: var(--muted); }
.payment-preview b { font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--text); }
.payment-preview .highlight { margin: 5px -5px -3px; padding: 10px 9px; border-radius: 9px; background: var(--green-bg); color: var(--green); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 17px; }
.detail-actions { padding: 15px 22px; border-top: 1px solid var(--line); }
.detail-block { padding-bottom: 26px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.detail-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.detail-block > h4 { margin: 0 0 14px; font-size: 15px; color: var(--text); }
.detail-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 9px; margin-bottom: 14px; }
.detail-summary > div { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-muted); }
.detail-summary span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.detail-summary b { font-size: 16px; color: var(--text); }
/* Subscriber page: KPI row, status strip and the current-period panel.
   Laid out so the arrears cycle reads at a glance -- which month is
   running now, what it will cost, when it becomes payable, and how far
   back the books are closed. */
.detail-kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 11px; margin-bottom: 14px; }
.detail-kpis > div { padding: 15px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-muted); }
.detail-kpis span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.detail-kpis strong { display: block; font-family: Inter, "Noto Sans Georgian", sans-serif; font-size: 22px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--text); }
.detail-kpis small { display: block; margin-top: 5px; color: var(--muted); font-size: 11.5px; }
.detail-statusbar { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 11px; margin-bottom: 16px; }
.detail-statusbar > div { padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-muted); }
.detail-statusbar small { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.detail-statusbar b { font-size: 13.5px; color: var(--text); }
.period-panel { border: 1px solid var(--primary-line); border-radius: 14px; background: var(--primary-soft); padding: 16px 18px; margin-bottom: 16px; }
.period-panel-grid { display: grid; grid-template-columns: 1.4fr repeat(3, .8fr); gap: 18px; align-items: start; }
.period-panel small { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.period-panel b { font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.period-bar { height: 6px; margin-top: 11px; border-radius: 9px; background: var(--panel); overflow: hidden; }
.period-bar i { display: block; height: 100%; background: var(--primary); border-radius: 9px; }
@media (max-width: 900px) {
  .detail-kpis { grid-template-columns: 1fr 1fr; }
  .detail-statusbar, .period-panel-grid { grid-template-columns: 1fr; }
}
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin-bottom: 14px; }
.info-item { padding: 11px 2px; border-bottom: 1px solid var(--line); }
.info-item span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; }
.info-item b { font-size: 14px; font-weight: 620; word-break: break-word; color: var(--text); }
.subsection-title { margin: 19px 0 8px; font-size: 14px; font-weight: 620; color: var(--text); }
.history-box { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.history-row { display: grid; grid-template-columns: 96px minmax(0,1fr) 100px 92px; gap: 8px; align-items: center; padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.history-row:last-child { border-bottom: 0; }
.history-row small { color: var(--muted); font-size: 11px; }
.history-box-scroll { max-height: 250px; overflow-y: auto; }
.history-row-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.history-row-main > div:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.history-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.prior-debt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 13px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-muted); font-size: 12.5px; color: var(--text-2); }
.prior-debt-row-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.prior-debt-row-controls input { width: 74px; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel); color: var(--text); font-size: 13px; }
.prior-debt-row-controls select { min-height: 36px; padding: 6px 30px 6px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel); color: var(--text); font-size: 13px; }
.prior-debt-row-controls .money-input input { width: 92px; padding-left: 32px; }
.icon-btn.danger:hover { border-color: var(--red-line); background: var(--red-bg); color: var(--red); }
.history-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 12px; font-size: 12.5px; color: var(--muted); }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: min(390px, calc(100vw - 40px)); padding: 13px 17px; border-radius: 13px; background: var(--panel-elevated); border: 1px solid var(--line-strong); color: var(--text); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 550; opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity .2s var(--ease), transform .2s var(--ease); }
.toast.show { opacity: 1; transform: translateY(0); }
.empty-state { padding: 42px 15px; color: var(--muted); font-size: 14px; text-align: center; }
.notice-box { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--amber-bg); border: 1px solid var(--amber-line); color: var(--text-2); font-size: 13px; line-height: 1.7; margin-bottom: 16px; }
.notice-box .icon { flex: 0 0 auto; width: 20px; height: 20px; color: var(--amber); margin-top: 1px; }
.notice-box b { color: var(--text); }
.loading-line { height: 3px; background: linear-gradient(90deg, transparent, var(--primary), transparent); animation: load 1.1s infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* Accessibility / reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ===================== Responsive ===================== */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .primary-grid { grid-template-columns: 1fr 1fr; }
  .quick-panel { grid-column: 1 / -1; }
  .secondary-grid { grid-template-columns: 1fr 1fr; }
  .secondary-grid > article:last-child { grid-column: 1 / -1; }
  .report-grid { grid-template-columns: repeat(2,1fr); }
  .expenses-charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 840px) {
  :root { --sidebar: 76px; }
  .sidebar { padding: 18px 8px 14px; }
  .brand { justify-content: center; padding: 4px 6px 20px; }
  .brand-text, .nav-item span:not(.nav-icon), .user-card > div:nth-child(2) { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .user-card { display: flex; justify-content: center; padding: 8px; }
  .workspace { margin-left: var(--sidebar); width: calc(100% - var(--sidebar)); }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 14px 36px; }
  .top-actions .month-chip { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .primary-grid, .secondary-grid { grid-template-columns: 1fr; }
  .secondary-grid > article:last-child { grid-column: auto; }
  .detail-summary { grid-template-columns: 1fr 1fr; }
  .two-cols { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .topbar { height: 68px; padding: 0 12px; }
  .page-heading p, .legend-note { display: none; }
  .top-actions { gap: 6px; }
  #quickPaymentBtn .btn-label { display: none; }
  #quickPaymentBtn { padding: 9px 11px; }
  .content { padding: 16px 12px 30px; }
  .welcome-row, .section-header { align-items: flex-start; flex-wrap: wrap; }
  .welcome-row > *:last-child, .section-header > *:last-child { flex: 1 1 100%; }
  .welcome-row .btn, .section-header .btn { width: 100%; }
  .header-actions { flex-direction: column; align-items: stretch; width: 100%; }
  .kpi-grid, .report-grid, .kpi-strip { grid-template-columns: 1fr; }
  .kpi-card { min-height: 110px; }
  .search-box { width: 100%; }
  .table-toolbar { align-items: stretch; flex-direction: column; position: static; }
  .table-toolbar select { width: 100%; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .status-legend { width: 100%; padding: 0 22px; }
  .detail-summary { grid-template-columns: 1fr 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 80px minmax(0,1fr) 84px; }
  .history-row > *:nth-child(4) { display: none; }
  .modal-backdrop { padding: 10px; }
  .modal { max-height: 96vh; border-radius: 16px; }
  .modal-head, .modal-body, .detail-actions { padding-left: 16px; padding-right: 16px; }
}

/* ===== Opticom Manager System — subscriber/package workspace ===== */
.toolbar-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-controls select { min-width: 180px; }
.zoom-control { display: flex; align-items: center; gap: 2px; height: 42px; padding: 0 4px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel-muted); }
.zoom-control button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font-size: 17px; font-weight: 600; line-height: 1; cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease); }
.zoom-control button:hover { background: var(--panel-elevated); color: var(--text); }
.zoom-control span { min-width: 40px; text-align: center; font-size: 12.5px; font-weight: 620; color: var(--text-2); }
.three-cols { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.proration-preview { margin: 2px 0 14px; padding: 13px 15px; border: 1px solid var(--primary-line); border-radius: 12px; background: var(--primary-soft); color: var(--text-2); font-size: 13px; line-height: 1.6; }
.proration-preview b { color: var(--primary); }

/* Main subscriber grids get a real frozen table header. */
.subscribers-scroll { position: relative; }
.subscribers-scroll table { min-width: 1120px; }
.subscribers-scroll thead th { position: sticky; top: 0; z-index: 6; background: var(--panel-muted); box-shadow: 0 1px 0 var(--line); }

.company-link { appearance: none; border: 0; padding: 0; background: transparent; color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.company-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.company-link.prominent { font-size: 14px; text-align: center; }

.company-cell { display: inline-flex; align-items: center; gap: 6px; }
.company-cell .row-action { width: 24px; height: 24px; border-radius: 7px; flex: none; }
.company-cell .row-action .icon { width: 14px; height: 14px; }

.service-badge { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 620; white-space: nowrap; }
.service-badge.active { color: var(--green); background: var(--green-bg); border: 1px solid var(--green-line); }
.service-badge.disconnected { color: var(--rose); background: var(--rose-bg); border: 1px solid var(--rose-line); }
.service-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }

.detail-tabs { display: flex; gap: 4px; padding: 9px 20px 0; border-bottom: 1px solid var(--line); background: var(--panel-elevated); overflow-x: auto; }
.detail-tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 10px 13px 11px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: color .14s var(--ease); }
.detail-tab:hover { color: var(--text); }
.detail-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tab-section-head h4 { margin: 0 0 3px; font-size: 15px; color: var(--text); }
.tab-section-head p { margin: 0; color: var(--muted); font-size: 12px; }
.profile-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.btn.small { min-height: 36px; padding: 7px 12px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: var(--red-line); background: var(--red-bg); }
.btn.danger:hover { background: var(--red-bg); border-color: var(--red); filter: brightness(1.08); }
.btn.success { color: var(--green); border-color: var(--green-line); background: var(--green-bg); }
.btn.success:hover { background: var(--green-bg); filter: brightness(1.08); }

#view-disconnected .table-card { border-color: var(--rose-line); }
#view-disconnected .subscribers-scroll thead th { background: var(--rose-panel); }

@media (max-width: 900px) {
  .three-cols { grid-template-columns: 1fr 1fr; }
  .toolbar-controls { width: 100%; }
  .toolbar-controls select { flex: 1; min-width: 150px; }
}
@media (max-width: 620px) {
  .three-cols { grid-template-columns: 1fr; }
  .detail-tabs { padding-left: 10px; padding-right: 10px; }
  .profile-grid { grid-template-columns: 1fr; }
}

/* Header sorting + inline subscriber actions */
.sort-hint { display: inline-flex; align-items: center; min-height: 42px; padding: 0 10px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.sort-head { appearance: none; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 630; letter-spacing: inherit; text-transform: inherit; padding: 0; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.sort-head:hover, .sort-head:focus-visible { color: var(--primary); outline: none; }
.sort-head .sort-arrow { color: var(--muted-2); line-height: 1; display: inline-flex; }
.sort-head.active { color: var(--text); }
.sort-head.active .sort-arrow { color: var(--primary); }

.subscriber-row { transition: background .15s var(--ease); }
.subscriber-row.expanded { background: var(--primary-soft); }
.company-toggle { display: inline-flex; align-items: center; gap: 5px; }
.subscriber-row.expanded .company-toggle { color: var(--primary); }

.inline-menu-row td { padding: 0 !important; border-bottom: 1px solid var(--line); background: var(--primary-soft); }
.subscriber-inline-menu { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 16px 12px 27px; border-top: 1px dashed var(--line-strong); box-shadow: inset 3px 0 0 var(--primary); }
.inline-menu-meta { min-width: 150px; display: flex; flex-direction: column; gap: 2px; }
.inline-menu-meta b { color: var(--text); font-size: 13px; }
.inline-menu-meta span { color: var(--muted); font-size: 11.5px; }
.inline-menu-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.inline-action { min-height: 36px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel); color: var(--text-2); padding: 6px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: .15s var(--ease); }
.inline-action span { color: var(--muted); }
.inline-action:hover, .inline-action:focus-visible { border-color: var(--primary-line); color: var(--primary); background: var(--primary-soft); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.inline-action.primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.inline-action.danger { color: var(--red); background: var(--red-bg); border-color: var(--red-line); }
.inline-action.success { color: var(--green); background: var(--green-bg); border-color: var(--green-line); }

#smsMessage { width: 100%; resize: vertical; min-height: 120px; border: 1px solid var(--line-strong); border-radius: 11px; padding: 11px 13px; color: var(--text); background: var(--panel-muted); font: inherit; font-size: 14px; line-height: 1.55; }
#smsMessage::placeholder { color: var(--muted-2); }
#smsMessage:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); outline: none; }

@media (max-width: 1100px) {
  .subscriber-inline-menu { align-items: flex-start; flex-direction: column; gap: 8px; }
  .inline-menu-actions { justify-content: flex-start; }
}
@media (max-width: 620px) {
  .sort-hint { display: none; }
  .subscriber-inline-menu { padding-left: 14px; }
  .inline-menu-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .inline-action { justify-content: flex-start; }
}

/* Anchored subscriber dropdown + Mbps packages */
.company-action-menu { position: fixed; z-index: 80; max-height: min(580px, calc(100vh - 24px)); overflow: auto; padding: 6px; background: var(--panel-elevated); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-lg); animation: modal-in .15s var(--ease); }
.company-action-menu.hidden { display: none; }
.company-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 9px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.company-menu-head div { min-width: 0; }
.company-menu-head b { display: block; color: var(--text); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-menu-head span { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.company-menu-close { width: 28px; height: 28px; display: grid; place-items: center; border: 0; background: var(--panel-muted); border-radius: 8px; color: var(--text-2); cursor: pointer; }
.company-action-menu > button[role="menuitem"] { width: 100%; min-height: 46px; display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; padding: 7px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); text-align: left; cursor: pointer; transition: background .12s var(--ease); }
.company-action-menu > button[role="menuitem"]:hover, .company-action-menu > button[role="menuitem"]:focus-visible { background: var(--primary-soft); outline: none; }
.company-action-menu > button[role="menuitem"] > span { display: flex; align-items: center; justify-content: center; }
.company-action-menu > button[role="menuitem"] b { display: block; font-size: 13px; font-weight: 630; color: var(--text); }
.company-action-menu > button[role="menuitem"] small { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; font-weight: 400; }
.company-action-menu > button.danger-menu b { color: var(--red); }
.company-action-menu > button.success-menu b { color: var(--green); }
.company-menu-separator { height: 1px; background: var(--line); margin: 4px 3px; }
.speed-main { font-size: 13px; font-weight: 600; color: var(--text); }

.package-explain-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.package-explain { display: flex; gap: 13px; align-items: flex-start; min-height: 108px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-sm); }
.package-type-icon { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 15px; }
.package-type-icon.split { background: var(--green-bg); color: var(--green); }
.package-explain h3 { margin: 1px 0 5px; font-size: 14px; color: var(--text); }
.package-explain p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.package-type-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 8px; font-size: 11.5px; font-weight: 620; white-space: nowrap; }
.package-type-badge.unified { color: var(--primary); background: var(--primary-soft); border: 1px solid var(--primary-line); }
.package-type-badge.split { color: var(--green); background: var(--green-bg); border: 1px solid var(--green-line); }
.pricing-fields { margin-bottom: 2px; }
.package-rate-box { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-muted); margin-bottom: 13px; }
.rate-example { margin-top: 4px; padding: 10px 12px; border-radius: 9px; background: var(--primary-soft); color: var(--text-2); font-size: 12px; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 42px; margin: 4px 0 8px; color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--primary); }
.permissions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-muted); }
.permissions-grid .check-row { margin: 2px 0; min-height: 34px; }
#subPackageTariff, #subSplitTariff { background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.sms-history-row { grid-template-columns: 118px 1fr auto; }

@media (max-width: 760px) {
  .package-explain-grid { grid-template-columns: 1fr; }
  .company-action-menu { max-width: calc(100vw - 20px); }
}

/* ===================== Bank statement matching ===================== */
.header-actions { display: flex; align-items: center; gap: 9px; }
.bank-match-row { display: grid; grid-template-columns: 20px minmax(0,1.4fr) auto minmax(0,1.6fr) auto; gap: 12px; align-items: center; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.bank-match-row:last-child { border-bottom: 0; }
.bank-match-row .bmr-check { width: 17px; height: 17px; accent-color: var(--primary); }
.bmr-info b { display: block; font-size: 13px; color: var(--text); }
.bmr-info small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.bmr-amount { font-size: 13px; white-space: nowrap; }
.bmr-select { width: 100%; min-height: 38px; padding: 6px 30px 6px 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-muted); color: var(--text); font-size: 12.5px; }
.bmr-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
@media (max-width: 760px) {
  .bank-match-row { grid-template-columns: 1fr; }
}

/* ===================== Settings ===================== */
.settings-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-muted); overflow-x: auto; }
.settings-tab { flex: 0 0 auto; padding: 9px 16px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 610; white-space: nowrap; cursor: pointer; transition: background .14s var(--ease), color .14s var(--ease); }
.settings-tab:hover { color: var(--text); background: var(--line); }
.settings-tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.settings-tab-panel { display: grid; gap: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; align-items: start; }
.settings-body { padding: 18px 20px 20px; }
.settings-body .field:last-child { margin-bottom: 0; }
.settings-body select { width: 100%; min-height: var(--control-h); padding: 8px 32px 8px 13px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel-muted); color: var(--text); font-size: 14.5px; }
.settings-body select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.settings-body .subsection-title:first-child { margin-top: 0; }
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
}

/* ===================== Document template editor (WYSIWYG) ===================== */
.template-editor-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; background: var(--panel-muted); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; margin-bottom: 10px; }
.tet-group { display: flex; align-items: center; gap: 2px; }
.tet-sep { width: 1px; align-self: stretch; background: var(--line-strong); margin: 3px 2px; flex: none; }
.tet-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 1px; min-width: 28px; height: 28px; padding: 0 7px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; line-height: 1; white-space: nowrap; }
.tet-btn:hover { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary); }
.tet-btn.active { background: var(--primary-soft-strong); border-color: var(--primary-line); color: var(--primary); }
.tet-italic { font-style: italic; }
.tet-underline { text-decoration: underline; }
.tet-strike { text-decoration: line-through; }
.tet-fontsize sub, .tet-fontsize sup { font-size: 9px; font-weight: 700; }
.tet-color { flex-direction: column; gap: 0; padding-top: 4px; padding-bottom: 3px; cursor: pointer; }
.tet-swatch { display: block; width: 16px; height: 3px; border-radius: 1px; margin-top: 2px; }
.tet-color input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; border: none; padding: 0; width: 100%; height: 100%; }
.align-icon { display: inline-flex; flex-direction: column; gap: 2px; width: 14px; }
.align-icon i { display: block; height: 2px; background: currentColor; border-radius: 1px; }
.align-left { align-items: flex-start; }
.align-left i:nth-child(1) { width: 100%; }
.align-left i:nth-child(2) { width: 65%; }
.align-left i:nth-child(3) { width: 85%; }
.align-center { align-items: center; }
.align-center i:nth-child(1) { width: 100%; }
.align-center i:nth-child(2) { width: 60%; }
.align-center i:nth-child(3) { width: 80%; }
.align-right { align-items: flex-end; }
.align-right i:nth-child(1) { width: 100%; }
.align-right i:nth-child(2) { width: 65%; }
.align-right i:nth-child(3) { width: 85%; }
.align-justify i { width: 100%; }
.template-editor-frame { background: #d9d9d9; border-radius: 12px; padding: 18px; max-height: 55vh; overflow-y: auto; }
.template-editor-canvas {
  background: #fff; color: #1a1a1a; max-width: 800px; margin: 0 auto; padding: 40px 48px;
  font-family: 'Noto Serif Georgian', 'Sylfaen', serif; font-size: 13.5px; line-height: 1.55;
  box-shadow: 0 2px 14px rgba(0,0,0,.18); outline: none; min-height: 300px;
}
.template-editor-canvas h1 { text-align: center; font-size: 18px; font-weight: 700; margin: 0 0 20px; }
.template-editor-canvas h2 { font-size: 14px; font-weight: 700; margin: 20px 0 8px; }
.template-editor-canvas p { margin: 0 0 10px; text-align: justify; white-space: pre-line; }
.template-editor-canvas table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 12.5px; }
.template-editor-canvas td, .template-editor-canvas th { border: 1px solid #ccc; padding: 6px 9px; vertical-align: top; text-align: left; }
.template-editor-canvas th { background: #f0f0f0; font-weight: 700; }
.template-editor-canvas .tpl-field { display: inline-block; background: #fff3b0; color: #6b5400; border-radius: 4px; padding: 1px 5px; font-size: 12px; font-weight: 600; cursor: default; user-select: none; }
