/* ============================================================
   Board Control Room — Design System
   شركة أحمد الموسى القابضة | Ahmed Al-Mousa Holding
   ------------------------------------------------------------
   Brand identity strictly per AhmedAlMousa_Brand_Guidelines.pdf:
     • Obsidian Luxe  #363940  (Primary 1)
     • Heritage Taupe #cab8a5  (Primary 2)
     • Sienna Brown   #b08a73  (Secondary)
   Typefaces:
     • Spica Arabic   — Arabic headings
     • Kanun AR+LT    — Arabic + Latin body
     • Tabac Glam G4  — Latin headings
   ============================================================ */

/* ---- @font-face: load the official brand fonts ---- */
@font-face {
  font-family: 'Spica Arabic';
  src: url('../assets/fonts/SpicaArabic-Book.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Spica Arabic';
  src: url('../assets/fonts/SpicaArabic-Bold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Kanun AR';
  src: url('../assets/fonts/KanunAR-Light.otf') format('opentype');
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: 'Kanun AR';
  src: url('../assets/fonts/KanunAR-Thin.otf') format('opentype');
  font-weight: 100;
  font-display: swap;
}
@font-face {
  font-family: 'Tabac Glam G4';
  src: url('../assets/fonts/TabacGlamG4-Medium.otf') format('opentype');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Tabac Glam G4';
  src: url('../assets/fonts/TabacGlamG4-Bold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}

/* ---- Light theme tokens (default) ---- */
:root {
  /* Brand colors */
  --obsidian: #363940;
  --obsidian-80: #5e6068;
  --obsidian-60: #868890;
  --obsidian-20: #d7d8dc;
  --taupe: #cab8a5;
  --taupe-80: #d5c6b7;
  --taupe-60: #dfd4c9;
  --taupe-20: #f5f0eb;
  --sienna: #b08a73;

  /* Semantic */
  --bg: #f7f5f1;
  --bg-elev: #ffffff;
  --bg-soft: #efebe5;
  --surface: #ffffff;
  --border: #e6e1d8;
  --border-strong: #cdc6b9;
  --text: #1f2024;
  --text-muted: #5e6068;
  --text-subtle: #868890;
  --primary: var(--obsidian);
  --primary-fg: #ffffff;
  --accent: var(--taupe);
  --accent-fg: #1f2024;
  --success: #2f7d4f;
  --warning: #c08a2b;
  --danger: #b3392f;
  --info: #2c5e8a;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(54, 57, 64, 0.06), 0 1px 3px rgba(54, 57, 64, 0.05);
  --shadow-md: 0 4px 14px rgba(54, 57, 64, 0.08), 0 2px 6px rgba(54, 57, 64, 0.05);
  --shadow-lg: 0 18px 40px rgba(54, 57, 64, 0.15), 0 8px 16px rgba(54, 57, 64, 0.07);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Spacing scale */
  /* Tightened spacing — denser, more refined feel */
  --space-1: 3px;
  --space-2: 6px;
  --space-3: 10px;
  --space-4: 14px;
  --space-5: 20px;
  --space-6: 28px;
  --space-7: 40px;
  --space-8: 56px;

  /* Typography */
  --font-heading-ar: 'Spica Arabic', 'Tahoma', sans-serif;
  --font-heading-en: 'Tabac Glam G4', 'Verdana', sans-serif;
  --font-body: 'Kanun AR', 'Tahoma', 'Verdana', sans-serif;

  /* Tightened scale — matches the polished, dense reference design */
  --fs-xs: 0.7rem;
  --fs-sm: 0.8rem;
  --fs-md: 0.9rem;
  --fs-lg: 1rem;
  --fs-xl: 1.18rem;
  --fs-2xl: 1.45rem;
  --fs-3xl: 1.8rem;

  /* Motion */
  --t-fast: 150ms ease;
  --t-med: 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---- Dark theme ---- */
[data-theme='dark'] {
  --bg: #1a1c20;
  --bg-elev: #23262c;
  --bg-soft: #2a2d33;
  --surface: #23262c;
  --border: #353841;
  --border-strong: #494d57;
  --text: #ece9e2;
  --text-muted: #b6b3ad;
  --text-subtle: #82807a;
  --primary: var(--taupe);
  --primary-fg: #1a1c20;
  --accent: var(--taupe);
  --accent-fg: #1a1c20;
  --obsidian-20: #353841;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.55);
}

/* ============================================================
   BASE
   ============================================================ */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
html[dir='rtl'] body { font-family: var(--font-body); }
html[dir='ltr'] body { font-family: 'Kanun AR', 'Verdana', sans-serif; }

h1, h2, h3, h4 {
  font-family: var(--font-heading-ar);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3);
  color: var(--text);
}
html[dir='ltr'] h1,
html[dir='ltr'] h2,
html[dir='ltr'] h3,
html[dir='ltr'] h4 {
  font-family: var(--font-heading-en);
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

a { color: var(--primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--sienna); }

button { font-family: inherit; }

::selection {
  background: var(--taupe);
  color: var(--obsidian);
}

/* Focus ring — accessibility non-negotiable */
*:focus-visible {
  outline: 2px solid var(--sienna);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   LAYOUT — header / main / footer
   ============================================================ */
.app-header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px var(--space-5);                /* shorter top/bottom */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  transition: opacity 0.18s ease;
  user-select: none;
}
.brand:hover { opacity: 0.92; }
.brand:focus-visible {
  outline: 2px solid var(--sienna, #b08a73);
  outline-offset: 4px;
  border-radius: 6px;
}
.brand img {
  height: 40px;
  width: auto;
  display: block;
  /* Light theme: dark logo on transparent background (per brand guidelines) */
  content: url('/assets/logos/logo-dark.png');
}
[data-theme='dark'] .brand img {
  /* Dark theme: beige logo on transparent background */
  content: url('/assets/logos/logo-beige.png');
}
.brand .name {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  gap: 1px;
}
.brand .name .title {
  font-family: 'Spica Arabic', 'Tahoma', sans-serif !important;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
html[dir='ltr'] .brand .name .title {
  font-family: 'Tabac Glam G4', 'Verdana', sans-serif !important;
}
.brand .name .subtitle {
  font-family: 'Kanun AR', 'Tahoma', sans-serif !important;
  font-size: 0.78rem;
  font-weight: 300;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.brand .name .subtitle .brand-sep {
  color: var(--taupe);
  font-weight: 700;
  padding: 0 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.icon-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.lang-pill {
  width: auto;
  min-width: 44px;
  padding: 0 12px;
  font-family: var(--font-heading-en);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
}

/* Mobile nav drawer controls — render NOTHING on desktop (>900px). All visible
   styling lives in the @media (max-width:900px) block; these base rules only hide
   them so the desktop layout stays pixel-for-pixel identical. */
.nav-hamburger { display: none; }
.nav-overlay { display: none; }

/* Header text button (e.g. logout) — text + icon side by side */
.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.text-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--danger);
}
.text-btn svg { width: 16px; height: 16px; }
.icon-btn .badge {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  background: var(--sienna);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
  line-height: 1.1;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
}
.user-chip .avatar {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: var(--primary-fg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font-heading-ar);
}

/* ============================================================
   APP LAYOUT — sticky header / sidebar / footer
   ============================================================ */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  flex: 1;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  position: relative;
}

/* Sidebar — extends to full viewport height (under header) */
.app-sidebar {
  background: var(--bg-elev);
  padding: var(--space-4) var(--space-3) var(--space-5);
  border-inline-start: 1px solid var(--border);
  border-inline-end: 0;
  position: sticky;
  top: 56px;
  align-self: start;
  height: calc(100vh - 56px);                   /* always full viewport height */
  overflow-y: auto;
  z-index: 30;
}
.sidebar-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  padding: var(--space-2) var(--space-3) var(--space-3);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.sidebar-section {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-subtle);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: default;
  user-select: none;
  pointer-events: none;
  opacity: 0.7;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

/* Signature progress bar (in /signatures view) */
.sig-progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.sig-progress-track {
  flex: 1;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
}
.sig-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--taupe), var(--sienna));
  transition: width 0.4s ease;
}
.sig-progress-meta {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  white-space: nowrap;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 11px 14px;
  margin-bottom: 4px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.nav-item:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.nav-item.active {
  background: var(--obsidian);
  color: #ffffff;
  border-color: var(--obsidian);
  font-weight: 600;
}
.nav-item.active svg { color: var(--taupe); }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  inset-inline-end: 4px;
  width: 3px;
  background: linear-gradient(180deg, var(--taupe), var(--sienna));
  border-radius: 2px;
}
[data-theme='dark'] .nav-item.active {
  background: #14161a;
  color: #ffffff;
  border-color: rgba(202,184,165,0.18);
}
[data-theme='dark'] .nav-item.active svg { color: var(--taupe); }
[data-theme='dark'] .nav-item.active::before {
  background: linear-gradient(180deg, var(--taupe), var(--sienna));
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Main */
.app-main {
  padding: var(--space-5) var(--space-6);
  min-height: calc(100vh - 56px - 32px);
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* Footer — sticky to viewport bottom (compact) */
.app-footer {
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding: 6px var(--space-5);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  position: sticky;
  bottom: 0;
  z-index: 40;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   HERO GREETING CARD (dashboard top)
   ============================================================ */
.hero-card {
  background:
    linear-gradient(135deg, rgba(202,184,165,0.10), rgba(176,138,115,0.04)),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-6);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
[data-theme='dark'] .hero-card {
  background:
    linear-gradient(135deg, rgba(202,184,165,0.06), rgba(176,138,115,0.02)),
    var(--surface);
}
.hero-card::after {
  content: '';
  position: absolute;
  top: -40px;
  inset-inline-end: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(202,184,165,0.18), transparent 70%);
  pointer-events: none;
}

/* For users without an action button — uniform background, no decorative gradient */
.hero-card.hero-card-plain {
  background: var(--surface);
}
[data-theme='dark'] .hero-card.hero-card-plain {
  background: var(--surface);
}
.hero-card.hero-card-plain::after { display: none; }
.hero-left {
  flex: 1;
  min-width: 280px;
  position: relative;
  z-index: 1;
}
.hero-eyebrow {
  color: var(--sienna);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-2);
}
[data-theme='dark'] .hero-eyebrow { color: var(--taupe); }

.hero-title {
  font-family: var(--font-heading-ar);
  font-size: 2.35rem;
  font-weight: 700;
  margin: 0 0 var(--space-2);
  line-height: 1.18;
  color: var(--text);
}
html[dir='ltr'] .hero-title { font-family: var(--font-heading-en); }

.hero-name {
  background: linear-gradient(90deg, var(--taupe), var(--sienna));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--sienna);
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 520px;
  line-height: 1.6;
}

.btn-lg {
  padding: 14px 26px;
  font-size: 0.95rem;
  position: relative;
  z-index: 1;
}

@media (max-width: 720px) {
  .hero-title { font-size: 1.95rem; }
  .hero-card { padding: var(--space-5); }
}

/* ============================================================
   COMPONENTS
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header .subtitle {
  color: var(--text-muted);
  font-size: var(--fs-md);
  margin-top: 4px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-med), transform var(--t-med);
}
.card.hoverable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 4px;
  height: 100%;
  background: var(--taupe);
}
.kpi-card .label {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-2);
  /* Leave room on the inline-end for the floating edit/delete buttons */
  padding-inline-end: 56px;
}
.kpi-card .value {
  font-family: var(--font-heading-en);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.kpi-card .unit { font-size: 0.85rem; color: var(--text-muted); margin-inline-start: 4px; }
.kpi-card.accent::before { background: var(--sienna); }
.kpi-card.success::before { background: var(--success); }
.kpi-card.warning::before { background: var(--warning); }

/* Clickable KPI cards — interactive feedback */
.kpi-card-clickable {
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.kpi-card-clickable:hover {
  transform: translateY(-2px);
  border-color: var(--sienna, #b08a73);
  box-shadow: 0 6px 20px -8px rgba(176, 138, 115, 0.35);
}
.kpi-card-clickable:focus-visible {
  outline: 2px solid var(--sienna, #b08a73);
  outline-offset: 2px;
}

/* Edit/delete buttons on KPI cards */
.kpi-card { position: relative; }
.kpi-card-actions {
  position: absolute;
  top: 8px;
  /* Always opposite side of the label/title so icons never overlap card content */
  inset-inline-end: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.kpi-card:hover .kpi-card-actions { opacity: 1; }
.kpi-act-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.kpi-act-btn:hover { background: var(--bg-elev); color: var(--text); }
.kpi-act-btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 18px;
  background: var(--primary);
  color: var(--primary-fg);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  font-size: var(--fs-md);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.secondary:hover { background: var(--bg-soft); }
.btn.accent {
  background: var(--taupe);
  color: var(--obsidian);
  border-color: var(--taupe);
}
.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: transparent;
}
.btn.ghost:hover { background: var(--bg-soft); }
.btn.sm { padding: 6px 12px; font-size: var(--fs-sm); }
.btn svg { width: 16px; height: 16px; }

.btn-group { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; }

/* Forms */
label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--fs-md);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--sienna);
  box-shadow: 0 0 0 3px rgba(176, 138, 115, 0.18);
}
.textarea { min-height: 96px; resize: vertical; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.form-field { display: flex; flex-direction: column; }

/* Badge / pill */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  color: var(--text-muted);
}
.badge-pill.scheduled { background: #e8eef5; color: #2c5e8a; }
.badge-pill.live { background: #fdeac9; color: #8a5a16; }
.badge-pill.completed { background: #e1efe6; color: #2f7d4f; }
.badge-pill.cancelled { background: #fbe5e2; color: #8a2e26; }
.badge-pill.draft { background: #efebe5; color: #5e6068; }
.badge-pill.for_signing { background: #fdeac9; color: #8a5a16; }
.badge-pill.published { background: #e1efe6; color: #2f7d4f; }

[data-theme='dark'] .badge-pill.scheduled { background: rgba(44,94,138,0.18); }
[data-theme='dark'] .badge-pill.live      { background: rgba(192,138,43,0.2); }
[data-theme='dark'] .badge-pill.completed { background: rgba(47,125,79,0.2); }
[data-theme='dark'] .badge-pill.cancelled { background: rgba(179,57,47,0.2); }
[data-theme='dark'] .badge-pill.draft     { background: rgba(255,255,255,0.06); }
[data-theme='dark'] .badge-pill.for_signing { background: rgba(192,138,43,0.2); }
[data-theme='dark'] .badge-pill.published   { background: rgba(47,125,79,0.2); }

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
}
table.data th,
table.data td {
  padding: 12px 16px;
  text-align: start;
  border-bottom: 1px solid var(--border);
}
table.data th {
  background: var(--bg-soft);
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--bg-soft); }

/* Calendar */
.calendar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
  flex-wrap: wrap;
}
.calendar-head h3 { margin: 0; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-dow {
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  padding: var(--space-2);
}
.cal-cell {
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  min-height: 88px;
  padding: 8px;
  position: relative;
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-cell:hover {
  border-color: var(--taupe-60);
  background: var(--taupe-20);
}
.cal-cell.outside { opacity: 0.4; }
.cal-cell.today {
  background: var(--bg-soft);
  box-shadow: inset 0 0 0 2px var(--sienna);
}
.cal-cell .day-num {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-heading-en);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
}
.cal-cell.today .day-num {
  background: var(--sienna);
  color: #fff;
  font-weight: 700;
}
.cal-event {
  background: var(--obsidian);
  color: #fff;
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme='dark'] .cal-event { background: var(--taupe); color: var(--obsidian); }
.cal-event.live { background: var(--sienna); }
.cal-event.completed { background: var(--success); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal.wide { max-width: 980px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: var(--fs-xl); }
.modal-body { padding: var(--space-5); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}

/* Toast */
.toast-stack {
  position: fixed;
  top: 84px;
  inset-inline-end: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--success);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-md);
  min-width: 260px;
  max-width: 420px;
  font-size: var(--fs-sm);
  animation: toastIn 0.24s var(--t-med);
  pointer-events: auto;
}
.toast.error { border-inline-start-color: var(--danger); }
.toast.warning { border-inline-start-color: var(--warning); }
.toast.info { border-inline-start-color: var(--info); }
@keyframes toastIn {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Notifications dropdown */
.notif-dropdown {
  position: absolute;
  top: 56px;
  inset-inline-end: var(--space-5);
  width: 380px;
  max-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 60;
  display: none;
  flex-direction: column;
}
.notif-dropdown.open { display: flex; }
.notif-dropdown-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.notif-list {
  flex: 1;
  overflow-y: auto;
  max-height: 380px;
}
.notif-item {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast);
}
.notif-item:hover { background: var(--bg-soft); }
.notif-item.unread { background: var(--taupe-20); }
[data-theme='dark'] .notif-item.unread { background: rgba(202,184,165,0.08); }
.notif-item .meta { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: 2px; }
.notif-item .subject { font-weight: 600; font-size: var(--fs-sm); margin-bottom: 2px; }
.notif-item .body { font-size: var(--fs-sm); color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ============================================================
   LOGIN SCREEN (brand-aligned, phone + OTP)
   ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, var(--taupe-20), transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(176,138,115,0.18), transparent 65%),
    var(--bg);
  padding: var(--space-5);
}
[data-theme='dark'] .login-screen {
  background:
    radial-gradient(circle at 20% 20%, rgba(202,184,165,0.06), transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(176,138,115,0.10), transparent 65%),
    var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  padding: var(--space-6) var(--space-6) var(--space-5);
  text-align: center;
  position: relative;
}
.login-toggles {
  position: absolute;
  top: var(--space-3);
  inset-inline-start: var(--space-3);
  display: flex;
  gap: 6px;
}
.login-toggles .icon-btn { width: 36px; height: 36px; }
.login-toggles .icon-btn svg { width: 18px; height: 18px; }
.login-toggles .lang-pill {
  font-family: var(--font-heading-en);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.login-logo {
  height: 110px;
  margin: var(--space-3) auto var(--space-3);
  display: block;
  filter: drop-shadow(0 2px 6px rgba(54,57,64,0.08));
  /* Light theme: dark logo on transparent background */
  content: url('/assets/logos/logo-dark.png');
}
[data-theme='dark'] .login-logo {
  content: url('/assets/logos/logo-beige.png');
  filter: none;
}

.login-title {
  font-size: var(--fs-2xl);
  margin: 0 0 var(--space-2);
  font-weight: 700;
  line-height: 1.25;
}
.login-subtitle {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-5);
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.login-subtitle-sep {
  color: var(--taupe);
  font-weight: 700;
  padding: 0 4px;
}

.login-form { text-align: start; margin-bottom: var(--space-3); }
.login-form label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: 8px;
}
.login-form .req { color: var(--danger); font-weight: 700; }

.login-input {
  font-family: var(--font-heading-en);
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  padding: 14px 16px;
  text-align: start;
}
.login-help {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin: 8px 0 var(--space-4);
  line-height: 1.6;
}

/* Bright info banner showing demo credentials */
.demo-banner {
  background: linear-gradient(135deg, var(--taupe-20), rgba(176,138,115,0.10));
  border: 1px dashed var(--taupe);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 12px 0;
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text);
  line-height: 1.8;
}
.demo-banner code {
  background: var(--obsidian);
  color: var(--taupe);
  padding: 3px 10px;
  border-radius: 6px;
  font-family: var(--font-heading-en);
  font-weight: 700;
  letter-spacing: 0.1em;
  margin: 0 4px;
}
[data-theme='dark'] .demo-banner {
  background: linear-gradient(135deg, rgba(202,184,165,0.08), rgba(176,138,115,0.04));
}
.login-help code {
  display: inline-block;
  background: var(--taupe-20);
  color: var(--obsidian);
  font-family: var(--font-heading-en);
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 6px;
  letter-spacing: 0.2em;
}
[data-theme='dark'] .login-help code {
  background: rgba(202,184,165,0.18);
  color: var(--taupe);
}

.btn-block { width: 100%; padding: 14px 18px; font-size: 1rem; }

.login-link {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-align: center;
  margin: var(--space-4) 0 var(--space-4);
  line-height: 1.6;
}
.login-link a {
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--taupe-60);
  text-underline-offset: 3px;
}
.login-link a:hover { color: var(--sienna); }

/* OTP single big input */
.otp-single {
  font-family: var(--font-heading-en);
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.6em;
  padding: 18px 24px;
  height: 70px;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  width: 100%;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.otp-single:focus {
  outline: none;
  border-color: var(--sienna);
  box-shadow: 0 0 0 4px rgba(176,138,115,0.2);
}
.otp-single::placeholder {
  color: var(--text-subtle);
  letter-spacing: 0.5em;
}

/* OTP inputs — 6 compact boxes (matches the reference design) */
.otp-label {
  display: block;
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}
.otp-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  direction: ltr;
}
.otp-input {
  width: 46px;
  height: 50px;
  text-align: center;
  font-size: 1.3rem;
  font-family: var(--font-heading-en);
  font-weight: 700;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  caret-color: var(--sienna);
  padding: 0;
}
.otp-input:focus {
  outline: none;
  border-color: var(--sienna);
  background: var(--surface);
  box-shadow: 0 0 0 2px rgba(176, 138, 115, 0.2);
}
.otp-input.filled {
  border-color: var(--taupe);
  color: var(--text);
}
[data-theme='dark'] .otp-input {
  background: rgba(255,255,255,0.04);
  color: #fff;
}
[data-theme='dark'] .otp-input:focus { background: rgba(176,138,115,0.12); }
[data-theme='dark'] .otp-input.filled { background: rgba(202,184,165,0.10); }

.otp-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: var(--space-3) 0 var(--space-2);
}
.otp-meta .otp-dot {
  color: var(--taupe);
  font-weight: 700;
}
.otp-resend {
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin: 0;
}
.otp-resend a {
  color: var(--sienna);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--taupe-60);
  text-underline-offset: 2px;
}
[data-theme='dark'] .otp-resend a { color: var(--taupe); }
.otp-resend a:hover { color: var(--text); }

@media (max-width: 480px) {
  .otp-input { width: 38px; height: 44px; font-size: 1.1rem; }
  .otp-inputs { gap: 5px; }
}

/* Demo accounts section */
.demo-section {
  margin-top: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-soft);
}
.demo-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  text-align: start;
  transition: background var(--t-fast);
}
.demo-toggle:hover { background: var(--bg-elev); }
.demo-arrow {
  display: inline-block;
  transition: transform var(--t-fast);
  color: var(--text-muted);
  font-size: 0.8rem;
}
html[dir='rtl'] .demo-arrow { transform: rotate(180deg); }
.demo-toggle[aria-expanded='true'] .demo-arrow { transform: rotate(90deg); }
html[dir='rtl'] .demo-toggle[aria-expanded='true'] .demo-arrow { transform: rotate(90deg); }
.demo-tag {
  margin-inline-start: auto;
  background: var(--taupe);
  color: var(--obsidian);
  font-family: var(--font-heading-en);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 4px;
}

.demo-content {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
  text-align: start;
}
.demo-account {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: 8px;
  cursor: pointer;
  text-align: start;
  font-family: inherit;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.demo-account:hover {
  border-color: var(--taupe);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.demo-account:last-child { margin-bottom: 0; }
.demo-account .demo-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.demo-account .demo-phone {
  font-family: var(--font-heading-en);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  direction: ltr;
  text-align: start;
}
.demo-account .demo-role {
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.demo-account .demo-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.demo-persona-tag {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.demo-persona-tag.persona-secretary {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}
.demo-persona-tag.persona-board {
  background: color-mix(in srgb, var(--success) 18%, transparent);
  color: var(--success);
}
.demo-persona-tag.persona-user {
  background: color-mix(in srgb, var(--info, #3a86c4) 18%, transparent);
  color: var(--info, #3a86c4);
}

/* User chip in the header — avatar + name + role */
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  margin-inline-end: 4px;
}
.user-chip-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}
.user-chip-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
}
.user-chip-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.user-chip-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading-ar);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  flex-shrink: 0;
}

/* (legacy) Active-persona badge — kept for any older selectors */
.role-badge {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid var(--border);
  margin-inline-end: 6px;
}
.role-badge.persona-secretary {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
/* Board members & system users get a neutral gray badge — gold is reserved for the Secretary */
.role-badge.persona-board_member,
.role-badge.persona-user {
  background: var(--bg-soft);
  color: var(--text-muted);
  border-color: var(--border);
}

/* Pending-signature card on the member's Signatures page */
.sign-pending-card {
  border-inline-start: 3px solid var(--warning);
}

/* ============================================================
   MEMBERS TABLE — compact, professional, icon actions
   All cells share the same small font, single-line, vertically centered.
   ============================================================ */
/* Horizontal scroll wrapper — ensures the Actions column (edit ✎ + permissions 👁)
   stays reachable even when the table is wider than the page. */
.members-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-radius: var(--radius-md);
}
.members-table-scroll::-webkit-scrollbar { height: 8px; }
.members-table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.members-table {
  table-layout: auto;
  font-size: 0.8rem;
  line-height: 1.4;
  min-width: 100%;
}
/* Ensure Actions column never collapses; keep both icons visible */
.mt-actions-col { white-space: nowrap; min-width: 80px; }
.mt-actions-col .action-icons { display: inline-flex; gap: 6px; }
/* All headers AND their data are centered → header sits directly above each value */
.members-table thead th {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  padding: 10px 12px;
  white-space: nowrap;
  text-align: center;
}
.members-table tbody td {
  padding: 12px;
  vertical-align: middle;
  white-space: nowrap;
  text-align: center;
}

/* Name column — keeps right-aligned (it's the row's identifier and reads RTL naturally) */
.mt-name-col { min-width: 180px; text-align: start; }
.members-table thead th:first-child { text-align: start; }
.mt-name-ar  { font-weight: 700; font-size: 0.82rem; color: var(--text); line-height: 1.3; white-space: nowrap; }

/* Compact columns — centered with monospace for LTR data so the alignment looks balanced */
.mt-code-col   { }
.mt-role-col   { color: var(--text); }
.mt-email-col  { color: var(--text-muted); font-family: monospace; font-size: 0.74rem; unicode-bidi: plaintext; }
.mt-phone-col  { color: var(--text-muted); font-family: monospace; font-size: 0.74rem; unicode-bidi: plaintext; }
.mt-login-col  { color: var(--text-muted); font-size: 0.72rem; unicode-bidi: plaintext; }
.mt-active-col { color: var(--success); font-weight: 700; font-size: 0.95rem; }
.mt-actions-col { width: 1%; }

/* Legacy class kept for back-compat */
.member-cell-name { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.col-active { text-align: center; color: var(--success); font-weight: 700; }
.action-icons {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}
.icon-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-family: inherit;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, opacity 140ms ease;
  padding: 0;
  line-height: 1;
}
.icon-action-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--taupe-60);
}

/* Member code pill — short abbreviation used in meeting minutes (e.g. "أ.م") */
.member-code-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-family: var(--font-heading-en);
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1.4;
  white-space: nowrap;
}

/* Code beside the member's name on the attendance grid (After-meeting tab) */
.att-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.att-code {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-family: var(--font-heading-en);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ============================================================
   PERMISSIONS MODAL
   ============================================================ */
.perm-modal-body { padding: 4px 2px; }
.perm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}
.perm-modal-name { font-weight: 700; font-size: 1.05rem; }
.perm-table { width: 100%; font-size: 0.88rem; }
.perm-table thead th {
  background: var(--bg-soft);
  text-align: center;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 10px 8px;
}
.perm-table thead th.perm-svc-head { text-align: start; }
.perm-table td { padding: 8px 10px; border-top: 1px solid var(--border); }
.perm-table .perm-svc { font-weight: 600; }
.perm-table .perm-cell { text-align: center; }
.perm-table .perm-na { color: var(--border); }
.perm-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 120ms ease;
}
.perm-checkbox-wrap:hover { background: var(--bg-soft); }
.perm-checkbox-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Empty / loading states */
.state {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--text-muted);
}
.state .icon { font-size: 2.5rem; margin-bottom: var(--space-3); opacity: 0.6; }
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Agenda / drag list */
.agenda-list { display: flex; flex-direction: column; gap: var(--space-2); }
.agenda-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: grab;
}
.agenda-item:hover { border-color: var(--border-strong); }
.agenda-item.dragging { opacity: 0.4; }
.agenda-item .handle {
  color: var(--text-subtle);
  cursor: grab;
  flex-shrink: 0;
}
.agenda-item .title { flex: 1; font-weight: 500; }
.agenda-item input.title-edit {
  flex: 1;
  background: transparent;
  border: none;
  padding: 4px;
  font: inherit;
  color: var(--text);
}
.agenda-item input.title-edit:focus { outline: 1px solid var(--sienna); border-radius: 4px; }

/* Attendance row */
.attendance-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.attendance-row:last-child { border-bottom: none; }
.attendance-row .member { display: flex; align-items: center; gap: var(--space-3); }
.attendance-row .avatar {
  width: 36px; height: 36px;
  background: var(--taupe-20); color: var(--obsidian);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--font-heading-ar);
}
[data-theme='dark'] .attendance-row .avatar { background: rgba(202,184,165,0.18); color: var(--taupe); }
.attendance-row .name { font-weight: 500; }
.attendance-row .role { font-size: var(--fs-sm); color: var(--text-muted); }
.attendance-buttons { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; }
.att-btn {
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  font-weight: 500;
}
.att-btn:hover { background: var(--bg-soft); }
.att-btn.active { background: var(--obsidian); color: #fff; border-color: var(--obsidian); }
.att-btn.active.present { background: var(--success); border-color: var(--success); }
.att-btn.active.absent  { background: var(--danger); border-color: var(--danger); }
.att-btn.active.excused { background: var(--info); border-color: var(--info); }
.att-btn.active.late    { background: var(--warning); border-color: var(--warning); }

/* Member multi-select */
.member-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 280px;
  overflow-y: auto;
}
.member-pick label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin: 0;
  transition: background var(--t-fast);
  font-weight: 400;
  font-size: var(--fs-sm);
}
.member-pick label:hover { background: var(--surface); }
.member-pick input[type='checkbox'] { accent-color: var(--obsidian); }

/* Signature canvas */
.sig-canvas-wrap {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  position: relative;
}
.sig-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 200px;
  cursor: crosshair;
}
.sig-canvas-wrap .clear-btn {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  font-size: var(--fs-xs);
}

/* Signatures grid */
.sig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.sig-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.sig-card .name { font-weight: 600; margin-bottom: 2px; font-size: var(--fs-sm); }
.sig-card .when { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--space-2); }
.sig-card img { width: 100%; height: 80px; object-fit: contain; background: var(--bg-soft); border-radius: 6px; }
.sig-card.pending { border-style: dashed; }

/* Templates editor */
.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.template-card h4 { margin-bottom: var(--space-3); }

/* Dashboard 2-column grid (calendar wide + upcoming narrow) */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--space-4);
  align-items: start;
}
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   MINUTES PAGE — attendance grid + 2-option chooser
   ============================================================ */
.attendance-summary {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
}
.att-chip strong {
  font-family: var(--font-heading-en);
  font-size: 1rem;
  font-weight: 700;
}
.att-chip.success { color: var(--success); border-color: rgba(47,125,79,0.3); }
.att-chip.danger  { color: var(--danger);  border-color: rgba(179,57,47,0.3); }
.att-chip.info    { color: var(--info);    border-color: rgba(44,94,138,0.3); }
.att-chip.muted   { color: var(--text-muted); }

.attendance-grid {
  display: grid;
  /* Slightly wider cards so name + code + role all fit on a single line */
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 8px;
}
.attendance-person {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-inline-start: 3px solid var(--border-strong);
}
.attendance-person.present { border-inline-start-color: var(--success); }
.attendance-person.late    { border-inline-start-color: var(--warning); }
.attendance-person.absent  { border-inline-start-color: var(--danger); }
.attendance-person.excused { border-inline-start-color: var(--info); }
.attendance-person.pending { border-inline-start-color: var(--border-strong); opacity: 0.85; }

.att-status {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-heading-en);
  font-size: 0.85rem;
  background: var(--bg-soft);
  color: var(--text-muted);
}
.attendance-person.present .att-status { background: rgba(47,125,79,0.15); color: var(--success); }
.attendance-person.late    .att-status { background: rgba(192,138,43,0.15); color: var(--warning); }
.attendance-person.absent  .att-status { background: rgba(179,57,47,0.15);  color: var(--danger); }
.attendance-person.excused .att-status { background: rgba(44,94,138,0.15);  color: var(--info); }

.att-info { min-width: 0; overflow: hidden; }
.att-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}
.att-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.att-role {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.att-code {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-family: var(--font-heading-en);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  line-height: 1.4;
  flex-shrink: 0;
}
.att-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 3px 10px;
  background: var(--bg-soft);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Minutes 2-option chooser */
.minutes-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.minutes-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-5);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  text-align: center;
}
.minutes-tab:hover { border-color: var(--taupe-60); background: var(--bg-soft); }
.minutes-tab.active {
  border-color: var(--taupe);
  background: var(--taupe-20);
  box-shadow: var(--shadow-sm);
}
[data-theme='dark'] .minutes-tab.active {
  background: rgba(202,184,165,0.12);
}
.minutes-tab-icon {
  margin-bottom: 6px;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.minutes-tab-icon svg {
  width: 30px;
  height: 30px;
  display: block;
}
.minutes-tab-title { font-weight: 700; font-size: 1.05rem; }
.minutes-tab-desc { font-size: var(--fs-sm); color: var(--text-muted); }
@media (max-width: 600px) {
  .minutes-tabs { grid-template-columns: 1fr; }
}

/* Editor template chooser (Blank vs Official) */
.editor-template-chooser {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.template-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.template-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: start;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, opacity 160ms ease;
  font-family: inherit;
}
.template-opt:hover {
  border-color: var(--taupe-60);
  transform: translateY(-1px);
}
.template-opt.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  box-shadow: 0 2px 8px rgba(176, 138, 115, 0.15);
}
[data-theme='dark'] .template-opt.active {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg));
}
.template-opt-icon { font-size: 1.6rem; }

/* "Build from attached PDF" pane (third option in meeting-detail minutes) */
.from-pdf-wrap { display: flex; flex-direction: column; gap: 4px; }
.from-pdf-help {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.from-pdf-icon { font-size: 1.6rem; flex-shrink: 0; }
.from-pdf-title { font-weight: 700; font-size: 1rem; color: var(--text); margin-bottom: 2px; }

/* ============================================================
   TEMPLATES VIEW — toolbar, search, filter chips, collapsible cards
   ============================================================ */
.tpl-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tpl-search {
  position: relative;
  flex: 1 1 280px;
  min-width: 200px;
}
.tpl-search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 12px;
  transform: translateY(-50%);
  opacity: 0.55;
  pointer-events: none;
  font-size: 0.95rem;
}
.tpl-search .input {
  padding-inline-start: 36px;
}
.tpl-filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, opacity 140ms ease;
  font-family: inherit;
}
.tpl-chip:hover { border-color: var(--taupe-60); color: var(--text); }
.tpl-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Channel tabs (Email / WhatsApp / SMS) — sits above the search/filter row */
.tpl-channel-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tpl-channel-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, opacity 140ms ease;
  font-family: inherit;
}
.tpl-channel-btn:hover { border-color: var(--taupe-60); color: var(--text); }
.tpl-channel-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Sticky control strip — pins the channel bar + toolbar together at the top of
   the .app-main scroll region while the template list scrolls beneath. The page
   header/notice/picker are earlier siblings in .app-main, so top:0 is correct.
   Ref: design-references/item2-sticky-control-strip.txt
   (dribbble.com/shots/23267684-Sticky-Search-Bar). */
.tpl-sticky-strip {
  position: sticky;
  top: 0;
  z-index: 20;                 /* above list rows; below app-header (50) & sidebar (30) */
  background: var(--bg-elev);  /* opaque, theme-aware — rows must not show through */
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding-block: 12px;
  /* Bleed out to the .app-main padding edges (base horizontal padding = --space-6,
     28px) so the border/shadow span the full content width, then restore the inner
     padding. Logical props keep this correct in both RTL and LTR. */
  margin-inline: calc(-1 * var(--space-6));
  padding-inline: var(--space-6);
}
.tpl-sticky-strip .tpl-channel-bar,
.tpl-sticky-strip .tpl-toolbar { margin-bottom: 0; }
.tpl-sticky-strip .tpl-channel-bar { margin-bottom: 12px; }
.tpl-channel-icon { font-size: 1rem; }

/* Meeting picker for live-preview on the Templates page */
.tpl-picker-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.tpl-picker-label {
  display: block;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--text);
  margin-bottom: 8px;
}
.tpl-picker-card .select { max-width: 540px; }
.tpl-picker-card .muted.text-sm {
  font-size: 0.7rem;
  opacity: 0.75;
  line-height: 1.5;
  margin-top: 6px;
}

/* Two-column layout: editor on the left, channel-styled preview on the right */
.tpl-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) {
  .tpl-two-col { grid-template-columns: 1fr; }
}
.tpl-editor-col, .tpl-preview-col { min-width: 0; }
.tpl-body-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.tpl-body-area {
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.7;
}
.tpl-sms-counter {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: monospace;
  font-weight: 700;
}
.tpl-sms-counter.over-limit { color: var(--danger); }

/* English section collapsed by default */
.tpl-en-section {
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  margin-bottom: 12px;
}
.tpl-en-section summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: 4px 0;
  list-style: none;
  user-select: none;
}
.tpl-en-section summary::-webkit-details-marker { display: none; }
.tpl-en-section summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 200ms ease;
}
.tpl-en-section[open] summary::before { content: '▾ '; }

/* Preview header */
.tpl-preview-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.tpl-preview-label { font-weight: 700; font-size: var(--fs-sm); color: var(--accent); }

/* ============================================================
   CHANNEL-SPECIFIC PREVIEWS — Email card / WhatsApp bubble / SMS phone
   ============================================================ */

/* --- Email preview --- */
.tpl-prev-email {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.tpl-prev-email-head {
  background: var(--bg-soft);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.tpl-prev-email-from {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--fs-sm);
}
.tpl-prev-email-subject {
  margin-top: 6px;
  font-weight: 700;
  color: var(--text);
}
.tpl-prev-email-body {
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.85;
  color: var(--text);
  max-height: 380px;
  overflow-y: auto;
}

/* --- WhatsApp preview --- */
.tpl-prev-whatsapp {
  background: #0b141a;
  background-image: linear-gradient(135deg, rgba(255,255,255,0.02) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.02) 50%, rgba(255,255,255,0.02) 75%, transparent 75%);
  background-size: 32px 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  min-height: 200px;
}
.tpl-prev-wa-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
}
.tpl-prev-wa-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-heading-ar);
  font-size: 1.05rem;
}
.tpl-prev-wa-name { font-weight: 700; color: #e9edef; font-size: 0.92rem; }
.tpl-prev-wa-head .muted { color: #8696a0; }
.tpl-prev-wa-bubble {
  background: #005c4b;
  color: #e9edef;
  padding: 10px 14px;
  border-radius: 14px;
  border-top-end-radius: 4px;
  max-width: 92%;
  margin-inline-start: auto;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}
.tpl-prev-wa-bubble pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.65;
  color: #e9edef;
}
.tpl-prev-wa-time {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  color: rgba(233,237,239,0.6);
  text-align: end;
}

/* --- SMS preview --- */
.tpl-prev-sms {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}
.tpl-prev-sms-screen {
  background: #f1f3f4;
  color: #202124;
  border-radius: 20px;
  padding: 16px 18px;
  max-width: 320px;
  width: 100%;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.tpl-prev-sms-from {
  font-size: 0.7rem;
  color: #5f6368;
  font-weight: 700;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  padding-bottom: 6px;
  letter-spacing: 0.02em;
}
.tpl-prev-sms-body {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.6;
  color: #202124;
}

/* Signature dialog — Draw / Upload tabs */
.sig-context {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.sig-context-name { font-weight: 700; font-size: 1rem; color: var(--text); margin-bottom: 2px; }
.sig-method-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.sig-method-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, opacity 140ms ease;
}
.sig-method-tab:hover { color: var(--text); }
.sig-method-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.sig-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 18px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}
.sig-upload-zone:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-soft)); }
.sig-upload-icon { font-size: 2rem; }
.sig-upload-text { font-weight: 600; color: var(--text-muted); }
.sig-upload-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}
.sig-upload-preview img {
  max-width: 100%;
  max-height: 180px;
  background: #fff;
  padding: 8px;
  border-radius: 6px;
}

/* Send-preview modal — used by every send action across the dashboard */
.send-preview-body { min-width: 0; }
.send-preview-meta {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--fs-sm);
}
.send-preview-meta-row { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.send-preview-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.send-preview-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, opacity 140ms ease;
}
.send-preview-tab:hover { color: var(--text); }
.send-preview-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.send-preview-pane {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  max-height: 380px;
  overflow-y: auto;
}
.send-preview-subject {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.send-preview-content {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text);
}

/* Legacy preview (fallback) */
.tpl-preview {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.tpl-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.tpl-preview-body {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text);
}

/* Channel tag inside each template card head (e.g. "WhatsApp") */
.template-channel-tag {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

/* Inline notice on the Templates page explaining "edit-only, send from context" */
.tpl-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 10px;
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

/* Collapsible template card */
.template-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.template-card.open {
  border-color: var(--taupe-60);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.template-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.template-card-head:hover { background: var(--bg-soft); }
.template-card-title { display: flex; align-items: center; gap: 10px; flex: 1; }
.template-card-title h4 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--text); }
.template-card-icon { font-size: 1.2rem; }
.template-phase-tag {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-weight: 600;
  border: 1px solid var(--border);
}
.template-phase-tag.before {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.template-phase-tag.after {
  background: color-mix(in srgb, var(--success) 10%, transparent);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

/* Member type pill (board / user) */
.member-type-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.member-type-tag.board {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.member-type-tag.user {
  background: color-mix(in srgb, var(--info, #3a86c4) 10%, transparent);
  color: var(--info, #3a86c4);
  border-color: color-mix(in srgb, var(--info, #3a86c4) 30%, transparent);
}

/* Members toolbar — narrower search so it doesn't take the full row */
.members-toolbar { gap: 16px; }
.members-search-narrow {
  flex: 0 1 360px;
  max-width: 360px;
}
@media (max-width: 700px) {
  .members-search-narrow { flex: 1 1 100%; max-width: 100%; }
}

/* Counts row — pill-shaped, color-coded, centered with title */
.members-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.members-count-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
}
.members-count-pill strong { font-size: 0.92rem; font-weight: 800; }
.members-count-pill.board strong { color: var(--accent); }
.members-count-pill.user  strong { color: var(--info, #3a86c4); }
.members-count-pill.all   strong { color: var(--text); }
.members-count-divider { margin-inline-start: auto; }
.template-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: inherit;
}
.template-toggle:hover { background: var(--bg-soft); color: var(--text); }
.template-card-body {
  padding: 0 16px 16px 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* Recipient preview strip & action row inside the template body */
.template-recipients {
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.template-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

/* Email preview modal */
.email-preview-section { margin-bottom: 14px; }
.email-preview-label {
  display: block;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: 6px;
}
.email-preview-recipients {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 10px;
  max-height: 140px;
  overflow-y: auto;
}
.email-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-family: monospace;
  color: var(--text);
}
.email-preview-subject {
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 600;
}
.email-preview-body {
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.8;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
}

@media (max-width: 600px) {
  .tpl-toolbar { flex-direction: column; align-items: stretch; }
  .tpl-search { width: 100%; }
  .template-actions { flex-direction: column; align-items: stretch; }
  .template-actions .btn { width: 100%; }
}

.template-opt-title { font-weight: 700; font-size: 1rem; color: var(--text); }
.template-opt-desc { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.5; }
@media (max-width: 600px) {
  .template-options { grid-template-columns: 1fr; }
}

/* ============================================================
   UPCOMING MEETINGS WIDGET (dashboard)
   ============================================================ */
.upcoming-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Activity / recent operations widget
   ============================================================ */
.activity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
/* Title/subtitle block on the inline-start, delete-all action on the inline-end,
   on one row. space-between + logical flow place the button on the correct side
   in both RTL and LTR (no left/right). Ref: design-references/item7-activity-head-row.txt
   (dribbble.com/shots/722496-Header-button-more-info). */
.activity-head {
  display: flex; flex-direction: row; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
/* Title + subtitle stay stacked in their own column wrapper (frontend wraps them
   in a <div>); min-width:0 lets the text shrink/wrap instead of shoving the button. */
.activity-head > div {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.activity-head h3 { margin: 0; font-size: 1.05rem; color: var(--text); font-weight: 700; }
.activity-head .activity-subtitle { font-size: 0.78rem; color: var(--text-muted); }
.activity-list {
  display: flex; flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}
.activity-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: var(--space-3);
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.activity-item:hover {
  border-color: var(--border);
  background: var(--surface);
}
.activity-dot {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 0.9rem; font-weight: 700;
  background: var(--bg-soft); color: var(--text-muted);
  border: 1px solid var(--border);
}
.activity-dot.success { background: rgba(34,139,86,0.12); color: var(--success, #228b56); border-color: rgba(34,139,86,0.25); }
.activity-dot.warning { background: rgba(217,164,68,0.14); color: var(--warning, #d9a444); border-color: rgba(217,164,68,0.28); }
.activity-dot.info    { background: rgba(176,138,115,0.14); color: var(--sienna, #b08a73); border-color: rgba(176,138,115,0.28); }
.activity-dot.accent  { background: rgba(202,184,165,0.18); color: var(--taupe, #8b7361); border-color: rgba(202,184,165,0.4); }
.activity-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.activity-text {
  font-size: 0.88rem; color: var(--text); line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  unicode-bidi: plaintext;
}
.activity-when {
  font-size: 0.72rem; color: var(--text-muted);
  font-family: 'Tahoma', sans-serif;
}

/* ============================================================
   Agenda editor widget
   ============================================================ */
.agenda-editor { display: flex; flex-direction: column; gap: var(--space-3); }
.agenda-head { display: flex; flex-direction: column; gap: 4px; }
.agenda-head h4 { margin: 0; font-size: 1rem; color: var(--text); font-weight: 700; }
.agenda-head .muted { color: var(--text-muted); font-size: 0.78rem; }
.agenda-list { display: flex; flex-direction: column; gap: 8px; }
.agenda-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: var(--space-3);
  padding: 12px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  align-items: start;
  transition: border-color 0.15s ease;
}
.agenda-item:hover { border-color: var(--sienna, #b08a73); }
.agenda-item.done { opacity: 0.7; }
.agenda-item.done .agenda-item-title { text-decoration: line-through; }
.agenda-item.live-added { border-color: var(--sienna, #b08a73); background: rgba(176,138,115,0.07); }
.agenda-num {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; min-width: 32px;
  font-weight: 700; color: var(--text-muted);
}
.agenda-num input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }
.agenda-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.agenda-item-title { font-weight: 600; color: var(--text); line-height: 1.5; unicode-bidi: plaintext; }
.agenda-notes {
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 36px;
  unicode-bidi: plaintext;
}
.agenda-notes:focus { outline: none; border-color: var(--sienna, #b08a73); }
.agenda-tag-live {
  align-self: flex-start;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--sienna, #b08a73);
  color: white;
  font-weight: 600;
}
.agenda-actions { display: flex; gap: 4px; align-self: start; }
.agenda-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 4px;
}

/* ============================================================
   Committees view (Members page — accordion style)
   ============================================================ */
.app-layout {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  /* Fixed-height app shell: lock the layout to the viewport (minus the 56px
     sticky header + 32px sticky footer) so #route-outlet/.app-main becomes the
     real scroll container and the full-height sidebar stays fixed while content
     scrolls. Without a definite height the body scrolled and the sidebar rode
     away with the page. Reset to auto on mobile (see ≤900px block below).
     Ref: Dashboard Sidebar Navigation (Dark/Light) — Fahad Ibn Sayeed / Musemind
     https://dribbble.com/shots/17122423-Dashboard-Sidebar-Navigation-Tooltip-Dark-Light
     reference note: /design-references/item1-sticky-sidebar.txt */
  height: calc(100vh - 56px - 32px);
}
.app-sidebar {
  /* Full-height fixed column; long menus scroll internally, not with the page.
     bg-elev is opaque in both themes so scrolling content never shows through. */
  height: auto !important;
  max-height: none !important;
  overflow-y: auto;
  overflow-x: hidden;
  align-self: stretch;
}
.app-main {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  max-width: 100%;
}
/* Mobile (≤900px): single-column shell. Sidebar becomes an off-canvas drawer —
   its full drawer definition lives in the "Responsive" block near the tail of this
   file (search: "SIDEBAR → off-canvas drawer"). Here we only undo the desktop
   fixed-height shell so the page scrolls naturally. */
@media (max-width: 900px) {
  /* SAFETY-NET guard: the top app container clips any stray sideways overflow so the
     PAGE can never scroll horizontally on phones/tablets, even if a future child
     misbehaves. This is the belt, not the cure — the real fix is min-width:0 below.
     Ref: design-references/item-mobile-overflow.txt */
  #app-view { overflow-x: hidden; max-width: 100vw; }
  /* min-width:0 is the REAL fix: a flex item defaults to min-width:auto (= its
     content's min-content), so .app-main grew to the wide calendar grid and outgrew
     the viewport — and an element's own overflow-x:hidden cannot clip itself, which
     is why the page scrolled sideways. Allowing the column and main region to shrink
     below min-content lets .app-main's existing overflow-x:hidden contain children. */
  .app-layout { display: flex; flex-direction: column; height: auto; min-width: 0; }
  .app-main { flex: 1 1 auto; min-width: 0; }
}

.committees-wrap { display: flex; flex-direction: column; gap: 10px; max-width: 100%; }
.committees-head { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.committees-head h2 { margin: 0; font-size: 0.98rem; font-weight: 700; color: var(--text); }
.committees-head .muted { color: var(--text-muted); font-size: 0.74rem; margin-top: 3px; }
.committees-stack { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

.committee-accordion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.committee-acc-head {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: start;
  transition: background 0.15s ease;
}
.committee-acc-head:hover { background: var(--bg-soft); }
.committee-acc-head .acc-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  color: var(--sienna, #b08a73);
  font-size: 0.85rem;
}
.committee-acc-head.open .acc-chevron { transform: rotate(180deg); }
.committee-acc-head .acc-title { flex: 1; }
.committee-acc-head .acc-count {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-weight: 600;
}
.committee-acc-head.open .acc-count {
  background: var(--sienna, #b08a73);
  color: white;
}

.committee-acc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.committee-acc-body .acc-desc {
  color: var(--text-muted);
  font-size: 0.74rem;
  padding: 4px 14px 0;
  margin: 0;
}

.committee-members {
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 8px 12px 12px;
}
.committee-member {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-soft);
  align-items: center;
}
.committee-member.is-chair {
  background: rgba(176,138,115,0.10);
  border-inline-start: 3px solid var(--sienna, #b08a73);
}
.committee-member.is-secretary {
  background: rgba(202,184,165,0.10);
  border-inline-start: 3px solid var(--taupe, #cab8a5);
}
.cm-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--sienna, #b08a73);
  color: white;
  font-weight: 700;
  font-size: 0.72rem;
}
.committee-member.is-secretary .cm-avatar { background: var(--taupe, #cab8a5); color: var(--text); }
.cm-info { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.cm-name { font-weight: 600; font-size: 0.82rem; color: var(--text); line-height: 1.3; }
.cm-role { font-size: 0.7rem; color: var(--text-muted); line-height: 1.3; }
.cm-contact {
  display: flex; flex-wrap: wrap; gap: 10px;
  font-size: 0.66rem; color: var(--text-muted);
  margin-top: 1px;
  font-family: 'Tahoma', sans-serif;
}
.cm-contact span { white-space: nowrap; }
.upcoming-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.upcoming-head h3 { margin: 0; font-size: var(--fs-xl); }
.upcoming-list {
  display: flex;
  flex-direction: column;
}
.upcoming-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast);
}
.upcoming-item:last-child { border-bottom: none; }
.upcoming-item:hover { background: var(--bg-soft); margin: 0 calc(-1 * var(--space-3)); padding-inline: var(--space-3); border-radius: var(--radius-md); border-color: transparent; }

.upcoming-date {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  text-align: center;
  min-width: 56px;
}
.upcoming-date .day {
  font-family: var(--font-heading-en);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.upcoming-date .month {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.upcoming-info { min-width: 0; }
.upcoming-info .title {
  font-weight: 600;
  font-size: var(--fs-md);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upcoming-info .meta {
  display: flex;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.upcoming-info .meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.today-tag {
  background: var(--taupe-20);
  color: var(--obsidian);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
[data-theme='dark'] .today-tag {
  background: rgba(202,184,165,0.18);
  color: var(--taupe);
}

/* ============================================================
   SETTINGS GRID — multi-card layout
   ============================================================ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.settings-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.settings-card-head h3 { margin: 0; font-size: var(--fs-lg); }
.settings-card-icon { font-size: 1.2rem; }
.api-key-input { font-family: var(--font-heading-en); letter-spacing: 0.1em; }

/* Numeric stepper with +/- buttons */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.stepper-btn {
  min-width: 56px;
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-heading-en);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  user-select: none;
  letter-spacing: 0.02em;
}
.stepper-btn.pos {
  border-color: var(--success);
  color: var(--success);
}
.stepper-btn.pos:hover {
  background: var(--success);
  color: #fff;
}
.stepper-btn.neg {
  border-color: var(--danger);
  color: var(--danger);
}
.stepper-btn.neg:hover {
  background: var(--danger);
  color: #fff;
}
.stepper-btn:active { transform: scale(0.95); }

.stepper-hints {
  display: flex;
  gap: var(--space-4);
  margin-top: 8px;
  font-size: var(--fs-sm);
}
.stepper-input {
  width: 90px;
  text-align: center;
  font-family: var(--font-heading-en);
  font-size: 1.2rem;
  font-weight: 700;
}
.stepper-unit {
  color: var(--text-muted);
  font-weight: 600;
  margin-inline-start: 4px;
}
.settings-savebar {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-3) 0;
}
.settings-savebar .btn { padding: 12px 28px; }

/* Lifecycle tabs */
.tabs {
  display: inline-flex;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 2px;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.tab-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Utility */
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--text-muted); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.bold { font-weight: 700; }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.center { text-align: center; }

/* Responsive
   ------------------------------------------------------------------
   MOBILE (≤900px). Desktop (>900px) is untouched: nothing here leaks
   upward. Ref: design-references/item-mobile-drawer.txt
   ("Side Menu / Drawer Navigation" — Andrew Daniels, dribbble.com/shots/
   2858471; nav-item continuity — Musemind dribbble.com/shots/17122423). */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }

  /* Header hamburger — matched to the other header .icon-btn's (40×40, radius-md) */
  .nav-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    cursor: pointer;
    padding: 0;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  }
  .nav-hamburger:hover { background: var(--bg-soft); border-color: var(--border); }
  .nav-hamburger:focus-visible { outline: 2px solid var(--sienna); outline-offset: 2px; }
  .nav-hamburger-icon { display: inline-flex; align-items: center; justify-content: center; }
  .nav-hamburger-icon svg { width: 22px; height: 22px; }

  /* SIDEBAR → off-canvas drawer. Anchored to its normal grid side via logical
     inset (start = RIGHT in RTL, LEFT in LTR); opaque --bg-elev so page content
     never shows through; scrolls internally; sits above the overlay. */
  .app-sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    inset-inline-start: 0;
    width: min(82vw, 320px);
    max-width: 320px;
    height: auto;
    max-height: none;
    display: block;
    padding: var(--space-4) var(--space-3) var(--space-5);
    background: var(--bg-elev);
    border-inline-start: none;
    border-inline-end: 1px solid var(--border);
    border-bottom: none;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    transition: transform var(--t-med);
  }
  /* Direction-aware off-canvas rest position (dir lives on <html>) */
  html[dir='rtl'] .app-sidebar { transform: translateX(100%); }
  html[dir='ltr'] .app-sidebar { transform: translateX(-100%); }
  /* Open state (body.nav-open on <body>) slides the drawer on-screen */
  html[dir='rtl'] body.nav-open .app-sidebar,
  html[dir='ltr'] body.nav-open .app-sidebar { transform: none; }

  /* Vertical nav list inside the drawer — base .nav-item block styling applies
     (full-width rows, active accent bar). Keep the drawer title as its header. */
  .sidebar-title { display: block; }

  /* Scrim behind the drawer + page scroll-lock while open */
  body.nav-open { overflow: hidden; }
  body.nav-open .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
  }

  .app-main { padding: var(--space-4); }
  /* Keep the sticky strip flush when .app-main padding shrinks to --space-4 */
  .tpl-sticky-strip {
    margin-inline: calc(-1 * var(--space-4));
    padding-inline: var(--space-4);
  }

  /* Two-column detail/editor areas stack on tablet */
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  /* --- Mobile header: compact SINGLE ROW (logo + control cluster, no wrap) ---
     Ref: design-references/item-mobile-header.txt
     The long brand title wrapped into several cramped lines and competed with the
     control cluster. On phones the brand collapses to just the logo mark and every
     control becomes a compact ~44px tap target on ONE nowrap row (fits 355px @360px). */
  .header-inner {
    padding: 8px var(--space-2);      /* 6px sides — keeps the row within 360px */
    gap: var(--space-2);
    flex-wrap: nowrap;
  }
  .brand { min-width: 0; flex-shrink: 0; }   /* logo never squeezed */
  .brand img { height: 32px; }               /* smaller mark → more room for cluster */
  .brand .name { display: none; }            /* hide title+subtitle → logo only, no wrap */

  .header-actions { gap: var(--space-2); flex-wrap: nowrap; }

  /* User chip → avatar only. Fixes the STALE span:not(.avatar) rule that never matched
     the .user-chip-info div markup. Strip the chip chrome so just the avatar shows. */
  .user-chip { padding: 0; background: transparent; border: none; margin-inline-end: 0; }
  .user-chip-info { display: none; }

  /* Logout → icon-only, sized like the sibling .icon-btn's (44px tap target) */
  #logout-btn { width: 44px; height: 44px; padding: 0; justify-content: center; }
  #logout-btn span[data-i18n="logout"] { display: none; }
  #logout-btn svg { width: 20px; height: 20px; }

  /* Notifications dropdown: anchor to the VIEWPORT, not the tiny bell wrapper mid-cluster.
     The old rule kept position:absolute so width:100vw stayed offset from the bell and ran
     off the right edge, hiding each item's subject+timestamp (only the ✕ showed). No header
     ancestor has transform/filter/perspective/will-change/contain, so position:fixed here is
     truly viewport-relative. top:64px clears the ~61px sticky mobile header with a small gap.
     Ref: design-references/item-mobile-notif.txt */
  .notif-dropdown {
    position: fixed;
    top: 64px;
    inset-inline-end: 8px;
    inset-inline-start: auto;
    width: min(92vw, 360px);
    max-width: calc(100vw - 16px);
    max-height: 72vh;
  }
  .notif-list { max-height: calc(72vh - 104px); }
  .notif-subject, .notif-time { overflow-wrap: anywhere; }

  /* --- Grids collapse to a single column (avoid minmax min > viewport overflow) --- */
  .kpi-grid { grid-template-columns: 1fr; }
  .attendance-grid { grid-template-columns: 1fr; }
  .sig-grid { grid-template-columns: 1fr; }

  /* --- Forms & buttons: full-width, 44px tap targets, no horizontal overflow --- */
  .form-row { grid-template-columns: 1fr; }
  .input, .textarea, .select { max-width: 100%; }
  .btn { width: 100%; min-height: 44px; }
  .btn.sm { width: auto; min-height: 0; }
  .btn-group { display: flex; flex-direction: column; align-items: stretch; }
  .btn-group .btn { width: 100%; }
  .row .btn { flex: 1 1 auto; }
  .icon-btn, .nav-hamburger { min-height: 44px; min-width: 44px; }
  /* Long strings (codes, emails) must never force sideways scroll */
  .kpi-card .value, .att-code, .email-chip { overflow-wrap: anywhere; }

  /* --- Tables: horizontal scroll so nothing is cut off (CSS-only, no markup change) --- */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table.data { min-width: 520px; }
  /* perm-table (5 narrow columns, lives in a modal): tighten so it fits, no scroll */
  .perm-table { font-size: 0.78rem; }
  .perm-table thead th, .perm-table td { padding: 6px 6px; }

  /* --- Modals: fill the small screen; body scrolls; footer buttons stack --- */
  .modal-backdrop { padding: 8px; align-items: flex-start; }
  .modal { max-width: 100%; width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .modal-body { overflow-y: auto; }
  .modal-footer { flex-direction: column-reverse; align-items: stretch; }
  .modal-footer .btn { width: 100%; }

  /* --- Tab strips wrap / scroll rather than overflow --- */
  .tabs { display: flex; width: 100%; flex-wrap: wrap; }
  .tab-btn { flex: 1 1 auto; text-align: center; }

  /* --- Login: fit + full-width CTA --- */
  .login-screen { padding: var(--space-4); }
  .login-card { padding: var(--space-5) var(--space-4) var(--space-4); }
  .login-logo { height: 84px; }

  /* --- Minutes on-screen editor/preview: readable + scrollable, print untouched --- */
  .mins-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* --- Calendar: REFLOW (not clip) so 7 tracks fit a ~360px viewport ---
     minmax(0,1fr) overrides the implicit minmax(auto,1fr) so day-tracks may shrink
     below their cell's min-content; cells clip and event pills ellipsis so no single
     cell can force a track wider than its 1/7 share. This is what removes the
     dashboard's horizontal overflow at its source (see item-mobile-overflow.txt),
     not the #app-view guard. */
  .calendar-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .cal-cell { min-width: 0; overflow: hidden; min-height: 58px; padding: 4px; gap: 3px; }
  .cal-cell .day-num { min-width: 20px; height: 20px; padding: 0 4px; font-size: 0.72rem; }
  .cal-event { max-width: 100%; font-size: 9px; padding: 2px 4px; }
  .cal-dow { padding: 2px 0; font-size: 0.66rem; }
  .calendar-wrap { padding: var(--space-4); }

  /* --- Dashboard cards/rows: reflow within 100%, never force width --- */
  .hero-card { padding: var(--space-4); max-width: 100%; box-sizing: border-box; gap: var(--space-3); }
  .hero-left { min-width: 0; flex-basis: 100%; }
  .hero-title { font-size: 1.6rem; }
  .btn-lg { width: 100%; }
  /* KPI section header (h3 + reset/add buttons): wrap the buttons under the title
     instead of forcing the row past the viewport width. */
  .row.between { flex-wrap: wrap; }
  .upcoming-card, .activity-card { padding: var(--space-4); max-width: 100%; box-sizing: border-box; }
}

/* ==========================================================================
   Official minutes — structured CARD editor (replaces the raw-text template)
   Uses theme tokens so it matches the panel (dark surface + taupe/sienna accent
   + rounded corners) and is fully RTL-safe.
   ========================================================================== */
.mins-doc { display: flex; flex-direction: column; gap: var(--space-3, 12px); }
.mins-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  position: relative;
}
/* Sienna accent bar on the inline-start edge (right in RTL) */
.mins-card::before {
  content: '';
  position: absolute;
  inset-inline-start: 0; top: 10px; bottom: 10px;
  width: 3px; border-radius: 3px;
  background: var(--sienna);
}
.mins-card-title {
  font-weight: 700;
  color: var(--taupe);
  margin-bottom: 10px;
  font-size: 0.98rem;
}
.mins-table { width: 100%; border-collapse: collapse; }
.mins-table th, .mins-table td {
  border: 1px solid var(--border);
  padding: 6px 8px; font-size: 0.85rem; text-align: start;
}
/* Header band --taupe-20 is a fixed light cream in BOTH themes, so the label must be
   a fixed-dark token (not --text, which flips to near-white in dark → invisible).
   --obsidian on --taupe-20 ≈ 10:1 contrast, well above WCAG AA (matches styles.css:~1782). */
.mins-table thead th { background: var(--taupe-20); color: var(--obsidian); font-weight: 700; }
/* An "axis" = one meeting topic, its own bordered sub-card with 3 sub-boxes */
.mins-axis {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  background: var(--bg);
}
.mins-axis:last-child { margin-bottom: 0; }
.mins-axis-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.mins-axis-title { flex: 1; font-weight: 700; }
.mins-subbox { margin-top: 8px; }
.mins-subbox > label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: 4px;
}
.mins-subbox textarea { min-height: 64px; }
/* Action-item rows: action | owner | deadline | delete */
.mins-actions-head,
.mins-action {
  display: grid;
  grid-template-columns: 1fr 140px 140px 34px;
  gap: 8px; align-items: center;
}
.mins-actions-head { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px; padding: 0 2px; }
.mins-action { margin-bottom: 8px; }
.mins-decision { display: grid; grid-template-columns: 1fr 34px; gap: 8px; margin-bottom: 8px; }
.mins-del { color: var(--sienna); }
@media (max-width: 640px) {
  .mins-actions-head { display: none; }
  .mins-action { grid-template-columns: 1fr 34px; }
  .mins-action [data-ai="owner"], .mins-action [data-ai="deadline"] { grid-column: 1 / 2; }
}

/* RTL/LTR specific tweaks */
/* Tail reconstructed after truncation (OneDrive/NUL-byte corruption; no clean
   copy in git or OneDrive). This html[dir='ltr'] .kpi-card::before rule was cut
   off mid-property and its original LTR-specific intent is unrecoverable. It is
   completed as a no-op vs the base .kpi-card::before rule, which already places
   the accent bar correctly in both directions via inset-inline-start: 0 — so
   there is zero visual regression. */
html[dir='ltr'] .kpi-card::before { inset-inline-start: 0; }
