/* =============================================================================
   styles.css — Design tokens, CSS reset, base styles, shell components
   All layout-specific rules live in mobile.css / desktop.css / rtl.css.
   All values come from design/LMP_Attendance_Screens_v3.html.
   ============================================================================= */

/* ── Fonts ──────────────────────────────────────────────────────────────────── */
/* Tajawal is the prototype's specified typeface — it covers both Arabic and
   Latin scripts in a single family, eliminating rendering inconsistencies when
   mixing scripts within one element. */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

/* ── Design tokens ──────────────────────────────────────────────────────────── */
/* All values extracted from design/LMP Attendance Screens v3 - HeroUI.         */
:root {
  /* ── Primary accent — HeroUI default blue ── */
  --c-primary:        oklch(0.62 0.195 254);   /* #2563EB-ish, from prototype  */
  --c-primary-hover:  oklch(0.56 0.195 254);   /* pressed / hover state        */
  --c-primary-active: oklch(0.50 0.195 254);   /* active / keyboard focus      */
  --c-primary-dim:    oklch(0.965 0.035 253);  /* soft tint for rings / fills  */
  --c-primary-mid:    oklch(0.82 0.12 254);    /* pulse ring border            */

  /* ── Status — four attendance states ── */
  --c-present:        oklch(0.733 0.194 151);  /* green — حاضر                 */
  --c-present-bg:     oklch(0.965 0.05 150);   /* soft green surface           */
  --c-present-border: oklch(0.88 0.09 150);    /* subtle green border          */

  --c-late:           oklch(0.782 0.158 72);   /* amber — متأخر                */
  --c-late-bg:        oklch(0.965 0.05 72);    /* soft amber surface           */
  --c-late-border:    oklch(0.895 0.09 72);    /* subtle amber border          */

  --c-absent:         oklch(0.627 0.206 27);   /* red-orange — غائب            */
  --c-absent-bg:      oklch(0.965 0.04 27);    /* soft red surface             */
  --c-absent-border:  oklch(0.875 0.09 27);    /* subtle red border            */

  /* On Leave — mapped to primary blue (matches prototype --onleave: var(--accent)) */
  --c-leave:          oklch(0.62 0.195 254);
  --c-leave-bg:       oklch(0.965 0.035 253);
  --c-leave-border:   oklch(0.87 0.07 253);

  /* On Mission — violet. Deliberately far from leave blue and holiday teal:
     "working off-site" must never be mistaken for "not working" at a glance */
  --c-mission:        oklch(0.53 0.19 300);
  --c-mission-bg:     oklch(0.965 0.035 300);
  --c-mission-border: oklch(0.87 0.075 300);

  /* Holiday — teal-slate to distinguish from leave */
  --c-holiday:        oklch(0.55 0.14 190);
  --c-holiday-bg:     oklch(0.965 0.04 190);
  --c-holiday-border: oklch(0.87 0.07 190);

  /* Pending sync / unresolved */
  --c-pending:        oklch(0.65 0.15 70);
  --c-pending-bg:     oklch(0.97 0.03 70);
  --c-pending-border: oklch(0.90 0.06 70);

  /* ── Surfaces ── */
  --c-bg:             oklch(0.9702 0 0);       /* page background              */
  --c-surface:        oklch(1 0 0);            /* cards, panels                */
  --c-surface-alt:    oklch(0.985 0 0);        /* zebra table rows             */
  --c-surface-raised: oklch(0.97 0 0);         /* input backgrounds            */
  --c-surface-hover:  oklch(0.96 0 0);         /* hover state                  */
  --c-border:         oklch(0.918 0.005 286);  /* default border               */
  --c-border-strong:  oklch(0.871 0.006 286);  /* strong border / divider      */
  --c-overlay:        rgba(15, 23, 42, 0.42);

  /* ── Text ── */
  --c-text:           oklch(0.2103 0.0059 286); /* primary text — eclipse       */
  --c-text-secondary: oklch(0.45 0.014 286);    /* secondary / label text       */
  --c-text-muted:     oklch(0.5517 0.014 286);  /* muted / placeholder text     */
  --c-text-inverse:   oklch(0.9911 0 0);        /* text on dark surfaces        */
  --c-text-link:      oklch(0.62 0.195 254);    /* inline links                 */

  /* ── Special surfaces ── */
  --c-navy:           oklch(0.27 0.10 256); /* sidebar — navy blue  */

  /* ── Typography ── */
  --font:             'Tajawal', sans-serif;   /* from prototype @font-face     */

  /* Type scale */
  --text-xs:    0.75rem;      /* 12px — captions, timestamps  */
  --text-sm:    0.8125rem;    /* 13px — labels, badges        */
  --text-base:  0.9375rem;    /* 15px — body copy             */
  --text-md:    1.0625rem;    /* 17px — sub-headings          */
  --text-lg:    1.25rem;      /* 20px — screen titles         */
  --text-xl:    1.625rem;     /* 26px — section headers       */
  --text-2xl:   2.25rem;      /* 36px — stat numbers          */
  --text-hero:  3rem;         /* 48px — check-in button label */

  /* Font weights — Tajawal supports 300 400 500 700 800 */
  --fw-light:   300;
  --fw-normal:  400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;
  --fw-black:   800;

  /* Line heights */
  --lh-tight:   1.2;
  --lh-snug:    1.35;
  --lh-base:    1.6;
  --lh-relaxed: 1.75;

  /* Spacing — 4px base unit */
  --sp-1:  0.25rem;   /*  4px */
  --sp-2:  0.5rem;    /*  8px */
  --sp-3:  0.75rem;   /* 12px */
  --sp-4:  1rem;      /* 16px */
  --sp-5:  1.25rem;   /* 20px */
  --sp-6:  1.5rem;    /* 24px */
  --sp-8:  2rem;      /* 32px */
  --sp-10: 2.5rem;    /* 40px */
  --sp-12: 3rem;      /* 48px */
  --sp-16: 4rem;      /* 64px */

  /* Border radius — HeroUI generous scale */
  --r-sm:   6px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-2xl:  20px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 3px 8px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 16px 40px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.07);

  /* Navigation */
  --sidebar-w:   220px;         /* matches prototype sidebar width  */
  --nav-h:       64px;          /* bottom tab bar height            */
  --header-h:    52px;          /* mobile top bar height            */

  /* Motion */
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:   cubic-bezier(0.4, 0, 1, 1);
  --ease-io:   cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:  100ms;
  --dur-base:  200ms;
  --dur-slow:  350ms;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: var(--fw-normal);
  line-height: var(--lh-base);
  color: var(--c-text);
  background-color: var(--c-bg);
  min-height: 100dvh;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Full-page background image — fixed behind all content at 15% opacity (85% transparent) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url('../background.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  opacity: 0.15;
  pointer-events: none;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5, h6 { font-weight: var(--fw-semi); line-height: var(--lh-tight); }
button { cursor: pointer; border: none; background: none; }
input, textarea, select {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-dim);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── App shell ──────────────────────────────────────────────────────────────── */
/* Layout is controlled by mobile.css / desktop.css. These are base rules only. */

#nav {
  position: fixed;
  z-index: 100;
}

#app {
  position: relative;
  min-height: 100dvh;
  min-height: 100vh;
}

/* Classes toggled by renderNav() */
#app.app-with-bottom-nav {
  padding-block-end: var(--nav-h);
}
#app.app-with-sidebar {
  margin-inline-start: var(--sidebar-w);
}

/* ── Loading screen ─────────────────────────────────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  transition: opacity var(--dur-slow) var(--ease-out);
}

#loading-screen.loading-hide {
  opacity: 0;
  pointer-events: none;
}

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-8);
}

.loading-logo-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}

.loading-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.loading-logo-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--r-xl);
  background: var(--c-primary);
  color: var(--c-text-inverse);
  font-weight: var(--fw-bold);
  font-size: var(--text-md);
  letter-spacing: 0.02em;
}

.loading-app-name {
  font-size: var(--text-lg);
  font-weight: var(--fw-semi);
  color: var(--c-text);
  letter-spacing: 0.01em;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--c-primary-dim);
  border-top-color: var(--c-primary);
  border-radius: var(--r-full);
  animation: spin 0.75s linear infinite;
  margin-block-start: var(--sp-2);
}

.loading-status {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  min-height: 1.2em;
  text-align: center;
}

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

/* ── Setup screen ───────────────────────────────────────────────────────────── */
#setup-screen {
  position: fixed;
  inset: 0;
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  padding: var(--sp-6);
}

#setup-screen[hidden] { display: none; }

.setup-card {
  width: 100%;
  max-width: 400px;
  background: var(--c-surface);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.setup-logo-wrap {
  display: flex;
  justify-content: center;
  margin-block-end: var(--sp-2);
}

.setup-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.setup-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  text-align: center;
  color: var(--c-text);
}

.setup-description {
  font-size: var(--text-sm);
  color: var(--c-text-secondary);
  text-align: center;
  line-height: var(--lh-relaxed);
}

.setup-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-secondary);
}

.setup-input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  text-align: start;
  direction: ltr;
}

.setup-error {
  font-size: var(--text-sm);
  color: var(--c-absent);
  text-align: center;
}
.setup-error[hidden] { display: none; }

.setup-btn {
  width: 100%;
  margin-block-start: var(--sp-2);
}

/* ── Base button ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  line-height: 1;
  transition: background var(--dur-fast) var(--ease-io),
              box-shadow var(--dur-fast) var(--ease-io),
              opacity var(--dur-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--c-primary);
  color: var(--c-text-inverse);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--c-primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--c-primary-active); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) { background: var(--c-surface-hover); }

.btn-ghost {
  background: transparent;
  color: var(--c-text-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--c-surface-hover); }

.btn-danger {
  background: var(--c-absent);
  color: var(--c-text-inverse);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  border-radius: var(--r-sm);
}

/* ── Base form field ────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.field-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-secondary);
}

.field-input {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-base);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  width: 100%;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.field-error {
  font-size: var(--text-xs);
  color: var(--c-absent);
}

/* ── Status badges ──────────────────────────────────────────────────────────── */
/* Extracted from prototype StatusBadge component:
   padding 3px 10px · border-radius 20px · fontSize 12 · fontWeight 600
   A 6×6 px dot (::before) uses currentColor to match the text tint.          */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-semi);
  line-height: 1;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
  flex-shrink: 0;
}

.badge-present  { background: var(--c-present-bg);  color: var(--c-present);  }
.badge-late     { background: var(--c-late-bg);     color: var(--c-late);     }
.badge-absent   { background: var(--c-absent-bg);   color: var(--c-absent);   }
.badge-leave    { background: var(--c-leave-bg);    color: var(--c-leave);    }
.badge-mission  { background: var(--c-mission-bg);  color: var(--c-mission);  }
.badge-holiday  { background: var(--c-holiday-bg);  color: var(--c-holiday);  }
.badge-pending  { background: var(--c-pending-bg);  color: var(--c-pending);  }

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-5);
  transition: border-color var(--dur-base) var(--ease-io),
              box-shadow var(--dur-base) var(--ease-io),
              transform var(--dur-base) var(--ease-io);
}

.card:hover,
.card:focus-within {
  border-color: var(--c-primary-mid);
  box-shadow: 0 0 0 1px var(--c-primary-mid),
              0 0 24px 4px var(--c-primary-dim),
              var(--shadow-md);
  transform: translateY(-3px);
}

/* ── View placeholder ───────────────────────────────────────────────────────── */
.view-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60dvh;
  min-height: 60vh;
  padding: var(--sp-8);
}

.view-placeholder-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  text-align: center;
}

.view-placeholder-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.view-placeholder-label {
  font-size: var(--text-md);
  font-weight: var(--fw-medium);
  color: var(--c-text-secondary);
}

.view-placeholder-route {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

/* ── Toast / snackbar ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  inset-block-end: calc(var(--nav-h) + var(--sp-4));
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: center;
  pointer-events: none;
  width: min(calc(100vw - var(--sp-8)), 400px);
}

.toast {
  background: var(--c-text);
  color: var(--c-text-inverse);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
  pointer-events: all;
  text-align: center;
  max-width: 100%;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success  { background: var(--c-present);  }
.toast-error    { background: var(--c-absent);   }
.toast-warning  { background: var(--c-late);     color: var(--c-text); }
.toast-info     { background: var(--c-primary);  }

/* ── api.js cold-start connecting banner ────────────────────────────────────── */
/* Injected by api.js when the loading screen is no longer visible.
   Shown only once — on the first API call after the loading screen hides. */
.api-connecting-banner {
  position: fixed;
  inset-block-start: var(--sp-4);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 9400;
  background: var(--c-text);
  color: var(--c-text-inverse);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  pointer-events: none;
  animation: connecting-pulse 1.4s ease-in-out infinite;
}

@keyframes connecting-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

/* ── Sync indicator (inline badge, used inside view headers) ────────────────── */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
}
.sync-indicator::before {
  content: '●';
  font-size: 0.5em;
}
.sync-pending { color: var(--c-late); }
.sync-synced  { color: var(--c-present); }
.sync-error   { color: var(--c-absent); }

/* ── Offline sync status bar (injected by offline.js) ──────────────────────── */
/* Fixed pill above the bottom nav (or top of screen on desktop).              */
.sync-bar {
  position: fixed;
  inset-block-end: calc(var(--nav-h) + var(--sp-3));
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 9200;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  transition: opacity var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
}

.sync-bar-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(6px);
  pointer-events: none;
}

.sync-bar-pending {
  background: var(--c-late-bg);
  color: var(--c-late);
  border: 1px solid var(--c-late-border);
}

.sync-bar-synced {
  background: var(--c-present-bg);
  color: var(--c-present);
  border: 1px solid var(--c-present-border);
}

/* On desktop the bottom nav is hidden; reposition bar to the top */
@media (min-width: 900px) {
  .sync-bar {
    inset-block-end: auto;
    inset-block-start: var(--sp-4);
  }
}

/* ── App update banner — bottom floating card, slides up from below ─────────── */
/*    Sits above the bottom nav on mobile; clears the sidebar on desktop.        */
.update-banner {
  position: fixed;
  inset-block-end: calc(var(--nav-h) + var(--sp-3));
  inset-inline-start: var(--sp-4);
  inset-inline-end: var(--sp-4);
  z-index: 9300;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 14px 16px;
  background: var(--c-navy);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  border-radius: var(--r-xl);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.14);
  animation: _update-slide-up var(--dur-slow) var(--ease-out) both;
}

.update-banner[hidden] { display: none; }

@keyframes _update-slide-up {
  from { transform: translateY(calc(100% + var(--sp-3))); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* On desktop: not competing with the bottom nav, nudge down slightly */
@media (min-width: 900px) {
  .update-banner {
    inset-block-end: var(--sp-5);
    max-width: 420px;
  }
}

.update-banner-msg {
  flex: 1;
  line-height: var(--lh-snug);
}

/* 'Update Now' button — solid primary, visible against dark banner */
.update-banner-btn {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: var(--r-full);
  background: var(--c-primary);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--fw-semi);
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition: background var(--dur-fast);
  white-space: nowrap;
}

.update-banner-btn:hover {
  background: var(--c-primary-hover);
}

/* ── Overlay / modal backdrop ───────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--c-overlay);
  z-index: 800;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
  pointer-events: none;
}
.overlay.overlay-visible {
  opacity: 1;
  pointer-events: all;
}

/* ── Divider ────────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--c-border);
  border: none;
  margin-block: var(--sp-4);
}

/* ── Utility: visually hidden (accessible) ──────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Skeleton loader ────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--c-border) 0%,
    var(--c-surface-raised) 40%,
    var(--c-border) 80%
  );
  background-size: 300% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--r-md);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-8);
  text-align: center;
}

.empty-state-icon {
  font-size: 3rem;
  line-height: 1;
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--text-md);
  font-weight: var(--fw-semi);
  color: var(--c-text-secondary);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  max-width: 260px;
  line-height: var(--lh-relaxed);
}

/* ── Auth screens ───────────────────────────────────────────────────────────── */
/* Login and password-change screens rendered by auth.js                        */

.auth-screen {
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: var(--sp-4);
  position: relative;
}

/* Top bar — spans the full width; back button at start, lang toggle at end */
.auth-top-bar {
  position: absolute;
  inset-block-start: var(--sp-3);
  inset-inline-start: var(--sp-3);
  inset-inline-end: var(--sp-3);
  display: flex;
  align-items: center;
  z-index: 10;
}

.auth-lang-btn,
.auth-back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-secondary);
  background: transparent;
  border: none;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  line-height: 1;
}
.auth-lang-btn:hover,
.auth-back-btn:hover {
  background: var(--c-surface-hover);
  color: var(--c-text);
}

/* Push the lang button to the inline-end of the bar (works with 0 or 1 back buttons) */
.auth-lang-btn {
  margin-inline-start: auto;
}

/* ── Card ── */
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--c-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: _auth-enter var(--dur-slow) var(--ease-out) both;
}

@keyframes _auth-enter {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ── Branded header strip ── */
.auth-card-header {
  background: var(--c-primary);
  padding: var(--sp-8) var(--sp-6) var(--sp-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  text-align: center;
}

/* Password-change variant — slightly deeper blue to signal required action */
.auth-card-header-change {
  background: var(--c-primary-hover);
}

.auth-logo-wrap {
  width: 56px;
  height: 56px;
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-block-end: var(--sp-1);
  flex-shrink: 0;
}

.auth-logo-wrap svg {
  display: block;
}

.auth-lock-icon {
  color: rgba(255, 255, 255, 0.9);
  margin-block-end: var(--sp-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-app-name {
  font-size: var(--text-md);
  font-weight: var(--fw-semi);
  color: white;
  line-height: var(--lh-tight);
}

.auth-app-tagline {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.72);
  line-height: var(--lh-snug);
}

/* ── Card body (form area) ── */
.auth-card-body {
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-block-end: var(--sp-2);
}

/* ── Inline error ── */
.auth-error {
  background: var(--c-absent-bg);
  border: 1px solid var(--c-absent-border);
  color: var(--c-absent);
  font-size: var(--text-sm);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  line-height: var(--lh-snug);
  margin-block-end: var(--sp-3);
}
.auth-error[hidden] { display: none; }

/* ── Password input + eye toggle ── */
.auth-input-wrap {
  position: relative;
}
.auth-input-wrap .field-input {
  padding-inline-end: 2.75rem;
  width: 100%;
}
.auth-pw-input {
  letter-spacing: 0.05em; /* tiny spacing improves masked password readability */
}

.auth-eye-btn {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: var(--sp-3);
  transform: translateY(-50%);
  color: var(--c-text-muted);
  background: transparent;
  border: none;
  padding: var(--sp-1);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.auth-eye-btn:hover {
  color: var(--c-text-secondary);
  background: var(--c-surface-hover);
}

/* ── Submit button ── */
.auth-submit {
  width: 100%;
  padding-block: var(--sp-3);
  font-size: var(--text-base);
  font-weight: var(--fw-semi);
  letter-spacing: 0.02em;
  margin-block-start: var(--sp-1);
}

/* ── Footer ── */
.auth-footer {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  text-align: center;
  margin-block-start: var(--sp-5);
}

/* ── Password requirements (change-password screen) ── */
.auth-requirements {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-1) 0 var(--sp-3);
}

.auth-requirement {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  line-height: var(--lh-tight);
  transition: color var(--dur-base);
}

.auth-requirement.met {
  color: var(--c-present);
}

/* Dot indicator — filled when requirement is met */
.auth-req-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--c-border-strong);
  flex-shrink: 0;
  transition: background var(--dur-base);
}

.auth-requirement.met .auth-req-dot {
  background: var(--c-present);
}

/* ── Tight screens ── */
@media (max-width: 400px) {
  .auth-card       { border-radius: var(--r-lg); }
  .auth-card-header { padding: var(--sp-6) var(--sp-5) var(--sp-5); }
  .auth-card-body  { padding: var(--sp-5); }
}
