/**
 * wateer-portal.css — thin, page-LAYOUT-only stylesheet for my.wateer.com.sa.
 *
 * Loaded after the vendored design-system (static/design-system/design-system.css)
 * on every customer-portal page. It does two things, and nothing else:
 *
 *   1. A one-time alias bridge: every legacy custom-property name the portal's
 *      markup already used (--bg-card, --accent, --text-primary, ...) is
 *      redefined here to point at the vendored design-system's own tokens
 *      (--color-bg-elevated, --color-accent, --color-text-primary, ...)
 *      instead of a hardcoded hex value. This is what makes the reskin take
 *      effect on every page's existing markup/classes without having to
 *      rewrite each page's selectors one at a time. New work should reach for
 *      the design-system tokens directly (var(--color-accent), the .btn/.card/
 *      .badge/.input/.table classes, etc.) rather than adding to this list.
 *
 *   2. The page-chrome layout rules that used to live as inline <style> blocks
 *      in base.html / login.html / signup.html / privacy_policy.html /
 *      terms_of_use.html / privacy_center.html / privacy_index.html — moved
 *      here verbatim (selectors and rule bodies unchanged, ids/classes the JS
 *      depends on untouched) so every page shares ONE stylesheet stack instead
 *      of each shipping its own copy-pasted <style> block.
 *
 * --accent-text exists because --accent (brand-500, #075AA1) is a FILLED
 * SURFACE colour (buttons, active pills, gradients — white text on top of it
 * clears AA in both themes) and is NOT safe as TEXT color on this portal's
 * dark background: 2.98:1, below the 4.5:1 WCAG AA floor. See the
 * fix/wateer-contrast-aa branch in ~/Coding/design-system for the full
 * before/after contrast numbers. Every spot in this portal that colors TEXT
 * (a link, an icon-as-text, a border that doubles as one) with the accent hue
 * uses --accent-text instead, which resolves to the design-system's own
 * --color-text-link — brand-500 in light mode (identical to --accent there,
 * so nothing changes visually in light), and the corrected, legible blue in
 * the wateer brand's dark mode.
 */

/* ── 1. Legacy token bridge ── */
:root,
[data-theme] {
  --bg-primary: var(--color-bg-primary);
  --bg-secondary: var(--color-bg-secondary);
  --bg-body: var(--color-bg-primary);
  --bg-card: var(--color-bg-elevated);
  --card: var(--color-bg-elevated);
  --bg: var(--color-bg-primary);

  --bg-sidebar: var(--brand-900);
  --bg-sidebar-hover: rgba(255, 255, 255, 0.12);
  --bg-sidebar-active: rgba(255, 255, 255, 0.2);
  --text-sidebar: rgba(255, 255, 255, 0.85);
  --text-sidebar-active: #ffffff;

  --text-primary: var(--color-text-primary);
  --text: var(--color-text-primary);
  --text-secondary: var(--color-text-secondary);
  --text-muted: var(--color-text-tertiary);
  --muted: var(--color-text-tertiary);
  --footer-text: var(--color-text-tertiary);

  --border-color: var(--color-border-primary);
  --border: var(--color-border-primary);

  /* Filled surfaces / borders only — see file docstring. */
  --accent: var(--color-accent);
  --primary: var(--color-accent);
  --accent-dark: var(--brand-900);
  --accent-light: color-mix(in srgb, var(--color-accent) 12%, transparent);
  --accent-gradient: linear-gradient(135deg, var(--brand-900) 0%, var(--color-accent) 100%);

  /* Plain TEXT (links, icon glyphs, "as text" strong/h2 accents) — AA-safe
     in both themes. See file docstring. */
  --accent-text: var(--color-text-link);

  /* Text sitting directly ON a filled --accent-gradient surface (a hero
     banner, a card header) — see the ".brand-surface" rule below. White at
     both gradient endpoints: ~11:1 on --brand-900, ~7:1 on --color-accent,
     in both themes (the gradient is theme-independent). */
  --color-text-on-brand: #ffffff;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.08);

  --success: var(--color-success);
  --success-bg: var(--color-success-bg);
  --success-text: var(--color-success);
  --danger: var(--color-error);
  --error-bg: var(--color-error-bg);
  --error-text: var(--color-error);
  --warning: var(--color-warning);
  --info: var(--color-info);

  --changelog-bg: var(--color-bg-tertiary);

  /* IBM Plex Sans Arabic is what every portal page has always loaded (Google
     Fonts link, see base.html/login.html/etc.) and what mywateer-app itself
     uses for Arabic (src/constants/theme.ts FontFamily.arabic) — kept as the
     portal's Arabic face instead of the design-system's own default
     (Noto Naskh Arabic) so the web portal and the app read as one brand. */
  --font-arabic: 'IBM Plex Sans Arabic', 'Inter', var(--font-sans);
}

/* Light-theme secondary/tertiary text. The vendored design system maps them to neutral-600/500
   (#868e96 3.3:1, #adb5bd 2.1:1 on white) which fails WCAG AA for the small captions, labels and
   hints the portal sets in them on every page; same fix mywateer-app made in theme.ts (A8).
   #5c636a = 6.1:1 on white, #666f77 = 5.1:1 on white / 4.6:1 on the #f1f3f5 tint. */
[data-brand="wateer"][data-theme="light"] {
  --color-text-secondary: #5c636a;
  --color-text-tertiary: #666f77;
}

[data-theme="dark"] {
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ── 2. Base (was static/css/wateer-base.css) ── */
.skip-to-main {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0.5rem;
  z-index: 10000;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 6px;
  text-decoration: none;
  box-shadow: var(--shadow-md);
}

.skip-to-main:focus {
  inset-inline-start: 0.5rem;
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── 3. App shell (was base.html's inline <style>) ── */
body.wateer-app-shell {
  background: var(--bg-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  /* Sticky + an explicit height, not the old `position: fixed` (which took
     it out of flow, needing .main-content's own margin-inline-start hack
     to compensate) -- a `position: fixed` sidebar only paints across the
     ORIGINAL viewport height, so a full-page screenshot of a page taller
     than one viewport showed the sidebar stopping partway down with bare
     background below it, even though a real scrolling user always saw it
     full-height. Sticky is a normal flex sibling: it is exactly as tall as
     the page (matching .main-content) and stays pinned to the viewport
     while scrolling either way. Mobile (<=991px) switches back to a fixed
     overlay drawer, below -- it must NOT push .main-content when closed. */
  position: sticky;
  inset-inline-start: 0;
  top: 0;
  height: 100dvh;
  z-index: 1000;
  transition: transform var(--duration-slow) var(--ease-default);
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .brand-icon {
  width: 140px;
  max-width: 100%;
  flex-shrink: 0;
  display: block;
  line-height: 0;
}

.sidebar-brand .brand-icon img#brandLogo {
  width: 100%;
  height: auto;
  max-height: 56px;
  object-fit: contain;
  display: block;
  vertical-align: middle;
}

.sidebar-brand h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.sidebar-brand small {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  opacity: 0.9;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  text-transform: none;
}

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; }

.nav-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.65); /* was .35 at 10px: 3.2:1 on the sidebar */
  padding: 1rem 0.75rem 0.5rem;
}

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  color: var(--text-sidebar);
  font-size: 0.88rem;
  font-weight: 500;
  /* Not `all`: that would also transition the visibility it inherits from a closed drawer, so the
     links stayed unfocusable for a frame after the drawer opened. */
  transition: background-color var(--duration-normal) var(--ease-default), color var(--duration-normal) var(--ease-default);
  margin-bottom: 2px;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}

.nav-link-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-link-item.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); }
.nav-link-item i { width: 20px; text-align: center; font-size: 1rem; opacity: 0.8; }
.nav-link-item.active i { opacity: 1; }
.nav-link-item:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, 0.08); }

.main-content { flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

@media (max-width: 991px) {
  /* Below the sidebar breakpoint it becomes an overlay drawer: fixed (out
     of flow, so a closed drawer takes no layout space) instead of the
     desktop's sticky-in-flow sidebar. */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    height: auto;
    transform: translateX(-100%);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  /* A closed drawer is only off-screen; visibility:hidden also takes its links out of the tab order
     and the accessibility tree (hidden after the slide-out, shown at once on open). */
  .sidebar {
    visibility: hidden;
    transition: transform var(--duration-slow) var(--ease-default), visibility 0s linear var(--duration-slow);
  }
  .sidebar.open { transform: translateX(0); visibility: visible; transition-delay: 0s; }
  /* No scrolling the page behind an open drawer. */
  body.nav-open { overflow: hidden; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: blur(12px);
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-title { font-size: 1.15rem; font-weight: 600; color: var(--text-primary); }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; justify-content: flex-end; }

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  min-width: 44px;
  min-height: 44px;
}
.mobile-toggle:hover { background: var(--accent-light); }
.mobile-toggle:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
/* Shown below 992px. It must come AFTER the base `.mobile-toggle { display: none }` rule above:
   the two have equal specificity, so source order decides, and the old copy inside the
   max-width:991px block (earlier in the file) always lost, leaving phones with no menu at all. */
@media (max-width: 991px) { .mobile-toggle { display: inline-flex; align-items: center; justify-content: center; } }

.theme-toggle {
  position: relative;
  width: 52px;
  height: 28px;
  background: var(--border-color);
  border-radius: 14px;
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-default);
  border: none;
  padding: 0;
}
.theme-toggle::before {
  content: '';
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--duration-normal) var(--ease-default);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
[data-theme="dark"] .theme-toggle { background: var(--accent); }
[data-theme="dark"] .theme-toggle::before { transform: translateX(24px); }
[dir="rtl"][data-theme="dark"] .theme-toggle::before { transform: translateX(-24px); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
/* The visible switch is 52x28; this transparent pseudo-element grows the tappable area to 52x44. */
.theme-toggle::after { content: ''; position: absolute; inset-block: -8px; inset-inline: 0; }
.theme-toggle-icons { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; height: 100%; font-size: 0.7rem; }
.theme-toggle-icons .fa-sun { color: var(--color-warning); }
.theme-toggle-icons .fa-moon { color: rgba(255, 255, 255, 0.7); }

.content-area { padding: 2rem; flex: 1; }
/* After the base .topbar/.content-area rules above: the same rules used to sit in the drawer's
   991px block, ahead of them, so the base padding won and phones kept the desktop 2rem gutters. */
@media (max-width: 991px) { .content-area { padding: 1.25rem; } .topbar { padding: 1rem 1.25rem; } }
@media (max-width: 576px) { .content-area { padding: 1rem; } }

.wateer-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal) var(--ease-default);
  overflow: hidden;
}
.wateer-card:hover { box-shadow: var(--shadow-md); }
.wateer-card .card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wateer-card .card-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin: 0; }
.wateer-card .card-body { padding: 1.5rem; }

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--duration-normal) var(--ease-default);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.stat-card .stat-info h4 { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.stat-card .stat-info .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); line-height: 1; }

.btn-wateer {
  background: var(--accent-gradient);
  color: var(--color-text-on-brand);
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  min-height: 44px;
}
.btn-wateer:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-brand); color: #fff; }
.btn-wateer:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.btn-outline-wateer {
  background: transparent;
  color: var(--accent-text);
  border: 1px solid var(--accent-text);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  min-height: 44px;
}
.btn-outline-wateer:hover { background: var(--accent-light); color: var(--accent-text); }
.btn-outline-wateer:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.form-control-wateer {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all var(--duration-fast) var(--ease-default);
  width: 100%;
  min-height: 44px;
}
.form-control-wateer:focus {
  outline: 2px solid var(--accent-text); /* a 1px border colour change alone is not a visible focus indicator */
  outline-offset: 1px;
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--bg-secondary);
}
.form-control-wateer::placeholder { color: var(--text-muted); }

.form-label-wateer {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-wateer { padding: 0.3rem 0.7rem; border-radius: var(--radius-sm); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-danger { background: var(--error-bg); color: var(--error-text); }
.badge-warning { background: rgba(245, 158, 11, 0.12); color: var(--color-warning); }
.badge-info { background: rgba(59, 130, 246, 0.12); color: var(--color-info); }

.wateer-toast {
  position: fixed;
  bottom: 2rem;
  inset-inline-end: 2rem;
  max-width: min(420px, calc(100vw - 2rem));
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding-block: 0.85rem;
  padding-inline: 1rem 0.75rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  z-index: var(--z-toast);
  transform: translateY(120%);
  opacity: 0;
  transition: all var(--duration-slow) var(--ease-default);
}
.wateer-toast.show { transform: translateY(0); opacity: 1; }
.wateer-toast .toast-body { display: flex; align-items: flex-start; gap: 0.65rem; flex: 1; min-width: 0; }
.wateer-toast-dismiss {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-block: -0.6rem 0;
  margin-inline: 0 -0.6rem;
}
.wateer-toast-dismiss:hover { background: var(--bg-primary); color: var(--text-primary); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 999; }
.sidebar-overlay.active { display: block; }

.amount-with-sar { display: inline-flex; align-items: center; gap: 0.35rem; }
.amount-with-sar .sar-icon { display: inline-flex; flex-shrink: 0; }
.amount-with-sar .sar-icon svg { width: 1em; height: 1em; vertical-align: middle; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fadeInUp 0.4s ease forwards; }
.animate-in-delay-1 { animation-delay: 0.1s; opacity: 0; }
.animate-in-delay-2 { animation-delay: 0.2s; opacity: 0; }
.animate-in-delay-3 { animation-delay: 0.3s; opacity: 0; }
.animate-in-delay-4 { animation-delay: 0.4s; opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .animate-in, .animate-in-delay-1, .animate-in-delay-2, .animate-in-delay-3, .animate-in-delay-4 {
    animation: none !important; opacity: 1 !important; transform: none !important;
  }
}

/* ── 4. Auth pages: login.html + signup.html (OTP flow) ── */
html.wateer-auth-html { min-height: 100%; min-height: 100dvh; }
body.wateer-auth-body {
  background: var(--bg-body);
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

.login-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
  min-height: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.login-top-controls {
  position: fixed;
  top: 0;
  inset-inline: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  padding: env(safe-area-inset-top) max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
}
.login-top-controls .theme-btn { margin-inline-start: auto; }

.theme-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-default);
  box-shadow: var(--shadow-sm);
}
.theme-btn:hover { transform: scale(1.05); border-color: var(--accent-text); color: var(--accent-text); }
.theme-btn:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.lang-toggle {
  display: flex;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.lang-toggle button {
  padding: 0 0.9rem;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  font-family: inherit;
}
.lang-toggle button:hover { background: var(--accent-light); color: var(--accent-text); }
.lang-toggle button.active { background: var(--accent); color: var(--color-accent-text, #fff); }
.lang-toggle button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: -2px; }

[data-theme="light"] .theme-btn .fa-sun { display: inline; }
[data-theme="light"] .theme-btn .fa-moon { display: none; }
[data-theme="dark"] .theme-btn .fa-sun { display: none; }
[data-theme="dark"] .theme-btn .fa-moon { display: inline; }

.login-card-wrap { width: 100%; max-width: 420px; flex-shrink: 0; }
.login-card {
  width: 100%;
  max-width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  overflow: hidden;
  position: relative;
  z-index: 10;
  animation: wateerSlideUp 0.5s ease;
}
@keyframes wateerSlideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .login-card { animation: none; } }

.login-card-header {
  background: var(--accent-gradient);
  padding: 2.5rem 2rem 2rem;
  text-align: center;
  color: var(--color-text-on-brand);
  position: relative;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.login-brand-icon { width: 56px; height: auto; max-height: 56px; object-fit: contain; margin: 0 auto 1rem; display: block; }
.login-card-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; word-wrap: break-word; }
.login-card-header p { opacity: 0.85; font-size: 0.88rem; word-wrap: break-word; }
.login-card-body { padding: 1.75rem 2rem 2rem; background: var(--bg-card); }

.msg-box { padding: 0.7rem 1rem; border-radius: var(--radius-md); margin-bottom: 1rem; font-size: 0.85rem; font-weight: 500; display: none; align-items: center; gap: 0.5rem; }
.msg-box.show { display: flex; }
.msg-box.error { background: var(--error-bg); color: var(--error-text); }
.msg-box.success { background: var(--success-bg); color: var(--success-text); }

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.04em; }

.input-wrap { position: relative; }
.input-wrap i { position: absolute; inset-inline-start: 0.9rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.88rem; }
.input-wrap input {
  width: 100%;
  /* Fully logical (padding-block/padding-inline), not the old physical
     `padding: T R B L` shorthand -- that hardcoded the icon-clearance gap
     to the LEFT regardless of direction. Logical properties alone were
     NOT enough, though: browsers give <input>/<textarea> their own
     default `direction: ltr` independent of the ancestor's `dir`
     attribute (confirmed live -- <html dir="rtl">'s computed direction
     is rtl, but a plain <input> inside it still computes ltr), so
     "padding-inline-start" on the INPUT resolved to physical LEFT even
     while the sibling icon/prefix (positioned on .input-wrap, not the
     input) correctly resolved inset-inline-start to physical RIGHT --
     two logical properties, two different physical sides, hence the
     overlap. `direction: inherit` pins the input to the SAME direction
     as its container so both resolve the same way. */
  direction: inherit;
  padding-block: 0.7rem;
  padding-inline: 2.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--bg-body);
  color: var(--text-primary);
  transition: all var(--duration-fast) var(--ease-default);
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}
.input-wrap input:focus { outline: 2px solid var(--accent-text); outline-offset: 1px; border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-light); background: var(--bg-card); }
.input-wrap input::placeholder { color: var(--text-muted); }
.input-prefix { /* the &lrm; in the markup keeps '+' (a neutral) on the left of the digits in RTL */ unicode-bidi: isolate; position: absolute; inset-inline-start: 2.5rem; top: 50%; transform: translateY(-50%); font-size: 0.9rem; color: var(--text-muted); font-weight: 500; pointer-events: none; }
.input-with-prefix { padding-inline-start: 5rem !important; }

#otp { direction: ltr; text-align: center; letter-spacing: 0.25em; padding-inline: 2.5rem; }
/* The code is always LTR digits, but the field's lock icon sits at the inline start of the (maybe RTL)
   container: pad both sides equally so centred digits clear the icon in either direction. */

.otp-consent-notice { display: none; align-items: flex-start; gap: 0.4rem; margin-top: 1rem; font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; text-align: center; }
.otp-consent-notice.show { display: flex; justify-content: center; flex-wrap: wrap; }
.otp-consent-notice a { color: var(--accent-text); text-decoration: none; font-weight: 500; }
.otp-consent-notice a:hover { text-decoration: underline; }
.otp-consent-notice i { font-size: 0.72rem; margin-top: 0.15rem; flex-shrink: 0; }

.otp-timer { text-align: center; font-size: 0.82rem; font-weight: 600; color: var(--error-text); margin-top: 0.65rem; display: none; }
.otp-timer.show { display: block; }

.btn-login {
  width: 100%;
  padding: 0.75rem 1rem;
  min-height: 48px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.btn-login:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.btn-primary-login { background: var(--accent-gradient); color: #fff; }
.btn-primary-login:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: var(--shadow-brand); }
.btn-primary-login:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-success-login { background: linear-gradient(135deg, #059669 0%, var(--color-success) 100%); color: #fff; }
.btn-success-login:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.25); }
.btn-success-login:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

#otpSection { display: none; }
#verifyOtpBtn { display: none; }

.login-card-footer { text-align: center; padding: 0 2rem 1.75rem; }
.login-card-footer p { font-size: 0.82rem; color: var(--text-muted); }
.login-card-footer a { color: var(--accent-text); text-decoration: none; font-weight: 500; }
.login-card-footer a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .login-main { padding-top: calc(env(safe-area-inset-top) + 3.5rem); padding-left: 0; padding-right: 0; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  .login-card-wrap { max-width: none; padding: 0 1rem; margin-top: 0; margin-bottom: 1rem; }
  .login-top-controls { padding: env(safe-area-inset-top) max(0.75rem, env(safe-area-inset-right)) 0 max(0.75rem, env(safe-area-inset-left)); }
  .theme-btn { width: 42px; height: 42px; font-size: 1rem; }
  .lang-toggle button { padding: 0 0.7rem; height: 42px; font-size: 0.8rem; }
  .login-card { border-radius: 14px; }
  .login-card-header { padding: 1.5rem 1.25rem 1.25rem; }
  .login-brand-icon { width: 48px; max-height: 48px; margin-bottom: 0.6rem; }
  .login-card-header h1 { font-size: 1.2rem; line-height: 1.3; }
  .login-card-header p { font-size: 0.8rem; line-height: 1.4; }
  .login-card-body { padding: 1.25rem; }
  .login-card-footer { padding: 0 1.25rem 1.25rem; padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); }
  .input-wrap input { font-size: 16px; min-height: 48px; }
  .msg-box { font-size: 0.8rem; padding: 0.6rem 0.85rem; }
  .btn-login { font-size: 1rem; min-height: 48px; }
}
@media (max-width: 360px) {
  .login-card-wrap { padding: 0 0.75rem; }
  .login-top-controls { padding: env(safe-area-inset-top) max(0.5rem, env(safe-area-inset-right)) 0 max(0.5rem, env(safe-area-inset-left)); }
  .lang-toggle button { padding: 0 0.5rem; font-size: 0.75rem; }
}

/* ── 5. Standalone legal/consent pages: privacy_policy.html + terms_of_use.html
   (privacy_center.html / privacy_index.html use design-system classes + their
   own small page-specific rules directly in-template — see those files) ── */
/* Bottom padding reserves room for .wateer-print-fab (fixed, 48px + 20px
   inset) so it never sits on top of the footer's text on a short page --
   the FAB stays fixed (so it's reachable without scrolling), the page
   keeps clear space below its own content instead. */
.wateer-legal-page { max-width: 1000px; margin: 0 auto; padding: 20px; padding-bottom: max(88px, env(safe-area-inset-bottom)); }

.wateer-legal-header {
  background: var(--accent-gradient);
  color: var(--color-text-on-brand);
  padding: 40px 0;
  text-align: center;
  margin-bottom: 30px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.wateer-legal-header::after { content: ''; position: absolute; inset-inline-end: -40px; top: -40px; width: 200px; height: 200px; background: rgba(255, 255, 255, 0.06); border-radius: 50%; }
.wateer-legal-header::before { content: ''; position: absolute; inset-inline-start: -30px; bottom: -50px; width: 150px; height: 150px; background: rgba(255, 255, 255, 0.04); border-radius: 50%; }
.wateer-legal-header h1 { font-size: 2.5rem; margin-bottom: 10px; font-weight: 700; position: relative; z-index: 1; color: #fff; }
.wateer-legal-header .version-info { font-size: 1.1rem; opacity: 0.9; position: relative; z-index: 1; }

.wateer-legal-content {
  background: var(--bg-card);
  padding: 40px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  margin-bottom: 30px;
}
.wateer-legal-content table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 0.95rem; }
.wateer-legal-content th, .wateer-legal-content td { border: 1px solid var(--border-color); padding: 10px 14px; text-align: start; color: var(--text-secondary); vertical-align: top; }
.wateer-legal-content th { background: var(--color-bg-tertiary); color: var(--text-primary); font-weight: 600; }
.wateer-legal-content section { margin-bottom: 30px; }
.wateer-legal-content h2 { color: var(--accent-text); border-bottom: 2px solid var(--border-color); padding-bottom: 10px; margin-bottom: 20px; font-size: 1.8rem; }
.wateer-legal-content h3 { color: var(--text-secondary); margin: 20px 0 15px 0; font-size: 1.3rem; }
.wateer-legal-content p { margin-bottom: 15px; font-size: 1.05rem; color: var(--text-secondary); }
.wateer-legal-content ul, .wateer-legal-content ol { margin: 15px 0; padding-inline-start: 30px; color: var(--text-secondary); }
.wateer-legal-content li { margin-bottom: 8px; }
.wateer-legal-content strong { color: var(--accent-text); }
.wateer-legal-content a { color: var(--accent-text); text-decoration: none; }
.wateer-legal-content a:hover { text-decoration: underline; }

.wateer-legal-footer { text-align: center; padding: 20px; color: var(--footer-text); border-top: 1px solid var(--border-color); margin-top: 30px; }
.wateer-legal-footer a { color: var(--accent-text); text-decoration: none; }
.wateer-legal-footer a:hover { text-decoration: underline; }

.wateer-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent-gradient);
  color: #fff;
  padding: 12px 24px;
  text-decoration: none;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  transition: all var(--duration-normal) var(--ease-default);
  font-weight: 500;
  font-size: 0.9rem;
  min-height: 44px;
}
.wateer-back-link:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-brand); color: #fff; }
.wateer-back-link:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.wateer-no-policy { text-align: center; padding: 40px; background: var(--bg-card); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border-color); }
.wateer-no-policy h2 { color: var(--text-muted); margin-bottom: 15px; }
.wateer-no-policy p { color: var(--text-secondary); }

.wateer-changelog {
  background: var(--changelog-bg);
  border-inline-start: 4px solid var(--accent-text);
  padding: 20px;
  margin: 30px 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
[dir="rtl"] .wateer-changelog { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.wateer-changelog h3 { color: var(--accent-text); margin-top: 0; }
.wateer-changelog p { color: var(--text-secondary); }

.wateer-print-fab {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  width: 48px;
  height: 48px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  z-index: 100;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-default);
}
.wateer-print-fab:hover { transform: scale(1.05); }
.wateer-print-fab:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

@media (max-width: 768px) {
  .wateer-legal-header { padding: 30px 20px; }
  .wateer-legal-header h1 { font-size: 2rem; }
  .wateer-legal-content { padding: 25px; }
  .wateer-legal-content h2 { font-size: 1.5rem; }
  .wateer-legal-content h3 { font-size: 1.2rem; }
}
@media (max-width: 480px) {
  .wateer-legal-header h1 { font-size: 1.8rem; }
  .wateer-legal-content { padding: 20px; }
  .wateer-legal-content h2 { font-size: 1.3rem; }
}
@media print {
  .wateer-back-link, .wateer-legal-footer, .theme-btn, .wateer-print-fab { display: none !important; }
  .wateer-legal-header { background: var(--brand-900) !important; -webkit-print-color-adjust: exact; }
  body { background: #fff !important; color: #333 !important; }
  .wateer-legal-content { box-shadow: none !important; border: none !important; }
}

/* ── 6. Brand surfaces ──
   The design system's own base/reset.css sets `h1..h6 { color:
   var(--color-text-primary) }` GLOBALLY (right for a whole page, wrong for
   a bespoke colored banner) — a heading with no color of its own no longer
   inherits the container's white text once that rule exists; found live on
   two banners during the 2026-09-27 reskin's own screenshots (dashboard
   welcome banner, login/signup card header), the coordinator's review
   found a third (privacy/terms hero) the same session.

   Fix once, here, not per page: every container that fills itself with
   --accent-gradient gets the marker class "brand-surface" in its template,
   and every heading/paragraph inside one reads --color-text-on-brand
   instead of a hardcoded #fff. A new container only needs the class, not a
   new color rule — test_brand_surface_headings_use_token.py greps every
   template for a --accent-gradient container missing the class, so this
   can't quietly regress a fourth time. */
.brand-surface,
.brand-surface h1,
.brand-surface h2,
.brand-surface h3,
.brand-surface h4,
.brand-surface p {
  color: var(--color-text-on-brand);
}

/* ── 7. Focus-visible baseline (WCAG) for every interactive element the
   design-system's own reset does not already cover on this portal ── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

/* Bootstrap's modal close button is 32px; make it a 44px target on touch screens. */
@media (pointer: coarse) { .btn-close { min-width: 44px; min-height: 44px; } }
