/* ============================================================
   Study Dog CRM — branded styles
   Brand colours are injected as CSS variables in header.php
   ============================================================ */
:root {
  --primary: #833BA6;
  --primary-dark: #5E2A78;
  --accent: #F59E0B;
  --bg: #F6F4F9;
  --card: #FFFFFF;
  --ink: #1F2430;
  --muted: #6B7280;
  --line: #E7E2EE;
  --green: #16A34A;
  --red: #DC2626;
  --blue: #3B82F6;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(30,20,45,.06), 0 6px 24px rgba(30,20,45,.06);
  --font: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; font-family: var(--font-head); font-weight: 600; letter-spacing: -.01em; }
.brand, .kpi .value, .col-head, .nav a, .btn { font-family: var(--font-head); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }

/* ---------- Layout ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 16px; height: 60px; position: relative;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--primary-dark); }
.brand img { height: 30px; width: auto; display: block; }
.brand .tag { font-size: .7rem; color: var(--muted); font-weight: 500; display: block; }
.menu { display: flex; align-items: center; gap: 16px; flex: 1; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  padding: 8px 14px; border-radius: 9px; color: var(--ink);
  font-weight: 500; font-size: .92rem;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }

/* Nav dropdown menus (CRM / Projects) */
.navmenu { position: relative; }
.navmenu-trigger {
  font-family: var(--font-head); font-size: .92rem; font-weight: 500; color: var(--ink);
  background: none; border: 0; cursor: pointer; padding: 8px 12px; border-radius: 9px;
  display: inline-flex; align-items: center; gap: 5px;
}
.navmenu-trigger:hover { background: var(--bg); }
.navmenu-trigger .caret { font-size: .7rem; color: var(--muted); }
.navmenu.active > .navmenu-trigger { background: var(--primary); color: #fff; }
.navmenu.active > .navmenu-trigger .caret { color: #fff; }
.navmenu-pop {
  position: absolute; top: 100%; left: 0; z-index: 70;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--shadow); padding: 5px; min-width: 172px; display: none;
}
/* Invisible bridge so the cursor can cross from trigger to menu without closing. */
.navmenu::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 8px; }
.navmenu:hover::after { display: block; }
.navmenu:hover > .navmenu-pop, .navmenu.open > .navmenu-pop { display: block; }
.nav-emoji { font-size: .95em; }
.navmenu-pop a { display: block; padding: 7px 11px; border-radius: 8px; color: var(--ink); font-size: .9rem; font-weight: 500; white-space: nowrap; }
.navmenu-pop a:hover { background: var(--bg); text-decoration: none; }
.navmenu-pop a.active { color: var(--primary-dark); background: var(--bg); }

@media (max-width: 760px) {
  /* In the collapsed mobile menu, show dropdowns expanded inline. */
  .navmenu, .navmenu-pop { position: static; }
  .navmenu-trigger { width: 100%; justify-content: space-between; }
  .navmenu-trigger .caret { display: none; }
  .navmenu-pop { display: block; box-shadow: none; border: 0; padding: 0 0 4px 10px; margin: 0; min-width: 0; }
  .navmenu.active > .navmenu-trigger { background: none; color: var(--primary-dark); }
}

/* Top-right icon cluster (notifications / settings / log out) */
.actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: none; cursor: pointer;
  color: var(--muted); text-decoration: none;
}
.icon-btn:hover { background: var(--bg); color: var(--primary-dark); text-decoration: none; }
.icon-btn.active { background: var(--primary); color: #fff; }
.icon-badge {
  position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; line-height: 17px;
  padding: 0 4px; border-radius: 999px; background: var(--accent); color: #1F2430;
  font-size: .62rem; font-weight: 700; text-align: center; box-shadow: 0 0 0 2px var(--card);
}

/* Notification cards */
.notif { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 10px; background: var(--card); }
.notif .nicon { font-size: 1.4rem; line-height: 1.2; }
.notif .nbody { flex: 1; min-width: 0; }
.notif .ntitle { font-weight: 700; }
.notif .ndetail { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.notif .nactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.notif.t-renewal { border-left: 4px solid var(--primary); }
.notif.t-task_due { border-left: 4px solid var(--red); }
.notif.t-quiet_lead, .notif.t-winback { border-left: 4px solid var(--accent); }
.notif.t-welcome, .notif.t-onboarding_stalled { border-left: 4px solid var(--green); }
.notif.t-term_reengage { border-left: 4px solid var(--blue); }
.snooze-menu { position: relative; display: inline-block; }
.snooze-menu .opts { display: none; position: absolute; right: 0; top: 100%; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 160px; }
.snooze-menu.open .opts { display: block; }
.snooze-menu .opts a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--ink); font-size: .85rem; }
.snooze-menu .opts a:hover { background: var(--bg); text-decoration: none; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.userbox a { color: var(--muted); }
.nav-toggle {
  display: none; background: none; border: 1px solid var(--line);
  border-radius: 10px; font-size: 1.2rem; line-height: 1; width: 40px; height: 40px; cursor: pointer;
  color: var(--primary-dark); align-items: center; justify-content: center;
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .menu {
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--card); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow); padding: 8px 12px; display: none; z-index: 60;
  }
  .menu.open { display: flex; }
  .nav { flex-direction: column; gap: 2px; }
  .nav a { padding: 12px 10px; }
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }

/* ===================== App shell: sidebar + bottom bar ===================== */
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 232px; background: var(--card);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px;
  z-index: 50; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700;
  color: var(--primary-dark); padding: 4px 8px 14px; font-size: 1.05rem; }
.side-brand img { height: 30px; width: auto; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  color: var(--ink); font-weight: 500; font-size: .92rem; }
.side-link:hover { background: var(--bg); text-decoration: none; }
.side-link.active { background: var(--primary); color: #fff; }
.side-link.sub { padding: 8px 10px 8px 34px; font-size: .88rem; }
.side-section { margin-top: 10px; }
.side-section-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 700; padding: 6px 10px 4px; display: flex; align-items: center; gap: 8px; }
.side-foot { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.mini-badge { display: inline-block; min-width: 18px; height: 18px; line-height: 18px; text-align: center;
  padding: 0 5px; border-radius: 999px; background: var(--accent); color: #1F2430; font-size: .68rem; font-weight: 700; margin-left: auto; }
.side-link.active .mini-badge { background: #fff; color: var(--primary-dark); }

/* Hidden on desktop; shown on mobile */
.mtopbar, .bottombar, .sheet, .sheet-backdrop { display: none; }

@media (min-width: 900px) { main.wrap { margin-left: 232px; } }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .mtopbar { display: flex; position: sticky; top: 0; height: 54px; align-items: center; gap: 12px;
    padding: 0 14px; background: var(--card); border-bottom: 1px solid var(--line); z-index: 50; }
  .mtopbar .brand img { height: 26px; width: auto; display: block; }
  .mtopbar .mtitle { flex: 1; text-align: center; font-family: var(--font-head); font-weight: 700;
    font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wrap { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  .bottombar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--card);
    border-top: 1px solid var(--line); z-index: 60; padding-bottom: calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
  .bottombar a, .bottombar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 9px 0 4px; background: none; border: 0; color: var(--muted); font-size: .64rem; font-weight: 600;
    font-family: var(--font); cursor: pointer; text-decoration: none; }
  .bottombar .ic { font-size: 1.25rem; line-height: 1; }
  .bottombar .active { color: var(--primary); }
  .sheet-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,10,25,.4); z-index: 70;
    opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sheet-backdrop.open { opacity: 1; pointer-events: auto; }
  .sheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; background: var(--card);
    border-radius: 18px 18px 0 0; z-index: 80; padding: 6px 18px calc(18px + env(safe-area-inset-bottom));
    transform: translateY(110%); transition: transform .25s ease; max-height: 82vh; overflow-y: auto;
    box-shadow: 0 -8px 30px rgba(0,0,0,.2); }
  .sheet.open { transform: translateY(0); }
  .sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 10px; }
  .sheet a { display: flex; align-items: center; gap: 12px; padding: 13px 6px; border-bottom: 1px solid var(--line);
    color: var(--ink); font-weight: 600; font-size: .95rem; }
  .sheet a:active { background: var(--bg); }
  .sheet-head { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
    font-weight: 700; padding: 12px 6px 2px; }
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- Cards & grid ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 { font-size: 1rem; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px){ .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; } }

/* ---------- KPI tiles ---------- */
.kpi { padding: 18px 20px; }
.kpi .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.9rem; font-weight: 700; color: var(--primary-dark); margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: .82rem; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--primary); color: #fff; border: 0; border-radius: 9px;
  padding: 9px 16px; font-weight: 600; font-size: .9rem; font-family: var(--font);
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--primary-dark); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--bg); }
.btn.small { padding: 5px 10px; font-size: .8rem; }
.btn.danger { background: var(--red); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #faf8fc; }
tfoot td { border-top: 2px solid var(--line); background: #faf8fc; }
tfoot tr:hover { background: #faf8fc; }
td.num, th.num { text-align: right; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge.lead   { background: #EEF1F5; color: #4B5563; }
.badge.client { background: #E7F6ED; color: var(--green); }
.badge.lost   { background: #FBE9E9; color: var(--red); }
.pill { display:inline-block; padding: 3px 10px; border-radius: 999px; font-size:.72rem; font-weight:600; color:#fff; }

/* Subject colour chips */
.subject-chip {
  display: inline-block; padding: 4px 12px; border-radius: 8px;
  font-size: .72rem; font-weight: 700; line-height: 1.4; letter-spacing: .02em;
  white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Onboarding checklist */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .check { font-size: 1.15rem; line-height: 1; text-decoration: none; color: var(--primary); }
.checklist .lbl { flex: 1; }
.checklist li.done .lbl { color: var(--muted); text-decoration: line-through; }
.checklist .del { opacity: 0; font-size: .8rem; transition: opacity .15s; }
.checklist li:hover .del { opacity: 1; }

/* Progress bar (onboarding) */
.progress { background: var(--line); border-radius: 999px; height: 8px; overflow: hidden; margin-top: 5px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.swatch { display:inline-block; width:18px; height:18px; border-radius:5px; border:1px solid var(--line); vertical-align:middle; }

/* Lead card extra rows */
.lead-card .who { display:flex; align-items:center; gap:6px; color: var(--ink); font-size:.8rem; margin-top:6px; }
.lead-card .who .ico { color: var(--muted); }
.lead-card .seen { color: var(--muted); font-size:.74rem; margin-top:3px; }
.lead-card .chips { margin-top:6px; }

.tag-due { font-weight: 600; font-size: .78rem; }
.due-today  { color: var(--accent); }
.overdue    { color: var(--red); }
.due-soon   { color: var(--primary); }
.due-later  { color: var(--muted); }

.type-call    { color: var(--blue); }
.type-email   { color: var(--primary); }
.type-meeting { color: var(--accent); }
.type-note    { color: var(--muted); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: .82rem; margin-bottom: 5px; color: #374151; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font-family: var(--font); font-size: .92rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea { min-height: 80px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px){ .row2 { grid-template-columns: 1fr; } }
.help { color: var(--muted); font-size: .8rem; margin-top: 4px; }

/* ---------- Kanban ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.col { background: #efeaf4; border-radius: var(--radius); min-width: 250px; flex: 1; display: flex; flex-direction: column; }
.col-head { padding: 12px 14px; font-weight: 700; font-size: .9rem; display: flex; align-items: center; justify-content: space-between; border-top: 4px solid var(--primary); border-radius: var(--radius) var(--radius) 0 0; background:#fff; }
.col-head .count { background: var(--bg); color: var(--muted); border-radius: 999px; padding: 1px 9px; font-size: .75rem; }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; flex: 1; }
.col-foot { padding: 8px 12px; color: var(--muted); font-size: .78rem; border-top:1px dashed var(--line); }
.lead-card {
  background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); cursor: grab;
}
.lead-card:hover { border-color: var(--primary); }
.lead-card.dragging { opacity: .5; }
.lead-card .name { font-weight: 600; }
.lead-card .meta { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.lead-card .val { color: var(--primary-dark); font-weight: 700; font-size: .82rem; margin-top: 6px; }
.col.dragover { outline: 2px dashed var(--primary); outline-offset: -4px; }

/* ---------- Misc ---------- */
.section-title { display:flex; align-items:center; justify-content:space-between; margin: 26px 0 12px; }
.dash-h { font-family: var(--font-head); font-size: 1.1rem; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.stage-rows { display: flex; flex-direction: column; gap: 2px; }
.stage-row { display: flex; align-items: center; gap: 9px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.stage-row:last-child { border-bottom: 0; }
.stage-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.stage-row .nm { flex: 1; font-weight: 500; font-size: .9rem; }
.stage-row .ct { font-weight: 700; font-family: var(--font-head); color: var(--primary-dark); min-width: 22px; text-align: right; }
.empty { color: var(--muted); padding: 16px; text-align: center; }
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.flash.ok  { background: #E7F6ED; color: #14622f; }
.flash.err { background: #FBE9E9; color: #8a1b1b; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 18px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: .78rem; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ===================== PROJECTS module ===================== */
.subnav { display: flex; gap: 4px; margin-top: 8px; }
.subnav a { padding: 5px 12px; border-radius: 8px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.subnav a:hover { background: var(--bg); text-decoration: none; }
.subnav a.active { background: var(--primary); color: #fff; }

.cat-chip { display: inline-block; padding: 3px 11px; border-radius: 8px; font-size: .76rem; font-weight: 700; border: 1px solid transparent; }

.pm-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }

/* Board grid (status columns + category bands) */
.pm-grid { display: grid; gap: 10px; align-items: start; }
.pm-h { font-weight: 700; font-size: .82rem; color: var(--ink); padding: 4px 4px 0; display: flex; align-items: center; gap: 7px; font-family: var(--font-head); }
.pm-h .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pm-band { padding: 10px 4px 2px; }
.pm-cell { background: #efeaf4; border-radius: 12px; min-height: 60px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.pm-cell.over { outline: 2px dashed var(--primary); outline-offset: -3px; }

.pm-card { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 10px 11px; box-shadow: 0 1px 2px rgba(0,0,0,.04); cursor: pointer; }
.pm-card:hover { border-color: var(--primary); }
.pm-card.dragging { opacity: .5; }
.pm-card-title { font-weight: 600; font-size: .9rem; }
.pm-card-meta { color: var(--muted); font-size: .76rem; margin-top: 5px; }
.pm-card-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.prio { padding: 2px 8px; border-radius: 6px; font-size: .68rem; font-weight: 700; }
.pm-tag { font-size: .7rem; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 2px 7px; }
.pm-move, .pm-move-sprint { display: none; width: 100%; margin-top: 8px; font-size: .78rem; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
@media (hover: none) { .pm-move, .pm-move-sprint { display: block; } .pm-card { cursor: default; } }

/* Gantt / sprint planner */
.gantt { min-width: 760px; }
.gantt-row { display: grid; grid-template-columns: 200px 1fr; align-items: center; border-bottom: 1px solid var(--line); }
.gantt-head { grid-template-columns: 200px repeat(7, 1fr); border-bottom: 2px solid var(--line); }
.gantt-day { text-align: center; padding: 8px 0; font-size: .74rem; color: var(--muted); }
.gantt-day strong { display: block; color: var(--ink); font-size: .95rem; }
.gantt-day.today strong { color: #fff; background: var(--primary); border-radius: 50%; width: 24px; height: 24px; line-height: 24px; margin: 2px auto 0; }
.gantt-label { padding: 8px 10px; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-track { display: grid; grid-template-columns: repeat(7, 1fr); padding: 6px 0; }
.gantt-bar { color: #fff; font-size: .76rem; font-weight: 600; padding: 5px 9px; border-radius: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.gantt-bar:hover { text-decoration: none; filter: brightness(.95); }
.gantt-bar.st-done { opacity: .55; }
.gantt-band { padding: 10px 10px 4px; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; min-width: 700px; }
.cal-dow { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; text-align: center; padding: 4px 0; }
.cal-cell { background: #fff; border: 1px solid var(--line); border-radius: 10px; min-height: 96px; padding: 6px; }
.cal-cell.empty-cell { background: transparent; border: 0; }
.cal-cell.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-num { font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.cal-cell.today .cal-num { color: var(--primary-dark); }
.cal-task { display: flex; align-items: center; gap: 5px; font-size: .74rem; padding: 3px 5px; border-radius: 6px; background: var(--bg); margin-bottom: 4px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-task:hover { text-decoration: none; background: #efeaf4; }
.cal-task .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.cal-task.st-done { opacity: .5; text-decoration: line-through; }

@media (max-width: 760px) {
  .subnav { flex-wrap: wrap; }
}

/* ===================== QBR ===================== */
.qbr-table th, .qbr-table td { white-space: nowrap; }
.qbr-input { width: 96px; text-align: right; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--font); }
.qbr-pre, .qbr-suf { color: var(--muted); font-size: .85rem; }
.chg-up { color: var(--green); font-weight: 700; font-size: .82rem; }
.chg-down { color: var(--red); font-weight: 700; font-size: .82rem; }
.spark { vertical-align: middle; }

/* ===================== Print (QBR / investor view) ===================== */
@media print {
  .topbar, .sidebar, .mtopbar, .bottombar, .sheet, .sheet-backdrop, .no-print, .nav-toggle, .actions, .subnav, .btn, button { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main.wrap, .wrap { max-width: none; padding: 0; margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .qbr-input { border: 0; padding: 0; width: auto; background: transparent; }
  a { color: #000; text-decoration: none; }
  .page-head h1 { font-size: 1.4rem; }
}

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.login-card { background: #fff; padding: 34px; border-radius: 18px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-card h1 { font-size: 1.2rem; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 20px; font-size: .85rem; }

/* ---------- Touch stage selector on lead cards ---------- */
/* Shown on touch devices (and narrow screens) as a fallback for drag & drop. */
.move-stage {
  display: none; margin-top: 8px; width: 100%; font-size: .8rem;
  padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
}
@media (hover: none) { .move-stage { display: block; } .lead-card { cursor: default; } }
@media (max-width: 760px) { .move-stage { display: block; } }

/* ---------- Mobile responsiveness ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .wrap { padding: 16px 14px 48px; }
  .page-head { gap: 10px; }
  .page-head h1 { font-size: 1.3rem; }
  /* Let wide tables scroll horizontally inside their card */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 520px; }
  /* KPI tiles a touch more compact */
  .kpi .value { font-size: 1.6rem; }
  /* Stack the two-column inline forms */
  .row2 { grid-template-columns: 1fr; }
  /* Buttons easier to tap */
  .btn { padding: 11px 16px; }
  .btn.small { padding: 8px 12px; }
  /* Kanban columns size for a phone */
  .col { min-width: 80vw; }
}
@media (max-width: 480px) {
  .topbar-inner { padding: 0 14px; }
  .brand .tag { display: none; }
}
