/* ==========================================================================
   PRO-J Books — Design System
   Deep emerald rail, light content, restrained red for errors and risk.
   Single stylesheet for all application pages. Pure CSS, no framework.

   Contents
   1. Tokens
   2. Base & typography
   3. App shell (sidebar, main, headers)
   4. Cards & KPIs
   5. Buttons
   6. Forms
   7. Tables
   8. Status, alerts & badges
   9. Navigation (sidebar groups, mobile tab bar, drawers)
  10. Overlays (modal, loader)
  11. Charts
  12. Auth & setup pages
  13. Admin & Super Admin
  14. Plans, switches & permissions
  15. Utilities
  16. Responsive
  17. Reduced motion
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* ---------- 1. Tokens ------------------------------------------------------ */
:root {
  /* Emerald accent (primary fill, white text passes at 600 weight) */
  --green-500: #059669;   /* primary fill */
  --green-600: #047857;   /* hover */
  --green-700: #065F46;   /* text on light tints, pressed */
  --green-100: #D1FAE5;   /* tint */
  --green-50:  #ECFDF5;   /* pale surface */
  --mint:      #34D399;   /* highlights on dark surfaces */
  --mint-soft: #6EE7B7;

  /* Deep rail (sidebar) */
  --rail-top:    #0B2119;
  --rail-bottom: #0F2D23;
  --rail-text:   #C4D6CE;
  --rail-muted:  #7FA396;

  /* Neutrals */
  --white:  #FFFFFF;
  --bg:     #F4F6F5;      /* page background, slightly warm */
  --ink:    #111B17;      /* primary text */
  --muted:  #64748B;      /* secondary text */
  --border:      #E4EAE7;
  --border-strong: #CBD5D0;

  /* Red — errors, overdue, negative values, destructive actions only */
  --red:     #DC2626;
  --red-700: #B91C1C;
  --red-50:  #FEE2E2;

  /* Compatibility aliases */
  --primary:   var(--green-700);
  --primary-2: var(--green-600);
  --accent:    var(--green-500);
  --accent-2:  var(--green-600);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --fs-body: 15px;
  --fs-body-mobile: 16px;
  --fs-small: 13px;
  --fs-tiny: 12px;
  --fs-label: 13px;
  --fs-button: 15px;
  --fs-input: 15px;
  --fs-input-mobile: 16px;
  --fs-h1: 26px;
  --fs-h1-mobile: 24px;
  --fs-h2: 18px;
  --fs-h3: 16px;
  --fs-figure: 24px;
  --lh-body: 1.55;
  --lh-heading: 1.25;

  /* Shape */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(17, 27, 23, .05);
  --shadow-sm: 0 1px 3px rgba(17, 27, 23, .07), 0 1px 2px rgba(17, 27, 23, .04);
  --shadow-lg: 0 18px 40px rgba(17, 27, 23, .18);
  --focus-ring: 0 0 0 3px rgba(5, 150, 105, .25);

  /* Motion */
  --dur: .18s;
  --ease: ease-in-out;

  /* Layout */
  --sidebar-w: 256px;
  --content-max: 1440px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- 2. Base & typography ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button, input, select, textarea { font-family: inherit; }

img, svg { max-width: 100%; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
a:hover { color: var(--green-600); }

:focus-visible {
  outline: 2px solid var(--green-500);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--green-100); color: var(--ink); }

h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 700;
  line-height: var(--lh-heading);
  letter-spacing: -.01em;
}
h1 { font-size: var(--fs-h1); margin: 0 0 6px; }
h2 { font-size: var(--fs-h2); font-weight: 600; margin: 0 0 14px; }
h3 { font-size: var(--fs-h3); font-weight: 600; margin: 0 0 8px; }

p { margin: 0 0 10px; }
strong, b { font-weight: 600; }
small { font-size: var(--fs-tiny); }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

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

.muted { color: var(--muted); font-size: var(--fs-small); }

.eyebrow {
  display: block;
  margin: 0 0 6px;
  color: var(--green-700);
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ---------- 3. App shell --------------------------------------------------- */
.app { min-height: 100vh; display: block; }

/* Desktop sidebar (white rail, green active state) */
.app > aside {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 14px 20px;
  min-width: 0;
  background: linear-gradient(180deg, var(--rail-top) 0%, var(--rail-bottom) 100%);
  border-right: 0;
  box-shadow: 4px 0 24px rgba(11, 33, 25, .14);
}
.app > aside::-webkit-scrollbar { width: 6px; }
.app > aside::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 0;
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.brand::before {
  content: "";
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--mint);
}
.brand:hover { color: #FFFFFF; }

.app > aside .muted { display: block; padding: 4px 10px 0; color: var(--rail-muted); }

aside nav { display: grid; gap: 2px; margin-top: 20px; min-width: 0; }
aside nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: var(--rail-text);
  font-size: 14px;
  font-weight: 500;
}
aside nav a:hover { background: rgba(255, 255, 255, .07); color: #FFFFFF; }
aside nav a.active {
  background: rgba(52, 211, 153, .14);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--mint);
}

/* Main content column */
main {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 28px 32px 48px;
  min-width: 0;
}
.app > main,
.admin-main {
  width: calc(100% - var(--sidebar-w));
  margin-left: var(--sidebar-w);
  margin-right: 0;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
header p:not(.eyebrow) { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
header h1 { margin-bottom: 0; }

.app > main > header { max-width: var(--content-max); margin: 0 auto 22px; }
.app > main > .card,
.app > main > .kpis,
.app > main > .moregrid,
.app > main > section {
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
}

.page-back { margin-bottom: 4px; }

/* ---------- 4. Cards & KPIs ------------------------------------------------ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
  min-width: 0;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpis .card { position: relative; margin: 0; overflow: hidden; }
.kpis .card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green-500), var(--mint));
}
.kpis span { display: block; color: var(--muted); font-size: var(--fs-small); font-weight: 500; }
.kpis strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: var(--fs-figure);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.moregrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.module {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--ink);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.module:hover { border-color: #A7F3D0; background: var(--white); color: var(--ink); }
.module span { font-size: var(--fs-small); color: var(--muted); }

/* ---------- 5. Buttons ----------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--green-500);
  border-radius: var(--radius-sm);
  background: var(--green-500);
  color: #FFFFFF;
  font-family: var(--font-sans);
  font-size: var(--fs-button);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--green-600); border-color: var(--green-600); color: #FFFFFF; box-shadow: 0 8px 18px -8px rgba(5, 150, 105, .6); }
.btn:active { background: var(--green-700); border-color: var(--green-700); }
.btn:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Secondary: white, green border, green text */
.btn.secondary {
  background: var(--white);
  border: 1px solid var(--green-500);
  color: var(--green-700);
}
.btn.secondary:hover { background: var(--green-50); border-color: var(--green-600); color: var(--green-700); }
.btn.secondary:active { background: var(--green-100); }

/* Danger: destructive actions only */
.btn.danger { background: var(--red); border-color: var(--red); color: #FFFFFF; }
.btn.danger:hover { background: var(--red-700); border-color: var(--red-700); color: #FFFFFF; }

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.back-button:hover { background: var(--bg); border-color: var(--border-strong); color: var(--ink); }
.back-button span:first-child { font-size: 18px; line-height: 1; }
.auth .back-button { align-self: flex-start; margin-bottom: 0; }
.setup-shell .back-button { margin-bottom: 0; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-actions form { display: inline; }
.row-actions .btn { min-height: 34px; padding: 6px 10px; font-size: 14px; }

.hero-actions,
.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.modal-actions { justify-content: flex-end; margin-top: 14px; }

/* ---------- 6. Forms ------------------------------------------------------- */
form { display: grid; gap: 14px; }

label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: 1.4;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  font-size: var(--fs-input);
  font-weight: 400;
  line-height: 1.4;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input::placeholder, textarea::placeholder { color: #94A3B8; opacity: 1; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: var(--focus-ring);
}
input:disabled, select:disabled, textarea:disabled,
input[readonly] {
  background: var(--bg);
  color: var(--muted);
}
textarea { min-height: 96px; resize: vertical; }
select { cursor: pointer; }

input[type="checkbox"], input[type="radio"] {
  width: 16px;
  min-height: 0;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--green-600);
  box-shadow: none;
  cursor: pointer;
}
input[type="file"] { padding: 8px; background: var(--bg); }

.gridform {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 16px;
}
.gridform .btn { grid-column: 1 / -1; width: max-content; }

.filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filters label { min-width: 140px; flex: 1; }
.filters input, .filters select { min-width: 0; }

.full-span { grid-column: 1 / -1; }

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--ink);
  font-weight: 500;
  align-self: end;
}
.check-label input { width: auto; }

.check-all {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green-700);
  font-size: var(--fs-small);
  font-weight: 500;
}
.check-all input { width: auto; margin: 0; }

.password-hint { margin: -6px 0 0; color: var(--muted); font-size: var(--fs-tiny); }

.section-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head-row h2 { margin: 0 0 3px; }
.section-head-row .muted { margin: 0; }

/* ---------- 7. Tables ------------------------------------------------------ */
.tablewrap { overflow: auto; }

table {
  width: 100%;
  min-width: 640px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
th, td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
th {
  background: var(--bg);
  color: var(--muted);
  font-size: var(--fs-label);
  font-weight: 600;
  white-space: nowrap;
}
td { color: var(--ink); }
tbody tr:hover td { background: #FAFCFD; }
tbody tr:last-child td { border-bottom: 0; }
td strong { font-weight: 600; }

/* ---------- 8. Status, alerts & badges ------------------------------------ */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: #F1F5F9;
  color: #475569;
  font-size: var(--fs-tiny);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.status-pill.active { background: var(--green-100); color: var(--green-700); }
.status-pill.suspended { background: var(--red-50); color: var(--red-700); }

.ok {
  padding: 12px 14px;
  border: 1px solid #A7F3D0;
  border-radius: var(--radius-md);
  background: var(--green-100);
  color: var(--green-700);
  font-size: 14px;
  font-weight: 500;
}
.error {
  padding: 12px 14px;
  border: 1px solid #FECACA;
  border-radius: var(--radius-md);
  background: var(--red-50);
  color: var(--red-700);
  font-size: 14px;
  font-weight: 500;
}

/* ---------- 9. Navigation -------------------------------------------------- */

/* Grouped desktop navigation */
.nav-group { display: block; }
.nav-group-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--rail-text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.nav-group-toggle:hover { background: rgba(255, 255, 255, .07); color: #FFFFFF; }
.nav-group.open .nav-group-toggle { color: #FFFFFF; }
.nav-group-icon,
.side-icon,
.nav-icon,
.drawer-icon,
.nav-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--muted);
}
.nav-group-icon, .side-icon { width: 22px; height: 22px; }
.nav-chevron {
  color: var(--rail-muted);
  font-size: 16px;
  line-height: 1;
  text-align: center;
  transition: transform var(--dur) var(--ease);
}
.nav-group.open .nav-chevron { transform: rotate(180deg); }

.side-icon svg,
.nav-icon svg,
.nav-group-icon svg,
.drawer-icon svg,
.nav-symbol svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

aside nav a:hover .side-icon,
aside nav a.active .side-icon,
.nav-group-toggle:hover .nav-group-icon,
.nav-group.open .nav-group-icon { color: var(--green-600); }

.nav-sub {
  display: none;
  margin: 2px 0 4px 16px;
  padding: 2px 0 2px 10px;
  border-left: 1px solid rgba(255, 255, 255, .12);
}
.nav-group.open .nav-sub { display: grid; gap: 2px; }
.nav-sub a {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 8px;
  color: #AFC6BC;
  font-size: 14px;
  font-weight: 500;
}
.nav-sub a:hover { background: rgba(255, 255, 255, .07); color: #FFFFFF; }
.nav-sub a.active {
  background: rgba(52, 211, 153, .14);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--mint);
}

/* Sidebar icons on the dark rail */
.app > aside .side-icon,
.app > aside .nav-group-icon,
.admin-side .nav-symbol { color: var(--rail-muted); }
.app > aside nav a:hover .side-icon,
.app > aside nav a.active .side-icon,
.app > aside .nav-group-toggle:hover .nav-group-icon,
.app > aside .nav-group.open .nav-group-icon,
.admin-side nav a:hover .nav-symbol,
.admin-side nav a.active .nav-symbol { color: var(--mint-soft); }

/* Mobile bottom tab bar (hidden on desktop) */
.mobile-nav { display: none; }
.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 6px 2px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}
.mobile-nav a:hover { background: var(--bg); color: var(--ink); }
.mobile-nav a.active {
  background: var(--green-50);
  color: var(--green-700);
  box-shadow: inset 0 -2px 0 var(--green-500);
}
.mobile-nav .nav-icon { display: block; height: 20px; margin: 0; }
.mobile-nav .nav-icon svg { width: 20px; height: 20px; }

/* Drawers ("More" menus) */
.mobile-drawer { display: none; }
.mobile-drawer.open {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(23, 32, 26, .42);
}
.drawer-panel {
  position: absolute;
  right: 12px;
  bottom: max(12px, var(--safe-bottom));
  width: min(420px, calc(100% - 24px));
  max-height: 80vh;
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.drawer-head strong { display: block; color: var(--ink); font-size: var(--fs-h3); font-weight: 600; }
.drawer-head small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-small); }
.drawer-panel > a,
.drawer-footer a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}
.drawer-panel > a:hover,
.drawer-footer a:hover { background: var(--green-50); color: var(--green-700); }
.drawer-icon { width: 24px; height: 24px; color: var(--muted); }
.drawer-icon svg { width: 19px; height: 19px; }
.drawer-footer { display: grid; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.drawer-close {
  justify-self: end;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.drawer-close:hover { background: var(--border); }
.drawer-open { overflow: hidden; }

/* ---------- 10. Overlays --------------------------------------------------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(23, 32, 26, .42);
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-head h2 { margin: 0; }
.modal-head button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.bulk-row { display: grid; grid-template-columns: 2fr 1.4fr 1fr 1.2fr auto; gap: 8px; margin-bottom: 8px; }

/* Page loader: spinning ring and the PRO-J BOOKS wordmark. Hidden unless .show (or the pre-paint html.pj-nav class) is set. */
.page-loader {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  opacity: 0; visibility: hidden; pointer-events: none;
  -webkit-transform: translateZ(0); transform: translateZ(0);
  transition: opacity .2s ease, visibility .2s ease;
}
.page-loader.show, html.pj-nav .page-loader { opacity: 1; visibility: visible; pointer-events: auto; }
.pjl-box { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px; text-align: center; }
.pjl-ring {
  display: block; width: 52px; height: 52px; box-sizing: border-box;
  border: 4px solid var(--green-100); border-top-color: var(--green-500); border-radius: 50%;
  -webkit-animation: ds-spin .9s linear infinite; animation: ds-spin .9s linear infinite;
}
.pjl-word {
  font-family: 'Lobster', 'Brush Script MT', 'Segoe Script', cursive;
  font-weight: 700; font-style: italic; text-transform: uppercase;
  font-size: 22px; line-height: 1; letter-spacing: .03em; color: var(--ink);
}
.pjl-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.pjl-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green-500);
  -webkit-animation: pjl-pulse 1.2s ease-in-out infinite; animation: pjl-pulse 1.2s ease-in-out infinite;
}
@-webkit-keyframes pjl-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes pjl-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
body.is-loading { overflow: hidden; }

/* Wordmark used on the loader and sign-in pages */
.pj-wordmark {
  font-family: 'Lobster', 'Brush Script MT', 'Segoe Script', cursive;
  font-weight: 700; font-style: italic; text-transform: uppercase;
  letter-spacing: .03em; line-height: 1; color: #0b315d;
}

/* Submit buttons: spinner while the next page loads */
.btn[aria-busy="true"], button[aria-busy="true"] { opacity: .88; cursor: progress; }
.btn-spin {
  display: inline-block; width: 14px; height: 14px; margin-right: 9px; vertical-align: -2px;
  box-sizing: border-box; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  -webkit-animation: ds-spin .7s linear infinite; animation: ds-spin .7s linear infinite;
}

@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ---------- 11. Charts ----------------------------------------------------- */
.finance-chart { padding: 20px; }
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 14px;
}
.chart-head h2 { margin: 0 0 3px; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: 500;
}
.legend-dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; }
.legend-sales { background: var(--green-500); }
.legend-expenses { background: var(--muted); }
.legend-profit { background: var(--ink); }
.chart-wrap { width: 100%; overflow: auto; }
.finance-chart svg { display: block; width: 100%; min-width: 720px; height: 320px; }
.chart-grid { stroke: #E8EEF4; stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.chart-sales { fill: none; stroke: var(--green-500); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-expenses { fill: none; stroke: var(--muted); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-profit { fill: none; stroke: var(--ink); stroke-width: 1.75; stroke-dasharray: 6 5; }
.chart-point-sales { fill: var(--white); stroke: var(--green-600); stroke-width: 2; }
.chart-point-expenses { fill: var(--white); stroke: var(--muted); stroke-width: 2; }
.chart-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.chart-summary div { padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); }
.chart-summary span { display: block; color: var(--muted); font-size: var(--fs-tiny); font-weight: 500; }
.chart-summary strong { display: block; margin-top: 4px; color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }

.trend-list { display: grid; gap: 10px; }
.trend-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; align-items: center; }
.trend-label { color: var(--muted); font-size: var(--fs-small); }
.trend-bars { display: grid; gap: 4px; }
.trend-bar {
  display: flex;
  align-items: center;
  height: 24px;
  min-width: 2px;
  padding: 0 8px;
  border-radius: 6px;
  overflow: hidden;
  white-space: nowrap;
  font-size: var(--fs-tiny);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.trend-bar.sales { background: var(--green-100); color: var(--green-700); }
.trend-bar.expenses { background: #F1F5F9; color: #475569; }

/* ---------- 12. Auth & setup ----------------------------------------------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}
.auth .card { width: min(440px, 100%); display: grid; gap: 14px; padding: 28px; }
.auth .card > .btn { width: 100%; }
.auth h1 { color: var(--ink); font-size: 24px; }
.auth-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; font-size: 14px; }
.auth-links a { font-weight: 600; }
.auth-note { margin-top: 12px; color: var(--muted); font-size: var(--fs-tiny); text-align: center; }

/* ---------- 13. Admin & Super Admin --------------------------------------- */
.admin-shell { min-height: 100vh; display: block; min-width: 0; }

.admin-side {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow: auto;
  padding: 22px 14px;
  background: linear-gradient(180deg, var(--rail-top) 0%, var(--rail-bottom) 100%);
  border-right: 0;
  box-shadow: 4px 0 24px rgba(11, 33, 25, .14);
}
.admin-side .brand { margin-bottom: 10px; }
.admin-side nav { display: grid; gap: 2px; }
.admin-side nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: var(--rail-text);
  font-weight: 500;
}
.admin-side nav a:hover { background: rgba(255, 255, 255, .07); color: #FFFFFF; }
.admin-side nav a.active {
  background: rgba(52, 211, 153, .14);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--mint);
}

.admin-side nav a:hover .nav-symbol,
.admin-side nav a.active .nav-symbol { color: var(--green-600); }

.admin-badge {
  display: inline-flex;
  align-items: center;
  margin: 4px 10px 18px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(52, 211, 153, .16);
  color: var(--mint-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.admin-main { min-width: 0; overflow-x: hidden; padding: 28px 32px 48px; }
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.admin-header h1 { font-size: var(--fs-h1); }
.admin-user {
  display: grid;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.admin-user span { color: var(--muted); font-size: var(--fs-tiny); }

.admin-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.admin-stat {
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.admin-stat span { display: block; color: var(--muted); font-size: var(--fs-tiny); font-weight: 500; }
.admin-stat strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: var(--fs-figure);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.admin-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 16px; min-width: 0; }
.admin-grid > * { min-width: 0; }

.admin-card {
  min-width: 0;
  margin-bottom: 16px;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.admin-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.admin-card-head h2 { margin: 0 0 3px; }
.admin-card-head p { margin: 0; color: var(--muted); font-size: var(--fs-small); }
.admin-card table { min-width: 720px; }
.admin-card .tablewrap { min-width: 0; max-width: 100%; overflow-x: auto; }

.plan-list { display: grid; gap: 8px; min-width: 0; }
.plan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.plan-row span { min-width: 0; overflow-wrap: anywhere; }

.admin-mini-stat { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.admin-mini-stat span { display: block; color: var(--muted); font-size: var(--fs-tiny); }
.admin-mini-stat strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.admin-quick { margin-bottom: 16px; }
.admin-mobile-nav { display: none; }
.admin-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-700);
  font-weight: 700;
}

/* Super Admin: same light system, with a calm header band */
.super-admin-body { background: var(--bg); color: var(--ink); }
.super-admin-body .admin-main { min-height: 100vh; padding-bottom: 64px; background: var(--bg); }
.super-admin-body .page-back a { color: var(--ink); }
.super-admin-body .page-back a:hover { color: var(--green-700); }
.super-admin-body .platform-nav-label {
  padding: 16px 10px 6px;
  color: var(--rail-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.super-admin-body .admin-side .admin-badge { margin-top: 0; }

.platform-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 18px;
  padding: 26px 28px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0B2119 0%, #13473A 100%);
  box-shadow: 0 14px 34px rgba(11, 33, 25, .18);
  color: #FFFFFF;
}
.platform-hero .platform-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--mint-soft);
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.platform-hero h1 { margin: 0 0 6px; color: #FFFFFF; font-size: var(--fs-h1); line-height: 1.2; }
.platform-hero p { max-width: 720px; margin: 0; color: #B7D3C6; font-size: 14px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); }

.platform-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--radius-lg);
  box-shadow: none;
  color: #FFFFFF;
}
.platform-user > div { display: flex; flex-direction: column; }
.platform-user span { color: #B7D3C6; font-size: var(--fs-tiny); }

.platform-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; }
.platform-stat {
  min-width: 0;
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.platform-stat span { display: block; color: var(--muted); font-size: var(--fs-tiny); font-weight: 500; }
.platform-stat strong {
  display: block;
  margin: 6px 0 2px;
  color: var(--ink);
  font-size: var(--fs-figure);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.platform-stat small { color: var(--muted); font-size: var(--fs-tiny); }
.platform-stat.stat-primary { border-top: 3px solid var(--mint); }

.platform-overview { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 14px; margin-bottom: 14px; }
.platform-panel {
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  color: var(--ink);
}
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-title h2 { margin: 2px 0 0; font-size: 17px; }
.panel-title .eyebrow { margin: 0; }

.health-badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--green-100);
  color: var(--green-700);
  font-size: var(--fs-tiny);
  font-weight: 600;
}
.health-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.health-grid > div {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.health-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-700);
  font-size: 12px;
  font-weight: 700;
}
.health-grid strong, .health-grid small { display: block; }
.health-grid strong { font-size: var(--fs-small); font-weight: 600; }
.health-grid small { margin-top: 2px; color: var(--muted); font-size: var(--fs-tiny); }

.focus-list { display: grid; gap: 8px; margin-top: 10px; }
.focus-list a {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink);
}
.focus-list a:hover { border-color: #A7F3D0; background: var(--green-50); color: var(--ink); }
.focus-list a > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--green-700);
  font-weight: 700;
}
.focus-list strong, .focus-list small { display: block; }
.focus-list strong { font-size: var(--fs-small); font-weight: 600; }
.focus-list small { margin-top: 2px; color: var(--muted); font-size: var(--fs-tiny); }
.focus-list b { color: var(--green-600); }

.super-admin-body .admin-card-head h2 { color: var(--ink); }
.super-admin-body .admin-card-head p { color: var(--muted); }
.super-admin-body .platform-actions { margin-bottom: 14px; }
.super-admin-body .platform-actions .module { background: var(--white); }
.super-admin-body .platform-actions .module:hover { border-color: #A7F3D0; }
.super-admin-body .platform-actions .module b { color: var(--ink); }
.super-admin-body .platform-actions .module span { color: var(--muted); }

/* ---------- 14. Plans, switches & permissions ------------------------------ */
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.plan-editor {
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.plan-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.plan-title strong { display: block; color: var(--ink); font-size: 17px; font-weight: 600; }
.plan-title span { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-tiny); }
.plan-editor label { display: block; color: var(--ink); font-size: var(--fs-label); font-weight: 500; }
.plan-editor input { width: 100%; margin-top: 6px; box-sizing: border-box; }
.plan-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 10px 0 12px; }
.plan-add { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.plan-access { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.plan-access-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }

.switch { position: relative; display: block; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch span {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}
.switch span:after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + span { background: var(--green-500); }
.switch input:checked + span:after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--focus-ring); }

.page-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 200px;
  overflow: auto;
  padding: 2px;
}
.page-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.page-check:hover { border-color: var(--border-strong); }
.page-check input { width: auto; margin: 0; }
.page-check:has(input:checked) { border-color: var(--green-500); background: var(--green-50); }

/* ---------- 15. Utilities -------------------------------------------------- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.num, .amount, .money { font-variant-numeric: tabular-nums; }
.text-danger { color: var(--red); }
.text-success { color: var(--green-700); }

/* ---------- 16. Responsive ------------------------------------------------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .platform-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .platform-overview { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .admin-grid { grid-template-columns: 1fr; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .expense-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Mobile layout: sidebar becomes a bottom tab bar + drawers */
@media (max-width: 900px) {
  body { font-size: var(--fs-body-mobile); }

  .app > aside, .admin-side { display: none; }
  .app > main, .admin-main {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(104px + var(--safe-bottom)) max(16px, env(safe-area-inset-left, 0px));
  }

  h1, .admin-header h1, .platform-hero h1 { font-size: var(--fs-h1-mobile); }
  h2 { font-size: 18px; }

  header { align-items: flex-start; flex-wrap: wrap; }

  input, select, textarea { font-size: var(--fs-input-mobile); min-height: 44px; }
  .btn { min-height: 44px; font-size: var(--fs-button); }
  .back-button { min-height: 42px; padding: 10px 14px; }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .moregrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gridform { grid-template-columns: 1fr; }
  .gridform .btn { width: 100%; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters label { min-width: 0; }
  .section-head-row { display: block; }
  .row-actions { display: flex; flex-wrap: wrap; }
  .row-actions form { margin: 2px 0; }

  table { min-width: 600px; }

  /* Bottom tab bar */
  .mobile-nav {
    position: fixed;
    z-index: 90;
    left: 12px;
    right: 12px;
    bottom: max(12px, var(--safe-bottom));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
    background: rgba(255, 255, 255, .97);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .admin-mobile-nav { display: grid !important; }
  .admin-shell .mobile-nav:not(.admin-mobile-nav) { display: none; }

  .mobile-drawer.open { overflow: hidden; overscroll-behavior: contain; touch-action: none; }
  .drawer-panel {
    left: 12px;
    right: 12px;
    width: auto;
    max-height: min(82vh, 720px);
    padding: 16px 16px calc(20px + var(--safe-bottom));
    border-radius: 20px 20px 0 0;
    bottom: 0;
    touch-action: pan-y;
  }
  .drawer-panel > a, .drawer-footer a { min-height: 50px; }
  .drawer-head { position: sticky; top: -16px; z-index: 2; padding-top: 4px; background: var(--white); }

  /* Admin "More" drawer uses two columns for quick scanning */
  .admin-drawer-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-content: start;
    width: min(680px, calc(100vw - 24px));
    margin: 0 auto;
  }
  .admin-drawer-panel .drawer-head,
  .admin-drawer-panel .drawer-footer { grid-column: 1 / -1; }
  .admin-drawer-panel > a { min-height: 58px; }

  .admin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-header { display: block; }
  .admin-user { margin-top: 12px; }

  .platform-hero { flex-direction: column; align-items: flex-start; }
  .platform-user { width: 100%; min-width: 0; box-sizing: border-box; }
  .platform-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .platform-overview { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .plan-grid { grid-template-columns: 1fr; }
  .plan-fields { grid-template-columns: 1fr 1fr; }
  .page-check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 240px; }

  .chart-head { display: block; }
  .chart-legend { margin-top: 12px; }
  .chart-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .expense-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .bulk-row { grid-template-columns: 1fr 1fr; }
  .bulk-row button { grid-column: 1 / -1; }

  .modal-backdrop { padding: 12px; }
  .modal { padding: 18px; }
  .modal-actions .btn { flex: 1; }
}

@media (max-width: 800px) {
  .plan-fields { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .card { padding: 16px; }
  .kpis strong { font-size: var(--fs-figure); }
  .chart-summary { grid-template-columns: 1fr; }
  .finance-chart svg { min-width: 620px; height: 285px; }
  .platform-stat { padding: 14px; }
  .platform-stat strong { font-size: 20px; }
  .platform-panel { padding: 14px; }
  .health-grid { grid-template-columns: 1fr; }
  .plan-fields { grid-template-columns: 1fr; }
  .page-check-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .bulk-row { grid-template-columns: 1fr; }
  .moregrid { grid-template-columns: 1fr; }
  .admin-drawer-panel { grid-template-columns: 1fr; }
  .admin-drawer-panel .drawer-head, .admin-drawer-panel .drawer-footer { grid-column: auto; }
  .admin-kpis, .platform-kpis, .expense-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-stat, .platform-stat { padding: 14px; }
  .auth .card { padding: 22px; }
  .page-back { margin-bottom: 0; }
}

/* ---------- 12b. Login & signup ------------------------------------------
   login.php and signup.php carry inline <style> blocks with the same class
   names. Those load after this file, so the properties they set are
   overridden here with !important. Layout and copy are unchanged. */
.auth-page {
  padding: 32px !important;
  background:
    radial-gradient(900px 520px at 0% 0%, #D1FAE5 0%, rgba(209, 250, 229, 0) 60%),
    radial-gradient(760px 480px at 100% 100%, #E3F4EE 0%, rgba(227, 244, 238, 0) 55%),
    #F4F6F5 !important;
}
.auth-shell {
  width: min(1040px, 100%) !important;
  border: 1px solid rgba(17, 27, 23, .06) !important;
  border-radius: 24px !important;
  background: #FFFFFF !important;
  box-shadow: 0 30px 80px -24px rgba(11, 33, 25, .28), 0 2px 6px rgba(11, 33, 25, .05) !important;
}
.auth-brand-panel {
  padding: 52px !important;
  min-height: 640px !important;
  color: #FFFFFF !important;
  background:
    radial-gradient(620px 380px at 90% 8%, rgba(52, 211, 153, .24), rgba(52, 211, 153, 0) 60%),
    linear-gradient(160deg, #0B2119 0%, #0F2D23 55%, #13473A 100%) !important;
}
.auth-brand-panel:after {
  width: 380px !important;
  height: 380px !important;
  right: -170px !important;
  bottom: -170px !important;
  border: 56px solid rgba(52, 211, 153, .09) !important;
}
.auth-logo {
  width: min(240px, 70%) !important;
  border-radius: 14px !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
}
.auth-eyebrow {
  color: var(--mint-soft) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  letter-spacing: .1em !important;
}
.auth-brand-panel h2 {
  color: #FFFFFF !important;
  font-size: 40px !important;
  font-weight: 700 !important;
  line-height: 1.12 !important;
  letter-spacing: -.02em !important;
  margin: 14px 0 !important;
}
.auth-brand-panel p {
  color: #B7D3C6 !important;
  font-size: 16px !important;
  line-height: 1.65 !important;
}
.auth-form-panel { padding: 48px 52px !important; }
.auth-home {
  align-self: flex-start;
  margin-bottom: 32px !important;
  padding: 9px 14px !important;
  border: 1px solid #DDE5E1 !important;
  border-radius: 10px !important;
  background: #FFFFFF !important;
  color: var(--ink) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
}
.auth-home:hover {
  border-color: #A7F3D0 !important;
  color: var(--green-700) !important;
  box-shadow: 0 6px 16px rgba(5, 150, 105, .12) !important;
}
.auth-form-panel .auth-form { max-width: 400px !important; }
.auth-form-panel h1 {
  margin: 0 0 8px !important;
  color: var(--ink) !important;
  font-size: 30px !important;
  font-weight: 700 !important;
  letter-spacing: -.02em !important;
}
.auth-subtitle {
  margin: 0 0 28px !important;
  color: var(--muted) !important;
  font-size: 15px !important;
}
.auth-form label { gap: 8px; font-size: 14px; font-weight: 600; }
.auth-form input { min-height: 46px; border-radius: 10px; border-color: #D5DDD9; }
.auth-form .btn {
  width: 100% !important;
  min-height: 48px !important;
  padding: 13px 18px !important;
  border-radius: 12px !important;
  background: var(--green-500) !important;
  border-color: var(--green-500) !important;
  font-size: 15px !important;
  box-shadow: 0 12px 24px -12px rgba(5, 150, 105, .75) !important;
}
.auth-form .btn:hover {
  background: var(--green-600) !important;
  border-color: var(--green-600) !important;
}
.auth-links { color: var(--muted); font-size: 14px !important; }
.auth-links a { color: var(--green-700); font-weight: 600 !important; }
.auth-note {
  margin-top: 20px !important;
  color: #8A96A0 !important;
  font-size: 12px !important;
}
.auth-logo-mobile { width: 160px !important; }

/* Password show / hide (added by assets/js/password-toggle.js) */
.pw-field { position: relative; display: block; }
.pw-field input { width: 100%; padding-right: 52px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.pw-toggle:hover { background: var(--bg); color: var(--green-700); }
.pw-toggle:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.pw-toggle[aria-pressed="true"] { color: var(--green-700); }
.pw-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 760px) {
  .auth-page { padding: 14px !important; }
  .auth-shell { grid-template-columns: 1fr !important; border-radius: 20px !important; }
  .auth-brand-panel { display: none !important; }
  .auth-form-panel { padding: 28px 22px !important; }
  .auth-form-panel h1 { font-size: 26px !important; }
  .auth-logo-mobile { display: block !important; margin-bottom: 22px !important; }
  .auth-home { margin-bottom: 22px !important; }
  .auth-form input { font-size: 16px; }
}

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

/* Sign-in, sign-up and passcode pages: wordmark beside the logo */
.auth-brand-panel .pj-wordmark { color: #fff; font-size: 40px; margin: 18px 0 0; }
.auth-wordmark-m { display: none; font-size: 30px; margin: -8px 0 22px; }
@media (max-width: 760px) { .auth-wordmark-m { display: block; } }
