/* ============================================
   FILE: styles.css
   EDIT THIS FILE to change: colours, fonts,
   layout, buttons, cards, badges, forms

   Brand theme (approved Oct 2026): white / light corporate look.
   Yellow + grey are the brand. Purple is ONLY an accent (active menu
   item, progress, links, focus). Red / amber / green only mean
   late / due soon / done.

   The OLD variable names (--bg, --bg2, --text3, --gold, --gold-dim …)
   are used inline all over the JS files, so they are kept and simply
   remapped to light-theme values here. New code should prefer the
   brand tokens (--card, --line, --t2, --yellow, --purple-soft …).
   ============================================ */

/* --- VARIABLES & THEME --- */
:root {
  /* Brand tokens */
  --card:        #FFFFFF;
  --line:        #E3E3E0;
  --line2:       #D2D2CE;
  --t2:          #555552;
  --t3:          #6B6B67;   /* was #7A7A76 (4.3:1 on white — below the 4.5:1 minimum for normal text) */
  --yellow:      #FBD100;
  --yellow-soft: #FFF6CC;
  --purple-soft: #F3EAF1;
  --red-soft:    #FDECEC;
  --amber:       #B45309;
  --amber-soft:  #FFF4E5;
  --green-soft:  #E8F5E9;
  --ink-on-yellow: #1E1E1E;
  --gold-ink:    #6E5500;   /* readable "gold" for TEXT on white (yellow text is unreadable) */

  /* Legacy names → light theme */
  --bg:      #F5F5F3;
  --bg1:     #FFFFFF;
  --bg2:     #FFFFFF;
  --bg3:     #FAFAF8;
  --bg4:     #F0F0EC;
  --border:  #E3E3E0;
  --border1: #EFEFEC;
  --border2: #D2D2CE;
  --border3: #BDBDB8;
  --text:    #1E1E1E;
  --text1:   #1E1E1E;
  --text2:   #555552;
  --text3:   #6B6B67;   /* a touch darker than --t3 for small secondary text (readability) */
  --gold:    #FBD100;   /* backgrounds / buttons only */
  --gold2:   #EBC400;
  --gold-dim:#FFF6CC;
  --red:     #C62828;
  --red-dim: #FDECEC;
  --orange:  #B45309;
  --ora-dim: #FFF4E5;
  --orange-dim: #FFF4E5;
  --green:   #2E7D32;
  --grn-dim: #E8F5E9;
  --green-dim: #E8F5E9;
  --blue:    #2F5B8A;   /* readable dark slate-blue */
  --blu-dim: #EAF0F7;
  --blue-dim:#EAF0F7;
  --purple:  #5F2C57;
  --pur-dim: #F3EAF1;
  --purple-dim: #F3EAF1;
  --teal:    #0F6E78;   /* readable dark teal */
  --teal-dim:#E6F3F4;
  --r:       12px;
  --sidebar: 232px;
  --font:    'DM Sans', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --bottom-nav-h: 62px;
  --safe-b:  env(safe-area-inset-bottom, 0px);
}

/* --- RESET --- */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--text); }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

/* One font everywhere: the old display font (Syne) is gone, and several
   screens still ask for it inline or in their own <style> blocks. */
body, body *:not(svg):not(svg *) { font-family: var(--font) !important; }

/* --- LAYOUT --- */
#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
#sidebar { width: var(--sidebar); min-width: var(--sidebar); background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; transition: transform .3s ease; z-index: 100; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
#topbar { height: 60px; min-height: 60px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 24px; gap: 12px; }
#content { flex: 1; overflow-y: auto; padding: 24px; }
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(30,30,30,.35); z-index: 99; }

/* --- SIDEBAR --- */
.brand { padding: 18px 16px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.brand-logo { height: 84px; width: auto; display: block; }
.brand-name { font-family: var(--font); font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--t3); letter-spacing: .18em; text-transform: uppercase; font-weight: 700; }
#sidebar-tools { display: none; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-btn { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; border: none; background: none; color: var(--t2); width: 100%; text-align: left; font-size: 14px; font-weight: 500; transition: background .15s, color .15s; position: relative; }
.nav-btn.active { background: var(--purple-soft); color: var(--purple); font-weight: 700; box-shadow: inset 3px 0 0 var(--purple); }
.nav-btn svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }
.nav-btn.active svg { opacity: 1; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; min-width: 20px; text-align: center; }
.sidebar-user { padding: 14px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: var(--t3); }
.user-actions { display: flex; gap: 6px; }

/* --- TOPBAR --- */
#hamburger { display: none; background: none; border: none; color: var(--text); padding: 4px; align-items: center; justify-content: center; }
.topbar-badge { display: none; height: 30px; width: auto; }
#page-title { font-family: var(--font); font-size: 20px; font-weight: 700; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overdue-pill { display: flex; align-items: center; gap: 6px; background: var(--red-soft); border: 1px solid #F3B8B8; border-radius: 20px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--red); cursor: pointer; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
/* Personal / Role toggle (colours are painted by _paintViewModeButtons) */
#view-mode-toggle { background: var(--bg4) !important; border-color: var(--line) !important; }

/* Round "+" new-task button — phone only (see mobile section) */
#fab-new-task { display: none; }

/* --- BOTTOM TAB BAR (phone only) --- */
#bottom-nav { display: none; }

/* --- BUTTONS --- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 14px; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; line-height: 1.2; }
.btn-gold { background: var(--yellow); color: var(--ink-on-yellow); border-color: var(--yellow); font-weight: 700; }
.btn-ghost { background: var(--card); color: var(--text); border-color: var(--line2); }
.btn-green { background: var(--green-soft); color: var(--green); border-color: #A5D6A7; }
.btn-red { background: var(--red-soft); color: var(--red); border-color: #EF9A9A; }
.btn-blue { background: var(--blu-dim); color: var(--blue); border-color: #B5C7DC; }
.btn-orange { background: var(--amber-soft); color: var(--amber); border-color: #F5C58A; }
.btn-teal { background: var(--teal-dim); color: var(--teal); border-color: #9FCFD4; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* --- CARDS --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-family: var(--font); font-size: 15px; font-weight: 700; color: var(--text); }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.stat-value { font-family: var(--font); font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--t2); margin-top: 6px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }

/* --- BADGES --- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; letter-spacing: .2px; }

/* Urgency badges */
.badge-critical  { background: var(--red-soft);   color: var(--red);    border: 1px solid #F3B8B8; }
.badge-high      { background: var(--amber-soft); color: var(--amber);  border: 1px solid #F5C58A; }
.badge-medium    { background: var(--yellow-soft); color: var(--gold-ink); border: 1px solid #F0DC7A; }
.badge-low       { background: var(--green-soft); color: var(--green);  border: 1px solid #A5D6A7; }

/* ── Workflow status badges ───────────────────────────────────────── */
/* Awaiting Acceptance — neutral slate, task exists but not started */
.badge-awaiting-accept { background: var(--blu-dim); color: var(--blue); border: 1px solid #C9D6E5; }
/* In Progress — neutral grey (as in the approved design) */
.badge-inprogress { background: #EFEFEC; color: var(--t2); border: 1px solid var(--line2); }
/* Awaiting Approval — purple accent, waiting for sign-off */
.badge-awaiting-approval { background: var(--purple-soft); color: var(--purple); border: 1px solid #DCC6D8; }
/* Done — green */
.badge-done { background: var(--green-soft); color: var(--green); border: 1px solid #A5D6A7; }
/* Overdue — red */
.badge-overdue   { background: var(--red-soft);  color: var(--red);  border: 1px solid #F3B8B8; }
/* Cancelled — muted */
.badge-cancelled { background: var(--bg4);       color: var(--t3);   border: 1px solid var(--line2); }
/* Timeline Countered — amber (new deadline proposed) */
.badge-counter   { background: var(--amber-soft); color: var(--amber); border: 1px solid #F5C58A; }
/* Request (cross-dept) */
.badge-request   { background: var(--blu-dim);  color: var(--blue);   border: 1px solid #C9D6E5; }

/* --- FORMS --- */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; color: var(--t2); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.form-input { background: var(--card); border: 1px solid var(--line2); border-radius: 8px; color: var(--text); padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s; width: 100%; }
.form-input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(95,44,87,.12); }
.form-input::placeholder { color: var(--t3); }
select.form-input option { background: var(--card); color: var(--text); }
textarea.form-input { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--t2); }
.form-check input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--purple); }
input[type=checkbox], input[type=radio] { accent-color: var(--purple); }
.recurring-options { background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 4px; display: flex; flex-direction: column; gap: 10px; }

/* --- MODALS --- */
.modal-wrap { position: fixed; inset: 0; background: rgba(30,30,30,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .15s ease; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 580px; }
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 960px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.modal-title { font-family: var(--font); font-size: 18px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; color: var(--t2); font-size: 22px; line-height: 1; padding: 4px 8px; border-radius: 6px; min-width: 36px; min-height: 36px; }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* Login screen logo (auth.js modal) */
.login-logo { display: block; height: 96px; width: auto; margin: 4px auto 0; }

/* --- TASK TABLE --- */
.task-table { width: 100%; border-collapse: collapse; }
.task-table th { font-size: 12px; color: var(--t3); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; padding: 10px 12px; text-align: left; background: var(--bg3); border-bottom: 1px solid var(--line); white-space: nowrap; }
.task-table td { padding: 11px 12px; border-bottom: 1px solid #EFEFEC; vertical-align: middle; }
.task-table tr:last-child td { border-bottom: none; }
.task-row-title { font-weight: 600; color: var(--text); cursor: pointer; }
.task-row-meta { font-size: 12px; color: var(--t3); margin-top: 2px; }
.task-overdue td { background: rgba(198,40,40,.035); }

/* --- AVATARS --- */
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--purple-soft); border: 1px solid #E2CFDD; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--purple); flex-shrink: 0; }
.avatar-sm { width: 22px; height: 22px; font-size: 9px; }
.avatar-lg { width: 38px; height: 38px; font-size: 14px; }

/* --- FILTERS --- */
.filters-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-select { background: var(--card); border: 1px solid var(--line2); border-radius: 8px; color: var(--text); padding: 7px 10px; font-size: 13px; outline: none; }
.filter-select:focus { border-color: var(--purple); }
.search-input { background: var(--card); border: 1px solid var(--line2); border-radius: 8px; color: var(--text); padding: 7px 12px; font-size: 14px; outline: none; min-width: 200px; }
.search-input:focus { border-color: var(--purple); }
.search-input::placeholder { color: var(--t3); }

/* --- TABS --- */
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; width: fit-content; max-width: 100%; margin-bottom: 20px; }
.tab-btn { padding: 7px 16px; border-radius: 8px; border: none; background: none; color: var(--t2); font-size: 14px; font-weight: 600; transition: background .15s, color .15s; }
.tab-btn.active { background: var(--purple); color: #fff; }

/* --- ACTION PANEL (approval / rejection) --- */
.action-panel { border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.action-panel.approval { background: var(--yellow-soft); border: 1px solid #F0DC7A; }
.action-panel.awaiting { background: var(--blu-dim); border: 1px solid #C9D6E5; }
.action-panel-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.action-panel.approval .action-panel-title { color: var(--gold-ink); }
.action-panel.awaiting .action-panel-title { color: var(--blue); }

/* --- MISC UTILITIES --- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--t3); }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--t3); }
.spinner { width: 24px; height: 24px; border: 3px solid var(--line); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
.section-title { font-family: var(--font); font-size: 13px; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.text-gold   { color: var(--gold-ink); }
.text-red    { color: var(--red); }
.text-green  { color: var(--green); }
.text-blue   { color: var(--blue); }
.text-muted  { color: var(--t3); }
/* Grid cells may shrink below their content's width (long text wraps or
   scrolls inside instead of pushing the page wider). */
.grid-2 > *, .grid-3 > *, .grid-4 > *, [style*="display:grid"] > *, [style*="display: grid"] > * { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.mb-16  { margin-bottom: 16px; }
.mb-20  { margin-bottom: 20px; }
.mb-24  { margin-bottom: 24px; }
.progress-bar { height: 6px; background: #EAEAE6; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--purple); border-radius: 4px; transition: width .3s; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border3); flex-shrink: 0; margin-top: 6px; }
.timeline-dot.action { background: var(--purple); }
.watcher-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.watcher-chip { display: flex; align-items: center; gap: 4px; background: var(--bg3); border: 1px solid var(--line2); border-radius: 20px; padding: 2px 8px 2px 4px; font-size: 13px; }
.watcher-chip button { background: none; border: none; color: var(--t3); font-size: 15px; line-height: 1; padding: 0 0 0 2px; }
.cross-dept-banner { background: var(--blu-dim); border: 1px solid #C9D6E5; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--blue); margin-bottom: 12px; }
.score-ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring-val { position: absolute; font-family: var(--font); font-weight: 700; font-size: 11px; color: var(--text); }
.podium-wrap { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 20px 0; }
.podium-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.podium-bar { border-radius: 6px 6px 0 0; width: 64px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; font-size: 12px; font-weight: 700; color: var(--ink-on-yellow); }
.podium-1 { background: var(--yellow); height: 90px; }
.podium-2 { background: #C9C9C4; height: 66px; }
.podium-3 { background: #D9B48C; height: 50px; }

/* In-app "turn on alerts" card for store logins (notifications-push.js) */
.oc-push-card { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 900; width: min(420px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--yellow); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.16);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.oc-push-card .oc-push-title { font-size: 16px; font-weight: 700; color: var(--text); }
.oc-push-card .oc-push-text { font-size: 14px; color: var(--t2); line-height: 1.4; }
/* Wave B: alert status bar on the Alerts screen */
.oc-alert-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px;
  color: var(--text); background: var(--bg2); line-height: 1.45; }
.oc-alert-bar.oc-alert-on { border-color: var(--green); background: var(--grn-dim); }
.oc-alert-bar.oc-alert-off { border-color: var(--gold); background: var(--gold-dim); }
.oc-alert-bar.oc-alert-blocked { border-color: var(--red); background: var(--red-dim); }
@media (max-width: 768px) { .oc-alert-bar { font-size: 14px; } }
.oc-push-card .oc-push-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* --- TOAST --- */
#toast { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast-item { background: var(--text); border: 1px solid var(--text); border-radius: 10px; padding: 12px 16px; font-size: 14px; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: slideUp .2s ease; pointer-events: auto; max-width: 340px; }
.toast-item.success { background: var(--green); border-color: var(--green); color: #fff; }
.toast-item.error   { background: var(--red);   border-color: var(--red);   color: #fff; }

/* --- ANIMATIONS --- */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════════════════════════
   INLINE-COLOUR SAFETY NET
   Many screens (other JS files) colour TEXT with var(--gold) inline.
   On white, yellow text is unreadable, so any element whose inline style
   says "color:var(--gold)" is shown in a dark gold ink instead. Elements
   that sit ON a yellow background always get dark ink.
   (A later theme sweep fixes these inline styles at the source.)
   ═══════════════════════════════════════════ */
[style*="color:var(--gold)"], [style*="color: var(--gold)"] { color: var(--gold-ink) !important; }
[style*="background:var(--gold)"], [style*="background: var(--gold)"],
[style*="background-color:var(--gold)"], [style*="background-color: var(--gold)"] { color: var(--ink-on-yellow) !important; }
/* Bright "on black" score colours hard-coded in the audit screens
   (au-*.js): shown in the readable brand equivalents on white. */
[style*="color:#22c55e"], [style*="color: #22c55e"], [style*="color:#4ade80"] { color: var(--green) !important; }
[style*="color:#14b8a6"], [style*="color: #14b8a6"] { color: var(--teal) !important; }
[style*="color:#eab308"], [style*="color: #eab308"], [style*="color:#facc15"],
[style*="color:#f5c518"], [style*="color:#F5C518"], [style*="color: #f5c518"] { color: var(--gold-ink) !important; }
[style*="color:#f97316"], [style*="color: #f97316"] { color: var(--amber) !important; }
[style*="color:#ef4444"], [style*="color: #ef4444"] { color: var(--red) !important; }
[style*="color:#60a5fa"], [style*="color: #60a5fa"] { color: var(--blue) !important; }
[style*="color:#a855f7"], [style*="color: #a855f7"] { color: var(--purple) !important; }
/* Screens that inject their own <style> with yellow text (cl-nav.js,
   view-locations.js, view-people.js, view-org-tree.js, view-markets.js,
   view-ownership.js). Active tabs use the purple accent; codes/tags dark gold. */
.cl-nav-btn.active { background: var(--purple-soft) !important; color: var(--purple) !important; font-weight: 700 !important; }
.lv-tab-active, .pv-tab-active { color: var(--purple) !important; border-bottom-color: var(--purple) !important; }
.lv-code, .lv-code-tag, .ow-code, .ot-node-role, .ot-market-tag, .mv-avatar { color: var(--gold-ink) !important; }
/* teal / blue were bright accents on black; their soft "-dim" backgrounds
   stay readable because the variables themselves are now dark tones. */

/* ═══════════════════════════════════════════
   HOVER — only on devices that really hover
   (stops "stuck" hover colours after a tap on phones)
   ═══════════════════════════════════════════ */
@media (hover: hover) {
  .nav-btn:not(.active):hover { background: var(--bg4); color: var(--text); }
  .btn-gold:hover { background: var(--gold2); border-color: var(--gold2); }
  .btn-ghost:hover { background: var(--bg4); color: var(--text); border-color: var(--border3); }
  /* Coloured buttons only deepen their soft tint on hover: screens often set
     the text colour inline, so a solid fill could hide the label. */
  .btn-green:hover { background: #DCEFDD; border-color: var(--green); }
  .btn-red:hover { background: #FADADA; border-color: var(--red); }
  .btn-blue:hover { background: #DCE6F1; border-color: var(--blue); }
  .btn-orange:hover { background: #FDE9CF; border-color: var(--amber); }
  .btn-teal:hover { background: #D5EBED; border-color: var(--teal); }
  .modal-close:hover { color: var(--text); background: var(--bg4); }
  .task-table tr:hover td { background: var(--bg3); }
  .task-row-title:hover { color: var(--purple); }
  .watcher-chip button:hover { color: var(--red); }
  .tab-btn:not(.active):hover { background: var(--bg4); color: var(--text); }
  #bottom-nav .bn-item:hover { color: var(--text); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   ═══════════════════════════════════════════ */

/* ── Tablet: ≤ 900px ─────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar: 210px; }
  #content { padding: 16px; }
  .grid-4 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ── Mobile: ≤ 768px ─────────────────────── */
@media (max-width: 768px) {
  html, body { font-size: 16px; }

  /* --- Sidebar: slide-over drawer (opened by "More") --- */
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    width: 300px;
    min-width: 300px;
    max-width: 88vw;
    transform: translateX(-100%);
    z-index: 1100;
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
    overflow-y: auto;
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay { display: none; z-index: 1099; }
  #sidebar-overlay.open { display: block; }
  #hamburger { display: flex; min-width: 44px; min-height: 44px; margin-left: -8px; }
  .brand { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 14px 16px; }
  .brand-logo { height: 52px; }
  .brand .brand-sub { font-size: 12px; }

  /* "View as" + Personal/Role live at the top of the menu on phones */
  #sidebar-tools { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  /* nothing to show (not the owner, not Founder/HOD) → no empty band */
  #sidebar-tools:empty { display: none; }
  /* separate rule: browsers without :has() drop only this one, not the :empty rule */
  #sidebar-tools:not(:has(> [style*="display: flex"], > [style*="display:flex"])) { display: none; }
  #sidebar-tools #view-as-picker { width: 100%; }
  #sidebar-tools #view-as-picker .va-label { display: inline !important; font-size: 13px; }
  #sidebar-tools #view-as-picker ._ss-wrap { width: auto !important; max-width: none !important; flex: 1; min-width: 0; }
  #sidebar-tools #view-as-picker ._ss-input { height: 44px !important; font-size: 16px !important; }
  #sidebar-tools [id^="_ss-drop-"] { position: absolute !important; top: 100% !important; left: 0 !important; right: 0 !important; }
  #sidebar-tools #view-mode-toggle { align-self: stretch; justify-content: stretch; }
  #sidebar-tools #view-mode-toggle .vm-btn { flex: 1; min-height: 40px; font-size: 14px !important; }
  #sidebar-tools .vm-label { display: inline !important; }

  /* Larger tap targets in sidebar nav */
  .nav-btn { padding: 12px 14px; font-size: 16px; gap: 14px; min-height: 48px; }
  .nav-btn svg { width: 20px; height: 20px; }
  .sidebar-nav { overflow: visible; flex: none; }
  .sidebar-user { padding: 16px; padding-bottom: calc(16px + var(--safe-b)); }
  .user-name { font-size: 16px; }
  .user-role { font-size: 13px; }
  .user-actions { gap: 8px; }
  .user-actions .btn { flex: 1; justify-content: center; padding: 10px; font-size: 14px; min-height: 44px; }

  /* --- Topbar: big clear page title --- */
  #topbar { padding: 0 12px; gap: 8px; height: 58px; min-height: 58px; }
  .topbar-badge { display: block; }
  #page-title { font-size: 20px; flex: 1 1 auto; max-width: none; }
  .topbar-actions { gap: 6px; flex-shrink: 0; }
  #overdue-pill { display: none !important; }
  .topbar-actions .btn-gold[onclick^="openNewTask"] { display: none; }

  /* Round + button for new tasks (never for store logins) */
  #fab-new-task {
    display: flex; position: fixed; right: 16px;
    bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 16px);
    width: 58px; height: 58px; border-radius: 50%; border: none;
    background: var(--yellow); color: var(--ink-on-yellow);
    font-size: 32px; font-weight: 400; line-height: 1;
    align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(0,0,0,.2); z-index: 800;
  }
  #fab-new-task:disabled { opacity: .45; }
  body.oc-store #fab-new-task { display: none; }

  /* --- Bottom tab bar --- */
  #bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 4px 4px var(--safe-b);
    box-shadow: 0 -2px 10px rgba(0,0,0,.04);
  }
  #bottom-nav .bn-item {
    flex: 1; min-width: 0; min-height: var(--bottom-nav-h); position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: none; color: var(--t3); font-size: 13px; font-weight: 600; padding: 6px 2px;
    -webkit-tap-highlight-color: transparent;
  }
  #bottom-nav .bn-item svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  #bottom-nav .bn-item.active { color: var(--purple); font-weight: 700; }
  #bottom-nav .bn-item.active::before { content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--purple); }
  #bottom-nav .bn-badge {
    position: absolute; top: 4px; left: calc(50% + 6px);
    background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
    border-radius: 10px; padding: 3px 6px; min-width: 19px; text-align: center;
  }
  #bottom-nav .bn-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* --- Content area: room for the bottom bar --- */
  #content { padding: 14px 16px; padding-bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 88px); overflow-x: hidden; }

  /* Things pinned to the bottom must sit above the tab bar */
  #toast { bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 12px); right: 12px; left: 12px; }
  .toast-item { max-width: 100%; font-size: 15px; }
  .oc-push-card { bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 12px); }

  /* --- Grids collapse --- */
  .grid-4,
  .grid-4[style*="grid-template-columns"] { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  /* Screens that lay out 4+ stat boxes in one inline row: 2 per row on phones */
  #content [style*="grid-template-columns:repeat(4"], #content [style*="grid-template-columns:repeat(5"],
  #content [style*="grid-template-columns:repeat(6"], #content [style*="grid-template-columns:repeat(7"],
  #content [style*="grid-template-columns:repeat(8"],
  #content [style*="grid-template-columns: repeat(4"], #content [style*="grid-template-columns: repeat(5"],
  #content [style*="grid-template-columns: repeat(6"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  /* --- Stat cards --- */
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 13px; }

  /* --- Cards --- */
  .card { padding: 14px; }
  .card-header { margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
  .card-title  { font-size: 16px; }

  /* --- Readable text sizes on phone --- */
  .badge, .pill { font-size: 13px; }
  .form-label { font-size: 13px; }
  .task-row-meta, .brand-sub { font-size: 13px; }
  .section-title { font-size: 13px; }
  .nav-badge { font-size: 13px; }
  .avatar { font-size: 12px; }
  .avatar-sm { width: 26px; height: 26px; font-size: 12px; }
  /* Inline tiny sizes written by screens (9–12px) are bumped to 13px */
  #content [style*="font-size:9px"], #content [style*="font-size:10px"], #content [style*="font-size:11px"], #content [style*="font-size:12px"],
  #content [style*="font-size: 9px"], #content [style*="font-size: 10px"], #content [style*="font-size: 11px"], #content [style*="font-size: 12px"],
  #content [style*="font-size:10.5px"], #content [style*="font-size:11.5px"], #content [style*="font-size:12.5px"],
  .modal [style*="font-size:9px"], .modal [style*="font-size:10px"], .modal [style*="font-size:11px"], .modal [style*="font-size:12px"],
  .modal [style*="font-size: 9px"], .modal [style*="font-size: 10px"], .modal [style*="font-size: 11px"], .modal [style*="font-size: 12px"],
  .modal [style*="font-size:10.5px"], .modal [style*="font-size:11.5px"], .modal [style*="font-size:12.5px"] { font-size: 13px !important; }

  /* --- Filters bar: horizontal scroll instead of wrap --- */
  .filters-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .filters-bar::-webkit-scrollbar { display: none; }
  .filter-select { flex-shrink: 0; font-size: 15px; padding: 8px 10px; max-width: 170px; min-height: 44px; }
  .search-input { flex-shrink: 0; min-width: 160px; font-size: 16px; min-height: 44px; }

  /* --- Tables: scroll sideways inside their own box, never the page --- */
  .task-table-wrap,
  .card > div[style*="overflow-x:auto"],
  .card > div[style*="overflow-x: auto"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* Wide tables already inside a sideways-scroll box keep their width… */
  .task-table { min-width: 580px; }
  /* …tables NOT inside such a box become their own scroll box */
  #content :not(.task-table-wrap):not([style*="overflow-x:auto"]):not([style*="overflow-x: auto"]) > table,
  .modal :not(.task-table-wrap):not([style*="overflow-x:auto"]):not([style*="overflow-x: auto"]) > table {
    display: block; max-width: 100%; min-width: 0 !important; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .task-table th, .task-table td { padding: 10px; font-size: 14px; }
  .task-row-title { font-size: 15px; }

  /* --- Dashboard pipeline card header --- */
  .card-header > div[style*="display:flex"] {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 2px;
    max-width: 100%;
  }
  .card-header > div[style*="display:flex"]::-webkit-scrollbar { display: none; }

  /* --- Tabs: scrollable row --- */
  .tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
    display: flex;
    flex-wrap: nowrap;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 10px 14px; font-size: 15px; white-space: nowrap; flex-shrink: 0; min-height: 44px; }

  /* --- Modals: bottom sheet on mobile --- */
  .modal-wrap { align-items: flex-end; padding: 0; z-index: 1200; }
  .modal {
    border-radius: 18px 18px 0 0;
    max-height: 94vh;
    max-height: 94dvh;
    max-width: 100% !important;
    width: 100%;
    border-bottom: none;
  }
  .modal-sm, .modal-md, .modal-lg, .modal-xl { max-width: 100%; }
  .modal-header { padding: 14px 16px 12px; }
  .modal-title { font-size: 18px; }
  .modal-body   { padding: 16px; gap: 14px; }
  .modal-footer { padding: 12px 16px calc(12px + var(--safe-b)); gap: 8px; flex-wrap: wrap; }
  .modal-close { min-width: 44px; min-height: 44px; font-size: 26px; }

  /* Drag handle indicator */
  .modal::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border2);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* --- Forms --- */
  .form-row { grid-template-columns: 1fr; gap: 12px; }
  .form-input { font-size: 16px; /* prevents iOS zoom on focus */ padding: 11px 12px; min-height: 46px; }
  select.form-input { font-size: 16px; }
  textarea.form-input { min-height: 90px; }
  .form-check { font-size: 15px; min-height: 44px; }

  /* Action panel buttons stack */
  .action-panel > div[style*="display:flex"] { flex-wrap: wrap; }

  /* --- New Task / Task detail grids inside modal --- */
  .modal-body .grid-2 { grid-template-columns: 1fr; gap: 12px; }

  /* --- Buttons: comfortable tap targets --- */
  .btn { min-height: 44px; font-size: 15px; padding: 10px 16px; justify-content: center; }
  .btn-sm { min-height: 44px; font-size: 14px; padding: 8px 12px; }
  .btn-xs { min-height: 40px; font-size: 13px; padding: 6px 10px; }

  /* --- Podium: scale down --- */
  .podium-bar { width: 52px; }
  .podium-1 { height: 72px; }
  .podium-2 { height: 54px; }
  .podium-3 { height: 40px; }
  .podium-wrap { gap: 6px; margin: 14px 0; }

  /* --- Performance leaderboard table --- */
  #perf-overall .card,
  #perf-dept    .card { overflow-x: auto; }

  /* --- People table --- */
  .task-table th:nth-child(3),
  .task-table td:nth-child(3) { display: none; } /* hide Reports To col on mobile people table */

  /* --- My Tasks cards --- */
  .card[style*="padding:14px 18px"] { padding: 12px 14px !important; }

  /* --- Section header row in pipeline --- */
  .mb-20 { margin-bottom: 14px; }
  .mb-16 { margin-bottom: 12px; }
}

/* ── Small mobile: ≤ 480px ───────────────── */
@media (max-width: 480px) {
  #content { padding: 12px; padding-bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 88px); }
  .stat-value { font-size: 22px; }

  /* Pipeline table: hide Dept col */
  #pipeline-body tr td:nth-child(6),
  .task-table thead tr th:nth-child(6) { display: none; }

  .modal-body { padding: 14px; gap: 12px; }
  .score-ring[style*="width:60px"] { transform: scale(0.85); }
}

/* ── Touch screens: no double-tap zoom delay, decent targets ── */
@media (hover: none) and (pointer: coarse) {
  html { touch-action: manipulation; }
  .btn     { min-height: 44px; }
  .btn-sm  { min-height: 44px; }
  .btn-xs  { min-height: 40px; }
  .nav-btn { min-height: 48px; }
  .filter-select, .form-input { min-height: 44px; }
  select.form-input { min-height: 46px; }
}

/* ============================================
   SHARED HOVER CLASSES (theme sweep, Oct 2026)
   Replace the old inline onmouseenter/onmouseover colour hacks in the JS
   files. Only on devices that really hover (mouse / trackpad), so a tap
   on a phone never leaves a card "stuck" in its hover colour.
   !important because the elements carry inline styles.
   ============================================ */
@media (hover: hover) {
  .oc-hov-bg:hover          { background: var(--bg4) !important; }
  .oc-hov-bg-soft:hover     { background: var(--bg3) !important; }
  .oc-hov-border:hover      { border-color: var(--border3) !important; }
  .oc-hov-lift:hover        { border-color: var(--border3) !important; box-shadow: 0 4px 16px rgba(30,30,30,.10) !important; }
  .oc-hov-accent:hover      { border-color: var(--purple) !important; }
  .oc-hov-accent-text:hover { border-color: var(--purple) !important; color: var(--purple) !important; }
  .oc-hov-text:hover        { color: var(--text) !important; }
  .oc-hov-danger:hover      { color: var(--red) !important; }
  .oc-hov-danger-bg:hover   { background: #F9D9D9 !important; border-color: #EF9A9A !important; }
  .oc-hov-info-bg:hover     { background: #DCE6F1 !important; }
  .oc-hov-tool:hover        { background: var(--bg4) !important; color: var(--text) !important; border-color: var(--border3) !important; }
  .oc-hov-outline:hover     { border-color: var(--border3) !important; background: var(--bg4) !important; }
  .oc-hov-star:hover        { color: var(--amber) !important; }
  .oc-hov-reveal:hover      { opacity: 1 !important; }
}
