/* ============================================================
   Sharjah Sports Council — corporate identity
   ------------------------------------------------------------
   Palette (from brand guide page 6):
     Navy   #183254   primary
     Gold   #CFA762   accent
     White  #FFFFFF   surface
     Grey   #CCCCCC   neutral
   Motifs:
     - Gold "tab" hanging from the top of every page
     - Repeating arched pattern (mihrab/door silhouette)
   Type: Cairo (closest open-source match for Sakkal Majalla)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Brand colors — exact match to the guide */
  --navy:        #183254;
  --navy-deep:   #0e2138;
  --navy-soft:   #2c4a73;
  --navy-tint:   #eef1f6;

  --gold:        #cfa762;
  --gold-soft:   #e6d0a6;
  --gold-deep:   #a8843f;
  --gold-tint:   #faf5eb;

  --grey:        #cccccc;
  --grey-soft:   #e8e8e8;

  /* Functional aliases used through the app */
  --bg:          #ffffff;
  --surface:     #ffffff;
  --surface-2:   #fbfaf6;
  --ink:         var(--navy);
  --ink-soft:    var(--navy-soft);
  --text:        #1a1a1a;
  --muted:       #6b7180;
  --muted-soft:  #a8aeb8;
  --line:        #e8e2d0;
  --line-strong: #d4cbb1;
  --accent:      var(--gold);
  --accent-deep: var(--gold-deep);
  --success:     #2f6e3a;
  --danger:      #b3261e;
  --danger-soft: #e0a8a3;

  --sans: 'Cairo', 'Sakkal Majalla', 'Segoe UI', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --radius:    4px;
  --radius-lg: 10px;
  --shadow:    0 1px 0 rgba(24,50,84,.04), 0 2px 12px rgba(24,50,84,.05);
  --shadow-lg: 0 8px 32px rgba(24,50,84,.10);

  /* Brand tab dimensions */
  --tab-w:  28px;
  --tab-h:  88px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

/* RTL gets a touch more line-height because Arabic glyphs are taller */
html[dir="rtl"] body { line-height: 1.75; letter-spacing: 0; }
html[dir="rtl"] { font-feature-settings: "kern", "liga"; }

body { min-height: 100vh; }

/* ----- Page-wide ambient: faint arch motif as watermark ---- */
/* The shape is the recognisable Sharjah arch/mihrab silhouette,
   tiled as a CSS background at very low opacity. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='62' viewBox='0 0 60 62'><g fill='none' stroke='%23cfa762' stroke-width='0.6'><path d='M4 60 L4 26 C4 12 14 4 30 4 C46 4 56 12 56 26 L56 60'/><path d='M14 60 L14 32 C14 22 21 16 30 16 C39 16 46 22 46 32 L46 60'/></g></svg>");
  background-size: 60px 62px;
  background-position: top left;
  opacity: 0.18;
}

a { color: var(--accent-deep); text-decoration: none; }
a:hover { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }

/* ----- Typography ------------------------------------------ */
h1, h2, h3, h4 {
  font-family: var(--sans);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.015em;
  line-height: 1.2;
}
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; font-weight: 600; }

.eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--gold-deep);
}

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }

/* ----- Gold "tab" — the signature brand element ------------ */
/* Hangs from the top of a card or page header. Recreates the
   rounded-bottom rectangle shown on every page of the guide. */
.brand-tab {
  position: absolute;
  top: 0;
  left: 36px;
  width: var(--tab-w);
  height: var(--tab-h);
  background: var(--gold);
  border-radius: 0 0 var(--tab-w) var(--tab-w) / 0 0 40% 40%;
  z-index: 2;
}
.brand-tab::after {
  /* subtle inner highlight to give the tab a hint of dimension */
  content: '';
  position: absolute;
  left: 2px; right: 2px; top: 0; bottom: 6px;
  background: linear-gradient(180deg, rgba(255,255,255,.18) 0%, transparent 25%);
  border-radius: inherit;
}

/* ----- Brand logo (Sharjah Sports Council mark) ----------- */
.brand-logo {
  height: 38px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.brand-logo-lg {
  height: 96px;
  width: auto;
  display: block;
  margin: 0 auto 14px;
}

/* ----- Brand mark (arch silhouette icon) ------------------- */
.brand-mark {
  display: inline-block;
  width: 36px;
  height: 44px;
  background-color: var(--gold);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 40'><path d='M2 40 L2 18 C2 8 8 2 16 2 C24 2 30 8 30 18 L30 40 Z M13 40 L13 28 C13 23 14 21 16 21 C18 21 19 23 19 28 L19 40 Z' fill-rule='evenodd'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 40'><path d='M2 40 L2 18 C2 8 8 2 16 2 C24 2 30 8 30 18 L30 40 Z M13 40 L13 28 C13 23 14 21 16 21 C18 21 19 23 19 28 L19 40 Z' fill-rule='evenodd'/></svg>") center/contain no-repeat;
}

/* ----- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .18s ease;
  user-select: none;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-deep); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(24,50,84,.18); }

.btn-accent   { background: var(--gold); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--gold-deep); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(168,132,63,.25); }

.btn-ghost    { background: #fff; color: var(--navy); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--gold-tint); border-color: var(--gold-soft); color: var(--gold-deep); }

.btn-danger   { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ----- Form fields ----------------------------------------- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
  margin-bottom: 7px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(207,167,98,.18);
}

/* ----- Cards / panels -------------------------------------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

/* ----- Auth pages ------------------------------------------ */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 76px 44px 36px;
  box-shadow: var(--shadow-lg);
  overflow: visible;
  animation: fadeUp .55s cubic-bezier(.2,.7,.3,1) both;
}
/* Gold tab hanging from the top of the auth card */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 44px;
  width: var(--tab-w); height: var(--tab-h);
  background: var(--gold);
  border-radius: 0 0 var(--tab-w) var(--tab-w) / 0 0 40% 40%;
}
.auth-card::after {
  /* hint of an inner highlight on the tab */
  content: '';
  position: absolute;
  top: 0; left: 46px;
  width: calc(var(--tab-w) - 4px); height: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.22), transparent);
  border-radius: 0 0 4px 4px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}
.auth-brand .brand-mark {
  margin-bottom: 14px;
}
.auth-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--navy);
}
.auth-card .subtitle {
  color: var(--muted);
  font-size: 13.5px;
}
.auth-foot {
  text-align: center;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

/* ----- App shell ------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.app-header-inner {
  position: relative;
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 32px 18px 88px;     /* extra left padding for the tab */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
/* In RTL the tab stays on the left (per the brand guide); we still want the
   88px breathing room next to it, so we keep the rule un-flipped. */
html[dir="rtl"] .app-header-inner {
  padding: 18px 32px 18px 88px;
}
.app-header-inner::before {
  /* the gold tab on every page, matching the brand guide */
  content: '';
  position: absolute;
  top: 0; left: 36px;
  width: var(--tab-w); height: 62px;
  background: var(--gold);
  border-radius: 0 0 var(--tab-w) var(--tab-w) / 0 0 50% 50%;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--navy);
}
.brand .brand-mark { width: 22px; height: 28px; }
.brand .name {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.brand .name .sub {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--gold-deep);
  margin-top: 2px;
}
html[dir="rtl"] .brand .name .sub {
  letter-spacing: 0.05em;   /* Arabic doesn't tolerate huge tracking */
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}
.user-chip .name { color: var(--navy); font-weight: 600; }

.app-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 32px 80px;
  position: relative;
  z-index: 1;
}

/* ----- Dashboard hero -------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 24px;
  margin-bottom: 40px;
}
@media (max-width: 880px) { .hero { grid-template-columns: 1fr; } }

.hero-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 36px 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero-card.primary {
  background:
    radial-gradient(circle at 100% 0%, rgba(207,167,98,.18) 0%, transparent 55%),
    linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  border-color: transparent;
}
.hero-card.primary::after {
  /* faint arch motif overlay in the top-right of the dark card */
  content: '';
  position: absolute;
  top: -10px; right: -10px;
  width: 240px; height: 240px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='42' viewBox='0 0 40 42'><g fill='none' stroke='%23cfa762' stroke-width='0.7'><path d='M3 40 L3 18 C3 9 10 3 20 3 C30 3 37 9 37 18 L37 40'/></g></svg>");
  background-size: 40px 42px;
  opacity: 0.22;
  pointer-events: none;
}
.hero-card.primary .eyebrow { color: var(--gold-soft); }
.hero-card.primary h2, .hero-card.primary h3 { color: #fff; }
.hero-card.primary .muted { color: rgba(255,255,255,.55); }

.hero-card .clock {
  font-family: var(--sans);
  font-weight: 300;
  font-size: 4.2rem;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 14px 0 6px;
  color: #fff;
  font-feature-settings: 'tnum';
}
.hero-card .date {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,.6);
}
.hero-card .action-area {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,.10);
  position: relative;
  z-index: 1;
}
.action-area .next-label {
  font-size: 11px;
  color: var(--gold-soft);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.20em;
  font-weight: 600;
}
.big-btn {
  width: 100%;
  padding: 22px;
  font-family: var(--sans);
  font-size: 1.35rem;
  font-weight: 700;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s;
  letter-spacing: 0.02em;
}
.big-btn:hover:not(:disabled) {
  background: var(--gold-deep);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(207,167,98,.4);
}
.big-btn:disabled { opacity: .55; cursor: not-allowed; }
.big-btn.checkout {
  background: #fff;
  color: var(--navy);
}
.big-btn.checkout:hover:not(:disabled) {
  background: var(--gold-soft);
  color: var(--navy);
}

/* Status panel */
.status-panel { padding: 36px 32px; }
.status-panel h3 { margin-bottom: 16px; }
.status-row {
  display: flex; justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.status-row:last-child { border-bottom: none; }
.status-row .label { color: var(--muted); }
.status-row .value { font-family: var(--mono); font-size: 12px; color: var(--text); }
.status-row .value.in  { color: var(--success); }
.status-row .value.out { color: var(--gold-deep); }

/* History list */
.history h3 { margin-bottom: 16px; }
.log-list { display: grid; gap: 8px; }
.log-item {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 16px;
  padding: 14px 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  align-items: center;
  font-size: 13px;
  transition: border-color .15s, transform .15s;
}
.log-item:hover { border-color: var(--gold-soft); transform: translateX(2px); }
html[dir="rtl"] .log-item:hover { transform: translateX(-2px); }
.log-item .tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.tag.in  { background: rgba(47,110,58,.10); color: var(--success); }
.tag.out { background: var(--gold-tint); color: var(--gold-deep); }
.log-item .time { font-family: var(--mono); color: var(--muted); }
.log-item .loc-link { font-size: 12px; }
.log-item .loc-link a { color: var(--navy); }
.log-item .loc-link a:hover { color: var(--gold-deep); }

/* ----- Admin tabs ------------------------------------------ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.tab {
  padding: 12px 22px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
}
.tab:hover { color: var(--navy); }
.tab.active {
  color: var(--navy);
  border-bottom-color: var(--gold);
  font-weight: 700;
}
.tab-content { display: none; animation: fadeUp .3s ease both; }
.tab-content.active { display: block; }

/* ----- Stats cards ----------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.stat-card {
  position: relative;
  padding: 22px 22px 22px 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.stat-card::before {
  /* tiny gold accent strip on the left edge */
  content: '';
  position: absolute;
  left: 0; top: 18px; bottom: 18px;
  width: 3px;
  background: var(--gold);
}
.stat-card .label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gold-deep);
  margin-bottom: 10px;
}
.stat-card .value {
  font-family: var(--sans);
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--navy);
}
.stat-card .accent { color: var(--gold-deep); }

/* ----- Filter bar ------------------------------------------ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.filter-bar .field { flex: 1 1 160px; margin: 0; }
.filter-bar .actions { display: flex; gap: 8px; margin-left: auto; }

/* ----- Data tables ----------------------------------------- */
.data-table {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
.data-table th,
.data-table td {
  padding: 13px 18px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.data-table th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: none;
}
.data-table tbody tr:nth-child(even) { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gold-tint); }
.data-table .mono { font-family: var(--mono); font-size: 12px; }
.data-table .action-cell { display: flex; gap: 6px; }

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

/* ----- Toasts ---------------------------------------------- */
#toasts {
  position: fixed;
  top: 24px; right: 24px;
  z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
}
html[dir="rtl"] #toasts { right: auto; left: 24px; }

.toast {
  padding: 14px 20px;
  background: var(--navy);
  color: #fff;
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  font-size: 13.5px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: slideIn .25s cubic-bezier(.2,.7,.3,1);
}
html[dir="rtl"] .toast {
  border-left: none;
  border-right: 3px solid var(--gold);
  animation-name: slideInRtl;
}
.toast.success { background: var(--success); border-left-color: #9bd3a5; }
.toast.error   { background: var(--danger); border-left-color: #f5c2bc; }
html[dir="rtl"] .toast.success { border-right-color: #9bd3a5; }
html[dir="rtl"] .toast.error   { border-right-color: #f5c2bc; }

/* ----- Modal ----------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(14,33,56,.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; }
.modal {
  position: relative;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .25s ease;
}
.modal::before {
  /* tab on the modal too */
  content: '';
  position: absolute;
  top: 0; left: 32px;
  width: var(--tab-w); height: 56px;
  background: var(--gold);
  border-radius: 0 0 var(--tab-w) var(--tab-w) / 0 0 50% 50%;
}
.modal h3 { margin-bottom: 22px; padding-top: 8px; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ----- Spinner --------------------------------------------- */
.spin {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Section heading ------------------------------------- */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.section-head .right { display: flex; gap: 8px; }
.section-head h1,
.section-head h2 { color: var(--navy); }

/* ----- Settings panel -------------------------------------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.settings-section {
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.settings-section:last-of-type { border-bottom: none; }
.settings-section h3 {
  margin-bottom: 4px;
  color: var(--navy);
}
.settings-section .desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

/* ----- Decorative arch row (used at bottoms of sections) --- */
.arch-row {
  height: 24px;
  margin: 32px 0 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='24' viewBox='0 0 30 24'><g fill='none' stroke='%23cfa762' stroke-width='0.8'><path d='M2 24 L2 12 C2 6 7 3 15 3 C23 3 28 6 28 12 L28 24'/></g></svg>");
  background-size: 30px 24px;
  background-repeat: repeat-x;
  background-position: bottom;
  opacity: 0.55;
}

/* ----- Animations ------------------------------------------ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRtl {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ----- Language toggle (single circular button) ------------ */
.lang-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--navy);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color .15s, color .15s, border-color .15s, transform .15s;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.lang-btn:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  transform: translateY(-1px);
}
.lang-btn:active { transform: translateY(0); }

/* Position on auth pages (top corner, opposite the gold tab) */
.auth-page .lang-btn {
  position: absolute;
  top: 24px;
  inset-inline-end: 24px;
  z-index: 3;
}

/* Numerals — keep Western digits inside .mono regardless of script */
.mono, .clock, code, input[type="date"], input[type="number"] {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

/* Date inputs in RTL still render their internal widgets LTR — ensure
   the label/value pair sits cleanly */
html[dir="rtl"] input[type="date"],
html[dir="rtl"] input[type="number"],
html[dir="rtl"] input[type="email"] {
  text-align: right;
}

/* Latin email/URL strings inside Arabic should display LTR for legibility */
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* ============================================================
   MOBILE LAYOUT  ≤ 640px
   ============================================================ */
@media (max-width: 640px) {

  html, body { font-size: 14px; }

  /* ----- App header gets compressed ----- */
  .app-header-inner {
    padding: 12px 14px 12px 60px;   /* tighter, less left-pad for the tab */
    gap: 8px;
    flex-wrap: nowrap;
  }
  html[dir="rtl"] .app-header-inner {
    padding: 12px 14px 12px 60px;
  }
  .app-header-inner::before {
    width: 22px;
    height: 48px;
    left: 14px;
    border-radius: 0 0 22px 22px / 0 0 50% 50%;
  }

  /* Brand block: shrink the mark, drop the sub tagline on phones */
  .brand { gap: 8px; min-width: 0; }
  .brand .brand-mark { width: 18px; height: 22px; }
  .brand .brand-logo { height: 30px; }
  .brand-logo-lg { height: 72px; }
  .brand .name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand .name .sub { display: none; }

  /* User chip: drop the "signed in as X" label, keep lang + sign-out */
  .user-chip { gap: 8px; font-size: 12px; }
  .user-chip .chip-label { display: none; }
  .lang-btn { width: 34px; height: 34px; font-size: 12px; }
  .user-chip .btn { padding: 6px 10px; font-size: 12px; }

  /* ----- Main padding ----- */
  .app-main { padding: 24px 14px 60px; }

  /* ----- Hero ----- */
  .hero { gap: 14px; margin-bottom: 24px; }
  .hero-card { padding: 22px; }
  .hero-card.primary { padding: 26px 22px 22px; }
  .hero-card .clock { font-size: 2.8rem; margin: 10px 0 4px; }
  .hero-card .date  { font-size: 11px; }
  .hero-card.primary::after { width: 160px; height: 160px; }
  .big-btn { padding: 18px; font-size: 1.1rem; }

  .status-panel { padding: 24px 22px; }
  .status-row { font-size: 13px; padding: 11px 0; }

  /* ----- Stats: 2 columns on phones ----- */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
  .stat-card { padding: 16px 16px 16px 20px; }
  .stat-card .label { font-size: 9px; }
  .stat-card .value { font-size: 1.8rem; }

  /* ----- Tabs: scroll horizontally if needed ----- */
  .tabs {
    overflow-x: auto;
    margin-bottom: 22px;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 10px 16px; font-size: 13px; flex-shrink: 0; white-space: nowrap; }

  /* ----- Filter bar: every field full-width, actions wrap ----- */
  .filter-bar { padding: 14px; gap: 10px; }
  .filter-bar .field { flex: 1 1 100%; }
  .filter-bar .actions { width: 100%; margin: 0; flex-wrap: wrap; }
  .filter-bar .actions .btn { flex: 1 1 auto; }

  /* ----- Log items: stack vertically ----- */
  .log-item {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px 16px;
  }
  .log-item .tag { width: fit-content; }
  .log-item:hover { transform: none; }   /* no hover slide on touch */

  /* ----- Section head: stack title + actions ----- */
  .section-head {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 18px;
  }
  .section-head h1, .section-head h2 { font-size: 1.5rem; }
  .section-head .right { width: 100%; }

  /* ----- Data tables: keep horizontal scroll, smaller cells ----- */
  .data-table th, .data-table td {
    padding: 10px 12px;
    font-size: 12px;
  }
  .data-table th { font-size: 9px; }
  .data-table .action-cell { flex-direction: column; gap: 4px; }
  .data-table .action-cell .btn { padding: 5px 10px; font-size: 11px; }

  /* ----- Modals: comfortable on small screens ----- */
  .modal-backdrop { padding: 12px; align-items: flex-start; padding-top: 40px; }
  .modal { padding: 30px 22px 22px; border-radius: 8px; }
  .modal::before { left: 22px; width: 22px; height: 44px; }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions .btn { width: 100%; }

  /* ----- Auth card: less generous, tab a bit smaller ----- */
  .auth-page { padding: 16px; align-items: flex-start; padding-top: 60px; }
  .auth-card { padding: 60px 24px 28px; border-radius: 8px; }
  .auth-card::before {
    left: 24px;
    width: 24px;
    height: 68px;
    border-radius: 0 0 24px 24px / 0 0 40% 40%;
  }
  .auth-card::after { left: 26px; width: 20px; }
  .auth-card h1 { font-size: 1.35rem; }
  .auth-page .lang-btn { top: 16px; inset-inline-end: 16px; }

  /* ----- Settings: single column ----- */
  .settings-grid { grid-template-columns: 1fr; gap: 14px; }
  .settings-section { margin-bottom: 24px; padding-bottom: 22px; }

  /* ----- Toasts ----- */
  #toasts {
    top: auto;
    bottom: 16px;
    left: 16px !important;
    right: 16px !important;
  }
  .toast { max-width: none; }

  /* Big touch targets for inputs */
  .field input, .field select, .field textarea { padding: 12px 14px; font-size: 16px; }
  /* iOS Safari won't zoom in on inputs when the font-size is ≥16px */

  /* Eyebrow text shrinks */
  .eyebrow { font-size: 10px; letter-spacing: 0.18em; }
}

/* Even narrower phones (≤ 380px) — one-column stats too */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .hero-card .clock { font-size: 2.4rem; }
  .brand .name { font-size: 13px; }
  .app-header-inner { padding-left: 54px; padding-right: 12px; }
  .app-header-inner::before { width: 20px; height: 42px; left: 12px; }
}
