/* Shaheen Network Billing — Design System
   Approved palette only. No colors outside these tokens. */

:root {
  --primary: #4A5FE8;
  --primary-hover: #3D50D4;
  --primary-dark: #12163A;
  --secondary-cyan: #0EA5B7;
  --accent-orange: #F5A524;
  --success: #16A34A;
  --warning: #F59E0B;
  --danger: #DC2626;
  --info: #0EA5E9;
  --bg: #F6F7FC;
  /* Phone-only page colour. Deliberately a few shades deeper than
     --bg: on a phone the list rows ARE the cards, and a white card on
     an almost-white page has nothing to stand on. This indigo-tinted
     grey is pulled from --primary so the lift reads as brand, not dirt.
     Desktop keeps --bg; only the <=760px rule below uses this. */
  --page-bg-mobile: #E6E9F7;
  --card: #FFFFFF;
  --text: #14162B;
  --text-secondary: #6B7085;
  --border: #E7E8F2;
  --hover-bg: #F9FAFE;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20,22,55,0.04), 0 6px 16px rgba(20,22,55,0.06);
  --shadow-lg: 0 12px 32px rgba(20,22,55,0.14);
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

/* Dark mode — same token NAMES, different values, so every component
   below (which all already read var(--bg)/var(--card)/var(--text)/etc,
   never hardcoded light-mode hex) re-themes automatically. Status/accent
   colors are lightened slightly versus their light-mode values, since
   the light-mode shades are tuned for contrast against a WHITE card,
   not a dark one — used as-is here, several would fail contrast. */
[data-theme="dark"] {
  --primary: #7C8CFF;
  --primary-hover: #96A3FF;
  --primary-dark: #12163A;
  --secondary-cyan: #2DD4E0;
  --accent-orange: #FBBF5A;
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;
  --info: #38BDF8;
  --bg: #0C0E22;
  /* Dark mode inverts the relationship — the card is LIGHTER than the
     page — so the phone background goes deeper, not lighter, to open
     the same gap between card and page. */
  --page-bg-mobile: #06081A;
  --card: #171A38;
  --text: #F3F4FC;
  --text-secondary: #B0B4D6;
  --border: #2C2F58;
  --hover-bg: #1E2148;

  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 6px 18px rgba(0,0,0,0.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.5);
}

/* Sunlight mode — a third theme, for a technician collecting payments
   outdoors at midday. The problem it solves is not "light vs dark":
   in direct sun the screen's own brightness is swamped by reflected
   glare, which lifts the blacks and crushes anything subtle. Mid-tone
   greys and pastel badge fills — perfectly readable indoors — simply
   disappear. So every value here is picked for measured contrast on
   white, not for looks:

     text            #000000   21.0:1
     text-secondary  #1C1F2E   16.3:1
     primary         #0A2FBF    9.7:1
     success         #035C27    8.2:1
     info            #04557A    8.1:1
     accent-orange   #7F4500    7.6:1
     warning         #7A4A00    7.5:1
     danger          #B3000F    7.2:1

   For comparison, the normal light theme's badge colours measure
   3.3:1 (success) and 2.2:1 (warning) on white — that is the exact
   text a technician has to read to tell Paid from Unpaid in the sun.
   Every colour above clears 7:1, the WCAG AAA body-text bar.

   Structural overrides follow the tokens: borders go black and 2px,
   decoration is removed (gradients and shadows only add glare and
   cost contrast), weights go up, and tap targets grow for gloved or
   hurried thumbs. */
[data-theme="sunlight"] {
  --primary: #0A2FBF;
  --primary-hover: #082498;
  --primary-dark: #061A6B;
  --secondary-cyan: #04555F;
  --accent-orange: #7F4500;
  --success: #035C27;
  --warning: #7A4A00;
  --danger: #B3000F;
  --info: #04557A;
  --bg: #FFFFFF;
  --page-bg-mobile: #FFFFFF;
  --card: #FFFFFF;
  --text: #000000;
  --text-secondary: #1C1F2E;
  --border: #000000;
  --hover-bg: #E4EAFF;

  /* Shadows are glare in disguise — a soft grey edge on a washed-out
     screen reads as smudge, not depth. Borders do the separating. */
  --shadow: none;
  --shadow-lg: none;
}

/* Flat white page — no dot grid, no corner glows, no decorative SVGs.
   Each of those sits UNDER content and steals local contrast. */
[data-theme="sunlight"] body {
  background: #FFFFFF;
  font-weight: 500;
}
[data-theme="sunlight"] .body-decor-map,
[data-theme="sunlight"] .topbar-decor-waves { display: none; }
[data-theme="sunlight"] .app-topbar {
  background: #FFFFFF;
  border-bottom: 2px solid #000000;
}

/* Hard black edges instead of soft grey ones. */
[data-theme="sunlight"] .card,
[data-theme="sunlight"] .stat-card,
[data-theme="sunlight"] input,
[data-theme="sunlight"] select,
[data-theme="sunlight"] textarea {
  border: 2px solid #000000;
}
[data-theme="sunlight"] th { border-bottom: 2px solid #000000; color: #000000; font-weight: 800; }
[data-theme="sunlight"] td { border-bottom: 2px solid #000000; }

/* Labels and "muted" text stop being muted — in sun, grey is invisible. */
[data-theme="sunlight"] .text-muted,
[data-theme="sunlight"] td::before,
[data-theme="sunlight"] .stat-card .label,
[data-theme="sunlight"] .empty-state { color: #1C1F2E; font-weight: 700; }
[data-theme="sunlight"] .stat-card .value { color: #000000; }

/* Badges carry the single most important fact on a collection round —
   Paid or Unpaid. A pale tint with matching text is the first thing
   to wash out, so here they invert: solid dark fill, white text. That
   is legible at arm's length in full sun, and tells the two apart by
   block colour before any word is read. */
[data-theme="sunlight"] .badge {
  color: #FFFFFF;
  font-weight: 800;
  padding: 5px 12px;
  border: 2px solid transparent;
}
[data-theme="sunlight"] .badge-active,
[data-theme="sunlight"] .badge-paid,
[data-theme="sunlight"] .badge-completed { background: var(--success); }
[data-theme="sunlight"] .badge-suspended,
[data-theme="sunlight"] .badge-pending,
[data-theme="sunlight"] .badge-due_soon { background: var(--warning); }
[data-theme="sunlight"] .badge-permanently_disconnected,
[data-theme="sunlight"] .badge-overdue,
[data-theme="sunlight"] .badge-danger { background: var(--danger); }
[data-theme="sunlight"] .badge-temporarily_disconnected,
[data-theme="sunlight"] .badge-inactive,
[data-theme="sunlight"] .badge-cancelled { background: #2B2F42; }
[data-theme="sunlight"] .badge-info,
[data-theme="sunlight"] .badge-upcoming,
[data-theme="sunlight"] .badge-partially_paid { background: var(--info); }

/* Same inversion for flash messages. */
[data-theme="sunlight"] .flash { color: #FFFFFF; font-weight: 700; border: 2px solid #000000; }
[data-theme="sunlight"] .flash-success { background: var(--success); }
[data-theme="sunlight"] .flash-error { background: var(--danger); }
[data-theme="sunlight"] .flash-info { background: var(--warning); }

/* Buttons: bigger targets, heavier type, hard edges. A technician is
   tapping these one-handed, standing, often in a hurry. */
[data-theme="sunlight"] .btn {
  font-weight: 800;
  border: 2px solid #000000;
  padding: 11px 18px;
}
[data-theme="sunlight"] .btn-sm { padding: 8px 14px; font-size: 14px; }
[data-theme="sunlight"] .btn-secondary { background: #FFFFFF; color: #000000; }

/* Links must not rely on hue alone once glare flattens colour. */
[data-theme="sunlight"] a { font-weight: 700; }
[data-theme="sunlight"] .app-content a:not(.btn):not(.sidebar-link):not(.sidebar-sublink):not(.stat-card) {
  text-decoration: underline;
}

@media (max-width: 560px) {
  /* The mobile row-cards need the same black edge, and a little more
     room — this is the screen the collection round actually runs on. */
  [data-theme="sunlight"] tr {
    border: 2px solid #000000;
    padding: 16px;
  }
  [data-theme="sunlight"] td { border-bottom: none; }
  [data-theme="sunlight"] body { font-size: 16px; }
  /* Needed explicitly: the sunlight rule `[data-theme="sunlight"] .card`
     scores (0,2,0) and so beats the plain `.card:has(table)` (0,1,1)
     that strips the wrapper on mobile — which put the black border
     back on and drew a second box around the row cards. Restating it
     here at (0,2,1) settles the cascade in the right direction. */
  [data-theme="sunlight"] .card:has(table) {
    border: none;
    background: transparent;
    padding: 0;
  }
}

* { box-sizing: border-box; }

/* Kills the default blue/grey flash Android's WebView (and the
   Play-Store TWA app built from this site) shows on every tap of a
   link, button or card — the "blue splash" on touch. A native app
   doesn't flash on tap, so none of this app's own UI should either.
   Same approach already used on the Learn Flow / Teach Flow PWAs for
   this same "feel native" request. */
html {
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}
* {
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}
/* Only interactive chrome (nav, buttons, topbar) — deliberately NOT
   body/table/card globally, so a long-press on an invoice number,
   connection ID or amount can still be copied as normal, both on
   desktop and on a phone. */
a, button, .btn, .btn-secondary, .sidebar-link, .sidebar-sublink,
.topbar-avatar-btn, .chevron, .sidebar-areas summary {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1px 1px at center, rgba(74,95,232,0.10) 1px, transparent 1.6px) 0 0/26px 26px,
    radial-gradient(900px 460px at 100% 0%, rgba(74,95,232,0.10), transparent 55%),
    radial-gradient(700px 420px at 0% 100%, rgba(14,165,183,0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.25s ease, color 0.25s ease;
  /* Safety net: nothing on this site should ever need horizontal
     page scroll — a stray wide element (e.g. the topbar's pill row on
     a narrow phone) should clip/shrink instead of dragging the whole
     page sideways and hiding controls like the hamburger off-screen. */
  overflow-x: hidden;
}
/* Smooth theme-toggle transition — scoped to surfaces that actually
   change color on toggle, not a blanket "body *" (which would fight
   with components that already define their own transition, like
   .stat-card's hover lift, and adds needless cost on large tables). */
body, .card, .stat-card, .sidebar, .app-topbar, table, th, td,
input, select, textarea, .btn-secondary, .badge, .flash,
.report-card, .neu-card {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.body-decor-map {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 260px;
  height: 180px;
  max-width: 24vw;
  opacity: 0.6;
  pointer-events: none;
  z-index: -1;
}

@media (max-width: 760px) {
  .body-decor-map { display: none; }

  /* Phones get ONE flat background colour — no dot grid, no corner
     glows. At desktop size those sit far behind wide content and read
     as texture; on a narrow screen they crowd right up against every
     card edge and the 26px dots start reading as a see-through /
     misaligned surface instead of decoration. */
  body { background: var(--page-bg-mobile); }
}

/* ---------- App Shell ---------- */

#nav-toggle { display: none; }
.sidebar-overlay { display: none; }

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

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--primary-dark);
  background-image: linear-gradient(165deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 45%, rgba(0,0,0,0.18) 100%);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-decor-globe {
  position: absolute;
  left: -30px;
  bottom: -40px;
  width: 220px;
  height: 220px;
  pointer-events: none;
  opacity: 0.9;
  z-index: -1;
}

.sidebar-brand {
  padding: 20px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar-brand small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  margin-top: 2px;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 500;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  text-decoration: none;
  color: #fff;
}

.sidebar-link.active {
  background: var(--primary);
  color: #fff;
}
.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
}

.sidebar-areas summary {
  cursor: pointer;
  list-style: none;
}
.sidebar-areas summary::-webkit-details-marker { display: none; }

.sidebar-areas[open] summary .chevron { transform: rotate(90deg); }
.chevron { display: inline-block; transition: transform 0.15s; margin-left: auto; }

.sidebar-subnav { padding-left: 12px; }

.sidebar-sublink {
  display: flex;
  justify-content: space-between;
  padding: 9px 20px 9px 34px;
  color: rgba(255,255,255,0.72);
  font-size: 13.5px;
}
.sidebar-sublink:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar-sublink.active { background: rgba(74,95,232,0.35); color: #fff; font-weight: 600; }
.sidebar-sublink .code-pill {
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 13px;
}
.sidebar-footer .role-badge {
  display: inline-block;
  background: var(--secondary-cyan);
  color: #04303a;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: var(--topbar-height);
  background:
    radial-gradient(420px 240px at 90% 45%, rgba(74,95,232,0.22), transparent 72%),
    linear-gradient(120deg, rgba(74,95,232,0.10), rgba(14,165,183,0.07) 55%, transparent 85%),
    var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  position: relative;
  z-index: 1;
}

.topbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--primary-dark);
  border: 1px solid rgba(255,255,255,0.14);
  color: #F2F3FA;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.topbar-pill-link {
  text-decoration: none;
  color: #A9B4FF;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.topbar-pill-link:hover { background: #1A1F52; color: #C7CEFF; text-decoration: none; }

.topbar-profile { position: relative; }
.topbar-avatar-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--hover-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px 4px 4px;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}
.topbar-avatar-name {
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}
.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.topbar-profile-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 20;
}
.topbar-profile-menu.open { display: block; }
.topbar-profile-menu-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.topbar-profile-menu a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
}
.topbar-profile-menu a:hover { background: var(--hover-bg); text-decoration: none; }
.topbar-profile-menu-logout { color: var(--danger) !important; }
.topbar-profile-menu-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.5;
}

@media (max-width: 640px) {
  span.pill-label-full { display: none; }
  .topbar-right { gap: 6px; }
  .topbar-pill { padding: 5px 10px; font-size: 12px; }
  .topbar-avatar-btn { padding: 4px; gap: 0; }
  /* Month/Year is the least essential pill on a phone-width header —
     dropping it (desktop keeps it) is what actually buys back enough
     room for the clock, Tekshyk link, dark-mode toggle, and avatar to
     fit without pushing the hamburger off screen. */
  .topbar-pill-monthyear { display: none; }
  /* The live clock and the Tekshyk link are the next-least essential
     pills at phone width — dropping both (desktop keeps them) is what
     makes room for the Online/Offline badge and the profile avatar to
     both stay visible without crowding out the hamburger on the left. */
  #topbarClock, .topbar-pill-link { display: none; }
}

/* Applied BEFORE the decorative classes below, and explicitly excludes
   them via :not() — otherwise this rule and .topbar-decor-* have equal
   specificity and, whichever came later in the file, would silently
   override their position:absolute back to relative, turning them into
   normal flex items that push/wrap the title and Logout button. */
.app-topbar > :not(.topbar-decor-waves) { position: relative; z-index: 1; }

.topbar-decor-waves { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.55; pointer-events: none; z-index: 0; }

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.hamburger {
  display: inline-flex;
  cursor: pointer;
  font-size: 20px;
  color: var(--text);
  background: none;
  border: none;
  flex-shrink: 0;
}

/* Desktop: the same checkbox/hamburger mechanism used on mobile also
   collapses the sidebar here — width to 0 rather than sliding
   off-screen, since on a wide viewport there's no need for an
   overlay or fixed positioning, just reclaiming the space for
   .app-main. */
@media (min-width: 901px) {
  .sidebar {
    transition: width 0.2s ease, min-width 0.2s ease;
  }
  #nav-toggle:checked ~ .app-shell .sidebar {
    width: 0;
    min-width: 0;
    overflow: hidden;
  }
}

.app-content {
  padding: 24px;
  flex: 1;
}

.app-footer {
  padding: 16px 24px 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  background: var(--card);
}
.app-footer a {
  font-weight: 700;
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
}
.app-footer a:hover { text-decoration: underline; }

/* Customer portal only (account.php, complaint.php — same dark-navy +
   golden-orange "Developed By" treatment as the staff login page's own
   footer, requested to match that look). Scoped to its own class so it
   never touches the plain .app-footer used throughout the staff app. */
.portal-footer-dark {
  background: var(--primary-dark) !important;
  color: rgba(255,255,255,0.55) !important;
  border-top: none !important;
}
.portal-footer-dark a { color: var(--accent-orange) !important; }

.portal-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 2;
}
.portal-footer a {
  pointer-events: auto;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--primary);
  text-decoration: none;
}
.portal-footer a:hover { text-decoration: underline; }
@media (max-width: 560px) {
  .portal-footer { position: static; margin-top: 22px; padding-bottom: 6px; }
}

/* ---------- Components ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.dash-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.dash-chart-grid .card { margin-bottom: 0; }
.chart-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  display: block;
  transition: box-shadow 0.15s, transform 0.15s;
}
.stat-card:hover { box-shadow: 0 4px 14px rgba(23,32,51,0.1); transform: translateY(-1px); }
.stat-card-clickable { text-decoration: none; color: inherit; cursor: pointer; }
.stat-card-clickable:hover { text-decoration: none; color: inherit; border-color: var(--primary); box-shadow: 0 6px 18px rgba(74,95,232,0.14); transform: translateY(-2px); }
.stat-card .label { font-size: 13px; color: var(--text-secondary); font-weight: 600; padding-right: 40px; }
.stat-card .value { font-size: 26px; font-weight: 800; margin-top: 6px; color: var(--primary-dark); }
.stat-card.accent-orange .value { color: var(--accent-orange); }
.stat-card.accent-success .value { color: var(--success); }
.stat-card.accent-danger .value { color: var(--danger); }

.stat-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74,95,232,0.09);
  color: var(--primary);
  flex-shrink: 0;
}
.stat-card.accent-success .stat-icon { background: rgba(22,163,74,0.12); color: var(--success); }
.stat-card.accent-orange .stat-icon { background: rgba(245,165,36,0.12); color: var(--accent-orange); }
.stat-card.accent-danger .stat-icon { background: rgba(220,38,38,0.1); color: var(--danger); }

/* Dark mode only: numbers, their icons, and the box titles all go
   pure bright white for maximum readability against the dark card —
   light mode is completely untouched (stays navy/green/orange/red as
   designed). The colored chip BEHIND each icon stays colored (still
   a nice accent), only the icon glyph itself and the text turn white. */
[data-theme="dark"] .stat-card .label { color: #FFFFFF; }
[data-theme="dark"] .stat-card .value,
[data-theme="dark"] .stat-card.accent-orange .value,
[data-theme="dark"] .stat-card.accent-success .value,
[data-theme="dark"] .stat-card.accent-danger .value { color: #FFFFFF; }
[data-theme="dark"] .stat-icon,
[data-theme="dark"] .stat-card.accent-success .stat-icon,
[data-theme="dark"] .stat-card.accent-orange .stat-icon,
[data-theme="dark"] .stat-card.accent-danger .stat-icon { color: #FFFFFF; }

/* ---------- Icons (inline SVG helper, App\Support\Icons) ---------- */
.icon { flex-shrink: 0; vertical-align: -3px; }
.sidebar-link .icon, .sidebar-areas summary .icon { color: rgba(255,255,255,0.65); }
.sidebar-link.active .icon { color: #fff; }
.sidebar-link:hover .icon { color: #fff; }
.card-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title-row .icon-badge {
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(74,95,232,0.09); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.card-title-row .card-title { margin: 0; }

/* ---------- Reports landing cards ---------- */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.report-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}
.report-card:hover {
  box-shadow: 0 6px 20px rgba(23,32,51,0.12);
  transform: translateY(-2px);
  border-color: var(--primary);
  text-decoration: none;
  color: inherit;
}
.report-card-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: rgba(74,95,232,0.09); color: var(--primary);
}
.report-card.accent-success .report-card-icon { background: rgba(22,163,74,0.12); color: var(--success); }
.report-card.accent-orange .report-card-icon { background: rgba(245,165,36,0.12); color: var(--accent-orange); }
.report-card.accent-info .report-card-icon { background: rgba(14,165,233,0.12); color: var(--info); }
.report-card-body { flex: 1; padding-right: 16px; }
.report-card-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--text); }
.report-card-desc { margin: 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.report-card-arrow {
  position: absolute; top: 22px; right: 20px;
  color: var(--text-secondary);
  transition: transform 0.15s, color 0.15s;
}
.report-card:hover .report-card-arrow { transform: translateX(3px); color: var(--primary); }

.report-header { margin-bottom: 4px; }
.report-back {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
}
.report-back .icon { transform: rotate(180deg); }
.report-back:hover { color: var(--primary); text-decoration: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(74,95,232,0.28), 0 1px 2px rgba(74,95,232,0.18);
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.btn:hover { text-decoration: none; background: var(--primary-hover); box-shadow: 0 4px 12px rgba(74,95,232,0.32); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(74,95,232,0.3); }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border); box-shadow: var(--shadow); }
.btn-secondary:hover { background: var(--hover-bg); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 2px 6px rgba(220,38,38,0.28); }
.btn-danger:hover { background: #C41F1F; box-shadow: 0 4px 12px rgba(220,38,38,0.32); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

input[type=text], input[type=tel], input[type=number], input[type=date], input[type=password],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74,95,232,0.15);
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 12px; color: var(--text-secondary); font-weight: 600; font-size: 12.5px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
/* Row hover is for real pointers only. On a touch screen :hover STICKS
   to whatever you last tapped — the row keeps the highlight long after
   your finger is gone, so one row in the list looks selected/different
   when nothing is selected at all. @media (hover: hover) tells phones
   and tablets to skip this rule entirely. */
@media (hover: hover) and (pointer: fine) {
  tr:hover td { background: var(--hover-bg); }
}

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-active, .badge-paid, .badge-completed { background: rgba(22,163,74,0.12); color: var(--success); }
.badge-suspended, .badge-pending, .badge-due_soon { background: rgba(245,158,11,0.14); color: var(--warning); }
.badge-permanently_disconnected, .badge-overdue, .badge-danger { background: rgba(220,38,38,0.1); color: var(--danger); }
.badge-temporarily_disconnected, .badge-inactive, .badge-cancelled { background: rgba(100,116,139,0.14); color: var(--text-secondary); }
.badge-info, .badge-upcoming, .badge-partially_paid { background: rgba(14,165,233,0.12); color: var(--info); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { text-decoration: none; color: var(--primary); }

.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.flash-success { background: rgba(22,163,74,0.1); color: var(--success); border: 1px solid rgba(22,163,74,0.25); }
.flash-error { background: rgba(220,38,38,0.08); color: var(--danger); border: 1px solid rgba(220,38,38,0.22); }
.flash-info { background: rgba(245,158,11,0.1); color: var(--warning); border: 1px solid rgba(245,158,11,0.28); }
[data-theme="dark"] .flash-info { background: rgba(251,191,36,0.14); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.empty-state .icon { font-size: 32px; margin-bottom: 8px; }

.search-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search-bar input[type=text] { max-width: 320px; }
.search-bar select { max-width: 200px; }

.login-wrap {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--primary-dark);
  background-image: linear-gradient(165deg, rgba(255,255,255,0.04) 0%, rgba(0,0,0,0.2) 45%, rgba(0,0,0,0.55) 100%);
  padding: 40px 20px;
}
.login-bg-net {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

.login-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 860px;
  display: flex;
  border-radius: 28px;
  box-shadow: 0 30px 60px rgba(4,18,31,0.45);
}
.login-hero { border-radius: 28px 0 0 28px; }
.login-form-col { border-radius: 0 28px 28px 0; }
@media (max-width: 760px) {
  .login-shell { flex-direction: column; max-width: 440px; }
  .login-hero { border-radius: 28px 28px 0 0; }
  .login-form-col { border-radius: 0 0 28px 28px; }
}

.login-hero {
  flex: 1;
  min-width: 0;
  position: relative;
  background: var(--primary-dark);
  background-image: linear-gradient(160deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.22) 55%, rgba(0,0,0,0.5) 100%);
  padding: 44px 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
}
.login-hero-brand { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.login-hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.4px;
  color: #FFB067;
  background: rgba(245,165,36,0.14);
  border: 1px solid rgba(245,165,36,0.32);
  padding: 6px 14px; border-radius: 100px;
  margin: 0 0 18px;
}
.login-hero-eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-orange); box-shadow: 0 0 0 3px rgba(245,165,36,0.25); }
.login-hero-h1 { font-size: 25px; font-weight: 700; margin: 0 0 10px; line-height: 1.2; }
.login-hero-h1 em { font-style: normal; color: var(--accent-orange); }
.login-hero-lede { font-size: 14px; color: rgba(255,255,255,0.75); line-height: 1.6; margin: 0 0 22px; max-width: 300px; }
.login-trust-row { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.login-trust-item { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 600; color: rgba(255,255,255,0.85); }
.login-trust-item .ic-circle {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.login-form-col {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  padding: 28px 32px 36px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
@media (max-width: 760px) {
  .login-hero { padding: 34px 28px 30px; }
  .login-form-col { padding: 24px 22px 32px; }
}

/* ---------- Embossed (neumorphic) card — same background tone as the
   panel it sits on, "raised" purely via a light/dark shadow pair. ---------- */
.neu-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border-radius: 20px;
  padding: 34px 30px;
  box-shadow: 9px 9px 20px rgba(18,22,58,0.14), -9px -9px 20px rgba(255,255,255,0.9);
}
.neu-card h1 { font-size: 19px; margin: 0 0 4px; color: var(--text); }
.neu-card p.sub { color: var(--text-secondary); font-size: 13.5px; margin: 0 0 22px; }
.neu-card .form-group { margin-bottom: 18px; }
.neu-card input[type=text], .neu-card input[type=password] {
  background: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 13px 14px;
  box-shadow: inset 5px 5px 10px rgba(18,22,58,0.09), inset -5px -5px 10px rgba(255,255,255,0.8);
}
.neu-card input[type=text]:focus, .neu-card input[type=password]:focus {
  box-shadow: inset 4px 4px 8px rgba(18,22,58,0.12), inset -4px -4px 8px rgba(255,255,255,0.75), 0 0 0 3px rgba(74,95,232,0.15);
}
.neu-password-wrap { position: relative; }
.neu-password-wrap input { padding-right: 42px; width: 100%; }
.neu-password-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 9px; border: none;
  background: var(--bg); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 3px 3px 6px rgba(18,22,58,0.1), -3px -3px 6px rgba(255,255,255,0.8);
}
.neu-card .btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  border-radius: 12px;
  box-shadow: 5px 5px 12px rgba(74,95,232,0.3), -3px -3px 8px rgba(255,255,255,0.5);
}
.neu-card .btn:active { box-shadow: inset 3px 3px 7px rgba(18,22,58,0.35); }
.btn-block { width: 100%; justify-content: center; }

.login-footer { position: relative; z-index: 1; color: rgba(255,255,255,0.45); font-size: 12.5px; margin-top: 24px; text-align: center; line-height: 1.7; }
.login-footer-brand { color: var(--accent-orange); font-weight: 700; font-size: 13px; text-decoration: none; }
.login-footer-brand:hover { text-decoration: underline; }

.field-error { color: var(--danger); font-size: 12.5px; margin-top: 4px; }

.text-muted { color: var(--text-secondary); }
.mb-0 { margin-bottom: 0; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    z-index: 20;
    width: 280px;
    height: 100vh;
    height: 100dvh; /* iOS/Android address-bar-safe viewport height — falls back to 100vh where unsupported */
    overflow-y: auto;
    overscroll-behavior: contain; /* stops the elastic scroll-bounce from revealing the page behind it */
    -webkit-overflow-scrolling: touch;
    transition: left 0.2s ease;
    box-shadow: 0 0 0 100vmax rgba(18,22,58,0);
  }
  #nav-toggle:checked ~ .app-shell .sidebar {
    left: 0;
    box-shadow: 0 0 0 100vmax rgba(18,22,58,0.45);
  }
  /* Invisible click-catcher over the rest of the screen while the
     sidebar is open on mobile — tapping anywhere outside the sidebar
     closes it. It's a <label for="nav-toggle">, so a tap toggles the
     same checkbox the hamburger does; no JS needed. */
  .sidebar-overlay { display: none; }
  #nav-toggle:checked ~ .app-shell .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    cursor: pointer;
  }
  .hamburger { display: inline-flex; }
  .app-content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .topbar-decor-waves { display: none; }
  .app-topbar { padding: 0 12px; }
  .topbar-title { font-size: 16px; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .search-bar input[type=text], .search-bar select { max-width: none; width: 100%; }
  .history-back-btn { display: flex; width: 100%; justify-content: flex-start; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }

  /* Bill History is a dense, 3-narrow-column receipt table — the
     generic "stack every table into unlabeled cards" rule above makes
     it an unreadable wall of unlabeled numbers on a phone. Keep it as
     a real, compact table with its header row, same as on desktop,
     one column wide on very narrow screens for room to read. */
  .inv2-bill-history-table { display: table; width: 100%; }
  .inv2-bill-history-table thead { display: table-header-group; }
  .inv2-bill-history-table tbody { display: table-row-group; }
  .inv2-bill-history-table tr { display: table-row; }
  .inv2-bill-history-table th, .inv2-bill-history-table td { display: table-cell; }
  .inv2-bill-history-table td::before { content: none; }
  .inv2-bill-history-cols { grid-template-columns: 1fr; }
  .inv2-bill-history-cols table + table { border-left: none; border-top: 1px solid var(--border); }
  /* On a phone the ROW is the card. A bare bottom-border row has no
     surface of its own, so it reads as text floating on the page —
     and where one row happened to be tinted (the old sticky :hover)
     and the next was not, the whole list looked half-transparent.
     Opaque fill + border + radius + real shadow gives every row the
     same solid card, lifted off the tinted page behind it.

     The border is NOT var(--border) (#E7E8F2): that measures 1.22:1
     against a white card, i.e. invisible, so two stacked cards ran
     together into one block. #8892C4 measures 3.02:1, clearing the
     WCAG non-text contrast bar, so each card has a real edge.
     Deliberately a colour of its own rather than a global token
     change — everything here is scoped to phones so the desktop
     table is untouched. */
  tr {
    background: var(--card);
    border: 1px solid #8892C4;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
  }
  [data-theme="dark"] tr { border-color: #646DB4; }   /* 3.54:1 on the dark card */
  tr:last-child { margin-bottom: 0; }
  td { border: none; padding: 4px 0; background: transparent; }
  /* Drop the wrapper card's own chrome when it only holds a table —
     otherwise every row is a white card sitting inside a second white
     card, which flattens both and double-insets the content. Stripped
     back, the rows sit straight on the page colour and read as cards.
     Scoped with :has() so form/text cards keep their normal look; an
     old WebView without :has() support simply ignores this one rule
     and still renders a correct (just slightly nested) list. */
  .card:has(table) {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  /* Badge chips, phone only. The pale-tint-plus-pale-text badges are
     the weakest thing on the screen — measured on their own fill they
     come out at 2.96:1 (Active/Paid), 1.95:1 (Suspended/Due Soon) and
     2.46:1 (Partially Paid). The green was the one that looked wrong,
     but the amber is worse, so all five are rebuilt the same way
     rather than leaving one dark chip sitting next to four faded
     ones. Each keeps its meaning-colour — green is still green — but
     goes to a deep shade of it on a slightly stronger tint, with a
     matching border so the chip has a defined edge:

       Active / Paid        7.06:1   (was 2.96)
       Suspended / Due Soon 7.45:1   (was 1.95)
       Overdue / Unpaid     6.40:1   (was 4.12)
       Partially Paid       6.71:1   (was 2.46)
       Inactive            10.81:1

     Scoped to <=560px on purpose: the desktop badges are unchanged. */
  .badge { border: 1px solid transparent; font-weight: 700; }
  .badge-active, .badge-paid, .badge-completed {
    background: #DFF3E5; color: #035C27; border-color: #035C27;
  }
  .badge-suspended, .badge-pending, .badge-due_soon {
    background: #FBEDD6; color: #6E4200; border-color: #6E4200;
  }
  .badge-permanently_disconnected, .badge-overdue, .badge-danger {
    background: #FBE2E4; color: #A8000E; border-color: #A8000E;
  }
  .badge-temporarily_disconnected, .badge-inactive, .badge-cancelled {
    background: #E6E8F0; color: #2B2F42; border-color: #2B2F42;
  }
  .badge-info, .badge-upcoming, .badge-partially_paid {
    background: #DBECF7; color: #04557A; border-color: #04557A;
  }
  /* Dark mode already has light-on-dark badges with usable contrast —
     it only needs the same defined edge, not a new palette. */
  [data-theme="dark"] .badge { border-color: currentColor; }
  [data-theme="dark"] .badge-active,
  [data-theme="dark"] .badge-paid,
  [data-theme="dark"] .badge-completed { background: rgba(52,211,153,0.16); color: #6EE7A0; }
  [data-theme="dark"] .badge-suspended,
  [data-theme="dark"] .badge-pending,
  [data-theme="dark"] .badge-due_soon { background: rgba(251,191,36,0.16); color: #FBBF24; }
  [data-theme="dark"] .badge-permanently_disconnected,
  [data-theme="dark"] .badge-overdue,
  [data-theme="dark"] .badge-danger { background: rgba(248,113,113,0.16); color: #F87171; }
  [data-theme="dark"] .badge-info,
  [data-theme="dark"] .badge-upcoming,
  [data-theme="dark"] .badge-partially_paid { background: rgba(56,189,248,0.16); color: #38BDF8; }

  /* Flash messages carry the same washed-out green/amber as the
     badges did ("Payment saved", "Bill generated") — same fix, same
     phone-only scope, so a confirmation is actually readable. */
  .flash { border-width: 1px; font-weight: 600; }
  .flash-success { background: #DFF3E5; color: #035C27; border-color: #035C27; }
  .flash-error   { background: #FBE2E4; color: #A8000E; border-color: #A8000E; }
  .flash-info    { background: #FBEDD6; color: #6E4200; border-color: #6E4200; }
  [data-theme="dark"] .flash-success { background: rgba(52,211,153,0.14); color: #6EE7A0; border-color: #6EE7A0; }
  [data-theme="dark"] .flash-error   { background: rgba(248,113,113,0.14); color: #F87171; border-color: #F87171; }
  [data-theme="dark"] .flash-info    { background: rgba(251,191,36,0.14);  color: #FBBF24; border-color: #FBBF24; }

  td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--text-secondary); font-weight: 700; text-transform: uppercase; }
  .app-footer { padding: 14px 16px 18px; font-size: 11.5px; }
}

/* ---------- Print (admin pages) ---------- */

@media print {
  .no-print, .sidebar, .app-topbar, .app-footer, .hamburger { display: none !important; }
  .app-content { padding: 0 !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* ---------- Public Invoice ---------- */

.public-invoice-body {
  background: var(--bg);
  min-height: 100vh;
  padding: 24px 16px 60px;
}

/* ---------- Public invoice — custom branded document design ---------- */

.invoice-page {
  max-width: 820px;
  margin: 0 auto;
}

.invoice-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.inv2-paper {
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 16px;
  padding: 34px 38px;
  box-shadow: var(--shadow);
}

.inv2-header {
  display: flex;
  align-items: flex-start;
  gap: 26px;
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--border);
}
.inv2-brand { flex: 1.3; min-width: 0; }
.inv2-brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.inv2-logo-img { width: 130px; height: 130px; object-fit: contain; flex-shrink: 0; }
.inv2-brand-name { font-size: 24px; font-weight: 800; color: var(--primary); letter-spacing: 0.3px; }
.inv2-contact-list { display: flex; flex-direction: column; gap: 5px; }
.inv2-proprietor { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.inv2-proprietor-label { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--primary); margin-bottom: 4px; }
.inv2-proprietor-name { font-size: 16px; font-weight: 800; color: var(--text); }
.inv2-proprietor-contact { display: flex; align-items: center; gap: 5px; font-size: 13.5px; color: var(--text-secondary); margin-top: 3px; }
.inv2-contact-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-secondary); }
.inv2-contact-item .icon { color: var(--primary); flex-shrink: 0; }

.inv2-divider { width: 2px; align-self: stretch; background: var(--border); flex-shrink: 0; }

.inv2-title-block { flex: 1; min-width: 0; text-align: right; }
.inv2-title { font-size: 34px; font-weight: 900; color: var(--primary); letter-spacing: 1px; line-height: 1; }
.inv2-tagline { font-size: 12.5px; color: var(--text-secondary); margin: 6px 0 14px; }
.inv2-invoice-no-box {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px;
  border: 1.5px solid var(--primary); border-radius: 8px;
  padding: 8px 16px; background: rgba(74,95,232,0.05);
  max-width: 100%; box-sizing: border-box;
}
.inv2-invoice-no-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--primary); }
.inv2-invoice-no-value { font-size: 14px; font-weight: 800; color: var(--text); word-break: break-word; overflow-wrap: anywhere; max-width: 100%; }

.inv2-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.inv2-box { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.inv2-box-title {
  background: var(--primary); color: #fff;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 9px 16px;
}
.inv2-box-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.inv2-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--text); }
.inv2-row .icon { color: var(--primary); flex-shrink: 0; margin-top: 1px; }

.inv2-charges { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.inv2-charges-header {
  background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  padding: 10px 18px; text-align: center;
}
.inv2-charges-body { padding: 4px 18px; }
.inv2-charge-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.inv2-charge-row:last-child { border-bottom: none; }
.inv2-charge-label { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.inv2-charge-label .icon { color: var(--primary); }
.inv2-charge-amount { font-size: 14px; font-weight: 600; color: var(--text); }

.inv2-totals { border: 1px solid var(--border); border-radius: 12px; padding: 4px 18px; margin-bottom: 20px; }
.inv2-total-row { display: flex; justify-content: space-between; padding: 10px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.inv2-total-row:last-child { border-bottom: none; }
.inv2-total-main { font-weight: 800; font-size: 16px; color: var(--primary); }
.inv2-total-remaining { font-weight: 800; font-size: 16px; color: var(--accent-orange); }
.inv2-total-remaining.inv2-settled { color: var(--success); }

.inv2-bill-history {
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 22px;
  box-shadow: 0 2px 4px rgba(20,22,55,0.04), 0 10px 24px rgba(20,22,55,0.06);
}
.inv2-bill-history-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px;
  padding: 13px 20px;
  display: flex; align-items: center; gap: 8px;
}
.inv2-bill-history-cols { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); }
.inv2-bill-history-cols table + table { border-left: 1px solid var(--border); }
.inv2-bill-history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv2-bill-history-table th {
  text-align: left; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-secondary); background: var(--hover-bg);
  padding: 9px 14px; border-bottom: 1.5px solid var(--border);
}
.inv2-bill-history-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.inv2-bill-history-table tbody tr:nth-child(even) { background: var(--hover-bg); }
.inv2-bill-history-table tbody tr:last-child td { border-bottom: none; font-weight: 700; }
.inv2-bill-history-table tbody tr:last-child { background: rgba(74,95,232,0.07); }
.inv2-bill-history-table th:nth-child(2), .inv2-bill-history-table td:nth-child(2),
.inv2-bill-history-table th:nth-child(3), .inv2-bill-history-table td:nth-child(3) { text-align: right; }
.inv2-bill-history-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; font-size: 16px; font-weight: 800; color: var(--accent-orange);
  background: rgba(245,165,36,0.08);
  border-top: 2px solid var(--border);
}
.inv2-bill-history-footer span:first-child {
  text-transform: uppercase; letter-spacing: 0.5px; font-size: 12.5px; color: var(--text);
}

.inv2-payment-methods { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 20px; max-width: 320px; }
.inv2-payment-methods .inv2-box-title { }
.inv2-methods-list { padding: 6px 16px; }
.inv2-method-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.inv2-method-item:last-child { border-bottom: none; }
.inv2-method-item .icon { color: var(--primary); }
.inv2-payment-account {
  display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--text);
  padding: 8px 16px; border-top: 1px solid var(--border);
}
.inv2-payment-account .icon { color: var(--primary); flex-shrink: 0; margin-top: 1px; }
.inv2-payment-account strong { color: var(--primary); }

.inv2-note-row {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border);
}
.inv2-note { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--text-secondary); max-width: 400px; }
.inv2-note .icon { color: var(--primary); flex-shrink: 0; margin-top: 1px; }
.inv2-note a { color: var(--primary); font-weight: 700; }
.inv2-signature { text-align: center; font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.inv2-signature-img { display: block; height: 96px; width: auto; max-width: 280px; object-fit: contain; margin: 0 auto -18px; }
.inv2-signature-line { width: 160px; border-bottom: 1px solid var(--text-secondary); margin-bottom: 6px; }

.inv2-footer-bar {
  background: linear-gradient(120deg, var(--primary), #2E3FCB); color: #fff;
  display: flex; justify-content: center; gap: 28px; flex-wrap: wrap;
  font-size: 13.5px; font-weight: 600; padding: 13px 18px; border-radius: 10px;
  margin-top: 20px;
}
.inv2-footer-bar span { display: flex; align-items: center; gap: 6px; }
.inv2-footer-bar .icon { color: #fff; }
.inv2-footer-bar a { color: #fff; font-weight: 800; text-decoration: none; }
.inv2-footer-bar a:hover { text-decoration: underline; }

/* ---------- Invoice PDF capture (auto-pdf-download.php) ----------
   html2pdf.js screenshots the LIVE on-screen DOM via html2canvas — it
   never triggers window.print() and never sees @media print rules at
   all. This class is added by that script, right before capture, so
   THAT specific path also gets a tightened, guaranteed-one-page
   layout — completely independent of the native-browser Print button,
   which already gets its own @media print rules below. */
.inv2-compact { padding: 22px 26px !important; }
.inv2-compact .inv2-header { padding-bottom: 14px; margin-bottom: 14px; }
.inv2-compact .inv2-logo-img { width: 95px; height: 95px; }
.inv2-compact .inv2-brand-name { font-size: 20px; }
.inv2-compact .inv2-two-col { margin-bottom: 14px; gap: 12px; }
.inv2-compact .inv2-box-body { padding: 10px 14px; gap: 7px; }
.inv2-compact .inv2-charges { margin-bottom: 14px; }
.inv2-compact .inv2-charge-row { padding: 8px 0; }
.inv2-compact .inv2-totals { margin-bottom: 14px; padding: 2px 16px; }
.inv2-compact .inv2-total-row { padding: 7px 0; }
.inv2-compact .inv2-payment-methods { margin-bottom: 14px; }
.inv2-compact .inv2-note-row { margin-top: 16px; padding-top: 12px; }
.inv2-compact .inv2-signature-img { height: 70px; max-width: 210px; margin-bottom: -10px; }
.inv2-compact .inv2-proprietor { margin-top: 6px; padding-top: 6px; }
.inv2-compact .inv2-proprietor-label { font-size: 11px; }
.inv2-compact .inv2-proprietor-name { font-size: 13.5px; }
.inv2-compact .inv2-proprietor-contact { font-size: 11.5px; }
.inv2-compact .inv2-footer-bar { margin-top: 14px; padding: 10px 16px; }
.inv2-compact table th, .inv2-compact table td { padding: 6px 8px !important; }

@media (max-width: 640px) {
  .public-invoice-body { padding: 16px 10px 40px; }
  .inv2-paper { padding: 18px 16px; border-radius: 12px; }
  .inv2-header { flex-direction: column; }
  .inv2-divider { display: none; }
  .inv2-title-block { text-align: left; }
  .inv2-two-col { grid-template-columns: 1fr; }

  /* Everything below had a print-only compact size (@media print
     further down) but no on-screen mobile treatment at all — on a
     ~360-390px phone the desktop padding/font-sizes were wide enough
     to push content past the viewport edge or force awkward wrapping
     (the "Developed By" badge in particular, whose inner flex row had
     nowhere near enough room to stay on one line). */
  .inv2-box-body { padding: 10px 12px; gap: 7px; font-size: 13px; }
  .inv2-charge-row { padding: 7px 0; font-size: 13px; }
  .inv2-totals { padding: 2px 14px; margin-bottom: 16px; }
  .inv2-total-row { padding: 6px 0; }
  .inv2-payment-methods { max-width: 100%; margin-bottom: 16px; }
  .inv2-bill-history-table { font-size: 11px; }
  .inv2-bill-history-table th, .inv2-bill-history-table td { padding: 5px 6px; }
  .inv2-bill-history-footer { padding: 8px 12px; font-size: 12.5px; }
  .inv2-note-row { margin-top: 20px; padding-top: 14px; gap: 14px; }
  .inv2-note { max-width: 100%; font-size: 11.5px; }
  .inv2-signature-img { height: 76px; max-width: 200px; }
  .inv2-footer-bar {
    flex-direction: column; gap: 6px; text-align: center;
    padding: 12px 14px; font-size: 12.5px;
  }
  .inv2-footer-bar span { flex-direction: column; gap: 2px; }
  table { font-size: 12px; }
  th, td { padding: 6px 8px !important; }
}

@media print {
  .inv2-paper { box-shadow: none; }
}

.invoice-banner {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-weight: 700;
  text-align: center;
  font-size: 15px;
}

.invoice-banner-paid { background: rgba(22,163,74,0.12); color: var(--success); border: 1px solid rgba(22,163,74,0.3); }
.invoice-banner-cancelled { background: rgba(100,116,139,0.14); color: var(--text-secondary); border: 1px solid var(--border); }
.invoice-banner-overdue { background: rgba(220,38,38,0.08); color: var(--danger); border: 1px solid rgba(220,38,38,0.25); }

/* Decorative "PAID" stamp — floats to the right so it sits naturally
   next to the Payment History table regardless of how much content
   (charges, discounts) comes before it, rather than a fixed absolute
   position that could overlap unpredictably on a longer invoice.
   Rotated and semi-transparent for the ink-stamp look; print-visible
   on purpose (no display:none in the print media query) since this
   is meant to show up on the saved/printed PDF, not just on-screen. */
.inv2-paid-stamp {
  float: right;
  width: 148px;
  margin: -12px 0 8px 16px;
  transform: rotate(-11deg);
  opacity: 0.92;
  pointer-events: none;
}
.inv2-paid-stamp svg { width: 100%; height: auto; display: block; }

@media (max-width: 560px) {
  .inv2-paid-stamp { width: 110px; margin: -6px 0 6px 10px; }
}

.invoice-section-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin: 28px 0 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.invoice-section-title .icon { color: var(--primary); }

.invoice-summary-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 16px;
}

.invoice-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.invoice-summary-row.total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 12px;
  font-weight: 700;
  font-size: 15px;
}

.invoice-summary-row.remaining {
  font-weight: 800;
  font-size: 17px;
  color: var(--accent-orange);
}

.invoice-summary-row.remaining.settled { color: var(--success); }

.invoice-footer-note {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

@media print {
  .public-invoice-body { padding: 0; background: #fff; }
  .invoice-actions { display: none !important; }
  .inv2-paper { box-shadow: none; border-color: var(--primary); padding: 0; }

  /* The whole point: force a predictable single page, and never let
     the browser's default page margins + this document's natural
     height combine into a near-empty second page (which is exactly
     what "downloads as 2 pages, misaligned" was — a few stray pixels
     of overflow spilling a border fragment onto page 2). */
  @page { size: A4; margin: 9mm 10mm; }

  html, body { height: auto; }
  .invoice-page { max-width: 100%; margin: 0; }

  /* Compact every section a bit for print only — the on-screen sizes
     stay exactly as they were; this only tightens the printed copy
     enough to reliably clear one A4 page even with the added payment/
     signature/footer content. */
  .inv2-header { padding-bottom: 14px; margin-bottom: 14px; }
  .inv2-logo-img { width: 90px; height: 90px; }
  .inv2-signature-img { height: 70px; max-width: 210px; margin-bottom: -10px; }
  .inv2-proprietor { margin-top: 6px; padding-top: 6px; }
  .inv2-proprietor-label { font-size: 11px; }
  .inv2-proprietor-name { font-size: 13.5px; }
  .inv2-proprietor-contact { font-size: 11.5px; }
  .inv2-two-col { margin-bottom: 14px; gap: 12px; }
  .inv2-box-body { padding: 10px 14px; gap: 7px; }
  .inv2-charges { margin-bottom: 14px; }
  .inv2-charge-row { padding: 8px 0; }
  .inv2-totals { margin-bottom: 14px; padding: 2px 16px; }
  .inv2-total-row { padding: 7px 0; }
  .inv2-payment-methods { margin-bottom: 14px; }
  .inv2-bill-history { margin-bottom: 14px; }
  .inv2-note-row { margin-top: 16px; padding-top: 12px; }
  .inv2-footer-bar { margin-top: 14px; padding: 10px 16px; }
  table { font-size: 12.5px; }
  th, td { padding: 6px 8px !important; }

  /* Never let a browser split these across a page boundary — each is
     short enough to always fit whole, so "avoid" just prevents an ugly
     mid-box break, it never forces an unwanted extra page. */
  .inv2-header, .inv2-box, .inv2-charges, .inv2-totals,
  .inv2-payment-methods, .inv2-bill-history, .inv2-note-row, .inv2-footer-bar,
  .invoice-banner, tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
