/* ===========================================================================
   Mage Marketer — DailyTask v7
   "Calm Game HUD" — game feel from progression, motion and feedback,
   not from neon. A dark command-rail top band + amber/teal duo-tone accents
   push this past "orange admin panel" without sacrificing readability.
   Single source of truth for tokens. Light + dark.
   =========================================================================== */

:root {
  /* Surfaces — soft warm neutrals, low glare for 8h use */
  --bg: #F4F2EF;
  --bg-grid: rgba(26, 22, 20, .028);
  --surface: #FFFFFF;
  --surface-2: #F8F6F3;
  --surface-3: #F1EDE8;
  --ink: #191512;
  --ink-2: #4A423C;
  --muted: #6E645C;
  --line: #E6DFD8;
  --line-strong: #D6CCC2;

  /* Brand — warm amber, deepened for 4.5:1 AA contrast on white in both
     text-on-white and white-text-on-fill directions */
  --accent: #BC500A;
  --accent-hover: #A1440A;
  --accent-ink: #FFFFFF;
  --accent-soft: #FDEEE1;

  /* Second accent — cool teal, used for XP/progress so it reads distinct
     from the "late/warning" amber family */
  --xp: #0C6E64;
  --xp-soft: #DFF3F0;

  /* HUD rail — a dark band behind the topbar/hero for game-console presence */
  --hud: #221812;
  --hud-2: #2C1F17;
  --hud-ink: #F7EFE8;
  --hud-line: rgba(255, 255, 255, .1);

  /* States */
  --ok: #106B38;
  --ok-soft: #E1F5E7;
  --warn: #9A5B06;
  --warn-soft: #FCEEDA;
  --danger: #B4231C;
  --danger-soft: #FCE9E7;
  --info: #1D6FA5;
  --info-soft: #E4F0F8;

  /* Game accents */
  --streak: #BC500A;
  --streak-glow: rgba(188, 80, 10, .38);
  --xp-track: #E7E1D8;

  --shadow-sm: 0 2px 6px rgba(26, 22, 20, .06);
  --shadow: 0 14px 32px rgba(26, 22, 20, .10);
  --shadow-lg: 0 28px 64px rgba(26, 22, 20, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --transition: .18s cubic-bezier(.2, .7, .3, 1);
}

html[data-theme="dark"] {
  --bg: #14100D;
  --bg-grid: rgba(255, 255, 255, .022);
  --surface: #1D1714;
  --surface-2: #241D18;
  --surface-3: #2C231D;
  --ink: #F3EBE5;
  --ink-2: #D2C5BB;
  --muted: #A79A8F;
  --line: #322721;
  --line-strong: #45362D;

  --accent: #FB8B3C;
  --accent-hover: #FF9F5B;
  --accent-ink: #1A0F06;
  --accent-soft: rgba(251, 139, 60, .16);

  --xp: #3FCBB8;
  --xp-soft: rgba(63, 203, 184, .14);

  --hud: #0F0B08;
  --hud-2: #171008;
  --hud-ink: #F7EFE8;
  --hud-line: rgba(255, 255, 255, .08);

  --ok: #56D98B;
  --ok-soft: rgba(86, 217, 139, .15);
  --warn: #F4B65C;
  --warn-soft: rgba(244, 182, 92, .15);
  --danger: #F58278;
  --danger-soft: rgba(245, 130, 120, .15);
  --info: #6DB9E8;
  --info-soft: rgba(109, 185, 232, .15);

  --streak: #FF9F5B;
  --streak-glow: rgba(255, 159, 91, .45);
  --xp-track: #33281F;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, .35);
  --shadow: 0 18px 42px rgba(0, 0, 0, .5);
  --shadow-lg: 0 32px 76px rgba(0, 0, 0, .65);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px) 0 0 / 100% 32px,
    var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: inherit; }
h1, h2, h3 { font-family: 'Sora', 'Inter', sans-serif; letter-spacing: -.015em; margin-top: 0; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ── Topbar — dark HUD rail, always dark regardless of theme ─────────── */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(135deg, var(--hud), var(--hud-2));
  border-bottom: 1px solid var(--hud-line);
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { height: 44px; width: auto; max-width: 220px; object-fit: contain; display: block; }
.brand-word { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 18px; letter-spacing: -.02em; color: var(--hud-ink); }
.menu-btn {
  display: none; background: rgba(255,255,255,.08); border: 1px solid var(--hud-line); color: var(--hud-ink);
  width: 36px; height: 36px; border-radius: 9px; cursor: pointer; padding: 0; place-items: center;
}
.who { display: flex; align-items: center; gap: 8px; }
.who-name { font-weight: 700; font-size: 14px; color: var(--hud-ink); }
.role-badge { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.role-badge.role-hr { background: var(--warn-soft); color: var(--warn); }
.role-badge.role-superadmin { background: var(--danger-soft); color: var(--danger); }
.theme-toggle { border: 1px solid var(--hud-line); background: rgba(255,255,255,.08); color: var(--hud-ink); width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; cursor: pointer; padding: 0; }
.theme-toggle:hover { border-color: var(--accent); background: rgba(255,255,255,.14); }
.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: block; }
.logout-link { text-decoration: none; font-weight: 700; font-size: 14px; color: rgba(247,239,232,.72); padding: 7px 12px; border-radius: 8px; }
.logout-link:hover { background: rgba(255,255,255,.08); color: var(--hud-ink); }
/* Icon-only button (e.g. the Password link) -- same square shape as
   .theme-toggle, colour adapts to context: dark HUD in the topbar, light
   surface in the sidebar drawer. */
.icon-btn { border: 1px solid var(--hud-line); background: rgba(255,255,255,.08); color: var(--hud-ink); width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; text-decoration: none; }
.icon-btn:hover { border-color: var(--accent); background: rgba(255,255,255,.14); color: var(--hud-ink); }
.sidebar-account .icon-btn { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink-2); }
.sidebar-account .icon-btn:hover { border-color: var(--accent); background: var(--surface-3); color: var(--ink); }

/* Streak pill in the topbar — small, always-visible progress cue */
.topbar-streak {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: #FFC98A;
  font-weight: 800; font-size: 13px; text-decoration: none;
  border: 1px solid var(--hud-line);
}
.topbar-streak:hover { border-color: var(--accent); background: rgba(255,255,255,.16); }
.topbar-streak .flame { filter: drop-shadow(0 0 4px var(--streak-glow)); }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 18px 12px; overflow-y: auto; z-index: 20;
  transition: transform var(--transition);
}
.sidebar nav { display: grid; gap: 4px; }
.nav-section { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  text-decoration: none; font-weight: 600; font-size: 14px; color: var(--muted);
  transition: background var(--transition), color var(--transition), transform var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); transform: translateX(2px); }
.nav-item.active { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px rgba(214, 95, 12, .3); }
.nav-item.active svg { stroke: var(--accent-ink); }
.nav-item .nav-count { margin-left: auto; font-size: 11px; font-weight: 800; background: var(--danger-soft); color: var(--danger); padding: 1px 7px; border-radius: 999px; }
.nav-item.active .nav-count { background: rgba(255,255,255,.25); color: var(--accent-ink); }

/* Account row (name/role/Password/Logout) at the bottom of the sidebar --
   hidden on desktop (the topbar already shows all of this); shown only on
   the mobile/tablet drawer, where the topbar hides its own copies instead,
   since the topbar has no room for them at that width. */
.sidebar-account { display: none; }
.sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 15; }
.sidebar-scrim.show { display: block; }

/* ── Content ──────────────────────────────────────────── */
.content { padding-top: var(--topbar-h); }
body.has-sidebar .content { margin-left: var(--sidebar-w); }
.shell { width: min(1180px, calc(100% - 40px)); margin: 24px auto; }
.page-title { margin-bottom: 18px; }
.page-title p, .muted, small { color: var(--muted); }
.spacer { flex: 1; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; margin-bottom: 12px; }
.back-link:hover { color: var(--accent); }

/* ── Flash ────────────────────────────────────────────── */
.flash { width: min(1180px, calc(100% - 40px)); margin: 16px auto -6px; padding: 12px 16px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.flash.error { background: var(--danger-soft); color: var(--danger); }

/* Server-rendered flash: a fixed-corner, auto-dismissing toast instead of an
   in-flow top-of-page banner, which was easy to scroll past unnoticed. The
   inline EOD warning (.inline-eod-warn) deliberately keeps the old in-flow,
   scroll-to-it behavior -- it's pointing at a specific form, not announcing
   a completed action. */
.flash.toast {
  position: fixed; top: 76px; right: 20px; z-index: 50;
  width: min(360px, calc(100% - 40px)); margin: 0;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: var(--shadow);
  animation: flash-in .25s ease-out;
}
.flash.toast.hide { animation: flash-out .2s ease-in forwards; }
.flash.toast span { flex: 1; }
.flash-close {
  background: none; border: 0; padding: 0; margin: -2px -2px 0 0;
  font-size: 18px; line-height: 1; color: inherit; opacity: .6; cursor: pointer;
}
.flash-close:hover { opacity: 1; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes flash-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-8px); } }

/* ── Cards ────────────────────────────────────────────── */
.auth-card, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.auth-card { max-width: 440px; margin: 56px auto; box-shadow: var(--shadow); }
.auth-sub { color: var(--muted); margin-top: -6px; font-size: 14px; }
.auth-switch { color: var(--muted); font-size: 14px; }
.auth-switch a, .card a.link-btn { color: var(--accent); font-weight: 700; text-decoration: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 4px 0 0; }
.card-head h2 { margin: 0; }
/* A filter-bar (From/To/Apply) sitting inside a card-head next to a heading
   must NOT use the grid form's stretchy minmax(140px,1fr) columns -- that
   made each label's own text-above-input stacking blow the form's height
   out to 3-4x the heading's, and align-items:center then centered the
   short heading against that tall form, leaving a big dead gap above/below
   it. Size it to its own content instead: a single compact row on desktop,
   wrapping to full-width fields on narrow screens. */
.card-head .filter-bar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin-bottom: 0; width: auto; }
.card-head .filter-bar label { width: auto; }
.card-head .filter-bar input[type="date"] { width: auto; }
@media (max-width: 640px) {
  .card-head .filter-bar { width: 100%; }
  .card-head .filter-bar label { flex: 1 1 130px; }
  .card-head .filter-bar button { flex: 1 1 100%; }
}

/* ── Forms ────────────────────────────────────────────── */
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 14px; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; padding: 10px 12px; font: inherit; background: var(--surface); color: var(--ink); transition: border-color var(--transition), box-shadow var(--transition); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button { border: 0; border-radius: 9px; padding: 11px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; transition: background var(--transition), transform var(--transition), box-shadow var(--transition); }
button:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(226, 104, 15, .26); }
button:active:not(:disabled) { transform: translateY(1px) scale(.99); box-shadow: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); padding: 7px 11px; font-size: 13px; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); border-color: var(--accent); box-shadow: none; }
.btn-ghost.xs { padding: 4px 8px; font-size: 12px; }
.btn-ghost.danger { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.btn-ghost.danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.link-btn { color: var(--accent); font-weight: 700; text-decoration: none; font-size: 13px; }
.inline-search { max-width: 230px; }
.grid-form { grid-template-columns: 1fr 1fr; }
.grid-form .full { grid-column: 1 / -1; }
.grid-form > button { justify-self: start; }
.filter-bar { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; margin-bottom: 16px; gap: 12px 14px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Password field with a show/hide toggle */
.pw-field { position: relative; }
.pw-field input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0; display: grid; place-items: center;
  background: transparent; color: var(--muted); border-radius: 7px;
}
.pw-toggle:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); transform: translateY(-50%); box-shadow: none; }

/* ── 12-hour time picker ──────────────────────────────── */
.time-select { display: grid; gap: 6px; }
.time-label { font-weight: 700; font-size: 14px; }
.time-parts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.time-parts select { padding: 10px 6px; text-align: center; }

/* ── Stats ────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
/* A stat tile is a <div>, or an <a> when it links somewhere (e.g. the
   Employees tile linking to the roster) -- both must get the same card
   box, since a bare, unstyled <a> here just renders as plain underlined
   text with no background/border/shadow at all. */
.stats > div, .stats > a { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); text-decoration: none; display: block; transition: transform var(--transition), box-shadow var(--transition); }
.stats > a:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stats strong { display: block; font-size: 24px; font-family: 'Sora', sans-serif; }
.stats span { color: var(--muted); font-weight: 600; font-size: 13px; }
.stats .accent { color: var(--accent); }
.stats .ok { color: var(--ok); }
.stats .bad { color: var(--danger); }

/* Game stat tiles — subtle top rule in the tone colour */
.game-stats > div, .game-stats > a { position: relative; overflow: hidden; }
.game-stats > div::before, .game-stats > a::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--line-strong); }
.game-stats > div.tone-accent::before, .game-stats > a.tone-accent::before { background: var(--accent); }
.game-stats > div.tone-ok::before, .game-stats > a.tone-ok::before { background: var(--ok); }
.game-stats > div.tone-bad::before, .game-stats > a.tone-bad::before { background: var(--danger); }

/* ── Dashboard header — compact, not a big HUD band ───── */
.dash-head {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 4px 0 18px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
}
.dash-head-copy { min-width: 0; }
.dash-head h1 { margin: 4px 0 4px; }
.dash-head p { margin: 0; font-size: 14px; max-width: 62ch; line-height: 1.5; }
.eyebrow { font-size: 11px; text-transform: uppercase; font-weight: 800; letter-spacing: .12em; color: var(--accent); }

/* Rank + streak panel */
.rank-panel {
  display: grid; gap: 8px; min-width: 220px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.rank-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rank-label { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.rank-panel strong { font-family: 'Sora', sans-serif; font-size: 19px; color: var(--ink); }
.rank-track { height: 7px; border-radius: 999px; background: var(--xp-track); overflow: hidden; }
.rank-track i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--xp), #5FE0CC); transition: width .8s cubic-bezier(.2,.8,.3,1); }
.rank-panel small { color: var(--muted); font-size: 12px; }

/* Streak flame */
.streak-badge { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; font-size: 14px; color: var(--streak); }
.streak-badge .flame { width: 20px; height: 20px; filter: drop-shadow(0 0 5px var(--streak-glow)); animation: flicker 2.6s ease-in-out infinite; }
.streak-badge.cold { color: var(--muted); }
.streak-badge.cold .flame { filter: none; animation: none; opacity: .5; }

/* Running total-time badge on the employee's "Today's tasks" card — updates
   live via JS as durations are entered, no page reload. */
.task-head-badges { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.total-time-badge {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13.5px;
  color: var(--accent); background: var(--accent-soft); padding: 5px 11px; border-radius: 999px;
}
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  50% { transform: scale(1.08) rotate(1.5deg); }
}

/* ── Headline ticker ──────────────────────────────────── */
.headline-strip {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  margin-bottom: 16px; overflow: hidden; position: relative;
  display: flex; align-items: stretch; box-shadow: var(--shadow-sm);
}
.headline-tag {
  flex: 0 0 auto; display: flex; align-items: center;
  padding: 0 14px; background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
}
.headline-viewport { overflow: hidden; flex: 1; padding: 12px 0; }
.headline-track { display: inline-flex; gap: 44px; white-space: nowrap; padding-left: 100%; animation: headline-slide 38s linear infinite; }
.headline-strip:hover .headline-track { animation-play-state: paused; }
.headline-track span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.h-type { font-weight: 800; text-transform: uppercase; font-size: 11px; letter-spacing: .07em; margin-right: 7px; }
.h-type.news { color: var(--info); }
.h-type.appreciation { color: var(--accent); }
.h-type.achievement { color: var(--ok); }
@keyframes headline-slide { from { transform: translateX(0); } to { transform: translateX(-100%); } }

/* ── Module grid (the 4 dashboard sections) ───────────── */
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.module-card {
  display: grid; gap: 8px; align-content: start;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--radius);
  padding: 22px 20px; text-decoration: none; box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative; overflow: hidden; min-height: 152px;
  border-top: 3px solid var(--line-strong);
}
.module-icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 4px;
}
.module-card strong { font-family: 'Sora', sans-serif; font-size: 18px; }
.module-card small { color: var(--muted); line-height: 1.5; }
.module-card.playable:hover { transform: translateY(-5px); border-top-color: var(--accent); box-shadow: var(--shadow); }
.module-card.playable:active { transform: translateY(-2px) scale(.995); }
.module-card.playable::after {
  content: "\2192"; position: absolute; right: 18px; top: 22px; color: var(--muted);
  font-size: 18px; opacity: 0; transform: translateX(-6px); transition: all var(--transition);
}
.module-card.playable:hover::after { opacity: 1; transform: translateX(0); color: var(--accent); }
.module-card.locked { opacity: .58; cursor: not-allowed; background: var(--surface-2); border-top-color: var(--line); }
.module-card.locked .module-icon { background: var(--surface-3); color: var(--muted); }
.soon-tag { position: absolute; top: 16px; right: 16px; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: var(--surface-3); color: var(--muted); border: 1px solid var(--line); padding: 3px 8px; border-radius: 999px; }
.module-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ── Mission / quest cards ────────────────────────────── */
.mission-lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.mission-lanes > div { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 6px; align-content: start; }
.mission-lanes strong { font-family: 'Sora', sans-serif; font-size: 15px; }
.mission-lanes span { color: var(--muted); line-height: 1.5; font-size: 13px; }

/* Progress header for today's quests */
.quest-progress { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.quest-progress .track { flex: 1; min-width: 140px; height: 11px; border-radius: 999px; background: var(--xp-track); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
.quest-progress .track i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--xp), #4FD8C4); transition: width .7s cubic-bezier(.2,.8,.3,1); }
.quest-progress .count { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 15px; white-space: nowrap; }

/* Task rows — the tick + time UI. Deliberately calm: one line per task. */
.task-stack { display: grid; gap: 22px; }
.task-client-group { display: grid; gap: 10px; }
.task-client-heading {
  margin: 0; font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.task-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center; gap: 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 13px 15px;
  transition: border-color var(--transition), background var(--transition);
}
.task-row:hover { border-color: var(--line-strong); }
.task-row.is-done { background: var(--ok-soft); border-color: var(--ok); }
.task-row.is-done .task-title { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--muted); }
.task-row.carried { border-left: 3px solid var(--warn); }
.task-row.excused { border-left: 3px solid var(--info); opacity: .85; }
.task-row.excused .task-title { color: var(--muted); }

.task-rank { font-family: 'Sora', sans-serif; font-size: 12px; font-weight: 800; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; width: 26px; height: 26px; display: grid; place-items: center; flex: 0 0 auto; }
/* Priority tone by list position — #1-2 urgent, #3-4 elevated, rest calm */
.task-rank.pri-high { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.task-rank.pri-medium { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.task-row.is-done .task-rank.pri-high,
.task-row.is-done .task-rank.pri-medium { color: var(--muted); background: var(--surface); }
.task-main { display: grid; gap: 3px; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.task-edit-btn {
  display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0;
  margin-left: 6px; vertical-align: middle; background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 6px;
}
.task-edit-btn:hover { background: var(--surface-3); color: var(--accent); box-shadow: none; transform: none; border-color: var(--line); }
.task-note { font-size: 12px; color: var(--muted); }
.task-note.manager { color: var(--warn); font-weight: 600; }

/* Custom checkbox that feels tactile */
.task-check { display: flex; align-items: center; cursor: pointer; margin: 0; }
.task-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.task-box {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line-strong);
  background: var(--surface); display: grid; place-items: center; flex: 0 0 auto;
  transition: all var(--transition);
}
.task-box svg { opacity: 0; transform: scale(.5); transition: all var(--transition); }
.task-check input:checked + .task-box { background: var(--ok); border-color: var(--ok); transform: scale(1.06); }
.task-check input:checked + .task-box svg { opacity: 1; transform: scale(1); }
.task-check input:focus-visible + .task-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.task-check:hover .task-box { border-color: var(--accent); }

/* Client tag inline with a task title */
.task-client {
  display: inline-flex; align-items: center; margin-left: 8px; vertical-align: middle;
  font-size: 11px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase;
  background: var(--xp-soft); color: var(--xp); padding: 2px 8px; border-radius: 999px;
}
.task-row.is-done .task-client { opacity: .7; }

/* Duration input: quick-pick chips + free-text fallback */
.duration-input { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-self: end; }
.duration-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip-btn {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  font-size: 11px; font-weight: 800; padding: 5px 9px; border-radius: 999px; cursor: pointer;
  transition: all var(--transition);
}
.chip-btn:hover { border-color: var(--xp); color: var(--xp); transform: translateY(-1px); box-shadow: none; }
.chip-btn.active { background: var(--xp); border-color: var(--xp); color: #fff; }
.duration-text { width: auto; min-width: 128px; padding: 6px 10px; font-size: 12px; background: var(--surface); }
.task-row.is-done .duration-input { opacity: .85; }

/* Add-task composer — task + submit on a compact top row, client picker
   full-width underneath so nothing is left lopsided with dead space. */
.quest-add { display: grid; gap: 12px; }
.quest-add-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.quest-add-task { flex: 1; min-width: 220px; margin: 0; }
.quest-add-row > button { flex: 0 0 auto; }
.quest-add-client { margin: 0; }
.priority-hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.empty-quest { text-align: center; padding: 26px 16px; color: var(--muted); }
.empty-quest strong { display: block; font-family: 'Sora', sans-serif; color: var(--ink); font-size: 16px; margin-bottom: 6px; }

/* Department-filtered employee picker (appears wherever a manager/admin
   selects a team member — task assignment, scoreboard, attendance) */
.emp-picker { display: contents; }
.emp-picker-dept, .emp-picker-name { min-width: 160px; }

/* Multi-client picker on the employee's Add-task form: selected chips,
   search, then a scrollable checkbox list with "Miscellaneous" pinned. */
.client-multi { border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); padding: 10px; display: grid; gap: 8px; max-width: 620px; }
.client-multi-chips { display: none; flex-wrap: wrap; gap: 6px; }
.client-multi-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.4;
}
.client-multi-chip-x {
  border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 15px;
  line-height: 1; padding: 2px 4px; border-radius: 999px; opacity: .75;
}
.client-multi-chip-x:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.client-multi-search { border: 1px solid var(--line); padding: 8px 12px; font-size: 13.5px; }
/* Two columns on wide screens so a short client list doesn't stretch into a
   sparse full-width strip — collapses to one column on narrow ones. */
.client-multi-list {
  max-height: 170px; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1px 10px; align-content: start;
}
.client-multi-special { grid-column: 1 / -1; }
.client-multi-opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  font-weight: 500; font-size: 13.5px; cursor: pointer; margin: 0; min-height: 30px; min-width: 0;
}
.client-multi-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-multi-opt:hover { background: var(--surface-2); }
.client-multi-opt input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 auto; }
.client-multi-special { font-weight: 700; border-bottom: 1px solid var(--line-strong); border-radius: 0; margin-bottom: 2px; padding-bottom: 8px; }
.client-multi-warn { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--danger); }

@media (max-width: 640px) {
  .client-multi { padding: 8px; }
  .client-multi-list { max-height: 45vh; grid-template-columns: 1fr; }
  .client-multi-opt { padding: 10px 8px; min-height: 40px; font-size: 15px; }
}

/* Manageable headline list — edit / hide / reorder / delete */
.headline-manage-list { display: grid; gap: 8px; }
.headline-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
  padding: 10px 12px;
}
.headline-row.is-hidden { opacity: .55; }
.headline-row-order { display: flex; flex-direction: column; gap: 2px; }
.order-btn {
  width: 24px; height: 20px; padding: 0; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-2); border-radius: 6px; font-size: 11px; line-height: 1; cursor: pointer;
}
.order-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); box-shadow: none; transform: none; }
.order-btn:disabled { opacity: .3; cursor: not-allowed; }
.headline-row-body { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.headline-row-msg { font-size: 14px; overflow-wrap: anywhere; }
.headline-row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-self: end; }

/* ── Celebration popup ────────────────────────────────── */
.celebrate-scrim {
  position: fixed; inset: 0; background: rgba(12, 9, 7, .55);
  display: grid; place-items: center; z-index: 60; padding: 20px;
  animation: fade-in .25s ease;
}
.celebrate-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 34px 30px; max-width: 400px; width: 100%; text-align: center;
  box-shadow: var(--shadow-lg); position: relative;
  animation: pop-in .42s cubic-bezier(.2, 1.3, .4, 1);
}
.celebrate-card .crest { width: 74px; height: 74px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.celebrate-card h2 { font-size: 23px; margin-bottom: 8px; }
.celebrate-card p { color: var(--muted); margin: 0 0 20px; line-height: 1.55; }
.celebrate-stats { display: flex; justify-content: center; gap: 22px; margin-bottom: 22px; }
.celebrate-stats div { display: grid; gap: 2px; }
.celebrate-stats b { font-family: 'Sora', sans-serif; font-size: 22px; color: var(--accent); }
.celebrate-stats span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.88) translateY(14px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 61; overflow: hidden; }
.confetti i { position: absolute; top: -14px; width: 9px; height: 15px; opacity: .95; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translateY(106vh) rotate(720deg); opacity: .1; } }

/* ── Attendance calendar ──────────────────────────────── */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-bottom: 4px; }
.cal-cell {
  min-height: 66px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 7px 8px; display: flex; flex-direction: column; gap: 4px;
  position: relative; transition: transform var(--transition), border-color var(--transition);
}
.cal-cell:hover:not(.empty) { transform: translateY(-2px); border-color: var(--line-strong); }
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell .d { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cal-cell.today .d { color: var(--accent); }
.cal-cell .marks { display: flex; flex-direction: column; gap: 3px; margin-top: auto; }
.cal-dot { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; padding: 2px 5px; border-radius: 5px; text-align: center; }
.cal-dot.late { background: var(--danger-soft); color: var(--danger); }
.cal-dot.leave { background: var(--info-soft); color: var(--info); }
.cal-dot.half { background: var(--warn-soft); color: var(--warn); }
.cal-dot.perfect { background: var(--ok-soft); color: var(--ok); }
.cal-dot.absent { background: var(--surface-3); color: var(--muted); }
.cal-cell.off { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--surface-3) 6px, var(--surface-3) 12px); }
.cal-cell.off .d { color: var(--muted); }
.cal-cell .off-label { font-size: 9px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: auto; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }

/* ── Departments / team ───────────────────────────────── */
.dept-block { margin-bottom: 22px; }
.dept-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dept-head h3 { margin: 0; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 15px; }
.dept-count { background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px; }
.dept-tag { background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.today-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 999px; }
.chip.good { background: var(--ok-soft); color: var(--ok); }
.chip.pending { background: var(--warn-soft); color: var(--warn); }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.member { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.member-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 110px; }
.member-info small { color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-weight: 800; font-size: 13px; font-family: 'Sora', sans-serif; flex: 0 0 auto; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.transfer-form { display: flex; gap: 6px; width: 100%; margin-top: 4px; }
.transfer-form select { font-size: 12px; padding: 6px 8px; }

/* Team scoreboard (manager view of monthly numbers) */
.scoreboard { width: 100%; border-collapse: collapse; font-size: 14px; }
.scoreboard th, .scoreboard td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); }
.scoreboard th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; }
.scoreboard tbody tr:hover { background: var(--surface-2); }
.who-cell { display: flex; align-items: center; gap: 9px; }
.mini-track { width: 92px; height: 7px; border-radius: 999px; background: var(--xp-track); overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-track i { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.mini-track.low i { background: var(--danger); }
.mini-track.mid i { background: var(--warn); }

/* ── Reports ──────────────────────────────────────────── */
.report-list { display: grid; gap: 10px; }
.report-card, .request-card { border: 1px solid var(--line); border-radius: 12px; padding: 15px; background: var(--surface-2); }
.report-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.report-meta { color: var(--muted); margin: 8px 0; font-size: 13px; }
.status { border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 700; white-space: nowrap; display: inline-block; }
.status.done, .status.on_time { color: var(--ok); background: var(--ok-soft); }
.status.in-progress, .status.pending { color: var(--warn); background: var(--warn-soft); }
.status.late { color: var(--danger); background: var(--danger-soft); }
.status.exempt { color: var(--info); background: var(--info-soft); }
.status.absent { color: var(--muted); background: var(--surface-3); }
.blocker { border-left: 3px solid var(--danger); padding: 8px 10px; background: var(--danger-soft); color: var(--danger); border-radius: 0 8px 8px 0; margin-top: 8px; font-size: 14px; }
.blocker.sm { margin-top: 6px; font-size: 13px; padding: 6px 8px; }
.day-group { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--surface); }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.day-head strong { font-family: 'Sora', sans-serif; display: inline-flex; align-items: center; gap: 8px; }
.day-totals { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); align-items: center; }
.day-totals b { color: var(--ink); }
.ot-tag { display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); vertical-align: middle; }
.edited-tag { display: inline-block; margin-left: 6px; font-size: 11px; font-style: italic; color: var(--muted); }
.muted-sm { color: var(--muted); font-size: 12px; }

/* ── Bars ─────────────────────────────────────────────── */
.bar-row { display: grid; grid-template-columns: 190px 1fr 70px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.bar-row:last-child { border-bottom: none; }
.bar-row .track { height: 9px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-row i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-link:hover { background: var(--surface-2); border-radius: 8px; }

/* ── Requests / tables ────────────────────────────────── */
.request-list { display: grid; gap: 12px; margin-top: 14px; }
.request-week-header { margin: 4px 0 -2px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.request-week-header:first-child { margin-top: 0; }
.response { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.client-list { display: flex; flex-wrap: wrap; gap: 10px; }
.client-chip { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.client-chip button { padding: 4px 9px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.client-chip button:hover { background: var(--danger); color: #fff; }
.user-table { display: grid; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); flex-wrap: wrap; }
.user-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 150px; }
.user-actions { display: flex; gap: 6px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); }
.data-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.data-table tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.entry-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.entry-table th, .entry-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.entry-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.entry-table tbody tr:last-child td { border-bottom: none; }
.entry-table td.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions form { display: inline; }

.add-emp { border: 1px dashed var(--line-strong); border-radius: 12px; padding: 10px 14px; }
.add-emp summary { cursor: pointer; font-size: 15px; padding: 4px 0; }
.add-emp summary strong { color: var(--accent); }
.add-emp form { margin-top: 12px; }

/* ── Chat ─────────────────────────────────────────────── */
.chat-shell { display: flex; gap: 0; padding: 0; overflow: hidden; height: 70vh; min-height: 420px; }
.chat-sidebar { width: 280px; flex: 0 0 280px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.chat-sidebar-head { display: flex; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
.chat-thread-list { overflow-y: auto; flex: 1; }
.chat-thread-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); position: relative; }
.chat-thread-item:hover { background: var(--surface-2); }
.chat-thread-item.active { background: var(--accent-soft); }
.chat-thread-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.chat-thread-info strong { font-size: 14px; }
.chat-thread-info small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread-badge { background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; border-radius: 999px; padding: 2px 7px; }
.chat-conversation { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-conv-head { padding: 14px; border-bottom: 1px solid var(--line); font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

/* Each message is a row (bubble + reactions + hover action row) so the
   action buttons and reaction chips can sit outside the bubble itself
   without fighting its rounded/colored background. */
.chat-bubble-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 78%; position: relative; }
.chat-bubble-row.mine { align-self: flex-end; align-items: flex-end; }
.chat-bubble { background: var(--surface-2); border-radius: 14px 14px 14px 4px; padding: 8px 13px; font-size: 14px; word-break: break-word; display: flex; flex-direction: column; gap: 3px; }
.chat-bubble.mine { background: var(--accent); color: var(--accent-ink); border-radius: 14px 14px 4px 14px; }
.chat-bubble.deleted { font-style: italic; opacity: .7; }
.chat-bubble-sender { font-size: 12px; font-weight: 800; }
.chat-bubble-forwarded-tag { font-size: 10.5px; font-style: italic; opacity: .75; }
.chat-bubble-reply-quote { font-size: 12px; padding: 4px 8px; border-left: 2px solid currentColor; opacity: .75; background: rgba(0,0,0,.06); border-radius: 4px; }
.chat-bubble.mine .chat-bubble-reply-quote { background: rgba(255,255,255,.15); }
.chat-bubble-body { white-space: pre-wrap; }
.chat-bubble-edited-tag { font-size: 10.5px; opacity: .65; align-self: flex-end; }

/* Reaction chips sit just under the bubble; the picker is a small
   floating row of the fixed emoji set, positioned near whichever
   message's react button was clicked. */
.chat-reaction-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chat-reaction-chip { font-size: 12.5px; font-weight: 600; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 8px; box-shadow: var(--shadow-sm); }
.chat-reaction-picker {
  position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 8px; display: flex; gap: 4px; box-shadow: var(--shadow-lg);
}
.chat-reaction-picker[hidden] { display: none; }
.chat-reaction-picker button { background: none; border: 0; font-size: 18px; padding: 2px 4px; cursor: pointer; line-height: 1; border-radius: 6px; }
.chat-reaction-picker button:hover { background: var(--surface-2); }

/* Per-message action row: hidden until the row is hovered/focused (desktop),
   always visible on touch (see the <=720px block) since there's no hover there. */
.chat-bubble-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.chat-bubble-row:hover .chat-bubble-actions, .chat-bubble-row:focus-within .chat-bubble-actions { opacity: 1; }
.chat-bubble-actions button {
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-2);
  border-radius: 8px; font-size: 14px; cursor: pointer; line-height: 1;
  width: 28px; height: 28px; display: inline-grid; place-items: center; padding: 0;
  box-shadow: var(--shadow-sm);
}
.chat-bubble-actions button:hover { background: var(--surface-3); border-color: var(--accent); transform: none; box-shadow: var(--shadow-sm); }

.chat-reply-preview { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; background: var(--surface-2); border-top: 1px solid var(--line); font-size: 13px; }
.chat-reply-preview[hidden] { display: none; }
.chat-reply-preview button { background: none; border: 0; font-size: 16px; cursor: pointer; color: var(--muted); }

.chat-composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.chat-composer input { flex: 1; }
.chat-empty-state { padding: 40px; text-align: center; }
.chat-modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; display: grid; place-items: center; padding: 20px; }
.chat-modal[hidden] { display: none; }
.chat-modal-body { background: var(--surface); border-radius: var(--radius); padding: 24px; max-width: 420px; width: 100%; max-height: 85vh; overflow-y: auto; position: relative; box-shadow: var(--shadow-lg); }
.chat-modal-body h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.chat-modal-close { position: absolute; top: 10px; right: 14px; background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--muted); }

.chat-forward-target-list { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.chat-forward-target { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.chat-forward-target:hover { background: var(--surface-3); }

.chat-member-list { display: grid; gap: 6px; }
.chat-member-row { display: flex; align-items: center; gap: 10px; padding: 7px 9px; background: var(--surface-2); border-radius: 9px; }
.chat-member-row span:nth-child(2) { flex: 1; font-size: 13px; }

@media (max-width: 720px) {
  .chat-shell { flex-direction: column; height: auto; }
  .chat-sidebar { width: 100%; flex: none; border-right: 0; border-bottom: 1px solid var(--line); max-height: 240px; }
  /* No hover on touch -- keep the action row always visible there, and grow
     the buttons a bit further so they're a comfortable, unambiguous tap
     target rather than a cramped row of tiny glyphs. */
  .chat-bubble-actions { opacity: 1; gap: 6px; margin-top: 2px; }
  .chat-bubble-actions button { width: 32px; height: 32px; font-size: 15px; }
  .chat-bubble-row { max-width: 92%; }
}

/* ── Footer ───────────────────────────────────────────── */
.site-footer { text-align: center; padding: 24px 16px 32px; color: var(--muted); font-size: 13px; }

/* ── Responsive ───────────────────────────────────────── */

/* Tablet and below — sidebar becomes an overlay drawer */
@media (max-width: 900px) {
  .menu-btn { display: grid; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  body.has-sidebar .content { margin-left: 0; }

  /* Name/role/Password/Logout move into the sidebar drawer at this width --
     the topbar doesn't have room for all of it without things getting cut
     off, and the hamburger menu is already the natural place to look for
     account actions on a phone-sized screen. */
  .topbar-right .who, .topbar-right .icon-btn, .topbar-right .logout-link { display: none; }
  .sidebar-account {
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
    margin-top: 16px; padding: 14px 12px 4px; border-top: 1px solid var(--line);
  }
  .sidebar-account .logout-link { font-size: 14px; }

  .shell { width: calc(100% - 28px); margin: 16px auto; }
  .flash { width: calc(100% - 28px); }
  .flash.toast { top: 12px; right: 14px; left: 14px; width: auto; margin: 0; }
  .grid-form, .today-toggle { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-row .track { grid-column: 1 / -1; }
  .brand-logo { height: 28px; max-width: 140px; }
  .dash-head { padding-bottom: 14px; }
  .rank-panel { width: 100%; min-width: 0; }
  .module-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .team-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* Phones — stack almost everything to a single column */
@media (max-width: 620px) {
  body { font-size: 15px; }
  .shell { width: calc(100% - 20px); margin: 12px auto; }
  .flash { width: calc(100% - 20px); margin: 12px auto -4px; }
  .flash.toast { top: 10px; right: 10px; left: 10px; }
  h1 { font-size: 21px; }
  .card, .auth-card { padding: 16px; }
  .auth-card { margin: 24px auto; }

  /* Header: stack greeting above rank panel instead of squeezing side by side */
  .dash-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .dash-head h1 { font-size: 20px; }

  /* Forms: single column everywhere, full-width buttons */
  form { gap: 12px; }
  .grid-form, .today-toggle, .filter-bar { grid-template-columns: 1fr !important; }
  .quest-add { flex-direction: column; align-items: stretch; }
  .quest-add label, .quest-add-client { min-width: 0; flex: 1 1 auto; }
  .quest-add > button { width: 100%; }
  .inline-search { max-width: none; }
  .time-parts { grid-template-columns: 1fr 1fr 1fr; }

  /* Stat tiles: two per row instead of squeezing 4 into one line */
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats strong { font-size: 20px; }

  .module-grid { grid-template-columns: 1fr; }
  .module-card { min-height: 0; padding: 16px; }

  /* Task rows stack: tick + title on top, duration input underneath — stays readable */
  .task-row { grid-template-columns: auto auto 1fr; row-gap: 10px; padding: 11px 12px; }
  .duration-input { grid-column: 1 / -1; justify-content: flex-start; justify-self: start; }
  .task-title { font-size: 14px; }

  /* Duration chips are a comfortable tap target on desktop's mouse-sized
     hit area, but too small/tight to reliably tap on a touchscreen — grow
     them here rather than everywhere, so the compact desktop look stays. */
  .chip-btn { padding: 9px 13px; font-size: 12.5px; min-height: 36px; }
  .duration-chips { gap: 6px; }

  .emp-picker { display: grid; grid-template-columns: 1fr; gap: 10px; width: 100%; }

  /* Bar rows (breakdowns): label above its bar instead of a squashed 3-col grid */
  .bar-row { grid-template-columns: 1fr; gap: 4px; padding: 9px 0; }
  .bar-row .track { grid-column: auto; }

  /* Tables scroll horizontally rather than crushing columns unreadably */
  .data-table, .scoreboard, .entry-table { font-size: 13px; }
  .data-table th, .data-table td,
  .scoreboard th, .scoreboard td,
  .entry-table th, .entry-table td { padding: 8px 7px; }
  .who-cell { gap: 6px; }

  .user-row, .member, .client-chip { padding: 10px; }
  .transfer-form { flex-direction: column; }
  .transfer-form select, .transfer-form button { width: 100%; }

  .cal-grid { gap: 4px; }
  .cal-cell { min-height: 52px; padding: 4px 3px; overflow: hidden; }
  .cal-cell .d { font-size: 11.5px; }
  .cal-dot { font-size: 7.5px; padding: 1px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cal-cell .off-label { font-size: 7.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cal-legend { gap: 10px; font-size: 11.5px; }
  .celebrate-stats { gap: 14px; }
  .celebrate-card { padding: 24px 20px; }

  .headline-tag { display: none; }
  .headline-row { grid-template-columns: auto 1fr; }
  .headline-row-actions { grid-column: 1 / -1; justify-self: start; }

  .card-head { flex-direction: column; align-items: flex-start; }
  .mission-lanes { grid-template-columns: 1fr; }
}

/* Small phones — the calendar needs one more size step down */
@media (max-width: 400px) {
  /* who/Password/Logout already moved into the sidebar drawer at <=900px
     (see above) -- at this width just tighten what's left in the topbar
     (logo, hamburger, streak pill, theme toggle) so it doesn't feel cramped. */
  .topbar { padding: 0 10px; }
  .topbar-left, .topbar-right { gap: 6px; }
  .brand-word { display: none; }
  .topbar-streak { padding: 4px 8px; font-size: 12px; }

  .shell { width: calc(100% - 14px); margin: 10px auto; }
  .card, .auth-card { padding: 12px; }
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 44px; padding: 3px 2px; gap: 2px; }
  .cal-cell .d { font-size: 10.5px; }
  .cal-dow { font-size: 9px; }
  .cal-dot { font-size: 0; padding: 3px; border-radius: 50%; width: 8px; height: 8px; margin: 0 auto; }
  .cal-cell .off-label { font-size: 7px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats strong { font-size: 17px; }
}

/* ===========================================================================
   Sales module
   =========================================================================== */
.sales-dialog [hidden], .add-followup [hidden], .lead-form [hidden] { display: none !important; }
.owner-filter { display: flex; justify-content: flex-end; margin: -6px 0 12px; }
.owner-filter label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.owner-filter select { width: auto; min-width: 180px; padding: 7px 10px; }

/* Stage / score / type badges */
.stage-badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.stage-badge.stage-new { background: var(--info-soft); color: var(--info); }
.stage-badge.stage-contacted { background: var(--xp-soft); color: var(--xp); }
.stage-badge.stage-meeting { background: var(--warn-soft); color: var(--warn); }
.stage-badge.stage-proposal { background: var(--accent-soft); color: var(--accent); }
.stage-badge.stage-negotiation { background: #F1E6FA; color: #6B2FA3; }
html[data-theme="dark"] .stage-badge.stage-negotiation { background: rgba(167, 111, 222, .18); color: #C9A2F0; }
.stage-badge.stage-won { background: var(--ok-soft); color: var(--ok); }
.stage-badge.stage-lost { background: var(--surface-3); color: var(--muted); }
.score-badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.score-badge.score-hot { background: var(--danger-soft); color: var(--danger); }
.score-badge.score-warm { background: var(--warn-soft); color: var(--warn); }
.score-badge.score-cold { background: var(--info-soft); color: var(--info); }
.lead-tag { display: inline-block; border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 700; }
.lead-tag.tag-client { background: var(--ok-soft); color: var(--ok); }
.lead-tag.tag-returning { background: var(--info-soft); color: var(--info); }
.lead-next { font-size: 12px; font-weight: 600; color: var(--muted); }
.lead-next.late { color: var(--danger); }
.lead-next.warn { color: var(--warn); }

/* Lead cards (lists and the board) */
.lead-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.lead-card { display: grid; gap: 5px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); min-width: 0; }
.lead-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.lead-card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lead-card-top strong { font-size: 15px; margin-right: auto; overflow-wrap: anywhere; }
.lead-company { font-size: 13px; color: var(--ink-2); font-weight: 600; overflow-wrap: anywhere; }
.lead-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.lead-value { color: var(--ok); font-weight: 700; }
.lead-card-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lead-card-foot:empty { display: none; }
.lead-card.compact { padding: 10px 11px; }
.lead-card.compact .lead-card-top strong { font-size: 14px; }
.stage-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.stage-chips .chip-btn { text-decoration: none; font-size: 12px; }
.lead-search { grid-template-columns: 2fr 1fr auto; }

/* Board */
.board-summary { margin: 0 0 10px; }
.board-wrap { overflow-x: auto; padding-bottom: 8px; margin: 0 -4px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; padding: 0 4px; min-width: min-content; }
.board-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 160px; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.board-cards { display: grid; gap: 8px; align-content: start; }
.board-empty { text-align: center; padding: 16px 0; }

/* Today / follow-up rows */
.followup-list { display: grid; gap: 8px; }
.followup-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); text-decoration: none; }
.followup-row.plain:hover { border-color: var(--accent); }
.followup-main { flex: 1; min-width: 180px; display: grid; gap: 2px; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.followup-main small { color: var(--muted); font-size: 12px; }
.followup-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.followup-actions form { display: flex; gap: 6px; align-items: center; margin: 0; }
.followup-actions select { width: auto; padding: 5px 8px; font-size: 12px; }
.followup-actions a.btn-ghost { text-decoration: none; display: inline-block; }
.sla { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 12px; min-width: 74px; padding: 4px 8px; border-radius: 8px; background: var(--surface-3); color: var(--ink-2); text-align: center; }
.sla.late { background: var(--danger-soft); color: var(--danger); }
.cell-bad { color: var(--danger); font-weight: 800; }
.warn-text { color: var(--warn); }

/* Add lead form */
.service-picks { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.service-picks legend { font-weight: 700; font-size: 14px; padding: 0 4px; }
.service-picks .pick { display: inline-flex; font-weight: 600; font-size: 13px; }
.service-picks .pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.service-picks .pick span { border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 11px; cursor: pointer; background: var(--surface); transition: all var(--transition); }
.service-picks .pick input:checked + span { background: var(--xp); border-color: var(--xp); color: #fff; }
.service-picks .pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check-line input { width: auto; }
.sub-head { margin: 18px 0 8px; font-size: 15px; }

/* Settings: collapsible service/template rows */
.service-admin { display: grid; gap: 8px; }
.service-row { border: 1px solid var(--line); border-radius: 11px; padding: 10px 14px; background: var(--surface); }
.service-row.inactive { opacity: .65; }
.service-row summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.service-row[open] summary { margin-bottom: 12px; }
.delivery-rows { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; display: grid; gap: 8px; }
.delivery-rows legend { font-weight: 700; font-size: 14px; padding: 0 4px; }
.delivery-row { display: grid; grid-template-columns: 1.4fr .6fr 1fr; gap: 8px; }

/* Lead page */
.lead-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lead-head-main { display: grid; gap: 4px; min-width: 0; }
.lead-head h1 { margin: 2px 0 0; font-size: 26px; overflow-wrap: anywhere; }
.lead-company-lg { margin: 0; font-weight: 600; color: var(--ink-2); }
.lead-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.lead-owner { display: grid; gap: 4px; align-content: start; min-width: 190px; }
.lead-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 18px; }
.action-btn { display: flex; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 800; cursor: pointer; box-shadow: var(--shadow-sm); list-style: none; text-align: left; width: 100%; font: inherit; }
.action-btn::-webkit-details-marker { display: none; }
.action-btn:hover { border-color: var(--accent); color: var(--ink); background: var(--surface); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.action-btn svg { color: var(--accent); flex: none; }
.action-btn span { display: grid; font-weight: 800; }
.action-btn small { font-weight: 500; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.action-btn.disabled { opacity: .55; cursor: default; }
.action-menu { position: relative; }
.action-menu[open] .action-btn { border-color: var(--accent); }
.action-menu-list { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; min-width: 240px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; }
.action-menu-list a { padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; display: flex; justify-content: space-between; gap: 8px; }
.action-menu-list a:hover { background: var(--surface-2); }
.stage-track { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.stage-track li { text-align: center; font-size: 12px; font-weight: 700; padding: 8px 4px; background: var(--surface-3); color: var(--muted); border-radius: 6px; }
.stage-track li.passed { background: var(--xp-soft); color: var(--xp); }
.stage-track li.current { background: var(--accent); color: var(--accent-ink); }
.stage-track li.current.won { background: var(--ok); color: #fff; }
.stage-track li.current.lost { background: var(--ink-2); color: var(--surface); }
.stage-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stage-actions form { margin: 0; }
.stage-actions .won-btn { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); padding: 11px 16px; font-size: 14px; }
.stage-actions .danger { padding: 11px 16px; font-size: 14px; }
.stage-jump select { width: auto; padding: 9px 10px; }
.lead-columns { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.lead-col-main, .lead-col-side { display: grid; gap: 0; min-width: 0; }
.inline-edit { position: relative; }
.inline-edit summary { list-style: none; cursor: pointer; }
.inline-edit summary::-webkit-details-marker { display: none; }
.inline-edit-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px; box-shadow: var(--shadow); }
.inline-edit-form input { width: auto; padding: 6px 8px; }
.add-followup { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line-strong); display: grid; gap: 10px; }
.add-followup-fields { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.add-followup-fields label { font-size: 13px; }
.add-followup-fields .grow { flex: 1; min-width: 180px; }
.add-followup-fields select, .add-followup-fields input[type="date"], .add-followup-fields input[type="time"] { width: auto; }
.quick-note { display: flex; gap: 8px; margin-bottom: 14px; }
.quick-note input { flex: 1; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.tl-item { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 0 0 14px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: 0; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line-strong); margin-top: 3px; position: relative; z-index: 1; }
.tl-call .tl-dot, .tl-whatsapp .tl-dot, .tl-email .tl-dot, .tl-meeting .tl-dot { background: var(--xp); }
.tl-stage .tl-dot { background: var(--accent); }
.tl-enquiry .tl-dot { background: var(--info); }
.tl-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.tl-outcome { font-size: 12px; font-weight: 700; background: var(--surface-3); border-radius: 6px; padding: 1px 7px; }
.tl-body p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; overflow-wrap: anywhere; }
.enquiry-text { overflow-wrap: anywhere; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; }
.service-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.lead-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.lead-facts dt { color: var(--muted); font-weight: 600; }
.lead-facts dd { margin: 0; overflow-wrap: anywhere; }
.edit-details summary { cursor: pointer; }
.edit-details[open] summary { margin-bottom: 12px; }
.lead-col-side .grid-form { grid-template-columns: 1fr 1fr; }

/* The "what happened?" dialog */
.sales-dialog { max-width: 540px; text-align: left; max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px; }
.sales-log-form { display: grid; gap: 12px; }
.chip-radios { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-radios label { display: inline-flex; font-weight: 700; font-size: 13px; }
.chip-radios input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-radios span { border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 12px; cursor: pointer; background: var(--surface); transition: all var(--transition); }
.chip-radios input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-radios input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-radios.small span { padding: 5px 10px; font-size: 12px; }
.outcome-group { padding: 8px; border-radius: 10px; background: var(--surface-2); }
.outcome-group.needs-pick { outline: 2px solid var(--danger); }
.log-row { display: grid; gap: 6px; }
.log-label { font-weight: 700; font-size: 14px; }
.log-next-fields { display: flex; flex-wrap: wrap; gap: 10px; }
.log-next-fields label { font-size: 13px; }
.log-next-fields select, .log-next-fields input { width: auto; }
.dialog-actions { display: flex; gap: 8px; }

@media (max-width: 900px) {
  .lead-columns { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .lead-search { grid-template-columns: 1fr; }
  .lead-actions { grid-template-columns: 1fr 1fr; }
  .action-btn { padding: 12px 10px; }
  /* Message pickers open as a sheet along the bottom edge on phones. */
  .action-menu-list { position: fixed; top: auto; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); min-width: 0; max-height: 60vh; overflow-y: auto; z-index: 70; }
  .stage-track { grid-template-columns: repeat(3, 1fr); }
  .lead-head h1 { font-size: 22px; }
  .owner-filter { justify-content: stretch; }
  .owner-filter label, .owner-filter select { width: 100%; }
  .sla { min-width: 0; }
  .delivery-row { grid-template-columns: 1fr 1fr; }
  .delivery-row select { grid-column: 1 / -1; }
  .lead-col-side .grid-form { grid-template-columns: 1fr; }
  .sales-dialog { padding: 18px 14px; }
}

/* Sales settings: automatic lead capture */
.integration-list { display: grid; gap: 12px; }
.integration { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; background: var(--surface); }
.integration-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.integration-head > div:first-child { display: grid; gap: 2px; }
.integration label { font-size: 13px; }
.copy-field { display: flex; gap: 6px; align-items: center; }
.copy-field input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; padding: 7px 9px; min-width: 0; }
.integration-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.meta-secrets { border-top: 1px dashed var(--line-strong); padding-top: 10px; }

/* Sales: AI lead sorting */
.lead-tag.tag-notsales { background: var(--surface-3); color: var(--ink-2); }
.lead-ai-summary { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; overflow-wrap: anywhere; }
.ai-card { border-color: var(--xp); }
.ai-summary { margin: 0 0 6px; font-weight: 600; overflow-wrap: anywhere; }
.ai-fix { margin-top: 8px; }
.ai-fix summary { cursor: pointer; }
.ai-fix-form { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ai-fix-form select { width: auto; padding: 6px 8px; font-size: 13px; }
.ai-note { margin: -4px 0 16px; padding: 10px 14px; border-radius: 10px; background: var(--xp-soft); color: var(--ink); font-size: 14px; }
.ai-settings { display: grid; gap: 4px; margin-top: 10px; }
.ai-test { display: grid; gap: 8px; margin-top: 6px; }
.ai-test > button { justify-self: start; }
.ai-test-result { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.ai-test-result p { margin: 0 0 6px; }
.tl-ai .tl-dot, .tl-ai_fix .tl-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.job-row details { margin-top: 4px; }

/* Sales: quotes */
.quote-status { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); vertical-align: middle; }
.quote-status.qs-pending_approval { background: var(--warn-soft); color: var(--warn); }
.quote-status.qs-approved, .quote-status.qs-sent { background: var(--info-soft); color: var(--info); }
.quote-status.qs-viewed { background: var(--accent-soft); color: var(--accent); }
.quote-status.qs-accepted { background: var(--ok-soft); color: var(--ok); }
.quote-status.qs-declined, .quote-status.qs-expired { background: var(--danger-soft); color: var(--danger); }
.quote-status.qs-superseded { background: var(--surface-3); color: var(--muted); }
.page-title h1 .quote-status { font-family: Inter, system-ui, sans-serif; font-size: 13px; margin-left: 6px; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.plain-fieldset[disabled] input, .plain-fieldset[disabled] select, .plain-fieldset[disabled] textarea { opacity: .85; }
.quote-head { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quote-items { display: grid; gap: 10px; margin-bottom: 12px; }
.quote-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface-2); display: grid; gap: 8px; }
.qi-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; }
.qi-nums { display: grid; grid-template-columns: 1fr .6fr 1fr auto; gap: 8px; align-items: end; }
.qi-nums label { font-size: 12.5px; }
.qi-line { font-family: 'Sora', sans-serif; font-weight: 700; min-width: 110px; text-align: right; padding-bottom: 10px; }
.quote-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 14px; }
.quote-totals:empty { display: none; }
.quote-totals div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); display: grid; gap: 2px; }
.quote-totals span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.quote-totals strong { font-family: 'Sora', sans-serif; font-size: 20px; }
.quote-totals small { color: var(--muted); font-size: 12px; }
.quote-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 4px 0 18px; }
.quote-share { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quote-share form { margin: 0; }
.share-btn.wa { background: #1F8F4E; color: #fff; }
.share-btn.wa:hover:not(:disabled) { background: #177A41; }
.preview-link { text-decoration: none; display: inline-block; }
.approval-card { border-color: var(--warn); }
.discard-form { margin: -6px 0 20px; }
@media (max-width: 760px) {
  .quote-head { grid-template-columns: 1fr 1fr; }
  .qi-top { grid-template-columns: 1fr auto; }
  .qi-top select { grid-column: 1 / -1; }
  .qi-nums { grid-template-columns: 1fr 1fr; }
  .qi-line { grid-column: 1 / -1; text-align: left; padding-bottom: 0; }
}

/* Sales: handoff, contracts, onboarding */
.handoff-card { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.contract-card { border-color: var(--ok); }
.contract-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.contract-links a { text-decoration: none; }
.onboarding-list { display: grid; gap: 8px; }
.onboarding-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.ob-mark { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; font-weight: 800; flex: none; }
.ob-done .ob-mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.ob-na .ob-mark { background: var(--surface-3); color: var(--muted); }
.ob-done strong, .ob-na strong { color: var(--muted); }
.target-list { margin: 0 0 8px; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; }

/* Sales dashboard */
.report-controls { margin: -6px 0 16px; }
.report-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.report-controls select { width: auto; min-width: 170px; padding: 7px 10px; }
.target-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.target-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); display: grid; gap: 9px; align-content: start; }
.tt-label { color: var(--muted); font-weight: 700; font-size: 13px; }
.tt-value { font-family: 'Sora', sans-serif; font-size: 26px; font-weight: 700; line-height: 1.1; }
.tt-of { font-family: inherit; color: var(--muted); font-size: 14px; font-weight: 600; }
.tt-track { position: relative; height: 8px; border-radius: 999px; background: var(--xp-track); }
.tt-track i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.tt-track .pace { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink-2); border-radius: 2px; opacity: .55; }
.tt-state { justify-self: start; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.tt-state.hit, .tt-state.on_track { color: var(--ok); background: var(--ok-soft); }
.tt-state.behind { color: var(--warn); background: var(--warn-soft); }
.tt-state.missed { color: var(--danger); background: var(--danger-soft); }
.tt-state.none { color: var(--muted); background: var(--surface-3); }
.report-stats > div { display: grid; gap: 4px; align-content: start; }
.report-stats strong { font-size: 22px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }
.rbar { display: grid; grid-template-columns: minmax(110px, 170px) 1fr auto; gap: 12px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px; }
.rbar:last-of-type { border-bottom: none; }
a.rbar:hover { background: var(--surface-2); border-radius: 8px; }
.rbar-track { height: 9px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.rbar-track i { display: block; height: 100%; min-width: 2px; background: var(--accent); border-radius: 999px; }
.rbar-track.lost i { background: var(--danger); }
.rbar .num { white-space: nowrap; color: var(--ink-2); }
.scoreboard .num { text-align: right; font-variant-numeric: tabular-nums; }
.scoreboard tr.is-self td { background: var(--surface-2); }
.chip-gap { flex: 1; }
.target-form input { width: 100%; min-width: 90px; padding: 7px 9px; }
.target-actions { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-top: 14px; }
.target-actions label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; margin-left: auto; }
.target-actions label input { width: 110px; }
@media (max-width: 640px) {
  .report-grid { grid-template-columns: minmax(0, 1fr); }
  .target-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .target-tile { padding: 13px; }
  .tt-value { font-size: 20px; }
  .tt-of { display: block; font-size: 12px; margin-top: 2px; }
  .rbar { grid-template-columns: 100px 1fr auto; gap: 8px; }
  .chip-gap { flex-basis: 100%; height: 0; }
  .target-actions label { margin-left: 0; }
}
.module-card small.module-progress { color: var(--ok); font-weight: 700; }
