/* =====================================================================
   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;
  --pink: #ff5cb3;
  --pink-bg: rgba(255, 92, 179, .16);

  --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;
  --pink: #d6246e;
  --pink-bg: rgba(214, 36, 110, .1);

  --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; }
/* Tariff/speed/VAT changed since the last delivered contract or annex --
   an updated Annex N1 is owed. Its own hot pink, distinct from the muted
   --rose already used for disconnected companies. */
.needs-annex { color: var(--pink) !important; animation: invoice-blink 1.1s ease-in-out infinite; }
.status-badge.annex-alert { background: var(--pink-bg); color: var(--pink); animation: invoice-blink 1.1s ease-in-out infinite; }
/* A delivered contract/annex still has no client-signed copy uploaded --
   orange, the one status hue not used yet (--carrot was only a nav icon). */
.needs-signature { color: var(--carrot) !important; animation: invoice-blink 1.1s ease-in-out infinite; }
.status-badge.signature-alert { background: color-mix(in srgb, var(--carrot) 15%, transparent); color: var(--carrot); animation: invoice-blink 1.1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .needs-annex, .status-badge.annex-alert, .needs-signature, .status-badge.signature-alert { animation: none; } }

/* ===================== 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-notice { margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--amber-line); border-radius: 11px; background: var(--amber-bg); color: var(--text); font-size: 13px; line-height: 1.5; text-align: left; }
/* The minute before an automatic sign-out */
.idle-warning { position: fixed; left: 50%; bottom: 22px; z-index: 90; display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100% - 32px); padding: 12px 14px 12px 16px; border: 1px solid var(--amber-line); border-radius: 14px; background: var(--panel-elevated); box-shadow: var(--shadow-lg); color: var(--text-2); font-size: 13.5px; transform: translateX(-50%); }
.idle-warning > .icon { color: var(--amber); }
.idle-warning p { margin: 0; }
.idle-warning b { color: var(--text); font-variant-numeric: tabular-nums; }
.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; }
.login-card .login-remember { display: flex; align-items: flex-start; gap: 9px; margin: -3px 0 17px; font-weight: 600; cursor: pointer; }
.login-card .login-remember input { width: 16px; min-height: 0; height: 16px; margin: 2px 0 0; padding: 0; flex: none; accent-color: var(--primary); cursor: pointer; }
.login-remember em { display: block; margin-top: 3px; color: var(--muted-2); font-size: 12px; font-style: normal; font-weight: 500; line-height: 1.45; }
.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); }
@media (min-width: 1024px) {
  :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 clamp(14px, 1.6vw, 36px);
  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; }
/* The dashboard names itself below the bar ("ფინანსური სურათი"), so its title isn't repeated here. */
.topbar.is-bare .page-heading { display: none; }
/* The bar in three parts: the page's title at the left, the day's line (weather,
   rate, fuel, month) in the middle, the theme and the user's menu at the right. */
@media (min-width: 1181px) {
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(max-content, 1fr); align-items: center; column-gap: 16px; }
  .topbar .page-heading { grid-column: 1; }
  .topbar .top-info { grid-column: 2; flex: none; justify-content: center; padding: 0; }
  .topbar .top-actions { grid-column: 3; justify-self: end; }
}
/* The user's menu: who is signed in, the site's profile, sign-out. */
.user-menu { position: relative; }
.user-chip { min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text-2); font: inherit; box-shadow: var(--shadow-xs); cursor: pointer; transition: border-color .15s var(--ease); }
.user-chip:hover, .user-chip[aria-expanded="true"] { border-color: var(--primary-line); }
.user-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.user-chip .avatar { width: 32px; height: 32px; font-size: 13px; }
.user-chip-text { display: grid; gap: 1px; text-align: left; line-height: 1.25; }
.user-chip-text strong, .user-chip-text small { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-text strong { color: var(--text); font-size: 13px; font-weight: 650; }
.user-chip-text small { color: var(--muted); font-size: 11px; }
.user-chip .chip-chevron { width: 14px; height: 14px; color: var(--muted); transition: transform .15s var(--ease); }
.user-chip[aria-expanded="true"] .chip-chevron { transform: rotate(180deg); }
.user-pop { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: 300px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel-elevated); box-shadow: var(--shadow-md); }
.user-pop-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; padding: 10px 10px 13px; border-bottom: 1px solid var(--line); }
.user-pop-head .avatar { width: 42px; height: 42px; flex: none; font-size: 16px; }
.user-pop-head b { display: block; color: var(--text); font-size: 14px; font-weight: 650; }
.user-pop-head small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.user-pop-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font: inherit; text-align: left; cursor: pointer; }
.user-pop-item .icon { width: 18px; height: 18px; flex: none; color: var(--muted); }
.user-pop-item b { display: block; color: var(--text); font-size: 13px; font-weight: 600; }
.user-pop-item small { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px; }
.user-pop-item:hover, .user-pop-item:focus-visible { background: var(--panel-muted); outline: none; }
.user-pop-item:hover .icon, .user-pop-item:focus-visible .icon { color: var(--primary); }
.user-pop-item.is-danger b, .user-pop-item.is-danger .icon { color: var(--red); }
.user-pop-sep { height: 1px; margin: 6px 4px; background: var(--line); }
@media (max-width: 1760px) { .user-chip-text { display: none; } .user-chip { gap: 6px; padding: 0 8px 0 5px; } }
/* Weather, the official rate and fuel -- one line between the title and the actions. */
.top-info { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 0 9px 0 20px; }
.info-wrap { position: relative; }
.info-chip { min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--text-2); font: inherit; font-size: 13.5px; font-weight: 550; white-space: nowrap; box-shadow: var(--shadow-xs); font-variant-numeric: tabular-nums; }
.weather-chip, .fuel-chip { cursor: pointer; transition: border-color .15s var(--ease); }
.weather-chip:hover, .weather-chip[aria-expanded="true"], .fuel-chip:hover, .fuel-chip[aria-expanded="true"] { border-color: var(--primary-line); }
.weather-chip:focus-visible, .fuel-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.weather-chip b { color: var(--text); font-size: 15px; font-weight: 650; }
.weather-chip small, .rate-chip small, .fuel-chip small { color: var(--muted); font-size: 12px; font-weight: 500; }
.fuel-chip { gap: 8px; }
.fuel-chip .fuel-icon { width: 18px; height: 18px; color: var(--carrot); }
.fuel-chip .chip-chevron { width: 14px; height: 14px; color: var(--muted); transition: transform .15s var(--ease); }
.fuel-chip[aria-expanded="true"] .chip-chevron { transform: rotate(180deg); }
.rate-chip { gap: 14px; }
.rate-chip > span { display: inline-flex; align-items: baseline; gap: 5px; }
.rate-chip b { color: var(--text); font-weight: 650; }
.info-pop { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; display: grid; gap: 2px; min-width: 250px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--panel-elevated); box-shadow: var(--shadow-md); }
.info-pop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 8px 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.info-pop-head span { font-weight: 500; font-size: 11.5px; }
.info-pop-foot { padding: 6px 8px 2px; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.info-pop-foot a { color: inherit; }
.info-day { display: grid; grid-template-columns: 56px 22px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; font-size: 13px; color: var(--text-2); }
.info-day:first-of-type { background: var(--panel-muted); }
.info-day b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.info-day span:nth-child(3) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.fuel-pop { width: 360px; padding: 8px 10px 10px; gap: 6px; }
.fuel-pop-empty { display: grid; gap: 6px; padding: 4px 8px 6px; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.fuel-pop-empty small { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.fuel-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.fuel-table th { padding: 0 8px 6px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-align: right; }
.fuel-table th:first-child, .fuel-table td:first-child { text-align: left; padding-left: 8px; }
.fuel-table td { padding: 7px 8px; border-top: 1px solid var(--line); color: var(--text); text-align: right; white-space: nowrap; }
.fuel-table td:first-child { color: var(--text-2); font-weight: 600; }
.fuel-table td:first-child a { color: inherit; text-decoration: none; }
.fuel-table td:first-child a:hover { color: var(--primary); text-decoration: underline; }
.fuel-table td.is-best { color: var(--green); font-weight: 650; }
.fuel-table td.is-none { color: var(--muted); }
.fuel-table td.is-stale { color: var(--muted); }
.fuel-table sup { color: var(--amber); font-weight: 700; }
.fuel-more { justify-self: start; margin: 0 8px; padding: 2px 0; border: 0; background: transparent; color: var(--primary); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.fuel-more:hover { text-decoration: underline; }
.fuel-more:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
/* The day: the time, and a panel with the date, the billing month and the coming holidays. */
.clock-chip { cursor: pointer; transition: border-color .15s var(--ease); }
.clock-chip:hover, .clock-chip[aria-expanded="true"] { border-color: var(--primary-line); }
.clock-chip:focus-visible, .sms-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.clock-chip .icon { width: 18px; height: 18px; color: var(--primary); }
.clock-chip b { color: var(--text); font-size: 15px; font-weight: 650; }
.clock-chip small { color: var(--muted); font-size: 12px; font-weight: 500; }
.clock-chip small.is-holiday { color: var(--red); font-weight: 650; }
.clock-pop { width: 330px; left: 0; right: auto; }
.clock-today { display: grid; gap: 2px; padding: 2px 8px 10px; }
.clock-today b { color: var(--text); font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.clock-today span { color: var(--text-2); font-size: 13px; }
.clock-row { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 6px; padding: 8px; border-radius: 8px; background: var(--panel-muted); font-size: 12.5px; color: var(--muted); }
.clock-row b { color: var(--text); font-weight: 650; }
.holiday { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: baseline; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 13px; color: var(--text-2); }
.holiday b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.holiday small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.holiday.is-today { background: var(--red-bg); }
.holiday.is-today small { color: var(--red); font-weight: 650; }
/* SMS left on the gateway: red when it may not last a month's reminders. */
/* electricity: what the owner's Telmico subscribers owe */
.power-chip { gap: 7px; cursor: pointer; transition: border-color .15s var(--ease); }
.power-chip:hover, .power-chip[aria-expanded="true"] { border-color: var(--primary-line); }
.power-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.power-chip .icon { width: 17px; height: 17px; color: #f59e0b; }
.power-chip span { color: var(--muted); font-size: 12px; }
.power-chip b { color: var(--text); font-weight: 650; }
.power-chip.is-due b { color: var(--red); }
/* something to pay: the chip breathes -- a faint red glow comes and goes, slowly, never flashing */
@media (prefers-reduced-motion: no-preference) {
  .power-chip.is-due { animation: power-due 4.5s ease-in-out infinite; }
}
@keyframes power-due {
  0%, 100% { box-shadow: var(--shadow-xs); background: var(--panel); }
  50% { box-shadow: var(--shadow-xs), 0 0 0 3px color-mix(in srgb, var(--red) 12%, transparent), 0 0 14px color-mix(in srgb, var(--red) 16%, transparent);
        background: color-mix(in srgb, var(--red) 5%, var(--panel)); }
}
.power-pop { width: 340px; padding: 8px 10px 10px; gap: 6px; }
.power-pop .info-pop-head { white-space: nowrap; }
.power-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 9px 10px; border-radius: 9px; background: var(--panel-muted); }
.power-row b { display: block; color: var(--text); font-size: 13.5px; font-weight: 650; }
.power-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.power-sum { text-align: right; }
.power-sum b { font-size: 16px; font-variant-numeric: tabular-nums; }
.power-sum.is-due b { color: var(--red); }
.power-sum.is-ok b { color: var(--green); }
.power-row .power-err { grid-column: 1 / -1; color: var(--amber); }
.power-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.power-foot span { margin-right: auto; }
.power-refresh { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.power-refresh:disabled { color: var(--muted); cursor: default; }
.power-foot a { color: var(--primary); font-weight: 600; text-decoration: none; }
.power-foot a:hover { text-decoration: underline; }
.telmico-rows { display: grid; gap: 8px; margin-bottom: 10px; }
.user-telmico { display: grid; gap: 2px; }
.user-telmico .check-row { min-height: 36px; margin: 0; }
.telmico-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.telmico-row .field { margin: 0; }
@media (max-width: 560px) { .telmico-row { grid-template-columns: minmax(0, 1fr) auto; } .telmico-row .field:nth-child(2) { grid-row: 2; } }
.sms-chip { gap: 7px; cursor: pointer; transition: border-color .15s var(--ease); }
.sms-chip:hover { border-color: var(--primary-line); }
.sms-chip .icon { width: 17px; height: 17px; color: var(--primary); }
.sms-chip span { color: var(--muted); font-size: 12px; }
.sms-chip b { color: var(--text); font-weight: 650; }
.sms-chip.is-low { border-color: var(--red-line); background: var(--red-bg); }
.sms-chip.is-low .icon, .sms-chip.is-low b { color: var(--red); }
/* Notifications: what needs attention, in one place. */
.notif-menu { position: relative; }
.find-menu { position: relative; }
#findBtn[aria-expanded="true"] { border-color: var(--primary-line); color: var(--primary); }
.find-pop { width: 380px; max-height: min(560px, calc(100vh - 110px)); overflow-y: auto; }
.find-field { display: flex; align-items: center; gap: 8px; margin: 2px 2px 8px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel-muted); }
.find-field:focus-within { border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }
.find-field .icon { width: 17px; height: 17px; flex: none; color: var(--muted); }
.find-field input { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13.5px; outline: none; }
.find-results { display: grid; gap: 2px; }
.find-label { margin: 6px 10px 2px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.find-hint { margin: 4px 10px 8px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.find-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font: inherit; text-align: left; cursor: pointer; }
.find-item:hover, .find-item:focus-visible, .find-item.is-first { background: var(--panel-muted); outline: none; }
.find-item div { flex: 1; min-width: 0; }
.find-item b { display: block; overflow: hidden; color: var(--text); font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.find-item small { display: block; color: var(--muted); font-size: 11.5px; }
.find-item .status-badge { flex: none; }
.find-card { display: grid; gap: 6px; margin: 4px 2px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-muted); }
.find-card b { color: var(--text); font-size: 14px; font-weight: 650; }
.find-card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12.5px; }
.find-card dt { color: var(--muted); }
.find-card dd { margin: 0; color: var(--text-2); }
.find-card .btn { justify-self: start; margin-top: 4px; }
.notif-btn { position: relative; }
.notif-btn[aria-expanded="true"] { border-color: var(--primary-line); color: var(--primary); }
.notif-count { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; display: grid; place-items: center; border: 2px solid var(--bg); border-radius: 999px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; }
.notif-pop { width: 360px; max-height: min(560px, calc(100vh - 110px)); overflow-y: auto; }
.notif-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.notif-head b { color: var(--text); font-size: 14px; }
.notif-head small { color: var(--muted); font-size: 12px; }
.notif-group { --tone: var(--primary); display: grid; gap: 4px; padding: 8px 10px 10px; border-radius: 10px; }
.notif-group + .notif-group { border-top: 1px solid var(--line); border-radius: 0; }
.notif-group.tone-red { --tone: var(--red); }
.notif-group.tone-amber { --tone: var(--amber); }
.notif-group.tone-pink { --tone: var(--pink); }
.notif-group.tone-carrot { --tone: var(--carrot); }
.notif-group.tone-violet { --tone: var(--violet); }
.notif-group-head { display: flex; align-items: center; gap: 8px; }
.notif-group-head i { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--tone); }
.notif-group-head b { flex: 1; color: var(--text); font-size: 13px; font-weight: 650; }
.notif-group-head span { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--tone) 14%, transparent); color: var(--tone); font-size: 11.5px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.notif-group p { margin: 0 0 0 16px; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.notif-names { display: flex; flex-wrap: wrap; gap: 4px; margin-left: 16px; }
.notif-names button { max-width: 100%; overflow: hidden; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text-2); font: inherit; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.notif-names button:hover, .notif-names button:focus-visible { border-color: var(--primary-line); color: var(--primary); outline: none; }
.notif-go { justify-self: start; margin-left: 16px; padding: 2px 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; }
.notif-go:hover { text-decoration: underline; }
/* kinds of notices, the bell's tabs */
.notif-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 6px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.notif-tabs button { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.notif-tabs button span { min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--panel-muted); color: var(--text-2); font-size: 11px; text-align: center; }
.notif-tabs button[aria-selected="true"] { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary); }
.notif-acts { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.notif-hide { padding: 2px 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 11.5px; cursor: pointer; }
.notif-hide:hover, .notif-hide:focus-visible { color: var(--text); text-decoration: underline; outline: none; }
.notif-unhide { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.notif-unhide:hover { color: var(--primary); }
/* nothing urgent: the number stays, quieter */
.notif-count.calm { background: var(--primary); }
.notif-empty { display: grid; justify-items: center; gap: 6px; padding: 26px 16px; color: var(--muted); font-size: 13px; text-align: center; }
.notif-empty .icon { width: 28px; height: 28px; color: var(--green); }
/* Narrower screens drop the chips' small print first, so the line stays in the middle. */
@media (max-width: 1920px) { .fuel-chip small { display: none; } }
@media (max-width: 1760px) { .clock-chip small { display: none; } }
@media (max-width: 1600px) { .weather-chip small { display: none; } }
@media (max-width: 1440px) { .sms-chip span, .power-chip span { display: none; } }
@media (max-width: 1400px) { .clock-chip { display: none; } }
@media (max-width: 1180px) { .rate-chip { display: none; } }
@media (max-width: 760px) { .top-info { display: none; } }
.w-icon { width: 20px; height: 20px; flex: none; }
.w-icon.is-sun { color: #f59e0b; }
.w-icon.is-cloud, .w-icon.is-fog { color: var(--muted); }
.w-icon.is-rain, .w-icon.is-snow { color: var(--primary); }
.w-icon.is-storm { color: #a855f7; }
.w-icon.is-moon { color: #818cf8; }
.rate-diff { font-size: 11.5px; font-weight: 650; }
.rate-diff.is-up { color: var(--green); }
.rate-diff.is-down { color: var(--red); }
.rate-diff.is-flat { color: var(--muted); }

.month-chip { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 14px; white-space: nowrap; 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; }

/* The page takes the screen's width at any size (Full HD to 8K): side margins grow with the screen
   instead of a fixed cap leaving wide empty bands on large monitors. */
.content { --pad-x: clamp(14px, 1.6vw, 36px); --pad-top: 26px; --pad-bottom: 44px; width: 100%; padding: var(--pad-top) var(--pad-x) var(--pad-bottom); }
/* the demo copy: a plain band on every screen, and no "open the demo" from inside the demo itself */
.demo-ribbon { position: sticky; top: 0; z-index: 2000; padding: 5px 16px; background: #b45309; color: #fff; font-size: 12.5px; font-weight: 650; text-align: center; letter-spacing: .01em; }
body.is-demo #demoOpenPanel { display: none; }
.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; }
/* The dashboard's "live" note: when the figures were last read; a click reads them again. */
.fresh-note { font: inherit; font-size: 12.5px; cursor: pointer; transition: border-color .15s var(--ease), color .15s var(--ease); }
.fresh-note:hover { border-color: var(--primary-line); color: var(--text); }
.fresh-note:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.fresh-note .icon { width: 14px; height: 14px; color: var(--muted); }
.fresh-note:hover .icon { color: var(--primary); }
.fresh-note.is-busy .icon { animation: fresh-spin .9s linear infinite; }
.fresh-note.is-busy .live-dot { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-bg); }
@keyframes fresh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .fresh-note.is-busy .icon { animation: none; } }
.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(auto-fill, minmax(220px, 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:not(.kpi-icon):not(.kpi-text) { 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; }
/* The dashboard's seven figures: one even row on a wide screen (no gap at the
   end), 4 + 3 on a medium one, pairs on a phone. The icon sits beside the label,
   so each figure gets its card's whole width and never breaks onto two lines. */
#view-dashboard { container: dash / inline-size; }
#view-dashboard .kpi-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; }
#view-dashboard .kpi-card { display: grid; grid-template-columns: 36px minmax(0, 1fr); grid-template-rows: auto 1fr auto; align-items: center; column-gap: 10px; min-height: 0; padding: 16px 16px 15px 18px; }
#view-dashboard .kpi-card > .kpi-text { display: contents; }
#view-dashboard .kpi-icon { width: 36px; height: 36px; border-radius: 11px; }
#view-dashboard .kpi-icon .icon { width: 18px; height: 18px; }
#view-dashboard .kpi-card span:not(.kpi-icon):not(.kpi-text) { grid-column: 2; margin: 0; font-size: 12px; line-height: 1.3; }
#view-dashboard .kpi-card strong { grid-column: 1 / -1; align-self: end; margin-top: 14px; font-size: clamp(19px, 1.5cqi, 25px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-dashboard .kpi-card small { grid-column: 1 / -1; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@container dash (max-width: 1180px) {
  #view-dashboard .kpi-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  #view-dashboard .kpi-card { grid-column: span 3; }
  #view-dashboard .kpi-card:nth-child(n+5) { grid-column: span 4; }
  #view-dashboard .kpi-card strong { font-size: 24px; }
}
@container dash (max-width: 700px) {
  #view-dashboard .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #view-dashboard .kpi-card, #view-dashboard .kpi-card:nth-child(n+5) { grid-column: auto; }
  #view-dashboard .kpi-card:last-child { grid-column: 1 / -1; }
  #view-dashboard .kpi-card span:not(.kpi-icon):not(.kpi-text) { grid-column: 1 / -1; margin-top: 10px; }
  #view-dashboard .kpi-card strong { font-size: 21px; }
}

/* ===================== 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); }
/* a monthly cost: counted every month without being entered again */
.expense-kind { display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 640; vertical-align: middle; white-space: nowrap; }
/* the history: a month opens above */
.expense-history-row { cursor: pointer; }
.expense-history-row:hover td, .expense-history-row:focus-visible td { background: var(--panel-muted); }
.expense-history-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.expense-history-row.current td { font-weight: 700; color: var(--primary); }
.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; }
.legend-dot.pink { background: var(--pink); }
.legend-dot.carrot { background: var(--carrot); }
.history-row .signed-ok { color: var(--green); font-weight: 650; }
.history-row .signature-alert { white-space: normal; max-width: 100%; margin-top: 4px; }
.signed-files { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.signed-files a { color: var(--primary); font-size: 12px; overflow-wrap: anywhere; }
.signed-file-del { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: -6px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; vertical-align: middle; }
.signed-file-del:hover { background: var(--red-bg); color: var(--red); }
.signed-file-del .icon { width: 13px; height: 13px; }
@media (pointer: coarse) { .signed-file-del { width: 36px; height: 36px; } }
.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; }
/* the colours filter the list: one click shows that kind, a second shows everyone again */
#subLegend .legend-item { min-height: 30px; padding: 0 10px; border: 1px solid transparent; border-radius: 999px; background: transparent; font: inherit; font-size: 12px; cursor: pointer; transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease); }
#subLegend .legend-item:hover { color: var(--text); background: var(--panel-muted); }
#subLegend .legend-item[aria-pressed="true"] { color: var(--text); border-color: var(--primary-line); background: var(--primary-soft); font-weight: 650; }
#subLegend .legend-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
#subLegend .legend-item.is-empty { opacity: .5; }
.legend-n { min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--panel-muted); color: var(--text-2); font-size: 11px; font-weight: 700; text-align: center; }
.legend-n:empty { display: none; }
.legend-dot.blink { animation: invoice-blink 1.1s ease-in-out infinite; }
.sel-col { width: 40px; text-align: center !important; }
.sel-col input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
tr.is-picked td { background: var(--primary-soft); }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 12px; padding: 10px 14px; border: 1px solid var(--primary-line); border-radius: 12px; background: var(--primary-soft); }
.bulk-bar b { color: var(--text); font-size: 13.5px; margin-right: 6px; }
.bulk-bar .btn[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }
.queue-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding: 9px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--text); font-size: 13px; font-weight: 600; }
.bi-debt { width: 100%; }
.bi-debt button { flex: 1; white-space: normal; line-height: 1.25; padding: 6px 10px; }
.bi-edit-row { display: flex; flex-wrap: wrap; gap: 8px; }
.bi-edit-row .btn { flex: 1; }
.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 44px 8px 42px; }
.search-clear { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.search-clear[hidden] { display: none; }
.search-clear:hover { background: var(--panel); color: var(--text); }
.search-clear .icon { position: static; transform: none; width: 17px; height: 17px; color: inherit; }
.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); }
.row-action.is-danger:hover, .row-action.is-danger:focus-visible { border-color: var(--red-line); background: var(--red-bg); color: var(--red); }
.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%); }
/* A pop-up window of one's own size (winsize.js): pulled by its bottom right corner, the whole screen by the button
   beside "close" -- and it opens that size next time. Not on a phone: the window is the screen there. */
.modal.win-sized, .cp-dialog.win-sized { resize: both; min-width: min(340px, 100%); min-height: 120px; max-width: 100%; max-height: calc(100vh - 36px); }
.modal.win-maxed, .cp-dialog.win-maxed { resize: none; width: calc(100vw - 36px) !important; height: calc(100vh - 36px) !important; max-width: none; max-height: none; }
.win-max { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; margin-left: auto; border: 0; border-radius: 11px; background: var(--cp-soft, var(--panel-muted)); color: var(--cp-muted, var(--text-2)); cursor: pointer; transition: background .14s var(--ease), color .14s var(--ease); }
.win-max:hover { background: var(--cp-line, var(--line-strong)); color: var(--cp-text, var(--text)); }
.win-max:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.modal-head .win-max { background: var(--panel-muted); color: var(--text-2); }
.modal-head .win-max:hover { background: var(--line-strong); color: var(--text); }
@media (max-width: 860px) { .win-max { display: none; } }
.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); }

/* Top center: the bottom of the screen holds save bars and pinned modal
   buttons, where the button's own ✓ appears -- the message must not cover it. */
.toast { position: fixed; top: 18px; left: 50%; z-index: 80; width: max-content; max-width: min(460px, calc(100vw - 32px)); 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: translate(-50%, -14px); pointer-events: none; transition: opacity .2s var(--ease), transform .2s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast { display: flex; align-items: flex-start; gap: 10px; }
.toast .icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.toast.is-success { border-color: var(--green-line); background: color-mix(in srgb, var(--green) 14%, var(--panel-elevated)); }
.toast.is-success .icon { color: var(--green); }
.toast.is-removed, .toast.is-error { border-color: var(--red-line); background: color-mix(in srgb, var(--red) 13%, var(--panel-elevated)); }
.toast.is-removed .icon, .toast.is-error .icon { color: var(--red); }

/* Action feedback on the button that started a change (app.js sets
   data-fb-state): a spinner while it runs, then a short colored stamp.
   Solid green/red with white text reads the same in both themes. */
[data-fb-state] { position: relative; }
[data-fb-state="busy"] { color: transparent !important; pointer-events: none; }
[data-fb-state="busy"] > * { visibility: hidden; }
[data-fb-state="busy"]::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border: 2px solid var(--fb-ink, currentColor); border-right-color: transparent; border-radius: 50%; animation: fb-spin .7s linear infinite; }
[data-fb-state="done"]::after, [data-fb-state="removed"]::after, [data-fb-state="failed"]::after {
  content: attr(data-fb-label); position: absolute; inset: -1px; z-index: 1; display: flex; align-items: center; justify-content: center;
  padding: 0 8px; overflow: hidden; border-radius: inherit; color: #fff; font-size: 13px; font-weight: 650; white-space: nowrap; animation: fb-in .18s var(--ease);
}
[data-fb-state="done"]::after { background: #15803d; }
[data-fb-state="removed"]::after, [data-fb-state="failed"]::after { background: #c62828; }
[data-fb-state="failed"] { animation: fb-shake .32s var(--ease); }
@keyframes fb-spin { to { transform: rotate(360deg); } }
@keyframes fb-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes fb-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { [data-fb-state="done"]::after, [data-fb-state="removed"]::after, [data-fb-state="failed"]::after, [data-fb-state="failed"] { animation: none; } [data-fb-state="busy"]::after { animation-duration: 2s; } }
.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; }
}
/* Navigation by device:
   >=1024px  full sidebar (the owner can collapse it to a rail).
   768-1023  tablet: icon rail; its toggle opens the full, labelled sidebar
             as an overlay drawer instead of squeezing the page.
   <=767     phone: no rail -- the top bar's menu button opens the same
             drawer, so pages get the whole screen width. */
.nav-menu-btn, .nav-backdrop { display: none; }
@media (max-width: 1023px) {
  :root { --sidebar: 76px; }
  :root:not([data-nav-open]) .sidebar { width: 76px; padding: 18px 8px 14px; }
  :root:not([data-nav-open]) .brand { flex-direction: column; justify-content: center; padding: 4px 0 20px; gap: 10px; }
  :root:not([data-nav-open]) .sidebar-toggle-btn { margin-left: 0; }
  :root:not([data-nav-open]) .brand-text,
  :root:not([data-nav-open]) .nav-item span:not(.nav-icon),
  :root:not([data-nav-open]) .user-card > div:nth-child(2) { display: none; }
  :root:not([data-nav-open]) .nav-item { justify-content: center; padding: 10px; }
  :root:not([data-nav-open]) .user-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 4px; }
  .workspace { margin-left: var(--sidebar); width: calc(100% - var(--sidebar)); }
  :root[data-nav-open] .sidebar { width: min(300px, 86vw); z-index: 60; box-shadow: var(--shadow-lg); }
  :root[data-nav-open] .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(2, 5, 10, .55); animation: backdrop-in .16s var(--ease); }
  :root[data-nav-open] .nav-item, :root[data-nav-open] .user-card button, .sidebar-toggle-btn { min-height: 44px; min-width: 44px; }
}
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .22s var(--ease), visibility .22s; }
  :root[data-nav-open] .sidebar { transform: none; visibility: visible; }
  .workspace { margin-left: 0; width: 100%; }
  .nav-menu-btn { display: grid; flex: 0 0 auto; margin-right: 4px; }
}
@media (max-width: 840px) {
  .topbar { padding: 0 16px; }
  .content { --pad-top: 20px; --pad-x: 14px; --pad-bottom: 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; }
  .content { --pad-top: 16px; --pad-x: 12px; --pad-bottom: 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; }
.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; }
.field-hint.good { color: var(--green); }
.field-hint.bad { color: var(--red); }
/* Subscriber form: tax id -> RS.ge lookup */
.tin-input { position: relative; }
.tin-input.has-chip input { padding-right: 118px; }
.tin-input .vat-chip { position: absolute; top: 50%; right: 9px; transform: translateY(-50%); pointer-events: none; }
.vat-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.vat-chip.yes { background: var(--green-bg); color: var(--green); }
.vat-chip.no { background: var(--panel); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.vat-chip.busy { background: var(--primary-soft); color: var(--primary); }
.legal-name { display: grid; grid-template-columns: minmax(92px, 32%) minmax(0, 1fr); gap: 8px; }
.field .field-check { display: flex; align-items: center; gap: 7px; margin: 7px 0 0; color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer; }
.field .field-check input { width: auto; min-height: 0; padding: 0; accent-color: var(--primary); }
.dup-warn { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: -4px 0 14px; padding: 10px 12px; border: 1px solid var(--amber-line); border-radius: 11px; background: var(--amber-bg); color: var(--text); font-size: 13px; }
.dup-warn b { color: var(--amber); font-weight: 700; }
.dup-link { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.dup-link:hover { color: var(--primary-hover); }
.dup-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.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); }

/* Every other long table keeps its column titles on screen too (freeze.js looks at each and names its wrapper).
   A table that fits its card is scrolled by the page, and its titles stick under the top bar; one too wide for
   its card scrolls inside a wrapper of its own height, and its titles stick there. A card that only clipped for
   its rounded corners clips without becoming the thing the titles stick to. */
.table-scroll.head-page { overflow: clip; }
:is(.table-card, .panel, .noc-drawer):has(.head-page, .freeze-bar) { overflow: clip; }
.table-scroll.head-page thead th { top: var(--freeze-top, 0px); z-index: 5; box-shadow: 0 1px 0 var(--line); }
.table-scroll.head-own { max-height: var(--freeze-room, none); }
/* a list's own bar (a MikroTik's tabs on the network page) stays above it */
.freeze-bar { position: sticky; top: var(--freeze-top, 0px); z-index: 7; }
.noc-tabs.freeze-bar { background: var(--panel); }
/* A page's own menu or filter bar -- the settings' sections, the invoices' and the messages' search, the finance
   period -- stays under the top bar, with a little air and the page's colour around it: what scrolls passes under. */
:is(.settings-tabs, .billing-toolbar, .f-toolbar) { --freeze-pad: 8px; }
:is(.settings-tabs, .billing-toolbar, .f-toolbar).freeze-bar { box-shadow: 0 0 0 100vmax var(--bg); clip-path: inset(-8px -100vmax); }
.billing-toolbar.freeze-bar { background: var(--bg); }
.notif-tabs.freeze-bar { padding-top: 6px; background: var(--panel-elevated, var(--panel)); }   /* the bell's list: its tabs stay too */

/* 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); }
/* The registers (subscribers, disconnected) are frozen at the top: the search, the filters and the
   column titles stay in place while the rows scroll. Desktop: the register fills the screen exactly,
   so the page itself never moves -- only the rows do, under the titles. */
@media (min-width: 1024px) {
  .content:has(> :is(#view-subscribers, #view-disconnected).active) { --pad-bottom: 18px; }
  :is(#view-subscribers, #view-disconnected).active { display: flex; flex-direction: column; height: calc(100dvh - 76px - var(--pad-top) - var(--pad-bottom)); min-height: 520px; }
  :is(#view-subscribers, #view-disconnected).active > * { flex: none; }
  :is(#view-subscribers, #view-disconnected).active > .table-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  :is(#view-subscribers, #view-disconnected) .table-card > * { flex: none; }
  :is(#view-subscribers, #view-disconnected) .table-card > .subscribers-scroll { flex: 1 1 auto; min-height: 0; max-height: none; }
}
/* The registers' bar in two rows at any width: the search and the controls, then the colour filters --
   the search never squeezes down to a few letters. */
:is(#view-subscribers, #view-disconnected) .table-toolbar { flex-wrap: wrap; row-gap: 10px; }
:is(#view-subscribers, #view-disconnected) .table-toolbar > .search-box { flex: 1 1 300px; max-width: 520px; width: auto; }
:is(#view-subscribers, #view-disconnected) .table-toolbar > .toolbar-controls { width: auto; margin-left: auto; flex-wrap: nowrap; }
:is(#view-subscribers, #view-disconnected) .table-toolbar > .status-legend-inline { order: 3; flex: 1 1 100%; gap: 6px 14px; }
/* Tablets and phones (rows as cards, the page scrolls): the search and the filters stick under the
   top bar; the filters keep to one row you swipe, so the frozen part stays small. */
@media (max-width: 1023px) {
  :is(#view-subscribers, #view-disconnected) .table-card { overflow: clip; }
  :is(#view-subscribers, #view-disconnected) .table-toolbar { position: sticky; top: 76px; z-index: 8; box-shadow: 0 6px 14px -12px rgba(0, 0, 0, .5); }
  :is(#view-subscribers, #view-disconnected) .status-legend-inline { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  :is(#view-subscribers, #view-disconnected) .status-legend-inline::-webkit-scrollbar { display: none; }
}
@media (max-width: 560px) {
  :is(#view-subscribers, #view-disconnected) .table-toolbar { top: 68px; padding: 8px 10px; gap: 8px; }
  :is(#view-subscribers, #view-disconnected) .table-toolbar > :is(.search-box, .toolbar-controls, .status-legend-inline) { flex: none; max-width: none; width: 100%; margin-left: 0; }
}

@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; }
/* ---- the network page: the MikroTiks' live state ---- */
.noc-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#nocAddBtn { flex: none; white-space: nowrap; }
.noc-kpis b.noc-good { color: var(--green); }
.noc-kpis b.noc-bad { color: var(--red); }
.noc-kpis b.noc-warn { color: var(--amber); }
.noc-snet-btn { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-muted); color: var(--primary); font: inherit; font-size: 12px; cursor: pointer; }
.noc-snet-btn:hover { border-color: var(--primary); }
.noc-snet-btn:disabled { cursor: wait; opacity: .7; }
.noc-snet-btn svg { width: 14px; height: 14px; }
.noc-router { margin-bottom: 16px; }
.noc-router.is-down { border-color: var(--red-line, var(--red)); }
.noc-router .panel-head h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.noc-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.noc-metrics { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.noc-metric { flex: 1 1 130px; padding: 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: -1px; background: var(--panel); }
.noc-metric span { display: block; color: var(--muted); font-size: 12px; }
.noc-metric b { display: block; margin-top: 3px; font-size: 16px; font-variant-numeric: tabular-nums; color: var(--text); overflow-wrap: anywhere; }
.noc-metric.is-warn b { color: var(--amber); }
.noc-metric.is-bad b { color: var(--red); }
.noc-sparks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.noc-spark { display: grid; gap: 4px; }
.noc-spark span { color: var(--muted); font-size: 12px; }
.noc-spark span b { color: var(--text); font-size: 13px; }
.noc-spark small { color: var(--muted-2, var(--muted)); font-size: 11px; }
.noc-spark svg { width: 100%; height: 44px; }
.noc-spark-line { fill: none; stroke: var(--primary); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.noc-spark-area { fill: var(--primary-soft); stroke: none; }
.noc-spark.is-empty { min-height: 60px; }
.noc-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.noc-cols > section { min-width: 0; padding: 12px 16px 16px; }
.noc-cols > section + section { border-left: 1px solid var(--line); }
.noc-cols h4 { margin: 0 0 10px; font-size: 13.5px; font-weight: 650; color: var(--text); }
.noc-cols h4 small { margin-left: 6px; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.noc-filter { margin-bottom: 10px; flex-wrap: wrap; }
table.noc-table { min-width: 0; }
.noc-table th, .noc-table td { padding: 8px 10px; text-align: left; }
.noc-table td.money { text-align: right; }
.noc-table .mono { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
.noc-star { width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--muted-2, var(--muted)); font-size: 16px; cursor: pointer; }
.noc-star.on { color: var(--amber); }
.noc-star:hover:not(:disabled) { background: var(--panel-muted); }
.noc-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.noc-dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.noc-dot.idle { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }
.noc-wan { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 600; white-space: nowrap; }
.noc-wan-set { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: 11.5px; cursor: pointer; }
.noc-wan-set:hover { text-decoration: underline; }
.noc-link { width: 100%; min-width: 160px; min-height: 34px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-muted); color: var(--text); font: inherit; font-size: 12.5px; }
.noc-wait { padding: 16px 18px; color: var(--muted); font-size: 13px; }
.noc-old { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--amber-bg); color: var(--text); font-size: 13px; }
.noc-old svg { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--amber); }
.noc-empty-in { display: flex; gap: 16px; padding: 22px; align-items: flex-start; }
.noc-empty-in h3 { margin: 0 0 6px; }
.noc-empty-in p { margin: 0 0 10px; color: var(--text-2); max-width: 70ch; }
.noc-empty-ico { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.noc-note { color: var(--muted) !important; font-size: 12.5px; }
.noc-steps { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 4px; color: var(--text-2); font-size: 13.5px; }
.noc-variants { margin-bottom: 6px; flex-wrap: wrap; }
.noc-setup-text { width: 100%; min-height: 200px; max-height: 40vh; margin: 6px 0; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel-muted); color: var(--text); font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; line-height: 1.45; white-space: pre; overflow: auto; resize: vertical; }
.noc-secret { color: var(--amber) !important; }
@media (max-width: 1100px) { .noc-cols { grid-template-columns: minmax(0, 1fr); } .noc-cols > section + section { border-left: 0; border-top: 1px solid var(--line); } }
@media (max-width: 760px) { .noc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .noc-empty-in { flex-direction: column; } }
/* phones: the ports and the devices stay small tables (not cards), scrolling sideways inside their own box only */
@media (max-width: 767px) {
  .noc-cols .table-scroll { overflow-x: auto; }
  .table-scroll .noc-table thead { display: table-header-group; }
  .table-scroll .noc-table tbody { display: table-row-group; }
  .table-scroll .noc-table tbody tr { display: table-row; padding: 0; }
  .table-scroll .noc-table tbody td { display: table-cell; padding: 7px 6px; font-size: 12.5px; }
  .table-scroll .noc-table tbody td::before { display: none; }
  .table-scroll .noc-table tbody td[colspan] { display: table-cell; }
  .noc-table th { padding: 7px 6px; font-size: 11.5px; }
  .noc-link { min-width: 130px; }
  .noc-acts .btn { font-size: 12px; }
}
/* ---- the rack: each MikroTik drawn as it looks, one under another ---- */
/* the board: the rack on the left (the boxes on its rails or a shelf), each router's card level with it */
.noc-board { position: relative; display: grid; --rack-max: 56%; }
.noc-board.is-pulled { --rack-max: 78%; }   /* pulled by hand: as wide as it was pulled, the cards keeping their room */
.noc-row { display: grid; grid-template-columns: min(var(--rack-w, 50%), var(--rack-max)) minmax(0, 1fr); column-gap: 18px; }
/* the line between the rack and the cards: taken by the mouse, it makes the rack's side wider or narrower */
.noc-split { position: absolute; z-index: 3; top: 0; bottom: 0; left: min(var(--rack-w, 50%), var(--rack-max)); width: 18px; cursor: col-resize; touch-action: none; }
.noc-split::after { content: ''; position: absolute; top: 8px; bottom: 8px; left: 7px; width: 4px; border-radius: 3px; background: var(--line-strong); transition: background .14s var(--ease); }
.noc-split:hover::after, .noc-split:focus-visible::after, .noc-pulling .noc-split::after { background: var(--primary); }
.noc-split:focus-visible { outline: none; }
.noc-pulling { cursor: col-resize; user-select: none; }
.noc-bay { position: relative; display: flex; align-items: center; padding: 12px 0; background: #1d2126; cursor: pointer; container-type: inline-size; }
/* the stations above the rack: each one's rack is shown at a click -- the one shown folds away, the chosen unfolds */
.noc-places { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.noc-place { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: border-color .14s var(--ease), background .14s var(--ease); }
.noc-place:hover { border-color: var(--primary); }
.noc-place:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.noc-place[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.noc-place small { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.noc-place i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.noc-place i.ok { background: var(--green); } .noc-place i.bad { background: var(--red); }
.noc-row.rack-start .noc-bay { border-top-left-radius: 12px; border-top-right-radius: 12px; padding-top: 28px; }
.noc-row.rack-end .noc-bay { border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; padding-bottom: 18px; }
.noc-row.rack-start ~ .noc-row.rack-start { margin-top: 14px; }   /* the next rack of the station: a gap between the two */
.noc-rack-tag { position: absolute; z-index: 2; top: 6px; left: 4%; right: 4%; overflow: hidden; color: #cfd6de; font-size: 11.5px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; pointer-events: none; }
.noc-rack-tag small { color: #8f99a4; font-size: 11px; font-weight: 500; }
.noc-row.is-still .noc-bay, .noc-row.is-empty .noc-bay { cursor: default; }
/* the rack unit by unit: each unit's number on the left rail; an empty unit a thin dark slot to drop a device on */
.noc-u { position: absolute; z-index: 2; left: .2%; top: 50%; transform: translateY(-50%); width: 2.2%; color: #aeb7c2; font-size: 10px; font-weight: 700; text-align: center; line-height: 1.1; pointer-events: none; }
.noc-slot .noc-bay { padding-top: 3px; padding-bottom: 3px; }
.noc-slot.rack-start .noc-bay { padding-top: 28px; } .noc-slot.rack-end .noc-bay { padding-bottom: 12px; }
.noc-slot-in { position: relative; z-index: 1; display: block; width: 95.2%; margin: 0 2.4%; min-height: 24px; padding: 4px 10px; border: 1px dashed #3f4750; border-radius: 3px; background: #181c20; color: #77818c; font: inherit; font-size: 11px; text-align: left; }
button.noc-slot-in { cursor: pointer; } button.noc-slot-in:hover { color: #cfd6de; border-color: #5b6570; }
.noc-carrying .noc-slot-in { border-color: #5b6570; color: #aeb7c2; }
.noc-slot.drop-on .noc-slot-in { border: 2px solid var(--primary); background: rgba(59, 130, 246, .18); color: #fff; }
.noc-bay[draggable="true"] { cursor: grab; }
.noc-row.dragging .noc-dev { opacity: .45; }
.noc-twins { display: grid; gap: 8px; margin: 0 0 12px; }
.noc-twins .noc-old { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin: 0; }
.noc-twins .noc-old span { flex: 1 1 320px; }
/* the network page's parts: the MikroTiks and the racks here, the map's lists (links, equipment, frequencies) in a frame */
.noc-pages { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.noc-pages button { display: inline-flex; align-items: center; gap: 7px; padding: 11px 12px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.noc-pages button .icon { width: 17px; height: 17px; }
.noc-pages button:hover { color: var(--text); background: var(--panel-muted); }
.noc-pages button[aria-current] { color: var(--primary); border-bottom-color: var(--primary); }
@media (max-width: 700px) { .noc-pages button { flex: 1; justify-content: center; padding: 10px 4px; font-size: 11px; } .noc-pages button .icon { display: none; } }
.noc-row.is-still .noc-dev { opacity: .8; }
@keyframes noc-fold { to { transform: scaleY(.03); opacity: 0; } }
@keyframes noc-unfold { from { transform: scaleY(.03); opacity: 0; } }
.noc-board.is-folding { transform-origin: top center; animation: noc-fold .17s ease-in forwards; }
.noc-board.is-unfolding { transform-origin: top center; animation: noc-unfold .26s cubic-bezier(.2, .8, .2, 1); }
@media (prefers-reduced-motion: reduce) { .noc-board.is-folding, .noc-board.is-unfolding { animation: none; } }
.noc-bay::before, .noc-bay::after { content: ''; position: absolute; top: 0; bottom: 0; width: 2.4%; background: repeating-linear-gradient(to bottom, #3b424a 0 8px, #262b31 8px 11px, #3b424a 11px 20px); }
.noc-bay::before { left: 0; }
.noc-bay::after { right: 0; }
.noc-row:first-child .noc-bay { border-radius: 12px 12px 0 0; padding-top: 18px; }
.noc-row:last-child .noc-bay { border-radius: 0 0 12px 12px; padding-bottom: 18px; }
.noc-row:only-child .noc-bay { border-radius: 12px; }
.noc-dev { position: relative; z-index: 1; display: block; width: 100%; height: auto; }
.noc-row.sel .noc-dev { outline: 2px solid #3b82f6; outline-offset: 3px; border-radius: 3px; }
.noc-row.is-down .noc-dev { opacity: .55; }
.noc-bay-empty { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; width: 92%; margin: 0 4%; padding: 14px; border: 1px dashed #4a525c; border-radius: 6px; color: #9aa4ae; font-size: 12.5px; }
.noc-bay-empty svg { width: 16px; height: 16px; flex: none; }
@container (max-width: 560px) { .nj-load, .nj-no, .nf-lbl, .nf-model { display: none; } }
.noc-card { display: grid; gap: 7px; align-self: center; min-width: 0; margin: 8px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.noc-row.sel .noc-card { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.noc-row.is-down .noc-card { box-shadow: inset 4px 0 0 var(--red); }
.noc-row.sel.is-down .noc-card { box-shadow: 0 0 0 1px var(--primary), inset 4px 0 0 var(--red); }
.noc-card-head { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; cursor: pointer; }
.noc-card-head h3 { margin: 0; font-size: 15px; font-weight: 650; color: var(--text); }
.noc-card-sub { color: var(--muted); font-size: 11.5px; }
.noc-card-wait { margin: 0; color: var(--muted); font-size: 12.5px; }
.noc-card .noc-figs { color: var(--muted); }
.noc-card .noc-fig b { color: var(--text); }
.noc-card .noc-fig.warn b { color: var(--amber); }
.noc-card .noc-fig.bad b { color: var(--red); }
.noc-card .noc-acts { justify-content: flex-start; }
.noc-card .noc-every-wrap { color: var(--muted); }
.noc-card .noc-every { border-color: var(--line-strong); background: var(--panel-muted); color: var(--text); }
.noc-card .noc-vchip { border-color: var(--line); background: var(--panel-muted); color: var(--text); }
.noc-card .noc-vchip small { color: var(--muted); }
.noc-card .noc-old { margin: 0; padding: 7px 10px; border: 0; border-radius: 8px; font-size: 12px; }
.noc-board + .noc-drawer { margin-top: 16px; border: 1px solid var(--line); }
.noc-drawer-head { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; padding: 12px 14px 4px; }
.noc-drawer-head h4 { margin: 0; font-size: 15px; font-weight: 650; color: var(--text); }
.noc-drawer-head small { color: var(--muted); font-size: 12px; }
@media (max-width: 900px) {
  .noc-row { grid-template-columns: minmax(0, 1fr); }
  .noc-split { display: none; }
  .noc-row .noc-bay { border-radius: 10px; padding: 12px 0; }
  .noc-card { margin: 8px 0 16px; }
}
.noc-rack { position: relative; display: grid; gap: 16px; padding: 16px 30px; border-radius: 14px; background: #1d2126; }
.noc-rack::before, .noc-rack::after { content: ''; position: absolute; top: 10px; bottom: 10px; width: 12px; border-radius: 3px; background: repeating-linear-gradient(to bottom, #3b424a 0 9px, #262b31 9px 13px, #3b424a 13px 22px); }
.noc-rack::before { left: 9px; }
.noc-rack::after { right: 9px; }
.noc-unit { position: relative; display: grid; gap: 8px; }
.noc-strip { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 8px 12px; border-radius: 9px; background: #2a3037; color: #e7eaee; }
.noc-unit.is-down .noc-strip { box-shadow: inset 4px 0 0 #ef4444; }
.noc-strip-name { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; min-width: 0; }
.noc-strip-name h3 { margin: 0; font-size: 14.5px; font-weight: 650; color: #fff; }
.noc-strip-name small { color: #9aa4ae; font-size: 11.5px; }
.noc-figs { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: #9aa4ae; }
.noc-fig b { color: #e7eaee; font-weight: 600; font-variant-numeric: tabular-nums; }
.noc-fig.warn b { color: #fbbf24; }
.noc-fig.bad b { color: #f87171; }
.noc-fig svg { width: 14px; height: 14px; vertical-align: -2px; }
.noc-strip .noc-acts { margin-left: auto; }
.noc-strip .btn.ghost { color: #e7eaee; border-color: #4a525c; background: transparent; }
.noc-strip .btn.ghost:hover { background: #343b43; }
.noc-strip .row-action { color: #c9d0d7; background: transparent; border-color: #4a525c; }
.noc-strip .row-action:hover { background: #343b43; }
.noc-every-wrap { display: inline-flex; align-items: center; gap: 5px; color: #9aa4ae; }
.noc-every-wrap svg { width: 15px; height: 15px; }
.noc-every { min-height: 30px; padding: 0 6px; border: 1px solid #4a525c; border-radius: 8px; background: #20252b; color: #e7eaee; font: inherit; font-size: 12.5px; }
.noc-every:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }
.noc-rack .noc-old { border-radius: 9px; border-bottom: 0; background: #3b3220; color: #f4e6bf; }
.noc-rack .noc-wait { border-radius: 9px; background: var(--panel); }
.noc-face { overflow-x: auto; border-radius: 4px; }
.noc-face svg { display: block; width: 100%; min-width: 760px; height: auto; }
.nf-white { fill: #f2f3f1; stroke: #c9ccc7; }
.nf-gray { fill: #d6d9dc; stroke: #b4b9be; }
.nf-black { fill: #2d2f33; stroke: #17181b; }
.nf-ear { fill: #e4e6e3; stroke: #c3c6c1; }
.nf-shelf { fill: #59616a; }
.nf-hole { fill: #23262a; }
.nf-vent { fill: none; stroke: #a9aea8; stroke-width: 1.4; }
.nf-slit { fill: #1c1e21; }
.nf-console { fill: #8d939a; stroke: #6f757c; }
.nf-usb { fill: #c7cbc6; stroke: #9da29c; }
.nf-usb-in { fill: #3b3f44; }
.nf-dc { fill: #1d1f22; stroke: #4a4e54; }
.nf-lbl { font: 600 7.5px "Noto Sans Georgian", Arial, sans-serif; fill: #6f756e; text-anchor: middle; }
.nf-lbl.l { text-anchor: start; }
.nf-lbl.w { fill: #b9bec5; }
.nf-lbl.s { font-size: 6.5px; }
.nf-logo { font: italic 800 17px Arial, sans-serif; fill: #2f3330; text-anchor: end; letter-spacing: -.3px; }
.nf-logo.w { fill: #d9dde2; font-size: 13px; font-style: normal; letter-spacing: 1.5px; }
/* a UPS's little screen */
.nf-lcd { fill: #1f3d52; stroke: #0d1b24; }
.nf-lcd-t { font: 700 13px Arial, sans-serif; fill: #8fd3ff; text-anchor: middle; }
.nf-model.w { fill: #9aa3ad; }
.nf-model { font: 600 8px Arial, sans-serif; fill: #6f756e; text-anchor: end; }
.nf-hap { font: 500 21px Arial, sans-serif; fill: #e3e6ea; }
.nf-hap-s { font-size: 11px; }
.nj-body { fill: #3a3d42; stroke: #23252a; }
.nj-body.dark { fill: #17181b; stroke: #0b0c0e; }
.nj-hole { fill: #111215; }
.nj-cage { fill: #b8bcc1; stroke: #868b92; }
.nj-no { font: 600 9px Arial, sans-serif; fill: #9097a0; text-anchor: middle; pointer-events: none; }
.nj-no.sfp { fill: #2d3136; }
.nj-led { fill: #4b4f55; }
.nj-led.on { fill: #3ddc61; }
.nj-load { font: 700 13px Arial, sans-serif; fill: #23733a; text-anchor: middle; }
.nj-load.w { fill: #7ee59a; }
.nj-star { font-size: 8px; fill: #f5b301; }
.nj.has { cursor: pointer; }
.nj.has:hover .nj-body, .nj.has:hover .nj-cage { stroke: #3b82f6; stroke-width: 1.6; }
.nj.off .nj-body, .nj.off .nj-cage { opacity: .5; }
.nj-sel { fill: none; stroke: #3b82f6; stroke-width: 2.4; }
.nj:focus { outline: none; }
.nj:focus-visible .nj-body, .nj:focus-visible .nj-cage { stroke: #3b82f6; stroke-width: 2; }
.noc-virt { display: flex; flex-wrap: wrap; gap: 6px; }
.noc-vchip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 11px; border: 1px solid #3c444d; border-radius: 999px; background: #262b31; color: #e7eaee; font: inherit; font-size: 12px; cursor: pointer; }
.noc-vchip small { color: #9aa4ae; font-size: 11px; }
.noc-vchip:hover { border-color: #5b6570; }
.noc-vchip.sel { border-color: #3b82f6; box-shadow: 0 0 0 1px #3b82f6; }
.nj-led-h { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #4b4f55; }
.nj-led-h.on { background: #3ddc61; }
@media (prefers-reduced-motion: no-preference) {
  .nj-led.on.lv1, .nj-led-h.on.lv1 { animation: nj-blink 3.2s steps(1, end) infinite; }
  .nj-led.on.lv2, .nj-led-h.on.lv2 { animation: nj-blink 1.6s steps(1, end) infinite; }
  .nj-led.on.lv3, .nj-led-h.on.lv3 { animation: nj-blink .7s steps(1, end) infinite; }
}
/* the rack's cables: a plug in its jack, the cords over the rack, the jack being carried */
.nj-plug { stroke: rgba(0, 0, 0, .45); stroke-width: 1; }
.nj-plug-in { fill: rgba(255, 255, 255, .28); }
.noc-cables { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; overflow: visible; }
.noc-board > .noc-row > .noc-card { position: relative; z-index: 4; }   /* a cord passes behind a card (the cards under the rack on a narrow screen) */
.noc-cord-edge { fill: none; stroke: rgba(0, 0, 0, .45); stroke-linecap: round; }
.noc-cord { fill: none; stroke-linecap: round; pointer-events: stroke; cursor: context-menu; }
.noc-cable-to { font: 600 11px/1 system-ui, sans-serif; fill: #e5e7eb; paint-order: stroke; stroke: rgba(10, 14, 22, .85); stroke-width: 3px; }
.nj[data-plug] { cursor: grab; }
body.noc-moving, body.noc-moving .nj { cursor: copy; }
body.noc-moving .nj:not([data-plug]) .nj-body, body.noc-moving .nj:not([data-plug]) .nj-cage { stroke: #60a5fa; stroke-width: 1.5; }
.nj.drop-to .nj-body, .nj.drop-to .nj-cage { stroke: #22c55e; stroke-width: 2.5; }
.noc-add-menu .noc-menu-h { padding: 6px 10px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.noc-add-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.noc-add-menu button.danger, .noc-add-menu button.danger svg { color: var(--red); }
.noc-colors { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.noc-colors label { display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; font-size: 11px; color: var(--muted); }
.noc-colors input { position: absolute; opacity: 0; pointer-events: none; }
.noc-colors span { width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 2px solid var(--line); box-shadow: inset 0 0 0 2px var(--panel); }
.noc-colors input:checked + span { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--panel), 0 0 0 2px var(--primary); }
.noc-colors input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.noc-dests { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 0 0 12px; max-height: 340px; overflow: auto; }
.noc-dests legend { padding: 0 4px; font-weight: 600; }
.noc-dests-h { margin: 8px 0 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.noc-dests-q { width: 100%; margin: 2px 0 6px; }
.noc-dest { display: flex; gap: 8px; align-items: flex-start; padding: 5px 2px; cursor: pointer; }
.noc-dest small { display: block; color: var(--muted); font-size: 12px; }
.noc-dest small input { margin-top: 4px; width: 100%; }
/* a device of a router's list that is our own equipment */
.noc-ours { color: var(--green); font-weight: 600; }
.noc-ours svg { width: 13px; height: 13px; vertical-align: -2px; }
/* "+ მოწყობილობის დამატება": its short menu; the catalogue's window over the page */
.noc-add-menu { position: absolute; z-index: 60; width: min(360px, calc(100vw - 16px)); padding: 6px; display: grid; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg, 0 18px 48px rgba(0,0,0,.25)); }
.noc-add-menu button { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.noc-add-menu button:hover, .noc-add-menu button:focus-visible { background: var(--panel-muted, rgba(127,127,127,.08)); outline: none; }
.noc-add-menu button svg { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--primary); }
.noc-add-menu b { display: block; font-size: 13.5px; }
.noc-add-menu small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.noc-add-layer { position: fixed; inset: 0; z-index: 80; background: rgba(8, 12, 20, .35); }
.noc-add-layer iframe { width: 100%; height: 100%; border: 0; background: transparent; }
button.noc-slot-in .noc-slot-add { margin-left: 8px; color: var(--primary); font-weight: 600; opacity: 0; transition: opacity .15s; }
.noc-slot:hover .noc-slot-add, button.noc-slot-in:focus-visible .noc-slot-add { opacity: 1; }
@media (hover: none) { button.noc-slot-in .noc-slot-add { opacity: 1; } }
/* a UPS on its battery: its light amber, blinking */
.nj-led.on.bat { fill: #f59e0b; }
@media (prefers-reduced-motion: no-preference) { .nj-led.on.bat { animation: nj-blink .9s steps(1, end) infinite; } }
/* a UPS's network card: its address and community, folded under the card */
.noc-ups-set { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.noc-ups-set summary { cursor: pointer; color: var(--text); font-weight: 600; }
.noc-ups-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; margin: 8px 0 4px; }
.noc-ups-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.noc-ups-form input { width: 150px; max-width: 100%; }
/* as a port's light on the router: lit, with short dark flickers at uneven gaps -- more often the more traffic */
@keyframes nj-blink { 0%, 13%, 30%, 41%, 61%, 82%, 94%, 100% { opacity: 1; } 9%, 27%, 36%, 58%, 77%, 91% { opacity: .15; } }
/* a router that has gone silent: its last lights and figures are not shown as if they were now */
.noc-unit.is-down .nj-led.on, .noc-unit.is-down .nj-led-h.on { fill: #4b4f55; background: #4b4f55; animation: none; }
.noc-unit.is-down .nj-load, .noc-unit.is-down .noc-vchip small { visibility: hidden; }
.noc-unit.is-down .noc-face { opacity: .55; }
.noc-drawer { border-radius: 10px; background: var(--panel); color: var(--text); overflow: hidden; }
.noc-pd-hint { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.noc-pd-hint svg { width: 15px; height: 15px; flex: none; }
.noc-pd { padding: 12px 14px 14px; border-bottom: 1px solid var(--line); }
.noc-pd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.noc-pd-head h4 { margin: 0 0 3px; font-size: 15px; font-weight: 650; color: var(--text); }
.noc-pd-cm { color: var(--text-2); font-weight: 500; }
.noc-pd-head small { margin-right: 6px; color: var(--muted); font-size: 12px; }
.noc-pd-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr); gap: 18px; margin-top: 10px; }
.noc-pd-behind h5 { margin: 0 0 8px; font-size: 13px; font-weight: 650; color: var(--text); }
.noc-pd-behind ul { display: grid; gap: 7px; max-height: 250px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.noc-pd-behind li { display: flex; align-items: flex-start; gap: 8px; }
.noc-pd-behind li .noc-dot { margin-top: 5px; flex: none; }
.noc-pd-behind li b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.noc-pd-behind li small { display: block; color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.noc-pd-wait { margin: 4px 0; color: var(--muted); font-size: 12.5px; }
.noc-tabs { display: flex; flex-wrap: wrap; gap: 0 20px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.noc-tabs button { padding: 10px 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.noc-tabs button:hover { color: var(--text); }
.noc-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }
.noc-tabs button span { margin-left: 4px; padding: 0 6px; border-radius: 6px; background: var(--panel-muted); font-size: 11.5px; }
.noc-sec { padding: 12px 14px; }
.noc-drawer .noc-queues { border-top: 0; }
.noc-drawer .noc-sparks { border-bottom: 0; }
.noc-pd-dev { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin: 10px 0 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-muted); color: var(--text-2); font-size: 12.5px; }
.noc-pd-dev > svg { width: 16px; height: 16px; flex: none; color: var(--primary); }
.noc-pd-dev label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.noc-pd-dev .noc-dev-pick { width: auto; min-width: 220px; max-width: 100%; }
.noc-pd-dev .noc-suggest { display: inline-block; margin: 0; }
.noc-l-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.noc-l-search { width: min(360px, 100%); min-height: 36px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-muted); color: var(--text); font: inherit; font-size: 13px; }
.noc-l-head small { color: var(--muted); font-size: 12px; }
.noc-suggest { display: block; margin-top: 5px; padding: 3px 9px; border: 1px dashed var(--primary-line, var(--line-strong)); border-radius: 8px; background: var(--primary-soft); color: var(--primary); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.noc-suggest:hover { border-style: solid; }
.noc-port-link { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: 12.5px; cursor: pointer; }
.noc-port-link:hover { text-decoration: underline; }
@media (max-width: 760px) {
  .noc-rack { padding: 12px 22px; }
  .noc-rack::before { left: 5px; }
  .noc-rack::after { right: 5px; }
  .noc-pd-grid { grid-template-columns: minmax(0, 1fr); }
  .noc-strip .noc-acts { margin-left: 0; }
}
/* the clients' queues: each company's speed now against its limit */
.noc-queues { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.noc-queues h4 { margin: 0 0 10px; font-size: 13.5px; font-weight: 650; color: var(--text); }
.noc-queues h4 small { margin-left: 6px; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.noc-queues-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.noc-q-search { width: min(280px, 100%); min-height: 34px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-muted); color: var(--text); font: inherit; font-size: 12.5px; }
.noc-qtable td.noc-rate { min-width: 130px; }
.noc-qtable td.noc-rate b { display: block; font-variant-numeric: tabular-nums; }
.noc-bar { display: block; height: 5px; margin-top: 4px; border-radius: 3px; background: var(--panel-muted); overflow: hidden; }
.noc-bar i { display: block; height: 100%; border-radius: 3px; background: var(--green); }
.noc-bar.is-high i { background: var(--amber); }
.noc-bar.is-full i { background: var(--red); }
.noc-qtable tr.is-full td { background: color-mix(in srgb, var(--red) 7%, transparent); }
.noc-qtable tr.is-off td { opacity: .55; }
/* live mode: a port's traffic every 5 seconds */
.noc-live { padding: 14px 16px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--primary) 5%, var(--panel)); }
.noc-live-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.noc-live-head small { color: var(--muted); font-size: 12px; }
.noc-live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: noc-blink 1.2s ease-in-out infinite; }
@keyframes noc-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .noc-live-dot { animation: none; } }
.noc-live-pick { margin-left: auto; min-height: 32px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel); color: var(--text); font: inherit; font-size: 12.5px; }
.noc-live-now { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 6px; }
.noc-live-now span { display: block; color: var(--muted); font-size: 12px; }
.noc-live-now b { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.noc-live-chart { width: 100%; height: 130px; display: block; }
.noc-live-rx, .noc-live-tx { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.noc-live-rx { stroke: var(--primary); }
.noc-live-tx { stroke: var(--green); }
.noc-live-scale { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.noc-live-scale i { display: inline-block; width: 12px; height: 3px; margin: 0 4px 2px 10px; border-radius: 2px; vertical-align: middle; }
.noc-live-scale i.rx { background: var(--primary); }
.noc-live-scale i.tx { background: var(--green); }
.noc-live-wait { margin: 6px 0 0; color: var(--text-2); font-size: 13px; }
/* what happens to a device taken off: one choice per row */
.rm-choices { display: grid; gap: 6px; margin-bottom: 8px; }
.rm-choices label { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); cursor: pointer; }
.rm-choices label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.rm-choices label.danger:has(input:checked) { border-color: var(--red); background: var(--red-bg); }
.rm-choices input { width: 17px; height: 17px; accent-color: var(--primary); }
.rm-choices b { display: block; font-size: 13.5px; color: var(--text); }
.rm-choices small { display: block; margin-top: 1px; color: var(--muted); 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); }
/* The user window: login fields, then the pages -- grouped, each a whole
   clickable row with its checkbox and name on one line. */
.user-modal { width: min(760px, calc(100vw - 36px)); }
.user-form { display: grid; gap: 14px; }
.user-form .field { margin: 0; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 46px; }
.pass-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.pass-toggle:hover, .pass-toggle:focus-visible { background: var(--primary-soft); color: var(--primary); outline: none; }
.user-active-switch { white-space: normal; }
.perm-section { display: grid; gap: 10px; }
.perm-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.perm-head h4 { margin: 0; color: var(--text-2); font-size: 13px; font-weight: 650; }
.perm-tools { display: flex; align-items: center; gap: 6px; }
.perm-count { margin-right: 4px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.perm-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 10px; }
.perm-group { display: grid; align-content: start; gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.perm-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 6px 6px; }
.perm-group-head b { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .02em; }
.perm-group-head button { padding: 2px 6px; border: 0; border-radius: 6px; background: transparent; color: var(--primary); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.perm-group-head button:hover, .perm-group-head button:focus-visible { background: var(--primary-soft); outline: none; }
.perm-item { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 4px 6px 4px 8px; border-radius: 8px; color: var(--text); font-size: 13.5px; transition: background .12s var(--ease); }
.perm-see { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 30px; cursor: pointer; }
.perm-mode { flex: none; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--primary); font: inherit; font-size: 11.5px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.perm-mode.is-view { border-color: var(--amber-line); background: var(--amber-bg); color: var(--amber); }
.perm-mode:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.perm-note { margin: -2px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.view-only-chip { display: inline-flex; align-items: center; margin-left: 8px; padding: 2px 9px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); font-size: 12px; font-weight: 650; letter-spacing: 0; vertical-align: middle; }
.perm-item:hover { background: var(--panel-muted); }
.perm-item:has(input:checked) { background: var(--primary-soft); }
.perm-item input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.perm-item:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 1px; }
@media (max-width: 640px) { .perm-groups { grid-template-columns: 1fr; } }
#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; }
/* Computers show every tab (wrapping if needed); phones scroll the strip. */
@media (min-width: 1024px) { .settings-tabs { flex-wrap: wrap; } }
.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; }

/* Desktop subscriber lists: let headers, names and status badges wrap
   instead of forcing one line each -- ~1720px of nowrap content came down
   to ~1290px, so the 11 columns fit a typical desktop without scrolling. */
@media (min-width: 1024px) {
  .subscribers-scroll thead th, .subscribers-scroll tbody td { padding-left: 9px; padding-right: 9px; }
  .subscribers-scroll thead th, .subscribers-scroll .sort-head, .subscribers-scroll .company-link, .subscribers-scroll .status-badge { white-space: normal; }
  .subscribers-scroll .status-badge { text-align: left; border-radius: 13px; }
  .subscribers-scroll table { min-width: 0; }
}

/* Data tables on smaller screens. Tablets: ordinary tables drop their
   desktop min-width and wrap; the per-company lists (.cards-md: subscribers,
   disconnected, payments, debts) become cards. Phones: every table becomes
   cards -- one row per card, each cell labelled with its column header
   (data-label, filled in by app.js from the table's own <thead>), so
   nothing needs sideways scrolling. Cells spanning several columns (empty
   states, subtotal rows) take the full card width, unlabelled. */
@media (max-width: 1023px) {
  .table-scroll table { min-width: 0; }
  .table-scroll thead th, .table-scroll tbody td { padding-left: 9px; padding-right: 9px; }
  .table-scroll thead th, .table-scroll .status-badge, .table-scroll .company-link { white-space: normal; }
  .cards-md, .table-toolbar + .cards-md { overflow: visible; max-height: none; }
  .cards-md thead { display: none; }
  .cards-md table, .cards-md tbody { display: block; }
  .cards-md tbody tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .subscribers-scroll tbody tr { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .cards-md tbody tr:last-child { border-bottom: 0; }
  .cards-md tbody td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; font-size: 14px; overflow-wrap: anywhere; }
  .cards-md tbody td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: normal; }
  .cards-md tbody td[data-label=""]::before, .cards-md tbody td[colspan]::before { display: none; }
  .cards-md tbody td[colspan] { grid-column: 1 / -1; }
  .cards-md .status-badge { text-align: left; }
  /* The company is each card's title. */
  :is(#disconnectedTable, #paymentsBody) td:nth-child(2), #subscribersTable tbody td:nth-child(3), #debtsBody td:first-child { grid-column: 1 / -1; order: -1; }
  :is(#disconnectedTable, #paymentsBody) td:nth-child(2)::before, #subscribersTable tbody td:nth-child(3)::before, #debtsBody td:first-child::before { display: none; }
  /* the tick sits at the card's top left, beside the company's name */
  #subscribersTable tbody tr { position: relative; }
  #subscribersTable tbody td.sel-col { position: absolute; left: 14px; top: 16px; width: auto; }
  #subscribersTable tbody td.sel-col::before { display: none; }
  #subscribersTable tbody td:nth-child(3) { padding-left: 28px; }
  .cards-md .company-link { font-size: 16px; text-align: left; }
  .cards-md .company-cell { display: flex; justify-content: space-between; width: 100%; }
  #subscribersTable tbody td:nth-child(9), #subscribersTable tbody td:nth-child(10) { grid-column: 1 / -1; }
  /* Automation: company as the title, contact under it, the three switches in a row. */
  .automation-cards tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-left: 0; padding-right: 0; }
  #autoCompaniesBody td:nth-child(-n+2) { grid-column: 1 / -1; }
  #autoCompaniesBody td:first-child::before { display: none; }
  #autoCompaniesBody .automation-contact { max-width: none; }
}
@media (max-width: 767px) {
  .table-scroll, .table-toolbar + .table-scroll { overflow: visible; max-height: none; }
  .table-scroll thead { display: none; }
  .table-scroll tbody { display: block; }
  .table-scroll tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .subscribers-scroll tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .table-scroll tbody tr:last-child { border-bottom: 0; }
  .table-scroll tbody td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; font-size: 14px; overflow-wrap: anywhere; }
  .table-scroll tbody td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: normal; }
  .table-scroll tbody td[data-label=""]::before, .table-scroll tbody td[colspan]::before { display: none; }
  .table-scroll tbody td[colspan] { grid-column: 1 / -1; }
  .table-scroll .status-badge { white-space: normal; text-align: left; }
}

/* Touch screens (phones, tablets): controls get a ~44px touch target
   (WCAG 2.5.5 / platform guidelines) and inputs a 16px font, which also
   stops iOS Safari from zooming the page on every field focus. Mouse-
   driven desktops keep their denser look. */
@media (pointer: coarse) {
  .btn, .icon-btn, .modal-close, .user-card button, .settings-tab, .row-action, .sort-head { min-height: 44px; }
  .icon-btn, .modal-close, .user-card button, .row-action { min-width: 44px; }
  .company-cell .row-action { width: 44px; height: 44px; }
  .search-clear { width: 40px; height: 40px; }
  .company-link, #financeRoot .f-link { min-height: 36px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea { min-height: 44px; font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
}

/* Phones: a form's action buttons stay pinned to the bottom of the modal,
   so "save"/"send" is reachable without scrolling long forms; with more
   than two buttons they wrap and share the width evenly. */
@media (max-width: 767px) {
  .modal-head, .modal-body { padding-left: 16px; padding-right: 16px; }
  .modal-body > .modal-actions:last-child { position: sticky; bottom: 0; z-index: 2; margin: 0 -16px -21px; padding: 12px 16px 16px; background: var(--panel-elevated); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-body > .modal-actions:last-child > .btn { justify-content: center; white-space: normal; text-align: center; }
  .modal-body > .modal-actions:last-child > .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* Phones: long page titles ("გათიშული კომპანიები", "ანალიტიკა/ფინანსები")
   get two lines next to the menu and action buttons instead of an ellipsis. */
@media (max-width: 560px) {
  .page-heading h1 { font-size: 17px; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
}

/* <small> inside already-small text shrinks to ~9px by default; keep a
   readable 11px floor everywhere. */
small { font-size: max(11px, .85em); }

/* Contract/annex history rows carry up to four wide buttons, more than the
   550px modal fits beside the text -- they go on their own line below. */
.history-row.doc-row { grid-template-columns: 88px minmax(0, 1fr); }
.history-row.doc-row > div:last-child { grid-column: 1 / -1; justify-content: flex-start !important; }
.history-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }

/* Settings -> ინვოისი: form on the left, a live A4 preview on the right
   (stacked below 1200px). The preview iframe is laid out at A4 width and
   scaled to its column by app.js. */
.invoice-settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.invoice-settings-form { display: grid; gap: 18px; min-width: 0; }
.invoice-settings-form form { display: grid; gap: 18px; }
.invoice-preview-col { position: sticky; top: calc(var(--freeze-end, 76px) + 20px); min-width: 0; }   /* under the top bar and the frozen menu */
.invoice-preview { position: relative; overflow: hidden; margin: 0 16px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.invoice-preview iframe { display: block; width: 794px; height: 1123px; border: 0; transform-origin: 0 0; background: #fff; }
.invoice-save-row { padding-top: 0; }
.invoice-number-example { margin: 4px 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--text-2); font-size: 13px; }
.invoice-number-example b { color: var(--primary); font-variant-numeric: tabular-nums; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type="color"] { width: 46px; min-width: 46px; height: 42px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel-muted); cursor: pointer; }
.color-field input:not([type="color"]) { flex: 1; min-width: 0; }
.image-field { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.image-field img { width: 100%; max-height: 70px; object-fit: contain; object-position: left center; }
.image-field img:not([src]), .image-field img[src=""] { display: none; }
.product-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.product-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: 13px; }
.product-row:last-child { border-bottom: 0; }
.product-row.inactive { opacity: .55; }
.product-row small { display: block; color: var(--muted); font-size: 12px; }
.product-row .row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 1200px) {
  .invoice-settings-grid { grid-template-columns: 1fr; }
  .invoice-preview-col { position: static; }
}

/* Email compose window -- laid out like a mail client: header fields as
   label/value rows, attachment chips, the editable text, then the signature
   on white exactly as the recipient's mail client will show it. */
.compose-fields { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.compose-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 48px; padding: 5px 12px; border-bottom: 1px solid var(--line); }
.compose-row:last-child { border-bottom: 0; }
.compose-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.compose-row input:not([type="checkbox"]):not([type="file"]) { width: 100%; min-width: 0; min-height: 38px; padding: 0 2px; border: 0; border-radius: 0; background: transparent; color: var(--text); font: inherit; font-size: 14.5px; outline: none; }
.compose-row input:not([type="checkbox"]):focus-visible { box-shadow: inset 0 -2px 0 var(--primary); }
.compose-from { color: var(--text); font-size: 14px; overflow-wrap: anywhere; }
.compose-from span { color: var(--muted); }
.compose-from .compose-warn { color: var(--amber); }
.compose-to { display: flex; align-items: center; gap: 10px; min-width: 0; }
.compose-sms { min-height: 34px; margin: 0; color: var(--text-2); font-size: 13px; }
.compose-sms span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-sms:has(input:disabled) { color: var(--muted); cursor: default; }
.compose-bcc { flex: none; min-height: 34px; margin: 0; padding: 0 11px; border-radius: 999px; background: var(--panel-muted); white-space: nowrap; }
.compose-files { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; padding: 5px 0; }
.compose-chips { display: contents; }
.compose-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 32px; padding: 3px 4px 3px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-muted); color: var(--text-2); font-size: 12.5px; }
.compose-chip.is-main { padding-right: 11px; border-color: var(--primary-line); background: var(--primary-soft); color: var(--text); }
.compose-chip .icon { flex: none; width: 15px; height: 15px; color: var(--primary); }
.compose-chip b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.compose-chip small { flex: none; color: var(--muted); }
.compose-chip button { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.compose-chip button:hover, .compose-chip button:focus-visible { background: var(--red-bg); color: var(--red); }
.compose-chip button .icon { width: 13px; height: 13px; color: inherit; }
.compose-body { display: block; width: 100%; min-height: 150px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--panel-muted); color: var(--text); font: inherit; font-size: 14.5px; line-height: 1.6; resize: vertical; transition: border-color .16s var(--ease), box-shadow .16s var(--ease); }
.compose-body:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.compose-signature { margin-top: 12px; padding: 2px 18px 16px; border: 1px dashed var(--line-strong); border-radius: 12px; background: #fff; overflow-x: auto; }
/* The signature is email HTML: keep the app's data-table rules off it. */
.compose-signature table { width: auto; min-width: 0; border-collapse: collapse; }
.compose-signature td { padding: 0; border: 0; color: inherit; font-size: inherit; text-align: left; }
@media (pointer: coarse) { .compose-chip button { width: 36px; height: 36px; } }
@media (max-width: 767px) {
  .compose-row { grid-template-columns: 1fr; gap: 0; padding: 8px 12px 4px; }
  .compose-to { flex-wrap: wrap; gap: 4px 10px; }
}

/* Issuing an invoice: a near-full-screen window laid out like a document
   viewer -- the A4 page on a grey canvas (scrolls on its own, 100% by
   default, "whole page" fits it to the height), and on the right a fixed
   panel with the period, a summary and every action, always in view.
   Below 900px it stacks: controls, page, then actions pinned to the bottom. */
.billing-invoice-modal { width: min(1320px, calc(100vw - 36px)); height: min(calc(100vh - 36px), 1240px); max-height: none; display: flex; flex-direction: column; overflow: hidden; }
.billing-invoice-modal > .modal-head { flex: none; }
.billing-invoice-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; padding: 0; }
.billing-invoice-viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel-muted); }
.billing-invoice-toolbar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.billing-invoice-scale { color: var(--muted); font-size: 12.5px; }
.billing-invoice-scale b { color: var(--text-2); font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.segmented button { min-height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: background .14s var(--ease), color .14s var(--ease); }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.segmented button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.billing-invoice-canvas { flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; padding: 24px; }
.billing-invoice-paper { position: relative; overflow: hidden; margin: 0 auto; border-radius: 3px; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 8px 28px rgba(15, 23, 42, .12); }
.billing-invoice-paper iframe { display: block; width: 794px; height: 1123px; border: 0; transform-origin: 0 0; background: #fff; }
.billing-invoice-side { display: flex; flex-direction: column; gap: 18px; min-height: 0; overflow: auto; padding: 20px 22px; border-left: 1px solid var(--line); background: var(--panel-elevated); }
.billing-invoice-controls .field { margin-bottom: 14px; }
.billing-invoice-actions { margin-top: auto; display: grid; gap: 8px; }
.billing-invoice-actions .btn { justify-content: center; }
.billing-invoice-summary { display: grid; gap: 12px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.billing-invoice-summary .status-badge { justify-self: start; }
.billing-invoice-facts { display: grid; gap: 8px; margin: 0; }
.billing-invoice-facts > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; }
.billing-invoice-facts dt { color: var(--muted); }
.billing-invoice-facts dd { margin: 0; color: var(--text); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.billing-invoice-facts dd.is-pending { color: var(--muted); font-weight: 500; }
.billing-invoice-facts .fact-amount dd { font-size: 17px; }
.billing-invoice-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.status-badge.issued { background: var(--green-bg); color: var(--green); }
.status-badge.draft { background: var(--panel-muted); color: var(--muted); }
@media (max-width: 899px) {
  .billing-invoice-modal { height: auto; max-height: 96vh; display: block; overflow: auto; }
  .billing-invoice-body { display: flex; flex-direction: column; }
  .billing-invoice-side { display: contents; }
  .billing-invoice-controls { order: 1; padding: 18px 22px 4px; }
  .billing-invoice-viewer { order: 2; }
  .billing-invoice-toolbar { display: none; }
  .billing-invoice-canvas { overflow: visible; padding: 14px; }
  .billing-invoice-actions { order: 3; position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; margin: 0; padding: 12px 22px 16px; background: var(--panel-elevated); border-top: 1px solid var(--line); }
  .billing-invoice-actions .btn { flex: 1 1 140px; white-space: normal; text-align: center; }
}
@media (max-width: 767px) {
  .billing-invoice-controls { padding: 16px 16px 4px; }
  .billing-invoice-actions { padding: 12px 16px 16px; }
}

/* Issued invoice: download plus the three ways to send it -- email,
   WhatsApp, or a link -- as one row of equal buttons. */
.invoice-share { display: grid; gap: 10px; }
.invoice-share-pdf { justify-content: center; }
.invoice-share-label { margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.invoice-share-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.invoice-share-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 64px; padding: 8px 4px; border: 1px solid var(--primary-line); border-radius: 11px; background: var(--panel); color: var(--primary); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .14s var(--ease), transform .12s var(--ease); }
.invoice-share-btn .icon { width: 21px; height: 21px; }
.invoice-share-btn:hover { background: var(--primary-soft); }
.invoice-share-btn:active { transform: scale(.97); }
.invoice-share-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.invoice-share-btn.is-whatsapp { border-color: var(--green-line); color: var(--green); }
.invoice-share-btn.is-whatsapp:hover { background: var(--green-bg); }
.invoice-link-row { display: flex; align-items: center; gap: 6px; }
.invoice-link-row input { flex: 1; min-width: 0; min-height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-muted); color: var(--text); font-size: 12.5px; }
@media (max-width: 899px) { .billing-invoice-actions .invoice-share { flex: 1 1 100%; } }

/* A one-line state note above the preview, and history rows with the
   number, amount and payment state side by side. */
.billing-invoice-main { display: flex; justify-content: space-between; gap: 12px; min-width: 0; }
.billing-invoice-sum { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.billing-invoice-row .invoice-no { color: var(--text); font-variant-numeric: tabular-nums; }
.billing-invoice-row.is-cancelled .invoice-no, .billing-invoice-row.is-cancelled .money { color: var(--muted); text-decoration: line-through; }
.status-badge.cancelled { background: var(--panel-muted); color: var(--muted); }
.status-badge.invoice-changed { margin-top: 6px; border-radius: 10px; white-space: normal; }

/* Settings -> ავტომატიზაცია: overview tiles, then one full-width section per
   automation -- fields on the left, its status and last run on the right --
   a save bar that stays in view, and the company switches at the bottom. */
.automation-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.automation-tile { display: grid; gap: 8px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); font: inherit; text-align: left; cursor: pointer; box-shadow: var(--shadow-xs); transition: border-color .15s var(--ease), transform .12s var(--ease); }
.automation-tile:hover { border-color: var(--primary-line); }
.automation-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.automation-tile-head { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 650; }
.automation-tile-count { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.automation-tile-count small { margin-left: 4px; color: var(--muted); font-size: 13px; font-weight: 500; }
.automation-tile-count.is-text { font-size: 18px; line-height: 1.45; }
.automation-tile-meta { color: var(--muted); font-size: 12.5px; }
.automation-tile.is-warn .automation-tile-meta { color: var(--amber); }
.automation-form { display: grid; gap: 18px; margin-bottom: 18px; }
.automation-section { scroll-margin-top: 90px; }
.automation-section-head { display: flex; align-items: flex-start; gap: 14px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.automation-section-title { flex: 1; min-width: 0; }
.automation-run-now { flex: none; align-self: center; }
.auto-run-kinds { display: grid; gap: 10px; margin: 0 0 14px; }
.auto-run-kind { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.auto-run-kind .check-row { min-height: 0; margin: 0; color: var(--text); font-size: 14px; font-weight: 650; }
.auto-run-kind ul { margin: 0; padding-left: 26px; color: var(--text-2); font-size: 12.5px; line-height: 1.6; }
.auto-run-kind small { color: var(--muted); font-size: 12px; }
.auto-run-kind.is-real { border-color: var(--red-line); }
.auto-run-kind .auto-run-warn { color: var(--red); font-weight: 600; }
.auto-run-result { display: grid; gap: 6px; }
.auto-run-result .cp-red { color: var(--red); }
.automation-section-title h3 { margin: 0 0 4px; font-size: 16px; font-weight: 650; color: var(--text); }
.automation-section-title p { margin: 0; max-width: 72ch; color: var(--muted); font-size: 13px; line-height: 1.6; }
.automation-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.automation-icon .icon { width: 19px; height: 19px; }
.automation-icon.small { width: 30px; height: 30px; border-radius: 9px; }
.automation-icon.small .icon { width: 15px; height: 15px; }
.automation-demo-btn { flex: none; }
.automation-section-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 28px; padding: 20px 22px 22px; }
.automation-fields { display: grid; gap: 4px; align-content: start; min-width: 0; }
.automation-fields > .field-hint { margin: 0; }
.automation-side { display: grid; gap: 10px; align-content: start; }
.automation-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 18px; }
.day-input { display: flex; align-items: center; gap: 10px; }
.day-input input { width: 96px !important; flex: none; text-align: center; font-variant-numeric: tabular-nums; }
.day-input span { color: var(--muted); font-size: 13px; }
.field-optional { margin-left: 6px; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.automation-sub { display: grid; gap: 6px; }
.automation-sub + .automation-sub { margin-top: 14px; padding-top: 18px; border-top: 1px dashed var(--line-strong); }
.automation-sub-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.automation-sub-head h4 { margin: 0 0 3px; font-size: 14px; font-weight: 650; color: var(--text); }
.automation-sub-head p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.automation-welcome-switch { margin: 2px 0 10px; font-size: 13px; }
.automation-debt-field { margin-top: 12px; }
.sms-block-title { margin: 10px 0 2px; color: var(--text); font-size: 13px; font-weight: 650; }
.sms-block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.sms-templates { display: grid; gap: 10px; }
.sms-template { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-muted); }
.sms-template-head { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.sms-template-head b { color: var(--text); font-size: 13px; font-weight: 650; }
.sms-template-head input { flex: 1; min-width: 0; }
.sms-template-head .row-action { margin-left: auto; }
.sms-template textarea { width: 100%; }
.sms-count { font-variant-numeric: tabular-nums; }
.automation-savebar { position: sticky; bottom: 14px; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px 12px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-elevated); box-shadow: var(--shadow-md); color: var(--muted); font-size: 13px; }
.automation-savebar.is-dirty { border-color: var(--amber-line); }
.automation-savebar.is-dirty span { color: var(--amber); font-weight: 600; }
.automation-status { display: grid; gap: 8px; }
.automation-note { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--text-2); font-size: 13px; line-height: 1.55; }
.automation-note .icon { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--primary); }
.automation-note.is-warn { background: var(--amber-bg); }
.automation-note.is-warn .icon { color: var(--amber); }
.automation-note.is-ok { background: var(--green-bg); }
.automation-note.is-ok .icon { color: var(--green); }
.automation-note details { margin-top: 4px; }
.automation-note summary { cursor: pointer; color: var(--red); font-weight: 600; }
.automation-note ul { margin: 6px 0 0; padding-left: 18px; }
.automation-companies { padding: 16px 22px 22px; }
.automation-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.automation-search { flex: 1 1 260px; max-width: 420px; }
.automation-bulk { display: flex; gap: 8px; flex-wrap: wrap; }
.automation-bulk select { min-height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel-muted); color: var(--text); font: inherit; font-size: 13.5px; }
.automation-table { min-width: 760px; }
.automation-table .auto-pick-col { width: 36px; padding-right: 0; }
.automation-table .auto-pick-col input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
.automation-bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; min-height: 42px; margin-bottom: 12px; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); font-size: 13px; }
.automation-bulkbar.is-active { border-style: solid; border-color: var(--primary-line); background: var(--primary-soft); color: var(--text); }
.automation-bulkbar .bulk-count { font-weight: 650; color: var(--text); }
.automation-bulkbar .bulk-group { display: inline-flex; align-items: center; gap: 6px; }
.automation-bulkbar .bulk-group b { font-size: 12.5px; font-weight: 600; }
.automation-bulkbar .bulk-clear { margin-left: auto; }
.automation-table td small { display: block; color: var(--muted); font-size: 11.5px; }
.automation-table .is-off-company { color: var(--muted); }
.automation-contact { max-width: 300px; overflow-wrap: anywhere; }
.automation-contact div + div { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
@media (max-width: 1000px) { .automation-section-body { grid-template-columns: 1fr; gap: 18px; } }
@media (max-width: 767px) {
  .automation-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .automation-tile { padding: 12px 13px; gap: 6px; }
  .automation-tile-head { font-size: 13px; }
  .automation-tile-count { font-size: 22px; }
  .automation-tile-count.is-text { font-size: 15px; }
  .automation-section-head { flex-wrap: wrap; padding: 16px; }
  .automation-demo-btn { width: 100%; justify-content: center; }
  .automation-section-body, .automation-companies { padding: 16px; }
  .automation-savebar { bottom: 8px; }
}

/* The automation demo: what would go out, before anything does. */
.auto-demo-modal { width: min(880px, 100%); }
.auto-demo-body { display: grid; gap: 14px; margin-bottom: 14px; }
.auto-demo-facts { display: grid; margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.auto-demo-facts > div { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.auto-demo-facts > div:last-child { border-bottom: 0; }
.auto-demo-facts dt { color: var(--muted); }
.auto-demo-facts dd { margin: 0; color: var(--text); font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.auto-demo-mail { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.auto-demo-mail-head { display: grid; gap: 4px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.auto-demo-mail-head span { color: var(--muted); }
.auto-demo-mail-body { padding: 14px 18px 16px; background: #fff; color: #222; font-size: 14px; white-space: pre-line; }
.auto-demo-mail-body .compose-signature-inline { white-space: normal; }
.auto-demo-mail-body table { width: auto; min-width: 0; border-collapse: collapse; }
.auto-demo-mail-body td { padding: 0; border: 0; color: inherit; font-size: inherit; text-align: left; }
.auto-demo-invoice { margin: 0; }
.auto-demo-phone { justify-self: center; width: min(360px, 100%); padding: 18px 16px 22px; border: 1px solid var(--line); border-radius: 26px; background: var(--panel-muted); }
.auto-demo-phone-to { margin-bottom: 10px; color: var(--muted); font-size: 12px; text-align: center; }
.auto-demo-bubble { padding: 11px 14px; border-radius: 16px 16px 16px 4px; background: var(--panel-elevated); color: var(--text); font-size: 14px; line-height: 1.5; box-shadow: var(--shadow-xs); white-space: pre-line; overflow-wrap: anywhere; }
.auto-demo-phone-meta { margin-top: 8px; color: var(--muted); font-size: 12px; text-align: center; }
.auto-demo-send { display: grid; gap: 6px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.auto-demo-send label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.auto-demo-send-row { display: flex; gap: 8px; flex-wrap: wrap; }
.auto-demo-send-row input { flex: 1 1 220px; min-height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel-muted); color: var(--text); font: inherit; }

/* The invoices page: filters in one row, delivery state beside payment. */
.billing-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.billing-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.billing-search { flex: 1 1 260px; max-width: 420px; }
.billing-toolbar select, .billing-month input { min-height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel); color: var(--text); font: inherit; font-size: 13.5px; }
.billing-month { display: flex; align-items: center; gap: 8px; }
/* Settings -> data: backups. */
.backup-body { display: grid; gap: 22px; }
.backup-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.backup-facts > div { display: grid; gap: 3px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-muted); }
.backup-facts span { color: var(--muted); font-size: 12px; }
.backup-facts b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.backup-facts small { color: var(--muted); font-size: 12px; }
.backup-facts .is-warn b { color: var(--red); }
.backup-block { display: grid; gap: 8px; }
.backup-block h4 { margin: 0; color: var(--text); font-size: 14px; font-weight: 650; }
.backup-block .field-hint { margin: 0; max-width: 80ch; }
.backup-email-row { display: flex; flex-wrap: wrap; gap: 8px; }
.backup-email-row input { flex: 1 1 260px; min-width: 0; min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel-muted); color: var(--text); font: inherit; }
.backup-table { width: 100%; }
.backup-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.backup-table td:last-child { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 767px) { .backup-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* The SMS page and its composer. */
#smsTable td:nth-child(4) { max-width: 520px; white-space: normal; line-height: 1.5; overflow-wrap: anywhere; }
#smsTable td small { display: block; color: var(--muted); font-size: 12px; }
.sms-bulk-modal { width: min(1080px, calc(100vw - 36px)); }
.sms-bulk-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.sms-bulk-recipients, .sms-bulk-compose { display: grid; gap: 10px; align-content: start; min-width: 0; }
.sms-bulk-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sms-bulk-count { margin-left: auto; color: var(--text-2); font-size: 13px; font-weight: 650; }
.sms-bulk-list { display: grid; gap: 4px; max-height: min(52vh, 460px); overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-muted); }
.sms-bulk-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; background: var(--panel); cursor: pointer; }
.sms-bulk-item b { display: block; overflow: hidden; font-size: 13.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.sms-bulk-item small { display: block; color: var(--muted); font-size: 12px; }
.sms-bulk-item .money { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.sms-bulk-item .money.is-zero { color: var(--muted); font-weight: 500; }
.sms-bulk-item.is-off { opacity: .55; cursor: default; }
.sms-bulk-item input { accent-color: var(--primary); width: 16px; height: 16px; }
.sms-bulk-preview { display: grid; gap: 6px; }
.sms-bulk-preview .auto-demo-bubble { min-height: 60px; white-space: pre-wrap; }
@media (max-width: 899px) {
  .sms-bulk-body { grid-template-columns: 1fr; }
  #smsTable tbody td:nth-child(4) { grid-column: 1 / -1; }
}
#billingInvoicesTable td small { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
#billingInvoicesTable .invoice-no { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
#billingInvoicesTable tr.is-cancelled .invoice-no, #billingInvoicesTable tr.is-cancelled .money { color: var(--muted); text-decoration: line-through; }
.delivery-failed { color: var(--red); font-weight: 600; }
@media (max-width: 1023px) { #billingInvoicesBody td:nth-child(2) { grid-column: 1 / -1; order: -1; } #billingInvoicesBody td:nth-child(2)::before { display: none; } }

/* "New invoice": pick the company, then the usual invoice window opens. */
.billing-pick-modal { width: min(560px, 100%); }
.billing-pick-search { margin-bottom: 12px; }
.billing-pick-list { display: grid; gap: 6px; max-height: min(56vh, 520px); overflow-y: auto; padding: 2px; }
.billing-pick-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color .14s var(--ease), background .14s var(--ease); }
.billing-pick-item:hover, .billing-pick-item:focus-visible { border-color: var(--primary-line); background: var(--primary-soft); outline: none; }
.billing-pick-item b { display: block; font-size: 14px; font-weight: 650; }
.billing-pick-item small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.billing-pick-item .money { flex: none; font-weight: 650; font-variant-numeric: tabular-nums; }
.billing-pick-item .money.is-zero { color: var(--muted); font-weight: 500; }

/* Picker: the clean invoice first, then companies for a billing invoice. */
.billing-pick-blank { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; border: 1px dashed var(--primary-line); border-radius: 12px; background: var(--primary-soft); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.billing-pick-blank:hover, .billing-pick-blank:focus-visible { border-style: solid; outline: none; }
.billing-pick-blank b { display: block; font-size: 14.5px; font-weight: 650; }
.billing-pick-blank small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.billing-pick-none { padding: 10px 4px 4px; color: var(--muted); font-size: 13px; text-align: center; }
.billing-pick-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; color: var(--muted); font-size: 12px; }
.billing-pick-divider::before, .billing-pick-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* The new-invoice window: the invoice itself is the form (built in a shadow
   root by app.js), with a slim panel for the buyer note, VAT and totals. */
.custom-invoice-side { overflow: hidden; padding: 0; gap: 0; }
.ci-panel { flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 16px; align-content: start; padding: 18px 20px; }
.ci-panel-block { display: grid; gap: 8px; }
.ci-panel-block h4 { margin: 0; color: var(--text); font-size: 13px; font-weight: 650; }
.ci-panel .buyer-linked, .ci-panel .field-hint, .ci-panel .field { margin: 0; }
.ci-vat-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12.5px; }
.ci-vat-row .vat-chip.yes { background: var(--green); color: var(--panel); }
.ci-vat-row .vat-chip.no { background: var(--muted-2); color: #fff; box-shadow: none; }
.custom-invoice-side .billing-invoice-actions { flex: none; margin-top: 0; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.invoice-editor-sheet { width: 794px; transform-origin: 0 0; background: #fff; }
.buyer-suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; display: grid; gap: 4px; max-height: min(52vh, 420px); overflow-y: auto; margin-top: 4px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--panel-elevated); box-shadow: var(--shadow-md); }
.buyer-option { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.buyer-option > span:first-child { min-width: 0; }
.buyer-option b { display: block; overflow: hidden; font-size: 13.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.buyer-option small { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.buyer-option .money { flex: none; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.buyer-option .money.is-zero { color: var(--muted); font-weight: 500; }
.buyer-suggest-empty { padding: 10px 11px; color: var(--muted); font-size: 12.5px; }
.buyer-option.is-active, .buyer-option:hover { border-color: var(--primary-line); background: var(--primary-soft); }
.buyer-linked { display: flex; align-items: center; gap: 8px; margin: -4px 0 10px; padding: 8px 10px; border-radius: 10px; background: var(--green-bg); color: var(--text-2); font-size: 12.5px; line-height: 1.45; }
.buyer-linked .icon { flex: none; width: 16px; height: 16px; color: var(--green); }
.buyer-linked button { flex: none; margin-left: auto; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer; }
.buyer-linked.is-new { flex-wrap: wrap; background: var(--primary-soft); }
.buyer-linked.is-new .icon { color: var(--primary); }
.buyer-linked.is-known { flex-wrap: wrap; background: var(--amber-bg); }
.buyer-linked.is-known .icon { color: var(--amber); }
.buyer-linked.is-new button, .buyer-linked.is-known button { color: var(--primary); font-weight: 650; text-underline-offset: 3px; }
.modal-backdrop.stacked { z-index: 60; }
.ci-pop { position: fixed; top: 0; left: 0; right: auto; z-index: 3; display: flex; flex-direction: column; gap: 0; margin: 0; padding: 0; overflow: hidden; }
.ci-pop-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 4px; padding: 6px; }
.ci-pop-foot { flex: none; padding: 8px; border-top: 1px solid var(--line); }
.ci-pop-foot .btn { width: 100%; justify-content: center; }
.ci-total { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-variant-numeric: tabular-nums; }
.ci-total > div { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.ci-total > div:first-child b { font-size: 17px; }
.ci-hint { color: var(--muted); font-size: 12.5px; }
.ci-hint.is-warn { color: var(--amber); }
.custom-paid { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.invoice-no-link { padding: 0; border: 0; background: transparent; color: var(--primary); font: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-variant-numeric: tabular-nums; white-space: nowrap; }
.invoice-no-link:hover { color: var(--primary-hover); }
@media (max-width: 899px) {
  .ci-panel { order: 1; overflow: visible; padding: 16px; }
}

/* On/off switch: a checkbox with role="switch" and its state in words. */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); transition: background .16s var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .16s var(--ease); }
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch.is-disabled { cursor: not-allowed; color: var(--muted); }
.switch.is-disabled .switch-track { opacity: .5; }
@media (prefers-reduced-motion: reduce) { .switch-track, .switch-track::after { transition: none; } }

/* Interface language button (KA / RU / EN) */
.lang-menu { position: relative; }
.lang-btn .lang-code { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; }
.lang-pop { width: 200px; }
.lang-pop .lang-code { display: grid; place-items: center; width: 30px; height: 22px; flex: none; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.lang-pop .user-pop-item[aria-checked="true"] b, .lang-pop .user-pop-item[aria-checked="true"] .lang-code { color: var(--primary); border-color: var(--primary-line); }

/* the MikroTik page: a router's own log */
.noc-log { display: grid; max-height: min(62vh, 640px); overflow-y: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 12.5px; }
.noc-log-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.noc-log-row:last-child { border-bottom: 0; }
.noc-log-row time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.noc-log-row time small { opacity: .7; }
.noc-log-msg { color: var(--text); overflow-wrap: anywhere; }
.noc-log-msg b { font-weight: 650; }
.noc-log-topics { color: var(--muted-2, var(--muted)); font-size: 11px; white-space: nowrap; }
.noc-log-row.is-warning { background: var(--amber-bg); }
.noc-log-row.is-warning .noc-log-msg b { color: var(--amber); }
.noc-log-row.is-error, .noc-log-row.is-critical { background: var(--red-bg); }
.noc-log-row.is-error .noc-log-msg b, .noc-log-row.is-critical .noc-log-msg b { color: var(--red); }
.noc-log-row.is-debug .noc-log-msg { color: var(--muted); }
.noc-log-more { margin-top: 10px; }
@media (max-width: 720px) { .noc-log-row { grid-template-columns: 78px minmax(0, 1fr); } .noc-log-topics { display: none; } }

/* the invoice changed before it is issued: months in advance, debt left off, lines of one's own */
.bi-editor { display: grid; gap: 10px; margin-bottom: 14px; }
.bi-editor-toggle { width: 100%; justify-content: center; }
.bi-editor-toggle[aria-expanded="true"] { border-color: var(--primary); color: var(--primary); }
.bi-editor-body { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.bi-ahead { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bi-ahead label { font-weight: 600; }
.bi-ahead input { width: 64px; min-height: 34px; padding: 4px 8px; text-align: center; }
.bi-ahead .btn { margin-left: auto; }
.bi-lines { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.bi-line { display: grid; grid-template-columns: minmax(0, 1fr) auto 26px; align-items: center; gap: 6px 8px; padding: 6px 6px 6px 10px; border-radius: 8px; background: var(--panel-muted); font-size: 12.5px; }
.bi-what { display: grid; min-width: 0; line-height: 1.3; }
.bi-what small { color: var(--muted); font-size: 11px; }
.bi-line.is-ahead .bi-what small { color: var(--primary); font-weight: 600; }
.bi-line b { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.bi-line.is-extra { grid-template-columns: minmax(0, 1fr) auto 26px; grid-template-areas: "name name name" "amt vat x"; }
.bi-line.is-extra .bi-name { grid-area: name; width: 100%; }
.bi-line.is-extra .bi-amt { grid-area: amt; }
.bi-line.is-extra .bi-vat { grid-area: vat; }
.bi-line.is-extra .bi-x { grid-area: x; }
.bi-line.is-off { opacity: .55; } .bi-line.is-off b, .bi-line.is-off .bi-amt { text-decoration: line-through; }
.bi-line.is-ahead { background: color-mix(in srgb, var(--primary) 8%, var(--panel)); }
.bi-line.is-empty { display: block; color: var(--muted); }
.bi-amt { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bi-amt input { width: 78px; min-height: 30px; padding: 3px 6px; text-align: right; }
.bi-name { box-sizing: border-box; min-height: 30px; padding: 3px 8px; }
.bi-vat { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.bi-x { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.bi-x:hover { background: var(--panel); color: var(--red, #d1332f); }
.bi-x:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.bi-x-gap { width: 26px; }
.bi-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bi-editor-note { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.billing-invoice-note.bi-edited { color: var(--primary); font-weight: 600; }

/* ---- The dashboard's figures open what they add up (a page, or the month's charges) ---- */
button.kpi-card { width: 100%; font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.kpi-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button.kpi-card:active { transform: translateY(0); }
.kpi-card .kpi-text { display: block; min-width: 0; }
.kpi-card[hidden] { display: none !important; }
/* the TBC account (the owner's, or whoever is given it): a bank blue of its own */
.kpi-card.tbc::before { background: #009fdf; }
.tbc .kpi-icon { background: color-mix(in srgb, #009fdf 14%, var(--panel)); color: #0089c2; }
[data-theme="dark"] .tbc .kpi-icon { color: #5cc8f2; }
.kpi-card.tbc.is-stale strong { color: var(--muted); }
/* eight figures (with the TBC card): one row on a wide screen, 4 + 4 on a medium one, pairs on a phone */
#view-dashboard .kpi-grid.has-bank { grid-template-columns: repeat(8, minmax(0, 1fr)); }
@container dash (max-width: 1400px) {
  #view-dashboard .kpi-grid.has-bank { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #view-dashboard .kpi-grid.has-bank .kpi-card { grid-column: auto; }
}
@container dash (max-width: 700px) {
  #view-dashboard .kpi-grid.has-bank { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-dashboard .kpi-grid.has-bank .kpi-card:last-child { grid-column: auto; }
}
/* a list page's filters: the search, then the chips, the month and the count */
.list-filters { flex-wrap: wrap; }
.list-filters .toolbar-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.month-pick { display: flex; align-items: center; gap: 6px; }
.month-pick input { min-height: 36px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-muted); color: var(--text); padding: 4px 8px; font: inherit; font-size: 13px; }
.list-total { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.list-total b { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .list-filters .search-box { width: 100%; } }
/* the month's charges, company by company */
#billedModal .modal-body { display: grid; gap: 12px; }
#billedModal .billed-search { width: 100%; }
#billedModal .billed-list { max-height: min(60vh, 640px); overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
#billedModal .billed-list table { min-width: 0; }
#billedModal td.money, #billedModal th:nth-child(n+2):nth-child(-n+4) { text-align: right; }
.billed-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 18px; color: var(--muted); font-size: 13px; }
.billed-foot b { color: var(--text); font-variant-numeric: tabular-nums; }
/* the archive window: like the month's charges */
#archiveModal .modal-body { display: grid; gap: 12px; }
#archiveModal .billed-list { max-height: min(60vh, 640px); overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
#archiveModal .billed-list table { min-width: 0; }
