/* ============================================================
   GAATW Members Platform — app.css
   Brand colours: Teal #06514F · Amber #dc8c1c
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --teal:         #06514F;
  --teal-mid:     #0a6e6b;
  --teal-light:   #e8f3f3;
  --teal-pale:    #f0f7f7;
  --teal-dark:    #04302F;
  --amber:        #dc8c1c;
  --amber-light:  #fdf3e3;
  --amber-dark:   #b8720f;

  --bg-primary:   #ffffff;
  --bg-secondary: #f8faf9;
  --bg-tertiary:  #f1f4f3;
  --border:       #e2e8e7;
  --border-mid:   #c8d5d4;

  --text-primary:   #1a2e2d;
  --text-secondary: #4a6665;
  --text-muted:     #7a9998;

  --red:          #c0392b;
  --red-light:    #fdecea;
  --green:        #1a7a4a;
  --green-light:  #e6f5ec;
  --blue:         #2e5da8;
  --blue-light:   #edf2fb;

  --radius:    9px;
  --radius-lg: 13px;
  --shadow:    0 1px 3px rgba(6,81,79,0.07), 0 4px 12px rgba(6,81,79,0.05);
  --shadow-lg: 0 8px 32px rgba(6,81,79,0.12);

  --font-sans:  'DM Sans', system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;

  --sidebar-width: 210px;
  --topbar-height: 50px;
}

[data-theme="dark"] {
  --bg-primary:   #1a2e2d;
  --bg-secondary: #152524;
  --bg-tertiary:  #0f1e1d;
  --border:       #2a4040;
  --border-mid:   #3a5555;
  --text-primary:   #e8f3f3;
  --text-secondary: #9aadac;
  --text-muted:     #5a7775;
  --teal-light:   #0f2e2d;
  --teal-pale:    #0a2322;
  --amber-light:  #2a1f0a;
  --red-light:    #2d1211;
  --green-light:  #0f2a1c;
  --blue-light:   #111e35;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font-sans); background: var(--bg-secondary); color: var(--text-primary); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--font-sans); }

/* ── Initial loader ────────────────────────────────────────── */
#initial-loader {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: var(--teal);
}
.loader-logo img { width: 64px; height: 64px; filter: brightness(0) invert(1); }
.loader-text { font-size: 16px; font-weight: 600; color: rgba(255,255,255,0.8); }
.loader-spinner {
  width: 28px; height: 28px; border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--amber); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth screens ──────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh; display: flex; align-items: stretch;
  background: var(--teal); position: relative; overflow: hidden;
}
.auth-bg {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 15% 65%, rgba(220,140,28,0.12) 0%, transparent 55%),
              radial-gradient(ellipse at 90% 15%, rgba(255,255,255,0.04) 0%, transparent 40%);
}
.auth-left {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 48px; position: relative; z-index: 2;
}
.auth-logo-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 36px; }
.auth-logo-img { width: 64px; height: 64px; flex-shrink: 0; }
.auth-logo-img img { width: 64px; height: 64px; object-fit: contain; }
.auth-brand { font-size: 20px; font-weight: 600; color: #fff; line-height: 1.2; }
.auth-url { font-size: 11px; color: rgba(255,255,255,0.45); margin-top: 2px; }
.auth-tagline {
  font-family: var(--font-serif); font-style: italic; font-size: 17px;
  color: rgba(255,255,255,0.88); line-height: 1.65; max-width: 380px;
  padding-left: 16px; border-left: 3px solid var(--amber);
}
.auth-tagline em { color: var(--amber); font-style: normal; }

.auth-right {
  width: 390px; background: var(--bg-primary);
  display: flex; flex-direction: column; justify-content: center;
  padding: 44px 40px; box-shadow: -24px 0 60px rgba(0,0,0,0.18);
  position: relative; z-index: 2; overflow-y: auto;
}
.auth-step { display: flex; flex-direction: column; }
.auth-step[hidden] { display: none; }
.auth-title { font-size: 20px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.auth-sub { font-size: 12px; color: var(--text-secondary); margin-bottom: 22px; line-height: 1.55; }

/* ── Form elements ─────────────────────────────────────────── */
.form-group { margin-bottom: 15px; }
.form-label {
  font-size: 10px; font-weight: 600; color: var(--text-secondary);
  display: block; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.05em;
}
.form-input {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: var(--font-sans); color: var(--text-primary);
  background: var(--bg-secondary); transition: border-color 0.15s, background 0.15s; outline: none;
}
.form-input:focus { border-color: var(--teal); background: var(--bg-primary); }
.form-input.error { border-color: var(--red); }
.form-hint { font-size: 10px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
.form-error {
  font-size: 12px; color: var(--red); background: var(--red-light);
  padding: 8px 10px; border-radius: var(--radius); margin-bottom: 10px;
}
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; }

/* Password strength */
.pw-strength { margin-top: 6px; }
.pw-bars { display: flex; gap: 3px; margin-bottom: 4px; }
.pw-bar { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background 0.2s; }
.pw-bar.weak { background: var(--red); }
.pw-bar.fair { background: var(--amber); }
.pw-bar.good { background: var(--green); }
.pw-label { font-size: 10px; color: var(--text-muted); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-main {
  width: 100%; padding: 11px; background: var(--teal); color: #fff; border: none;
  border-radius: var(--radius); font-size: 13px; font-weight: 600;
  font-family: var(--font-sans); letter-spacing: 0.02em;
  transition: background 0.15s; margin-top: 4px;
}
.btn-main:hover { background: var(--teal-mid); }
.btn-main:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-amber {
  padding: 7px 14px; background: var(--amber); color: #fff; border: none;
  border-radius: var(--radius); font-size: 12px; font-weight: 600;
  font-family: var(--font-sans); transition: background 0.15s;
}
.btn-amber:hover { background: var(--amber-dark); }
.btn-outline {
  padding: 6px 12px; background: transparent; color: var(--teal);
  border: 1.5px solid var(--teal); border-radius: var(--radius);
  font-size: 12px; font-weight: 500; font-family: var(--font-sans); transition: all 0.15s;
}
.btn-outline:hover { background: var(--teal-pale); }
.btn-sm {
  padding: 5px 10px; font-size: 11px; background: transparent;
  color: var(--teal); border: 1.5px solid var(--teal); border-radius: var(--radius);
  font-family: var(--font-sans);
}
.btn-danger {
  padding: 6px 12px; background: var(--red-light); color: var(--red);
  border: 1px solid #f5c2be; border-radius: var(--radius); font-size: 11px;
  font-family: var(--font-sans);
}

/* ── Auth misc ─────────────────────────────────────────────── */
.auth-links { display: flex; justify-content: space-between; margin-top: 10px; }
.auth-link { font-size: 11px; color: var(--teal); cursor: pointer; }
.auth-link-right { font-size: 11px; color: var(--text-muted); }
.auth-security-note { font-size: 10px; color: var(--text-muted); text-align: center; margin-top: 14px; }
.auth-back { font-size: 11px; color: var(--text-muted); text-align: center; cursor: pointer; margin-top: 10px; }
.auth-back:hover { color: var(--teal); }

/* OTP digit row */
.digit-row { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.digit {
  width: 44px; height: 52px; border: 2px solid var(--border); border-radius: var(--radius);
  font-size: 22px; font-weight: 600; text-align: center; font-family: var(--font-sans);
  color: var(--text-primary); background: var(--bg-secondary); outline: none;
  transition: border-color 0.15s;
}
.digit:focus { border-color: var(--teal); background: var(--bg-primary); }
.resend-link { font-size: 11px; color: var(--teal); cursor: pointer; text-align: center; margin-top: 6px; }
.otp-timer { font-size: 10px; color: var(--text-muted); text-align: center; margin-top: 3px; }

/* 2FA nudge */
.twofa-nudge {
  background: var(--amber-light); border: 1px solid #f5d9a0;
  border-radius: var(--radius); padding: 11px 13px; margin-top: 14px;
}
.twofa-title { font-size: 11px; font-weight: 600; color: var(--amber-dark); margin-bottom: 3px; }
.twofa-body { font-size: 10px; color: var(--amber-dark); line-height: 1.45; opacity: 0.9; }
.twofa-cta { display: block; font-size: 10px; font-weight: 600; color: var(--amber-dark); margin-top: 6px; }

/* Language switcher */
.lang-switcher { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.lang-chip {
  font-size: 10px; padding: 3px 8px; border-radius: 6px;
  background: var(--bg-tertiary); color: var(--text-secondary);
  cursor: pointer; border: 1px solid transparent;
}
.lang-chip.active { background: var(--teal); color: #fff; }
.lang-chip:hover:not(.active) { border-color: var(--teal); color: var(--teal); }

/* ── App layout ────────────────────────────────────────────── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--teal); display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}
.sb-logo {
  padding: 13px 14px; border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 9px; flex-shrink: 0;
}
.sb-logo-img { width: 30px; height: 30px; flex-shrink: 0; }
.sb-logo-img img { width: 30px; height: 30px; object-fit: contain; }
.sb-brand { font-size: 12px; font-weight: 600; color: #fff; line-height: 1.2; }
.sb-url { font-size: 9px; color: rgba(255,255,255,0.38); }
.sb-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sb-section {
  font-size: 9px; font-weight: 600; color: rgba(255,255,255,0.3);
  text-transform: uppercase; letter-spacing: 0.08em; padding: 9px 14px 3px;
}
.sb-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  cursor: pointer; color: rgba(255,255,255,0.6); font-size: 12px;
  border-left: 2px solid transparent; transition: all 0.1s; user-select: none;
}
.sb-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sb-item.active { background: rgba(255,255,255,0.1); color: #fff; border-left-color: var(--amber); }
.sb-badge {
  margin-left: auto; background: var(--amber); color: #fff;
  font-size: 9px; padding: 1px 5px; border-radius: 7px; font-weight: 600;
}
.sb-bottom { flex-shrink: 0; border-top: 1px solid rgba(255,255,255,0.08); }
.sb-theme-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; font-size: 11px; color: rgba(255,255,255,0.5); cursor: pointer;
}
.toggle-track {
  width: 34px; height: 18px; border-radius: 9px; background: rgba(255,255,255,0.2);
  position: relative; flex-shrink: 0;
}
.toggle-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
  position: absolute; top: 3px; left: 3px; transition: left 0.2s;
}
.toggle-track.on { background: var(--amber); }
.toggle-track.on .toggle-thumb { left: 19px; }
.sb-user {
  padding: 10px 14px; display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.sb-user:hover { background: rgba(255,255,255,0.05); }
.sb-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--amber);
  color: #fff; font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sb-user-name { font-size: 11px; color: #fff; font-weight: 500; }
.sb-user-role { font-size: 9px; color: rgba(255,255,255,0.38); }

/* Mobile sidebar */
.sb-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90;
}
.mobile-menu-btn {
  display: none; padding: 6px 10px; background: transparent; border: none;
  color: var(--text-primary); font-size: 18px;
}

/* Topbar */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: var(--topbar-height); background: var(--bg-primary);
  border-bottom: 1px solid var(--border); padding: 0 20px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; color: var(--text-primary); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* Page content */
.page-content { flex: 1; overflow-y: auto; background: var(--bg-tertiary); padding: 16px 18px; }

/* ── Layout utilities ──────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin-bottom: 12px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 13px 15px; margin-bottom: 12px;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px;
}
.card-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.card-sub { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.card-link { font-size: 11px; color: var(--amber); cursor: pointer; font-weight: 500; flex-shrink: 0; }

/* ── KPI cards ─────────────────────────────────────────────── */
.kpi-card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 13px;
}
.kpi-val { font-size: 22px; font-weight: 600; color: var(--teal); line-height: 1; margin-bottom: 3px; }
.kpi-val.amber { color: var(--amber); }
.kpi-val.red   { color: var(--red); }
.kpi-val.green { color: var(--green); }
.kpi-label { font-size: 10px; color: var(--text-secondary); }
.kpi-delta { font-size: 10px; margin-top: 3px; }
.delta-up   { color: var(--green); }
.delta-warn { color: var(--amber-dark); }
.delta-muted{ color: var(--text-muted); }

/* ── Filter bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center;
}
.filter-input {
  flex: 1; min-width: 160px; padding: 7px 11px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 12px; font-family: var(--font-sans);
  color: var(--text-primary); background: var(--bg-primary); outline: none;
  transition: border-color 0.15s;
}
.filter-input:focus { border-color: var(--teal); }
.filter-select {
  padding: 6px 10px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 11px; font-family: var(--font-sans);
  color: var(--text-primary); background: var(--bg-primary); cursor: pointer; outline: none;
}

/* ── News groups ───────────────────────────────────────────── */
.news-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 5px; overflow: hidden; }
.ng-head {
  display: flex; align-items: center; gap: 7px; padding: 8px 10px;
  cursor: pointer; background: var(--bg-tertiary); transition: background 0.1s; user-select: none;
}
.ng-head:hover { background: var(--teal-pale); }
.ng-stripe { width: 3px; height: 18px; border-radius: 2px; flex-shrink: 0; }
.ng-label { font-size: 12px; font-weight: 500; flex: 1; color: var(--text-primary); }
.ng-count {
  font-size: 10px; color: var(--text-secondary); background: var(--bg-primary);
  padding: 1px 7px; border-radius: 7px; border: 1px solid var(--border);
}
.ng-arrow { font-size: 10px; color: var(--text-muted); transition: transform 0.15s; }
.ng-arrow.open { transform: rotate(90deg); }
.ng-body { display: none; padding: 7px 10px; border-top: 1px solid var(--border); }
.ng-body.open { display: block; }
.ng-item { padding: 5px 0; border-bottom: 1px solid var(--bg-tertiary); font-size: 11px; line-height: 1.4; }
.ng-item:last-child { border-bottom: none; }
.ng-source { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ── Score badges ──────────────────────────────────────────── */
.score-badge { font-size: 9px; padding: 1px 5px; border-radius: 4px; font-weight: 600; }
.score-hi  { background: var(--green-light); color: var(--green); }
.score-mid { background: var(--amber-light); color: var(--amber-dark); }
.score-low { background: var(--bg-tertiary); color: var(--text-muted); }
.score-float { float: right; margin-left: 5px; }

/* ── Member cards ──────────────────────────────────────────── */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px; }
.member-card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.member-card:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.mc-top { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 8px; }
.mc-avatar {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.mc-name { font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--text-primary); }
.mc-location { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.mc-themes { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 6px; }
.mc-theme { font-size: 9px; padding: 2px 5px; border-radius: 5px; background: var(--teal-light); color: var(--teal); font-weight: 500; }
.mc-footer { display: flex; align-items: center; font-size: 10px; color: var(--text-muted); }
.mc-score { margin-left: auto; font-size: 12px; font-weight: 600; }

/* ── Media items ───────────────────────────────────────────── */
.media-item {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 14px; margin-bottom: 8px; display: flex; gap: 12px;
}
.mi-score-col {
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; width: 36px; flex-shrink: 0; padding-top: 2px;
}
.mi-score-val { font-size: 16px; font-weight: 700; }
.mi-score-lbl { font-size: 8px; color: var(--text-muted); text-align: center; line-height: 1.2; }
.mi-body { flex: 1; min-width: 0; }
.mi-title { font-size: 13px; font-weight: 600; line-height: 1.4; margin-bottom: 4px; color: var(--text-primary); }
.mi-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.mi-source {
  font-size: 10px; background: var(--bg-tertiary); padding: 1px 6px;
  border-radius: 4px; color: var(--text-secondary);
}
.mi-date { font-size: 10px; color: var(--text-muted); }
.mi-lang { font-size: 10px; color: var(--teal); background: var(--teal-light); padding: 1px 6px; border-radius: 4px; }
.mi-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 5px; }
.mi-tag { font-size: 9px; padding: 2px 6px; border-radius: 5px; font-weight: 500; }
.mi-summary { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }
.mi-org-tags { margin-top: 5px; font-size: 10px; color: var(--text-muted); }
.mi-org-tag { color: var(--teal); }

/* Topic tag colours */
.tag-trafficking  { background: #fdecea; color: #a93226; }
.tag-labour        { background: var(--teal-light); color: var(--teal); }
.tag-policy       { background: var(--amber-light); color: var(--amber-dark); }
.tag-migration    { background: var(--blue-light); color: var(--blue); }
.tag-srhr         { background: #f3edf9; color: #6a3b9a; }
.tag-domestic     { background: var(--green-light); color: var(--green); }
.tag-default      { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ── Opportunity items ─────────────────────────────────────── */
.opp-item {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 14px; margin-bottom: 8px; display: flex; gap: 12px;
}
.opp-icon { width: 40px; height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.opp-body { flex: 1; }
.opp-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.opp-funder { font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; }
.opp-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.opp-pill { font-size: 10px; padding: 2px 7px; border-radius: 5px; }
.pill-deadline { background: var(--red-light); color: var(--red); font-weight: 500; }
.pill-soon     { background: var(--amber-light); color: var(--amber-dark); font-weight: 500; }
.pill-open     { background: var(--green-light); color: var(--green); font-weight: 500; }
.pill-region   { background: var(--teal-light); color: var(--teal); }
.pill-amount   { background: var(--amber-light); color: var(--amber-dark); font-weight: 500; }
.pill-type     { background: var(--blue-light); color: var(--blue); }
.pill-free     { background: var(--teal-light); color: var(--teal); font-weight: 500; }

/* ── Attention panel ───────────────────────────────────────── */
.attention-list { display: flex; flex-direction: column; }
.attention-item {
  display: flex; gap: 8px; padding: 7px 0;
  border-bottom: 1px solid var(--bg-tertiary); align-items: flex-start;
}
.attention-item:last-child { border-bottom: none; }
.att-pip { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.att-pip.urgent  { background: var(--red); }
.att-pip.warning { background: var(--amber); }
.att-pip.info    { background: var(--teal); }
.att-title { font-size: 11px; font-weight: 500; line-height: 1.3; }
.att-detail { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

/* ── Bars ──────────────────────────────────────────────────── */
.region-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.rb-name { font-size: 11px; color: var(--text-secondary); width: 80px; flex-shrink: 0; }
.rb-track { flex: 1; background: var(--bg-tertiary); border-radius: 3px; height: 7px; overflow: hidden; }
.rb-fill  { height: 100%; border-radius: 3px; background: var(--teal); }
.rb-val   { font-size: 11px; color: var(--text-secondary); width: 24px; text-align: right; }

/* ── Sparkline ─────────────────────────────────────────────── */
.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 36px; }
.sp-bar { flex: 1; border-radius: 2px 2px 0 0; min-height: 3px; cursor: pointer; transition: opacity 0.1s; }
.sp-bar:hover { opacity: 0.8; }

/* ── Heat map ──────────────────────────────────────────────── */
.heat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.heat-cell { border-radius: 7px; padding: 7px 8px; text-align: center; }
.heat-label { font-size: 10px; font-weight: 500; }
.heat-val   { font-size: 17px; font-weight: 600; margin-top: 2px; }

/* ── Report buttons ────────────────────────────────────────── */
.report-btn {
  padding: 8px 10px; background: var(--bg-tertiary); border-radius: 8px;
  cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--text-primary); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; transition: border-color 0.15s;
}
.report-btn:hover { border-color: var(--teal); color: var(--teal); }

/* ── Settings rows ─────────────────────────────────────────── */
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--bg-tertiary);
}
.settings-row:last-child { border-bottom: none; }
.settings-label { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.settings-desc  { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.settings-select {
  font-size: 11px; padding: 4px 8px; border: 1.5px solid var(--border);
  border-radius: 7px; font-family: var(--font-sans); color: var(--text-primary);
  background: var(--bg-primary);
}
.settings-tag { font-size: 10px; padding: 2px 8px; border-radius: 5px; font-weight: 500; }
.stag-active { background: var(--green-light); color: var(--green); }
.stag-warn   { background: var(--amber-light); color: var(--amber-dark); }
.stag-off    { background: var(--bg-tertiary); color: var(--text-muted); }

/* Toggle */
.toggle {
  width: 34px; height: 18px; border-radius: 9px; background: var(--border);
  position: relative; cursor: pointer; transition: background 0.2s; flex-shrink: 0;
}
.toggle.on { background: var(--teal); }
.toggle::after {
  content: ''; position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: left 0.2s;
}
.toggle.on::after { left: 19px; }

/* Section tabs */
.section-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.section-tab {
  padding: 7px 14px; font-size: 11px; cursor: pointer; color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s;
}
.section-tab:hover { color: var(--text-primary); }
.section-tab.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 500; }

/* ── ACL table ─────────────────────────────────────────────── */
.acl-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.acl-table th {
  text-align: left; padding: 7px 9px; font-size: 10px; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); background: var(--bg-tertiary);
}
.acl-table td { padding: 7px 9px; border-bottom: 1px solid var(--bg-tertiary); vertical-align: middle; }
.acl-table tr:last-child td { border-bottom: none; }
.acl-table tr:hover td { background: var(--teal-pale); }
.perm { width: 22px; height: 22px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }
.perm-yes { background: var(--green-light); color: var(--green); }
.perm-no  { background: var(--red-light); color: var(--red); }
.perm-cfg { background: var(--amber-light); color: var(--amber-dark); cursor: pointer; }
.acl-role-col { text-align: center; }
.acl-section-row td { background: var(--bg-tertiary); font-size: 10px; font-weight: 600; color: var(--text-secondary); padding: 5px 9px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Empty states ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px; }
.empty-state-icon { font-size: 32px; margin-bottom: 8px; }

/* ── Loading skeleton ──────────────────────────────────────── */
.skeleton { background: var(--border); border-radius: 4px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Tooltips ──────────────────────────────────────────────── */
.tooltip-wrap { position: relative; display: inline-block; }
.tooltip-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; background: var(--border);
  color: var(--text-secondary); font-size: 9px; font-weight: 600; cursor: help; margin-left: 4px;
}
.tooltip-text {
  visibility: hidden; opacity: 0; position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: var(--text-primary); color: var(--bg-primary);
  font-size: 10px; padding: 5px 8px; border-radius: 5px; white-space: nowrap; max-width: 200px;
  white-space: normal; text-align: center; z-index: 100; transition: opacity 0.15s;
}
.tooltip-wrap:hover .tooltip-text { visibility: visible; opacity: 1; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -var(--sidebar-width); z-index: 100; transition: left 0.25s; }
  .sidebar.open { left: 0; }
  .mobile-menu-btn { display: block; }
  .auth-left { display: none; }
  .auth-right { width: 100%; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .member-grid { grid-template-columns: 1fr; }
  .page-content { padding: 12px; }
}
@media (max-width: 480px) {
  .media-item { flex-direction: column; }
  .mi-score-col { flex-direction: row; gap: 8px; width: auto; }
}
/* ============================================================
   MOBILE ADDITIONS — append to the bottom of app.css
   These supplement the existing responsive rules to ensure
   every page works smoothly on phones and tablets.
   ============================================================ */

/* ── Touch targets ─────────────────────────────────────────── */
/* All interactive elements must be at least 44px tall on mobile */
@media (max-width: 768px) {
  .btn-main, .btn-amber, .btn-outline { min-height: 44px; }
  .sb-item { padding: 10px 14px; }
  .form-input { padding: 11px 12px; font-size: 16px; /* prevents iOS zoom */ }
  .filter-input { font-size: 16px; }
  select.form-input { font-size: 16px; }
  .digit { width: 42px; height: 50px; font-size: 20px; }

  /* ── KPI grids collapse to 2×2 ──── */
  .grid-5, .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }

  /* ── Topbar ─────────────────────────────────────────────── */
  .topbar { padding: 0 12px; }
  .topbar-title { font-size: 14px; }

  /* ── Cards ──────────────────────────────────────────────── */
  .card { padding: 12px; }
  .card-title { font-size: 13px; }

  /* ── Media items ─────────────────────────────────────────── */
  .media-item { flex-direction: column; gap: 6px; }
  .mi-score-col { flex-direction: row; width: auto; gap: 6px; align-items: center; }
  .mi-score-val { font-size: 14px; }

  /* ── Sidebar in mobile ───────────────────────────────────── */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%); transition: transform 0.25s ease;
    z-index: 100; box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; }

  /* ── Member grid ─────────────────────────────────────────── */
  .member-grid { grid-template-columns: 1fr; }

  /* ── Auth screen ─────────────────────────────────────────── */
  .auth-right { padding: 28px 20px; }
  .auth-title { font-size: 18px; }

  /* ── OTP digits ──────────────────────────────────────────── */
  .digit-row { gap: 6px; }

  /* ── Page content ────────────────────────────────────────── */
  .page-content { padding: 10px 12px; }

  /* ── Opportunity items ───────────────────────────────────── */
  .opp-item { flex-direction: column; gap: 8px; }
  .opp-icon { align-self: flex-start; }

  /* ── Filter bar ──────────────────────────────────────────── */
  .filter-bar { flex-direction: column; }
  .filter-input, .filter-select { width: 100%; }

  /* ── Section tabs — scrollable on narrow screens ─────────── */
  .section-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .section-tabs::-webkit-scrollbar { display: none; }
  .section-tab { white-space: nowrap; flex-shrink: 0; }

  /* ── ACL table — horizontal scroll ──────────────────────── */
  .acl-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ── Reports buttons ─────────────────────────────────────── */
  .report-btn { padding: 10px 12px; }

  /* ── Settings rows ───────────────────────────────────────── */
  .settings-row { flex-direction: column; gap: 6px; align-items: flex-start; }
  .settings-row .settings-select { width: 100%; }

  /* ── Topbar actions — icon only on very small screens ─────── */
  .topbar-actions .btn-outline { display: none; } /* Hide secondary action on mobile */
}

/* ── Very small phones (< 360px) ──────────────────────────── */
@media (max-width: 360px) {
  .grid-5, .grid-4 { grid-template-columns: 1fr; }
  .auth-right { padding: 20px 16px; }
  .otp-digits { gap: 4px; }
  .digit { width: 38px; height: 44px; font-size: 18px; }
}

/* ── Tablet (768px–1024px) ─────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-width: 190px; }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .member-grid { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 14px 16px; }
}

/* ── Prevent iOS double-tap zoom on buttons ─────────────────── */
button, .btn-main, .btn-amber, .btn-outline, .sb-item, .member-card {
  touch-action: manipulation;
}

/* ── Smooth momentum scrolling on iOS ──────────────────────── */
.page-content, .sb-nav, .media-item, .member-grid {
  -webkit-overflow-scrolling: touch;
}

/* ── Safe area insets (iPhone notch / home bar) ────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sidebar {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .topbar {
    padding-top: calc(0px + env(safe-area-inset-top));
    height: calc(var(--topbar-height) + env(safe-area-inset-top));
  }
}

/* ── Print styles (for exported reports) ───────────────────── */
@media print {
  .sidebar, .topbar, .filter-bar, .btn-main, .btn-amber, .btn-outline { display: none !important; }
  .page-content { padding: 0; overflow: visible; }
  .main-area { overflow: visible; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}
/* =============================================================
   Additions to app.css — form section labels and wide modals
   ============================================================= */

/* ── Form section label ───────────────────────────────────────
   Visual divider between groups of fields inside a form.
   ─────────────────────────────────────────────────────────── */

.form-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

/* ── Wide form modal ──────────────────────────────────────────
   The form modal scroller needs its own scroll context so
   the header and footer stay sticky while content scrolls.
   ─────────────────────────────────────────────────────────── */

#form-modal {
  -webkit-overflow-scrolling: touch;
}

#form-modal-body input,
#form-modal-body select,
#form-modal-body textarea {
  font-size: 13px; /* override 16px mobile rule inside modals */
}

@media (max-width: 560px) {
  #form-modal {
    padding: 0;
    align-items: flex-end;
  }

  #form-modal > div {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    max-height: 94vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  #form-modal-body {
    flex: 1;
    overflow-y: auto !important;
    max-height: unset !important;
  }

  /* Two-column grids become single column inside modals on small screens */
  #form-modal-body > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  #form-modal-body > div[style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}
