/* CMG Business Manager. Brand: commercemediagroup.com (CMG blue #0065B2, ink #0A0C15, Inter). */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations'), url('/fonts/inter-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-wght-italic.woff2') format('woff2-variations'), url('/fonts/inter-latin-wght-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --page: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f2f5f9;
  --surface-3: #e5ebf2;
  --sidebar: #ffffff;
  --sidebar-text: #3b4352;
  --sidebar-hover: #f2f5f9;
  --sidebar-active: #e7f0f8;
  --text: #0a0c15;
  --text-2: #4a5161;
  --muted: #616a7b;
  --border: rgba(10, 12, 21, 0.09);
  --border-strong: rgba(10, 12, 21, 0.18);
  --grid: #e3e7ee;
  --axis: #c4cad5;
  --accent: #0065b2;
  --accent-hover: #00579a;
  --accent-ink: #ffffff;
  --accent-soft: #e7f0f8;
  --btn-ink: #141414;
  --btn-ink-text: #ffffff;
  --glow: rgba(0, 101, 178, 0.10);
  --series-1: #0065b2;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --good-text: #006300;
  --good-soft: #e3f5e3;
  --warning: #fab219;
  --warning-text: #7a5300;
  --warning-soft: #fdf3dc;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-text: #a32222;
  --critical-soft: #fbe6e6;
  --shadow: 0 1px 2px rgba(10, 12, 21, 0.04), 0 1px 1px rgba(10, 12, 21, 0.02);
  --shadow-lg: 0 16px 48px rgba(10, 12, 21, 0.16);
  --radius: 14px;
  --radius-btn: 12px;
  --logo-filter: none;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --page: #0b0d12;
    --surface: #141821;
    --surface-2: #1b2030;
    --surface-3: #252b3c;
    --sidebar: #0f1218;
    --sidebar-text: #c3cad6;
    --sidebar-hover: #181d29;
    --sidebar-active: #101d2d;
    --text: #eef1f6;
    --text-2: #b8c0ce;
    --muted: #8790a2;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);
    --grid: #252b3a;
    --axis: #3a4152;
    --accent: #3d8fd6;
    --accent-hover: #5aa2e0;
    --accent-ink: #0a0c15;
    --accent-soft: #14263a;
    --btn-ink: #f2f5f9;
    --btn-ink-text: #0a0c15;
    --glow: rgba(61, 143, 214, 0.12);
    --series-1: #3d8fd6;
    --series-2: #d95926;
    --series-3: #199e70;
    --good-text: #0ca30c;
    --good-soft: #13281a;
    --warning-text: #fab219;
    --warning-soft: #2d2512;
    --critical-text: #e66767;
    --critical-soft: #331818;
    --shadow: none;
    --logo-filter: brightness(0) invert(1);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0b0d12;
  --surface: #141821;
  --surface-2: #1b2030;
  --surface-3: #252b3c;
  --sidebar: #0f1218;
  --sidebar-text: #c3cad6;
  --sidebar-hover: #181d29;
  --sidebar-active: #101d2d;
  --text: #eef1f6;
  --text-2: #b8c0ce;
  --muted: #8790a2;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --grid: #252b3a;
  --axis: #3a4152;
  --accent: #3d8fd6;
  --accent-hover: #5aa2e0;
  --accent-ink: #0a0c15;
  --accent-soft: #14263a;
  --btn-ink: #f2f5f9;
  --btn-ink-text: #0a0c15;
  --glow: rgba(61, 143, 214, 0.12);
  --series-1: #3d8fd6;
  --series-2: #d95926;
  --series-3: #199e70;
  --good-text: #0ca30c;
  --good-soft: #13281a;
  --warning-text: #fab219;
  --warning-soft: #2d2512;
  --critical-text: #e66767;
  --critical-soft: #331818;
  --shadow: none;
  --logo-filter: brightness(0) invert(1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background-color: var(--page);
  background-image:
    radial-gradient(900px 520px at 12% -8%, var(--glow), transparent 70%),
    radial-gradient(700px 480px at 100% 0%, var(--glow), transparent 65%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.15; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
/* Brand signature: italic blue phrase with an underline, as on commercemediagroup.com. */
.accent-word { font-style: italic; font-weight: 400; color: var(--accent); border-bottom: 3px solid var(--accent); padding-bottom: 1px; letter-spacing: -0.02em; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.logo-img { display: block; height: auto; filter: var(--logo-filter); }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid var(--border);
  padding: 18px 12px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.brand { display: flex; flex-direction: column; gap: 4px; padding: 2px 10px 14px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.brand .logo-img { width: 168px; }
.brand-sub { font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding-left: 2px; }
/* Small heading above a list inside a page (Team Chat's side list). */
.side-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); padding: 0 10px 6px; }
/* Each menu category is a drop-down: a button that shows or hides its links. */
.nav-group { margin-top: 2px; }
.brand + .nav-group, .brand + .menu-account + .nav-group { margin-top: 10px; }
.nav-group-title {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px;
  background: none; cursor: pointer; text-align: left; font: inherit; font-size: 14px; font-weight: 650; color: var(--sidebar-text);
}
.nav-group-title:hover { background: var(--sidebar-hover); color: var(--text); }
.nav-group-title:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-group.open > .nav-group-title { color: var(--text); }
.nav-group-name { flex: 1; min-width: 0; }
.nav-chevron { flex: none; color: var(--muted); transition: transform 0.15s ease; }
.nav-group.open > .nav-group-title .nav-chevron { transform: rotate(90deg); }
.nav-group > .nav { display: none; padding: 2px 0 8px 10px; }
.nav-group.open > .nav { display: block; }
.nav-dot { display: none; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--critical); }
.nav-group:not(.open):has(.pill.alert:not(.hidden)) > .nav-group-title .nav-dot { display: inline-block; }
@media (prefers-reduced-motion: reduce) { .nav-chevron { transition: none; } }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 9px; color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
}
.nav a:hover { background: var(--sidebar-hover); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--sidebar-active); color: var(--accent); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent); }
.nav .pill { font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-2); padding: 0 7px; border-radius: 999px; }
.nav .pill.alert { background: var(--critical); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(8px); -webkit-backdrop-filter: saturate(160%) blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.search-box { position: relative; flex: 1; max-width: 460px; }
.search-box input { width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); }
.search-results {
  position: absolute; top: 38px; left: 0; right: 0; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg);
  max-height: 380px; overflow-y: auto; z-index: 30;
}
.search-results a { display: flex; justify-content: space-between; padding: 8px 12px; color: var(--text); border-bottom: 1px solid var(--border); }
.search-results a:hover { background: var(--surface-2); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { padding: 26px 28px 64px; max-width: 1440px; width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head > * { min-width: 0; max-width: 100%; }
.page-head .sub { color: var(--text-2); margin-top: 6px; max-width: 760px; font-size: 14.5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* In a table the cell must stay a table cell, or the row's cells stop lining up. */
td.actions { display: table-cell; white-space: nowrap; }
td.actions > * + * { margin-left: 8px; }

/* ----------------------------------------------------------------- cards */
.grid { display: grid; gap: 14px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-head h2 { font-size: 15px; font-weight: 700; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 14px 16px 0; }

.kpi { position: relative; overflow: hidden; }
/* A KPI that is not itself a card has no padding of its own: keep its text clear of the accent bar. */
.kpi:not(.card) { padding-left: 12px; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: 0.9; }
.kpi .label { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-size: 30px; font-weight: 800; margin-top: 6px; letter-spacing: -0.035em; line-height: 1.1; }
.kpi .value.good { color: var(--good-text); }
.kpi .delta { font-size: 12px; margin-top: 4px; color: var(--muted); }
.kpi .delta.up { color: var(--good-text); }
.kpi .delta.down { color: var(--critical-text); }
.mini-kpi .label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.mini-kpi .value { font-size: 19px; font-weight: 750; margin-top: 3px; letter-spacing: -0.02em; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--text); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }
/* Primary: the website's black button with a solid CMG-blue offset shadow. */
.btn.primary {
  background: var(--btn-ink); color: var(--btn-ink-text); border-color: var(--btn-ink);
  border-radius: var(--radius-btn); text-transform: uppercase; letter-spacing: 0.08em; font-size: 11.5px; font-weight: 700;
  padding: 9px 15px; box-shadow: 3px 3px 0 var(--accent);
}
.btn.primary:hover { background: var(--btn-ink); border-color: var(--btn-ink); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--accent); }
.btn.primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--accent); }
.btn.primary.sm { padding: 6px 11px; font-size: 10.5px; box-shadow: 2px 2px 0 var(--accent); }
.btn.danger { color: var(--critical-text); }
/* The confirm button of a destructive action (delete, remove): solid red in both themes, white text at 5.7 to 1. */
.btn.primary.danger-fill { background: #c0302b; border-color: #c0302b; color: #fff; }
.btn.primary.danger-fill:hover { background: #b3261e; border-color: #b3261e; }
.btn.good { color: var(--good-text); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: transparent; }
.seg { display: inline-flex; max-width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; overflow-x: auto; overflow-y: hidden; background: var(--surface); }
.seg button { flex: none; white-space: nowrap; border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 550; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ----------------------------------------------------------------- forms */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.field .req { color: var(--critical-text); }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.field .err { font-size: 12px; color: var(--critical-text); margin-top: 3px; }
input[type='text'], input[type='email'], input[type='url'], input[type='tel'], input[type='number'],
input[type='date'], input[type='datetime-local'], input[type='password'], input[type='search'], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
}
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 8px; padding-top: 22px; }
.check input { width: 16px; height: 16px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { min-width: 140px; }

.theme-btn { display: inline-flex; align-items: center; justify-content: center; }
/* Phone tab bar (shown at phone width, see the 820px rules below). */
.tabbar { display: none; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 49; background: rgba(10, 12, 21, 0.45); border: 0; padding: 0; width: 100%; cursor: default; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td .clip { display: block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-size: 12.5px; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar input[type='search'] { max-width: 260px; }
.toolbar select { width: auto; max-width: 200px; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 550; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
  /* A badge inside a heading must not pick up the heading's tight letter spacing. */
  letter-spacing: normal; text-transform: none; line-height: 1.5; vertical-align: middle;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-soft); color: var(--good-text); }
.badge.warn { background: var(--warning-soft); color: var(--warning-text); }
.badge.bad { background: var(--critical-soft); color: var(--critical-text); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.health-icon { font-size: 11px; line-height: 1; }

/* ----------------------------------------------------------------- board */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-width: 260px; width: 260px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.board-col-head { padding: 11px 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.board-col-head .sum { font-weight: 500; color: var(--muted); font-size: 12px; }
.board-col-body { padding: 0 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.board-col.drop .board-col-body { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: 8px; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; cursor: grab; box-shadow: var(--shadow); }
.board-card:hover { border-color: var(--accent); box-shadow: 2px 2px 0 var(--accent); }
.board-card .t { font-weight: 600; font-size: 13px; }
.board-card .m { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.board-card .m span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.board-card.dragging { opacity: 0.5; }

/* --------------------------------------------------------- lists, misc */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: 12px; color: var(--muted); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.progress { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progress.good > span { background: var(--good); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.alert-card {
  border-left: 4px solid var(--critical); background: var(--critical-soft); border-radius: 8px;
  padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start;
}
.alert-card { flex-wrap: wrap; }
.alert-card .grow { flex: 1 1 220px; }
.alert-card .tag { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; color: var(--critical-text); }
.todo-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.todo-item:last-child { border-bottom: 0; }
.todo-num { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.step { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: 0; }
.step .tick, .task-row .tick {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center;
  background: transparent; cursor: pointer; padding: 0; font-size: 12px; color: transparent; flex-shrink: 0;
}
.step .tick.done, .task-row .tick.done { background: #087f08; border-color: #087f08; color: #fff; }
.step .tick:disabled, .task-row .tick:disabled { cursor: default; }
.step .label { flex: 1; }
.step .label.done { color: var(--text-2); }
/* One row that scrolls sideways on a narrow screen, so the underline always sits on the line. */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; scrollbar-width: thin; }
.tabs button { flex: none; white-space: nowrap; border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; font-weight: 550; }
.tabs button.on { color: var(--text); border-bottom: 3px solid var(--accent); font-weight: 700; }
.eod-card .q { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-top: 8px; }
.eod-card .a { white-space: pre-wrap; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; word-break: break-all; }
.callout { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.system-row td:first-child { width: 34px; }

/* ---------------------------------------------------------------- charts */
.chart { width: 100%; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tooltip {
  position: fixed; pointer-events: none; z-index: 100; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; font-size: 12px; box-shadow: var(--shadow-lg);
  max-width: 260px;
}
.tooltip .tt-title { font-weight: 650; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.seg-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--surface); }
.seg-bar span { display: block; height: 100%; }
/* Email Campaigns (Instantly numbers) */
.ec-status { font-size: 13px; color: var(--text-2); margin: -8px 0 14px; }
.ec-chart { min-width: 0; }
.ec-chart svg { touch-action: pan-y; max-width: 100%; }
/* The campaign dialog keeps to the screen however wide its table is. */
.modal.ec-modal { width: min(760px, calc(100vw - 32px)); }
.ec-sort { border: 0; background: none; padding: 0; margin: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer; white-space: nowrap; }
.ec-sort:hover, th[aria-sort='ascending'] .ec-sort, th[aria-sort='descending'] .ec-sort { color: var(--text); }
.ec-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.ec-name { font-weight: 600; }
.ec-sub { display: none; }
@media (max-width: 640px) {
  .ec-wide { display: none; }
  .ec-sub { display: block; }
  .modal.ec-modal { width: calc(100vw - 20px); }
  .ec-campaigns table.data th, .ec-campaigns table.data td, table.data.ec-steps th, table.data.ec-steps td { padding-left: 7px; padding-right: 7px; }
  .ec-campaigns table.data th:first-child, .ec-campaigns table.data td:first-child { padding-left: 14px; width: 48%; }
  .ec-page .toolbar input[type='search'] { max-width: none; flex: 1 1 180px; }
}
@media (pointer: coarse) {
  .ec-sort, .ec-page .seg button { min-height: 44px; }
  .ec-page a.ec-name { display: inline-flex; align-items: center; min-height: 44px; }
  .ec-campaigns tr.clickable { -webkit-tap-highlight-color: transparent; }
}

.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; padding: 2px 0; }
.hbar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 14px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.hbar-track span { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 0; }
.hbar-value { color: var(--text); min-width: 52px; text-align: right; }

/* ------------------------------------------------- SEO (Ahrefs) section */
.seo-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.seo-delta { font-size: 12px; margin-top: 3px; color: var(--muted); }
.seo-delta.up { color: var(--good-text); }
.seo-delta.down { color: var(--critical-text); }
span.seo-delta { margin-top: 0; white-space: nowrap; }
.seo-block { margin-top: 20px; }
.seo-block h3 { margin: 0 0 2px; }
.seo-block > p { margin: 0 0 8px; }
.seo-notice { margin-bottom: 12px; }
.seo-notice.warn { background: var(--warning-soft); border-left-color: var(--warning); }
.seo-foot { margin: 16px 0 0; }
.seo-card .card-head { flex-wrap: wrap; }
.seo-card .card-head .hint { word-break: break-all; }
.seo-pick { cursor: pointer; align-items: flex-start; }
.seo-pick input { margin-top: 4px; }
/* On a narrow screen the tables scroll sideways inside their own box instead of squeezing every word onto its own line. */
.seo-card table.data { min-width: 520px; }
.seo-card table.seo-keywords { min-width: 600px; }
.seo-card table.seo-keywords td:first-child { min-width: 170px; }
@media (max-width: 1100px) { .seo-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .seo-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ----------------------------------------------------------------- modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 21, 0.5); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(760px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.modal.sm { width: min(460px, 100%); }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--btn-ink); color: var(--btn-ink-text); padding: 10px 14px; border-radius: 10px; box-shadow: 3px 3px 0 var(--accent), var(--shadow-lg); box-shadow: var(--shadow-lg); max-width: 380px; font-size: 13px; }
.toast.error { background: var(--critical); color: #fff; }

/* ------------------------------------------------------------------ auth */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.auth-card { width: min(440px, 100%); padding: 28px; border-radius: 18px; box-shadow: var(--shadow-lg); }
.auth-card .logo-img { width: 190px; margin-bottom: 22px; }
.auth-card h1 { margin-bottom: 6px; font-size: 28px; }
.auth-card .form { grid-template-columns: 1fr; }

/* ------------------------------------------------------------------ chat */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow-y: auto; padding: 4px 2px 8px; }
.chat .msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 82%; }
.chat .msg.me { align-self: flex-end; align-items: flex-end; }
.chat .bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat .msg.me .bubble { background: var(--accent-soft); border-color: transparent; }
.chat .msg .meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.chat .attach { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 13px; font-weight: 600; }
.composer { display: grid; gap: 8px; margin-top: 10px; }
.composer textarea { width: 100%; resize: vertical; }
.composer .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.file-pick { font-size: 13px; max-width: 100%; }
.portal-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.portal-nav .who { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tabs .count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--critical); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.task-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: 0; }
.task-row .grow { flex: 1; min-width: 0; }
.task-row .title { font-weight: 600; }
.task-row .title.done { color: var(--text-2); text-decoration: line-through; }
.task-row .desc { font-size: 13px; color: var(--text-2); white-space: pre-wrap; margin-top: 2px; }

/* ------------------------------------------------------------- team chat */
.chat-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 14px; align-items: start; }
.chat-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 8px; position: sticky; top: 12px; max-height: calc(100vh - 120px); overflow-y: auto; }
.chat-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 4px; }
.chat-nav { display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }
.chat-nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 9px; color: var(--sidebar-text); text-decoration: none; font-size: 14px; }
.chat-nav a span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-nav a:hover { background: var(--sidebar-hover); }
.chat-nav a.active { background: var(--sidebar-active); color: var(--accent); font-weight: 600; }
.chat-nav .pill, .chat-title .count { font-size: 11px; font-weight: 700; background: var(--critical); color: #fff; padding: 0 7px; border-radius: 999px; flex-shrink: 0; }
.chat-title .count { margin-left: 6px; }
.chat-main { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.chat-title h2 { margin: 0; font-size: 17px; }
.chat-banner { padding: 7px 18px; font-size: 13px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--text-2); }
.chat-banner.warn { background: var(--warning-soft); color: var(--warning-text); font-weight: 600; }
.chat-pane { display: flex; flex-direction: column; min-height: 0; }
.chat-list { display: flex; flex-direction: column; gap: 2px; height: min(58vh, 620px); overflow-y: auto; padding: 12px 18px; }
.chat-row { display: flex; gap: 10px; padding: 6px 0; align-items: flex-start; }
.chat-row .grow { flex: 1; min-width: 0; }
.chat-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.chat-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 1px; }
.chat-row .link-btn { border: 0; background: none; padding: 0; font-size: 12px; color: var(--muted); cursor: pointer; visibility: hidden; }
.chat-row:hover .link-btn, .chat-row:focus-within .link-btn { visibility: visible; }
.chat-row .link-btn:hover { color: var(--accent); text-decoration: underline; }
.chat-day { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.chat-day::before, .chat-day::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.chat-composer { display: grid; gap: 6px; padding: 12px 18px 14px; border-top: 1px solid var(--border); }
.chat-composer textarea { width: 100%; resize: vertical; }
.chat-composer .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chat-list .attach { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; font-weight: 600; }
/* Private channels and direct messages: the lock, quiet notes, the people lists and the dialogs. */
.chat-lock { font-size: 0.8em; margin-right: 5px; }
.chat-nav .chat-tag { font-size: 10px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.chat-side-hint { padding: 0 10px 8px; margin: 0; }
.chat-note { align-self: center; text-align: center; font-size: 12px; color: var(--muted); padding: 4px 10px; }
.chat-quote { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); margin: 0; }
.chat-back { display: none; }
.chat-more { display: none; flex: none; align-items: center; justify-content: center; width: 44px; height: 44px; margin: -6px -8px -6px 0; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.chat-more:hover, .chat-more:focus-visible { background: var(--surface-2); color: var(--text); }
.chat-picker { display: grid; gap: 6px; }
.chat-people { display: flex; flex-direction: column; gap: 1px; max-height: 240px; overflow-y: auto; border: 1px solid var(--border-strong); border-radius: 10px; padding: 4px; }
.chat-person { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--text); margin: 0; }
.field label.chat-person, .field label.chat-choice { display: flex; font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 0; }
.chat-side-head .side-title { white-space: nowrap; }
.chat-person:hover { background: var(--surface-2); }
.chat-person input, .chat-choice input { flex: none; width: 16px; height: 16px; }
.chat-person .grow, .chat-member .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.chat-choice { display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; }
.chat-choice + .chat-choice { margin-top: 6px; }
.chat-choice input { margin-top: 3px; }
.chat-choice strong { display: block; }
.chat-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chat-members { display: flex; flex-direction: column; margin-bottom: 12px; }
.chat-member { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.chat-member:last-child { border-bottom: 0; }
.chat-add .actions { margin-top: 8px; }
/* Small laptop windows and tablets: a narrower list leaves more room for the chat itself. */
@media (max-width: 1100px) {
  .chat-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .chat-side-head .side-title { white-space: normal; }
}
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  /* On a phone the list of chats and the open chat are two screens, like a phone chat app. */
  .chat-layout { grid-template-columns: 1fr; }
  .chat-side { position: static; max-height: none; }
  .chat-page.is-closed .chat-main { display: none; }
  .chat-page.is-open .chat-side, .chat-page.is-open .page-head { display: none; }
  .chat-page .page-head { margin-bottom: 12px; }
  .content:has(.chat-page.is-open) { padding-top: 10px; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  /* The open chat fills the screen down to the tab bar (chat.js sets the exact height), so the message box is always in reach. */
  .chat-page.is-open .chat-main { height: calc(100dvh - 160px); min-height: 300px; }
  .chat-page.is-open .chat-pane { flex: 1; }
  .chat-page.is-open .chat-list { flex: 1; height: auto; min-height: 0; padding: 10px 12px; }
  .chat-back { display: inline-flex; flex: none; }
  /* Title bar on a phone: the way back and the buttons on one row, the name of the chat on the next. */
  .chat-title { padding: 8px 12px; gap: 6px 8px; }
  .chat-title > .chat-back { order: 1; }
  .chat-title > .actions, .chat-title > .seg, .chat-title > button.btn { order: 2; margin-left: auto; }
  .chat-title > div:not(.seg):not(.actions) { order: 3; flex: 1 1 100%; min-width: 0; }
  .chat-title h2 { font-size: 16px; overflow-wrap: anywhere; }
  .chat-banner { padding: 6px 12px; font-size: 12px; }
  .chat-composer { grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 8px 12px 10px; }
  .chat-composer textarea { min-height: 44px; height: 44px; max-height: 30vh; }
  .chat-composer .chat-hint { display: none; }
  .chat-composer .chat-why { flex-basis: 100%; }
  .chat-composer:has(.chat-why) { grid-template-columns: 1fr; }
}
/* Touch screens: every control in Team Chat is at least 44 points tall. */
@media (pointer: coarse) {
  .chat-nav a { min-height: 44px; }
  .chat-side-head { min-height: 44px; }
  .chat-side .btn.sm, .chat-title .btn.sm, .chat-list .btn.sm, .chat-dialog .btn.sm { min-height: 44px; min-width: 44px; justify-content: center; }
  .chat-title .seg button { min-height: 44px; }
  .chat-person, .chat-choice { min-height: 44px; -webkit-tap-highlight-color: transparent; }
  .chat-row .link-btn { display: none; }
  .chat-more { display: inline-flex; }
}

/* ----------------------------------------------------------- quote page */
.quote-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.quote-doc { padding: 28px; }
.quote-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 3px solid var(--accent); padding-bottom: 16px; margin-bottom: 18px; }
.quote-head .logo-img { width: 190px; margin-bottom: 8px; }
.quote-meta { text-align: right; }
.quote-number { font-size: 22px; font-weight: 700; margin: 4px 0; }
.quote-for { margin-bottom: 14px; }
.quote-title { font-size: 24px; margin: 6px 0 10px; }
.quote-section { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin: 0 0 6px; }
.quote-items td { vertical-align: top; }
.quote-totals { margin: 10px 0 0 auto; min-width: 280px; border-collapse: collapse; }
.quote-totals td { padding: 4px 6px; }
.quote-totals .num { text-align: right; font-variant-numeric: tabular-nums; }
.quote-totals .grand td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--text); padding-top: 8px; }
@media (max-width: 640px) {
  .quote-doc { padding: 16px; }
  .quote-meta { text-align: left; }
}
@media print {
  .no-print, .toasts { display: none !important; }
  body { background: #fff !important; }
  .quote-page { max-width: none; padding: 0; }
  .quote-doc { border: 0; box-shadow: none; padding: 0; }
  .quote-doc details > summary { display: none; }
  .quote-doc details > div { display: block; }
}

/* ----------------------------------------------- line items (deals, quotes) */
.line-items { display: grid; gap: 10px; }
.line-item { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface-2); }
.line-item-main { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.line-item-main .field { margin: 0; }
.line-item-main .field.grow { flex: 1 1 240px; min-width: 200px; }
.line-item-main input, .line-item-main select { width: 100%; }
.line-item .line-amount { margin-left: auto; text-align: right; min-width: 110px; padding-bottom: 8px; }
.line-item-foot { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; }
.line-item-foot details { flex: 1; min-width: 0; }
.line-item details > summary { cursor: pointer; color: var(--accent); padding: 4px 0; }
.line-item details textarea { width: 100%; margin-top: 6px; }
.line-item-actions { display: flex; gap: 6px; justify-content: flex-end; flex: none; }
.line-add { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.line-add select { max-width: 420px; }
.line-totals { display: flex; gap: 28px; flex-wrap: wrap; justify-content: flex-end; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.line-total-block { min-width: 230px; }
.line-total-row { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; }
.line-total-row.grand { font-weight: 700; font-size: 16px; border-top: 2px solid var(--text); margin-top: 4px; padding-top: 6px; }
@media (max-width: 640px) {
  .line-item .line-amount { margin-left: 0; text-align: left; }
  .line-totals { justify-content: flex-start; }
}

/* ---------------------------------------------------------------- portal */
.portal { max-width: 920px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(60px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.portal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.portal-top .logo-img { width: 180px; }
.portal-hero {
  background-color: #0a0c15;
  background-image: radial-gradient(600px 300px at 90% -20%, rgba(0, 101, 178, 0.55), transparent 70%), radial-gradient(500px 260px at 0% 120%, rgba(0, 101, 178, 0.35), transparent 70%);
  color: #fff; border-radius: 18px; padding: 26px; box-shadow: 4px 4px 0 #0065b2;
}
.portal-hero .small { color: rgba(255, 255, 255, 0.75); text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px; font-weight: 700; }
.portal-hero h1 { font-size: 32px; margin: 8px 0 18px; color: #fff; }
.portal-hero .accent-word { color: #6db3ef; border-bottom-color: #6db3ef; }
.portal-hero .progress { background: rgba(255, 255, 255, 0.18); height: 9px; }
.portal-hero .progress > span { background: #3d8fd6; }
.portal-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.nps-scale { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.nps-scale button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); cursor: pointer; font-weight: 600; }
.nps-scale button.on { background: var(--btn-ink); color: var(--btn-ink-text); border-color: transparent; box-shadow: 2px 2px 0 var(--accent); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .grid.k4, .grid.k6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.split, .grid.k3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 264px; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar.open ~ .sidebar-backdrop { display: block; }
  /* Keep clear of the notch, the rounded corners and the home bar when the app runs full screen. */
  .sidebar { padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); padding-left: max(12px, env(safe-area-inset-left)); }
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .search-box { max-width: none; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 4px max(6px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 92%, transparent); border-top: 1px solid var(--border);
    backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  }
  .tabbar .tab {
    position: relative; flex: 1 1 0; min-width: 0; min-height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: none; padding: 4px 2px; border-radius: 12px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
    color: var(--muted); text-decoration: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  }
  .tabbar .tab:hover { text-decoration: none; }
  .tabbar .tab.active { color: var(--accent); }
  .tabbar .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .tabbar .tab-dot { display: none; position: absolute; top: 6px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--critical); border: 2px solid var(--surface); }
  .tabbar .tab.has-dot .tab-dot { display: block; }
  .toasts { left: 16px; right: 16px; bottom: calc(70px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { max-width: none; }
  .topbar-right .small { display: none; }
  .content { padding: 16px max(16px, env(safe-area-inset-right)) calc(86px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .grid.k2 { grid-template-columns: minmax(0, 1fr); }
  .form { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .portal-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .grid.k4, .grid.k6 { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 23px; }
  h1 { font-size: 23px; }
}
/* Touch screens: controls big enough for a thumb, and 16px text in boxes so iPhones do not zoom in when one is tapped. */
@media (pointer: coarse) {
  .btn { min-height: 44px; padding-left: 15px; padding-right: 15px; touch-action: manipulation; }
  .btn.sm { min-height: 36px; }
  /* A small button that stands alone in a table row or a card (Pay now): full thumb size on a phone. */
  .btn.sm.tap { min-height: 44px; }
  .modal-head .btn.sm { min-height: 44px; min-width: 44px; justify-content: center; }
  .nav a { padding-top: 11px; padding-bottom: 11px; }
  .nav-group-title { padding-top: 12px; padding-bottom: 12px; }
  .tabs button { padding-top: 12px; padding-bottom: 12px; }
  .seg button { padding-top: 10px; padding-bottom: 10px; }
  input[type='text'], input[type='email'], input[type='url'], input[type='tel'], input[type='number'], input[type='date'],
  input[type='datetime-local'], input[type='password'], input[type='search'], select, textarea { font-size: 16px; min-height: 44px; }
  textarea { min-height: 96px; }
  input[type='checkbox'], input[type='radio'] { width: 20px; height: 20px; }
  table.data td, table.data th { padding-top: 12px; padding-bottom: 12px; }
  a, button { -webkit-tap-highlight-color: transparent; }
}
/* Opened from the home screen: no browser bars, so nothing should bounce the whole page sideways. */
@media (display-mode: standalone) {
  body { overscroll-behavior-x: none; }
}

@media print {
  .sidebar, .topbar, .actions, .tabbar { display: none !important; }
  .app { grid-template-columns: 1fr; }
}

/* The main region is focused after navigation for screen readers; no visible ring needed. */
.content:focus, .content:focus-visible { outline: none; }

/* Multi-select fields: checkbox grid in forms, chips in lists. */
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 4px 16px; padding: 4px 0; }
.checks .check { padding-top: 4px; font-weight: 400; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* Settings > Fields */
.opt-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.opt-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.opt-row.archived .opt-name { color: var(--muted); }
.opt-row .opt-name { font-weight: 600; flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.opt-row .opt-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.opt-row .opt-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.opt-row select { width: auto; }

/* ------------------------------------------------------ ad spend tracker */
/* The Ad Spend screens are built from the shared styles above. Only what no
   other page has lives here: the client list beside the page (it borrows Team
   Chat's side list), payment dots, pacing colours and the spend bar. */
.adspend .tone-good { color: var(--good-text); }
.adspend .tone-warn { color: var(--warning-text); }
.adspend .tone-bad { color: var(--critical-text); }
/* Amounts here show cents, so the number in a tile shrinks to fit a narrow tile, and wraps before it would be cut off. */
.adspend .kpi, .adspend .mini-kpi { container-type: inline-size; }
.adspend .kpi .value, .adspend .mini-kpi .value { overflow-wrap: anywhere; }
.adspend .kpi .value { font-size: clamp(14px, 13.5cqw, 30px); }
.adspend .mini-kpi .value { font-size: clamp(14px, 13.5cqw, 19px); }
/* The open periods table has nine columns: a long heading may take two lines so the table fits beside the client list. */
.adspend table.data th { white-space: normal; vertical-align: bottom; }
.adspend-bar .progress { margin-bottom: 3px; }
.adspend .progress.warn > span { background: var(--warning); }
.adspend .progress.over > span { background: var(--critical); }
/* The list stays in view below the top bar while the page scrolls. */
.adspend-side { top: 72px; max-height: calc(100vh - 140px); }
.adspend-side-toggle { display: none; flex: 1; min-width: 0; min-height: 44px; align-items: center; gap: 8px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.adspend-side-toggle .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adspend-side-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.adspend-side.open .adspend-side-toggle .nav-chevron { transform: rotate(90deg); }
.adspend-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.adspend-dot.unpaid { background: none; box-shadow: inset 0 0 0 2px var(--warning-text); }
.adspend-archived > summary { cursor: pointer; padding: 8px 10px 4px; }
.adspend-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; padding: 10px 10px 2px; }
.adspend-legend span { display: inline-flex; align-items: center; gap: 5px; }
/* With less room the list folds away above the page, and a tap on "Clients" opens it. */
@media (max-width: 1365px) {
  .adspend .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .adspend-side { position: static; max-height: none; }
  .adspend-side h2, .adspend-side:not(.open) .adspend-side-body { display: none; }
  .adspend-side-toggle { display: flex; }
}
@media print {
  .adspend-side { display: none; }
  .adspend .chat-layout { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------- service lines */
/* The All | Media | Website | SEO switcher in the top bar. On narrow screens it takes its own row. */
.line-switch { flex: none; }
.line-switch button { padding: 6px 11px; }
@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .line-switch { order: 9; width: 100%; }
  .line-switch button { flex: 1 1 0; }
}
/* One task row in the work template editor. */
.tpl-row { border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: grid; gap: 6px; }
.tpl-main { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.tpl-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tpl-meta label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tpl-meta input[type='number'] { width: 72px; }
.tpl-meta input[type='text'] { flex: 1 1 150px; min-width: 0; width: auto; }
.tpl-meta select { flex: 0 1 150px; width: auto; }
@media (max-width: 640px) { .tpl-main { grid-template-columns: 1fr; } }

/* Company dashboard: one card per service line. */
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.grid.k1 { grid-template-columns: minmax(0, 1fr); }
.line-facts { display: grid; gap: 10px; }
.grid.k1 .line-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.line-fact strong { font-size: 15px; }
.line-panel { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.grid.k1 .line-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k1 .line-panel > a { grid-column: 1 / -1; }
@media (max-width: 1100px) { .line-cards.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .line-cards.k4 { grid-template-columns: minmax(0, 1fr); }
  .grid.k1 .line-facts, .grid.k1 .line-panel { grid-template-columns: minmax(0, 1fr); }
}
/* Media: share of budget spent against share of the period gone. */
.pace { display: grid; gap: 4px; }
.pace-row { display: grid; grid-template-columns: 62px minmax(60px, 1fr) 38px; gap: 8px; align-items: center; font-size: 12px; }
.pace-label { color: var(--text-2); white-space: nowrap; }
.pace-num { text-align: right; }
.progress.time > span { background: var(--text-2); opacity: 0.55; }
/* Website: build phases as a row of steps, and one card per site. */
.phase-bar { display: grid; gap: 6px; }
.phase-steps { display: flex; gap: 4px; }
.phase-step { flex: 1 1 0; height: 8px; border-radius: 999px; background: var(--surface-3); }
.phase-step.done { background: var(--good); }
.phase-step.now { background: var(--accent); }
.site-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.site-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 5px; min-width: 0; }
.site-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.site-head .btn { margin-left: auto; }
.site-line { display: grid; grid-template-columns: minmax(110px, 0.8fr) minmax(0, 2fr); gap: 8px; font-size: 13px; overflow-wrap: anywhere; }
/* SEO: this month's deliverables against the package, and rank changes. */
.quota-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.quota-row { display: grid; gap: 4px; }
.quota-label { font-size: 13px; }
.rank { white-space: nowrap; }
.rank-up { color: var(--good-text, var(--good)); font-weight: 600; white-space: nowrap; }
.rank-down { color: var(--critical-text); font-weight: 600; white-space: nowrap; }

/* ===================================================================== */
/* Phone app. "Phone layout" below is always the same media query:       */
/* a window up to 820px wide, or a phone turned sideways (touch, short). */
/* mobile.js uses the same query (PHONE_QUERY).                          */
/* ===================================================================== */

/* Pieces of the shell that only one layout uses. */
.app-back, .app-title, .app-line-btn, .app-icon-btn, .menu-account, .board-picker, .board-card .move-btn, .more-btn, .portal-appbar, .portal-tabbar { display: none; }
.app-back, .app-icon-btn {
  align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px;
  background: none; color: var(--accent); cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.app-back:hover, .app-icon-btn:hover { background: var(--surface-2); }
.app-back:focus-visible, .app-icon-btn:focus-visible, .app-line-btn:focus-visible, .menu-row:focus-visible, .sheet-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.app-back .ico { width: 26px; height: 26px; stroke-width: 2.4; }
/* Opened from the home screen there is no browser back button, so the app shows its own (desktop too). */
html.show-back .app-back { display: inline-flex; }
html.show-back .topbar .app-back { margin-left: calc(min(env(safe-area-inset-left), 8px) - 8px); }
.ico { display: block; flex: none; }

/* Search sheet (phone): covers the screen, like an app's search. */
.search-sheet {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: var(--page);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  animation: sheet-fade 0.18s ease-out;
}
.search-sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.search-field { position: relative; flex: 1; min-width: 0; }
.search-field .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-sheet .search-field input { width: 100%; padding-left: 40px; border-radius: 12px; background: var(--surface-2); font-size: 16px; min-height: 44px; }
.search-sheet-results { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px 0 calc(24px + env(safe-area-inset-bottom)); }
.search-sheet-results a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 10px 16px;
  color: var(--text); border-bottom: 1px solid var(--border); font-size: 16px;
}
.search-sheet-results a:hover, .search-sheet-results a:focus-visible { background: var(--surface-2); text-decoration: none; }
.search-sheet-results a .small { flex: none; font-size: 13px; }
.search-sheet-hint { padding: 22px 16px; color: var(--muted); font-size: 15px; text-align: center; }

/* Small banners: the update notice and "Add to Home Screen". Then the offline screen. */
/* Banners stack in one place, newest at the bottom, above the phone's tab bar. */
.app-banners { position: fixed; z-index: 45; right: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; }
.app-banners:empty { display: none; }
.app-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  animation: banner-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.app-banner .grow { flex: 1; min-width: 0; font-size: 14px; }
.app-banner .grow strong { display: block; font-size: 15px; }
.app-banner .ico-share { display: inline-block; vertical-align: -4px; color: var(--accent); }
.app-banner .app-icon-btn { display: inline-flex; color: var(--muted); }
.app-banner .app-mark { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.offline-screen {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: #0065b2; color: #fff; text-align: center;
}
.offline-screen .offline-box { max-width: 360px; display: grid; justify-items: center; gap: 14px; }
.offline-screen img { width: 96px; height: 96px; }
.offline-screen h1 { font-size: 26px; color: #fff; }
.offline-screen p { margin: 0; font-size: 16px; color: rgba(255, 255, 255, 0.92); }
.offline-screen .btn { background: #fff; color: #0a0c15; border-color: #fff; min-height: 48px; padding: 0 22px; font-size: 15px; }
.offline-screen .btn:hover { background: #e7f0f8; border-color: #e7f0f8; }
.offline-screen .btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* Action sheets (a list of choices) and the menu's Account section. */
.sheet-list { display: flex; flex-direction: column; margin: -4px -18px; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 12px 18px; border: 0; border-bottom: 1px solid var(--border);
  background: none; color: var(--text); font: inherit; font-size: 16px; text-align: left; cursor: pointer;
}
.sheet-item:last-child { border-bottom: 0; }
.sheet-item:hover { background: var(--surface-2); }
.sheet-item:disabled { color: var(--muted); cursor: not-allowed; }
.sheet-item.danger { color: var(--critical-text); }
.sheet-item.current { color: var(--accent); font-weight: 650; }
.sheet-item-label { flex: 1; min-width: 0; }
.sheet-item-hint { color: var(--muted); font-size: 13px; }
.sheet-item-tick { color: var(--accent); font-weight: 700; }
.sheet-message { margin-bottom: 12px; }
.sheet-steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; font-size: 15px; }
.sheet-steps .ico { display: inline-block; vertical-align: -5px; color: var(--accent); }
.sheet-grabber { display: none; }
.menu-account { padding: 4px 0 10px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.menu-account-title { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 6px; }
.menu-account-who { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; }
.menu-account-who .avatar { width: 40px; height: 40px; font-size: 14px; }
.menu-account-who .name { font-weight: 700; font-size: 16px; color: var(--text); }
.menu-account-who .small { font-size: 13px; overflow-wrap: anywhere; }
.menu-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 10px; border: 0; border-radius: 10px;
  background: none; color: var(--sidebar-text); font: inherit; font-size: 15px; font-weight: 550; text-align: left; cursor: pointer; text-decoration: none;
}
.menu-row:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
.menu-row .ico { color: var(--muted); }
.menu-row .grow { flex: 1; min-width: 0; }
.menu-row.danger { color: var(--critical-text); }
.menu-row.danger .ico { color: var(--critical-text); }
.menu-row .note { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
/* An on and off switch drawn after the label (Dark mode). */
.switch { position: relative; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3); transition: background 0.15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
[aria-checked='true'] > .switch { background: var(--accent); }
[aria-checked='true'] > .switch::after { transform: translateX(18px); }

/* A sheet rises from the bottom edge. It is uncovered rather than moved, so it is in its final
   place from the first frame (nothing jumps if it is tapped or measured while it opens). */
@keyframes sheet-up { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes banner-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }
/* The dimmed page behind a sheet darkens in (its colour, not its opacity, so the sheet stays solid). */
@keyframes dim-in { from { background-color: rgba(10, 12, 21, 0); } }

@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  body { font-size: 15px; }
  /* A long word or link breaks onto the next line instead of pushing the page sideways. */
  .content, .portal, .modal-body { overflow-wrap: break-word; }
  /* ------------------------------------------------ top bar, like an app */
  .topbar {
    flex-wrap: nowrap; gap: 4px; min-height: calc(52px + env(safe-area-inset-top)); row-gap: 0;
    padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  }
  .topbar .search-box, .topbar .line-switch, .topbar .topbar-right { display: none; }
  .app-title {
    display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; height: 52px; padding: 0 4px 0 8px;
    font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--text);
  }
  html.show-back .app-title { padding-left: 0; }
  .app-title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-title .app-mark { width: 28px; height: 28px; border-radius: 7px; flex: none; }
  html.show-back .app-title .app-mark { display: none; }
  .app-icon-btn { display: inline-flex; }
  .app-line-btn {
    display: inline-flex; align-items: center; gap: 4px; flex: none; min-height: 44px; max-width: 42vw; padding: 0 10px 0 12px;
    border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text);
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; touch-action: manipulation;
  }
  .app-line-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-line-btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
  .app-line-btn .ico { width: 16px; height: 16px; }
  /* The menu: Account first, then the categories. */
  .menu-account { display: block; }
  .sidebar { width: min(320px, 86vw); }
  .sidebar .brand { display: none; }
  .nav a { min-height: 44px; font-size: 15px; }
  .nav-group-title { min-height: 48px; font-size: 15px; }
  .nav .pill { font-size: 12px; }
  .brand-sub, .side-title { font-size: 12px; }
  .app-banners { left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); width: auto; bottom: calc(66px + env(safe-area-inset-bottom)); }
  html.has-banner .content { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
  html[data-dialogs] body { overflow: hidden; }

  /* ------------------------------------------------------ page heads */
  h1 { font-size: 24px; }
  .page-head { margin-bottom: 14px; gap: 12px; }
  .page-head .sub { font-size: 14px; }
  /* The page name is in the top bar; a heading that only repeats it is not shown again
     (it stays for screen readers, as the page's heading). */
  .page-head h1.dup-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .page-head div:has(> h1.dup-title) > .small.muted:first-child { display: none; }
  /* A heading with nothing beside it takes no room then, and a head with nothing else in it adds no space. */
  .page-head > div:has(> h1.dup-title:only-child) { display: contents; }
  .page-head:not(:has(> :nth-child(2))):has(> div > h1.dup-title:only-child) { margin-bottom: 0; }
  .page-head .actions { width: 100%; }
  .page-head .actions > .folded, .page-head .actions > .back-link { display: none; }
  .page-head .actions > .btn.primary { flex: 1 1 auto; }
  .more-btn { display: inline-flex; }
  .more-btn .ico { width: 20px; height: 20px; }

  /* ------------------------------------------------ text never small */
  .small { font-size: 13px; }
  .eyebrow, .kpi .label, .mini-kpi .label, .alert-card .tag, .eod-card .q, .tabs .count, .chat-nav .pill, .chat-title .count, .chat .msg .meta, .chat-nav .chat-tag, .portal-hero .small, .health-icon { font-size: 12px; }
  .field label { font-size: 14px; }
  .field .help, .field .err { font-size: 13px; }
  .btn { font-size: 15px; }
  .btn.sm { font-size: 14px; }
  .btn.primary { font-size: 13px; }
  .btn.primary.sm { font-size: 12px; }
  .badge { font-size: 12.5px; }
  .avatar { font-size: 12px; }
  .card-head h2 { font-size: 16px; }
  .kv { font-size: 15px; }
  .legend { font-size: 13px; }
  .hbar-row { font-size: 13px; }
  .list-item .meta, .board-card .m { font-size: 13px; }
  .board-card .t { font-size: 15px; }

  /* ------------------------------------------- every control a thumb */
  /* 16px text in boxes so an iPhone does not zoom in when one is tapped (also when the phone
     does not report a touch screen, for example with a keyboard case). */
  input[type='text'], input[type='email'], input[type='url'], input[type='tel'], input[type='number'], input[type='date'],
  input[type='datetime-local'], input[type='password'], input[type='search'], select, textarea { font-size: 16px; min-height: 44px; }
  textarea { min-height: 96px; }
  input[type='checkbox'], input[type='radio'] { width: 20px; height: 20px; }
  .btn, .btn.sm { min-height: 44px; min-width: 44px; justify-content: center; }
  .seg button, .tabs button { min-height: 44px; }
  .modal-close { min-width: 44px; min-height: 44px; }
  summary { min-height: 44px; display: flex; align-items: center; }
  label.check { min-height: 44px; }
  .check { padding-top: 0; }
  .step .tick, .task-row .tick {
    position: relative; z-index: 0; width: 44px; height: 44px; margin: -11px -6px -11px -11px; border: 0; background: none;
    color: transparent; font-size: 12px; line-height: 44px; text-align: center;
  }
  .step .tick::before, .task-row .tick::before { content: ''; position: absolute; z-index: -1; inset: 11px; border-radius: 50%; border: 2px solid var(--border-strong); }
  .step .tick.done::before, .task-row .tick.done::before { background: #087f08; border-color: #087f08; }
  .step .tick.done, .task-row .tick.done { background: none; color: #fff; }
  .step .label > a { display: inline-block; padding: 11px 0; }
  .nps-scale button { width: 44px; height: 44px; }
  .seg button { min-width: 44px; }
  label:has(> input[type='checkbox']), label:has(> input[type='radio']) { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; }
  input[type='file'] { width: 100%; min-height: 44px; font-size: 15px; }
  input[type='file']::file-selector-button {
    min-height: 44px; margin-right: 12px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  }
  .card-head a:not(.btn), .pager a { display: inline-flex; align-items: center; min-height: 44px; }

  /* --------------------------------------------- tables become cards */
  table.data.cards, table.data.cards > tbody, table.data.cards > tfoot, table.data.cards > tbody > tr, table.data.cards > tfoot > tr { display: block; width: 100%; }
  table.data.cards > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data.cards { font-size: 15px; }
  table.data.cards > tbody > tr, table.data.cards > tfoot > tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
  table.data.cards > tbody > tr:last-child { border-bottom: 0; }
  table.data.cards > tfoot > tr { border-top: 2px solid var(--border-strong); border-bottom: 0; font-weight: 700; }
  .card.flush table.data.cards > tbody > tr, .card.flush table.data.cards > tfoot > tr { padding-left: 16px; padding-right: 16px; }
  table.data.cards td {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0;
    text-align: right; min-width: 0; overflow-wrap: anywhere;
  }
  table.data.cards td::before { content: attr(data-label); flex: none; max-width: 48%; color: var(--muted); font-size: 13px; font-weight: 500; text-align: left; overflow-wrap: normal; }
  table.data.cards td[data-label='']::before { display: none; }
  table.data.cards td[data-label=''] { justify-content: flex-start; text-align: left; }
  table.data.cards td.cell-title { display: block; padding: 0 0 6px; text-align: left; font-size: 16px; font-weight: 650; }
  table.data.cards td.cell-title::before { display: none; }
  table.data.cards td.cell-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; padding-top: 10px; text-align: left; }
  table.data.cards td.cell-actions::before { display: none; }
  table.data.cards td.cell-actions > * + * { margin-left: 0; }
  table.data.cards td.cell-empty { display: none; }
  table.data.cards td .clip { max-width: none; white-space: normal; }
  table.data.cards td .badge { white-space: normal; text-align: left; }
  table.data.cards td .chips { justify-content: flex-end; min-width: 0; }
  table.data.cards tr.row-single > td { display: block; text-align: left; }
  table.data.cards tr.row-single > td::before { display: none; }
  table.data.cards tr.clickable { cursor: pointer; }
  table.data.cards tr.clickable:active { background: var(--surface-2); }
  table.data.cards tr.clickable:hover td { background: none; }
  table.data.cards .nowrap { white-space: normal; }
  .table-wrap:has(> table.data.cards) { overflow: visible; }
  /* A table kept as a table (a grid of numbers) scrolls inside its own card. */
  .table-wrap:has(> table.keep-table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.keep-table th, table.keep-table td { white-space: nowrap; padding: 10px 12px; }
  table.keep-table td { font-size: 14px; }
  table.keep-table th { font-size: 12px; }
  /* The first column (the month) stays in view while the numbers scroll sideways. */
  table.keep-table th:first-child, table.keep-table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }

  /* ---------------------------------------------- list toolbar */
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 12px; }
  .toolbar > input[type='search'] { grid-column: 1 / -1; max-width: none; }
  .toolbar > select { width: 100%; max-width: none; }
  .toolbar > .badge, .toolbar > .seg, .toolbar > .btn, .toolbar > .actions { grid-column: 1 / -1; justify-self: start; }
  .pager { padding: 10px 16px; font-size: 14px; }

  /* --------------------------------------------- boards: one column */
  .board-picker { display: flex; align-items: center; gap: 8px; padding: 12px 12px 0; }
  .board-picker select { flex: 1; min-width: 0; font-weight: 650; }
  .board-picker .app-icon-btn { border: 1px solid var(--border-strong); background: var(--surface); }
  .board-picker .app-icon-btn:disabled { color: var(--muted); opacity: 0.5; cursor: default; }
  .board.single { display: block; overflow: visible; padding: 12px !important; }
  .board.single .board-col { display: none; width: 100%; min-width: 0; max-height: none; }
  .board.single .board-col.current { display: flex; }
  .board.single .board-col-body { overflow: visible; }
  .board-card { cursor: pointer; display: flex; align-items: flex-start; gap: 8px; padding: 12px; }
  .board-card .board-card-text { flex: 1; min-width: 0; }
  .board-card .move-btn { display: inline-flex; flex: none; margin: -4px -4px -4px 0; }

  /* ------------------------------------- dialogs become bottom sheets */
  .modal-backdrop { place-items: end center; padding: max(12px, env(safe-area-inset-top)) 0 0; animation: dim-in 0.2s ease-out; }
  .modal, .modal.sm, .modal.ec-modal {
    width: 100%; max-width: none; border-radius: 20px 20px 0 0; animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-height: calc(100vh - max(12px, env(safe-area-inset-top))); max-height: calc(100dvh - max(12px, env(safe-area-inset-top)));
  }
  .sheet-grabber { display: block; flex: none; width: 38px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 8px auto 0; }
  .modal-head { padding: 8px max(10px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left)); }
  .modal-head h2 { font-size: 17px; }
  .modal-body { padding: 16px max(18px, env(safe-area-inset-right)) 20px max(18px, env(safe-area-inset-left)); overscroll-behavior: contain; }
  .modal-foot {
    flex-wrap: wrap; padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--surface);
  }
  .modal-foot > .btn { flex: 1 1 0; min-height: 48px; }
  .modal-foot:empty { display: none; }
  .modal-body:has(+ .modal-foot:empty) { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .sheet-actions .modal-foot > .btn { flex-basis: 100%; }

  /* ------------------------------------------------------- forms */
  .form .field > input:not([type='checkbox']):not([type='radio']), .form .field > select, .form .field > textarea { width: 100%; max-width: none !important; }
  .inline-form { flex-direction: column; align-items: stretch; }
  /* A row of text with a group of buttons: the buttons go under the text instead of squeezing it. */
  .list-item:has(> .actions), .list-item:has(> .btn ~ .btn) { flex-wrap: wrap; }
  .list-item:has(> .actions) > .grow, .list-item:has(> .btn ~ .btn) > .grow { flex-basis: 100%; }
  /* The top bar's back button replaces "All chats" inside an open chat. */
  .chat-title > .chat-back { display: none; }
  .chat-title > div:not(.seg):not(.actions) { order: 1; flex: 1 1 0; }
  .chat-title h2 { font-size: 15px; }
  .inline-form .field { min-width: 0; }
  /* Save stays in reach at the bottom of the screen while a long form scrolls past. */
  .save-row {
    position: sticky; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 5;
    margin: 14px -14px -14px !important; padding: 12px 14px; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; flex-wrap: wrap;
  }
  .save-row > .btn { flex: 1 1 auto; }
  .save-bar {
    position: sticky; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 6;
    margin: 0 calc(-1 * max(16px, env(safe-area-inset-right))) 0 calc(-1 * max(16px, env(safe-area-inset-left)));
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--page) 90%, transparent); border-top: 1px solid var(--border);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .save-bar > .btn { flex: 1 1 auto; min-height: 48px; }
  html.has-banner .save-row, html.has-banner .save-bar { bottom: calc(150px + env(safe-area-inset-bottom)); }

  /* ----------------------------------------------- number tiles */
  .grid.k3:has(> .kpi), .grid.k2:has(> .mini-kpi), .grid.k3:has(> .mini-kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { gap: 10px; }
  .kpi .value { font-size: 24px; }
  .card { padding: 14px; }
  .card.flush { padding: 0; }
  .card-head { flex-wrap: wrap; }
  .tabs { margin-left: -16px; margin-right: -16px; padding: 0 12px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .callout { font-size: 14px; }

  /* ------------------------------------------- the client portal app */
  .portal:has(> .portal-appbar) { padding-top: 0; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
  .portal:has(> .portal-appbar) > .portal-nav, .portal:has(> .portal-appbar) > .tabs { display: none; }
  .portal-appbar {
    display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 20;
    min-height: calc(52px + env(safe-area-inset-top)); margin: 0 calc(-1 * max(16px, env(safe-area-inset-right))) 14px calc(-1 * max(16px, env(safe-area-inset-left)));
    padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 90%, transparent); border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(160%) blur(8px); -webkit-backdrop-filter: saturate(160%) blur(8px);
  }
  .portal-appbar .app-back { display: inline-flex; }
  .portal-appbar-title { display: flex; align-items: center; flex: 1; min-width: 0; height: 52px; padding-left: 8px; font-size: 17px; font-weight: 700; }
  .portal-appbar .app-back + .portal-appbar-title { padding-left: 0; }
  .portal-appbar-logo { width: 134px; }
  .portal-appbar-who { flex: none; max-width: 42%; padding-right: 8px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .portal-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 4px max(6px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 92%, transparent); border-top: 1px solid var(--border);
    backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  }
  .bt-tab {
    position: relative; flex: 1 1 0; min-width: 0; min-height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: none; padding: 4px 2px; border-radius: 12px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
    color: var(--muted); text-decoration: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  }
  .bt-tab:hover { text-decoration: none; }
  .bt-tab.active { color: var(--accent); }
  .bt-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .bt-count {
    position: absolute; top: 2px; left: calc(50% + 6px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--critical); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; border: 2px solid var(--surface); box-sizing: content-box;
  }
  .portal-hero { padding: 20px; }
  .portal-hero h1 { font-size: 26px; margin-bottom: 14px; }
  .portal-tiles { gap: 10px; }
  .portal .chat { max-height: none; }
}
@media (max-width: 380px) {
  .kpi .value { font-size: 21px; }
}
/* The page's main button fills the row on a phone held upright, not on a tablet. */
@media (min-width: 521px) {
  .page-head .actions > .btn.primary { flex: 0 0 auto; }
}
/* A phone turned sideways has little height: slimmer bars, with each tab's icon beside its name. */
@media (pointer: coarse) and (max-height: 500px) and (orientation: landscape), (max-width: 820px) and (max-height: 500px) {
  .topbar { min-height: calc(44px + env(safe-area-inset-top)); }
  .app-title, .portal-appbar-title { height: 44px; }
  .tabbar .tab, .bt-tab { flex-direction: row; gap: 6px; min-height: 44px; }
  .tabbar .tab-dot { top: 8px; left: calc(50% - 4px); }
  .bt-count { top: 2px; left: auto; right: calc(50% - 40px); }
  .portal-appbar { min-height: calc(44px + env(safe-area-inset-top)); }
}
/* No sliding or fading for people who asked their phone for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* -------------------------------------------- sales commission (commission.js) */
.warn-text { color: var(--warning-text); }
.commission-amount { font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
.commission-bulk { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--accent-soft); }
.commission-table td .badge { white-space: nowrap; }
.commission-table td.actions { white-space: nowrap; }
@media (max-width: 640px) {
  .commission-amount { font-size: 19px; }
  .commission-bulk .btn { min-height: 40px; }
}

/* -------------------------------------------- phones: always fit the screen */
/* Real names, emails and web addresses can be one long word with no spaces. On a phone that long
   word must wrap, never push the page wider than the screen. These rules let any text break when
   it would not fit, keep every box, picture and form control inside its column, and, as a last
   safety net, stop the page itself from scrolling sideways. Tables and boards that are meant to
   scroll sideways still do, inside their own box. */
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  /* Last safety net: the page itself never scrolls sideways. (Only html is set to hidden, so the window
     stays the thing that scrolls; body uses clip, which does not make it a scrolling box.) */
  html { overflow-x: hidden; }
  body { overflow-x: clip; }
  body { overflow-wrap: anywhere; }
  .app, .main, .content, #view, .portal, .card, .stack, .grid > *, .page-head > *, .kv dd, .list-item .grow { min-width: 0; max-width: 100%; }
  img, svg, video, canvas, iframe { max-width: 100%; }
  input, select, textarea, button { max-width: 100%; }
  input, select, textarea { min-width: 0; }
  /* iPhones give date and time boxes a fixed width of their own; make them fill their column like the rest. */
  input[type='date'], input[type='datetime-local'], input[type='time'], input[type='month'] {
    -webkit-appearance: none; appearance: none; display: block; width: 100%;
  }
  input[type='date']::-webkit-date-and-time-value, input[type='datetime-local']::-webkit-date-and-time-value { text-align: left; }
  pre, code, .code { white-space: pre-wrap; overflow-wrap: anywhere; }
  table.data td .clip { max-width: 100%; }
  table.data.cards, .seo-card table.data.cards, .seo-card table.seo-keywords.cards { min-width: 0 !important; }
  /* One-column grids: the column may never grow wider than the screen because of one long word. */
  .site-card, .composer, .chat-composer, .chat-picker, .line-items, .tpl-row, .line-facts, .line-panel, .pace, .phase-bar, .quota-row, .sheet-steps { grid-template-columns: minmax(0, 1fr); }
  .site-head > a, .site-head strong { min-width: 0; overflow-wrap: anywhere; }
  .site-line { grid-template-columns: minmax(0, 0.8fr) minmax(0, 2fr); }
  .line-item-main .field.grow { min-width: 0; flex-basis: 100%; }
  .line-total-block, .quote-totals { min-width: 0; width: 100%; }
  .inline-form .field { min-width: 0; }
}

/* ---------------------------------------- Social Media: Content Calendar */
.sp-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sp-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-range { font-size: 16px; margin: 0 0 0 6px; }
.sp-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sp-filters select { max-width: 220px; }
.sp-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.sp-head { padding: 6px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.sp-day { min-height: 104px; min-width: 0; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.sp-day:nth-child(7n) { border-right: 0; }
.sp-day.out { background: var(--surface-2); }
.sp-day.out .sp-daynum { color: var(--muted); }
.sp-daynum { font-size: 12px; font-weight: 700; align-self: flex-start; padding: 0 6px; }
.sp-day.today .sp-daynum { background: var(--accent); color: var(--accent-ink); border-radius: 999px; }
.sp-chip { display: flex; flex-wrap: wrap; gap: 0 4px; align-items: center; min-width: 0; font-size: 12px; line-height: 1.3; padding: 3px 6px; border-radius: 6px; text-decoration: none; color: var(--text); background: var(--surface-3); border-left: 3px solid var(--border-strong); }
.sp-chip:hover { outline: 1px solid var(--accent); text-decoration: none; }
.sp-chip.sp-warn { background: var(--warning-soft); border-left-color: var(--warning); }
.sp-chip.sp-bad { background: var(--critical-soft); border-left-color: var(--critical); }
.sp-chip.sp-good { background: var(--good-soft); border-left-color: var(--good); }
.sp-chip.sp-info { background: var(--accent-soft); border-left-color: var(--accent); }
.sp-time { color: var(--text-2); white-space: nowrap; flex: none; }
.sp-title { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-client { flex: 1 1 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--text-2); }
.sp-new { width: 7px; height: 7px; border-radius: 50%; background: var(--critical); flex: none; }
.sp-more { border: 0; background: none; color: var(--accent); font: inherit; font-size: 12px; text-align: left; cursor: pointer; padding: 2px 0; }
.sp-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.sp-wday { border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 120px; }
.sp-wday.today { border-color: var(--accent); }
.sp-whead { font-size: 12px; font-weight: 700; }
.sp-wday .sp-title, .sp-wday .sp-client { white-space: normal; overflow-wrap: anywhere; }
.sp-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sp-post-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.sp-caption { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.sp-caption-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 14px 0 6px; }
.sp-media-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.sp-media { margin: 0; border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: grid; gap: 6px; min-width: 0; }
.sp-media img, .sp-media video { width: 100%; max-height: 240px; object-fit: contain; background: var(--surface-2); border-radius: 6px; }
.sp-media-name { overflow-wrap: anywhere; }
.sp-media-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sp-upload { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.sp-thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sp-entry { border-left: 3px solid var(--border-strong); padding: 4px 8px 4px 10px; }
.sp-entry.client { border-left-color: var(--accent); }
.sp-entry.new { background: var(--critical-soft); border-radius: 0 8px 8px 0; }
.sp-entry-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sp-entry-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.sp-good, .ps-good { color: var(--good-text); font-weight: 600; }
.sp-bad, .ps-bad { color: var(--critical-text); font-weight: 600; }
@media (max-width: 1100px) {
  .sp-post-grid { grid-template-columns: minmax(0, 1fr); }
  .sp-week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .sp-day { min-height: 64px; padding: 3px; }
  .sp-daynum { padding: 0 4px; }
  .sp-chip { padding: 2px 4px; border-left-width: 0; }
  .sp-chip .sp-title, .sp-chip .sp-client { display: none; }
  .sp-head { padding: 4px 2px; text-align: center; letter-spacing: 0; }
  .sp-week { grid-template-columns: minmax(0, 1fr); }
  .sp-filters, .sp-filters select { width: 100%; max-width: 100%; }
  .sp-filters select { flex: 1 1 140px; }
}
@media (pointer: coarse) {
  .sp-nav .btn.sm, .sp-media-actions .btn.sm { min-height: 44px; min-width: 44px; justify-content: center; }
  .sp-toolbar .seg button { min-height: 44px; }
}

/* ------------------- Client portal: sections unlocked by the client's services */
.ps-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 0 0 14px; }
.ps-card { display: grid; gap: 4px; align-content: start; text-decoration: none; color: var(--text); min-height: 44px; }
.ps-card:hover { border-color: var(--accent); text-decoration: none; }
.ps-card-head { display: flex; gap: 8px; align-items: center; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); }
.ps-card-text { font-weight: 650; font-size: 15px; }
.ps-card-text.warn { color: var(--warning-text); }
.ps-row { text-decoration: none; color: var(--text); min-height: 44px; }
.ps-row:hover { text-decoration: none; }
.ps-row:hover .title { color: var(--accent); }
.ps-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 10px 0 12px; }
.ps-month { display: flex; align-items: center; gap: 8px; }
.ps-month h3 { margin: 0; font-size: 16px; min-width: 9em; text-align: center; }
.ps-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.ps-head { font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; padding: 2px 0; text-transform: uppercase; }
.ps-cell { min-height: 84px; min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 4px; display: flex; flex-direction: column; align-items: stretch; gap: 3px; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.ps-cell.blank { border: 0; background: none; cursor: default; }
.ps-cell.has { background: var(--surface-2); }
.ps-cell.today .ps-num { color: var(--accent); }
.ps-cell.chosen { outline: 2px solid var(--accent); outline-offset: -1px; }
.ps-num { font-size: 12px; font-weight: 700; }
.ps-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.ps-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.ps-dot.warn { background: var(--warning); }
.ps-dot.bad { background: var(--critical); }
.ps-dot.good { background: var(--good); }
.ps-dot.info { background: var(--accent); }
.ps-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ps-title { font-size: 11.5px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.ps-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.ps-daylist { margin-top: 12px; }
.ps-day h4, .ps-daylist h4 { margin: 12px 0 2px; font-size: 13px; color: var(--text-2); }
.ps-facts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 13px; }
.ps-platforms { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ps-caption { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.55; }
.ps-media { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 12px; }
.ps-figure { margin: 0; display: grid; gap: 6px; min-width: 0; }
.ps-figure img, .ps-figure video { width: 100%; max-height: 420px; object-fit: contain; background: var(--surface-2); border-radius: 10px; }
.ps-figure figcaption { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ps-fname { flex: 1 1 120px; min-width: 0; overflow-wrap: anywhere; }
.ps-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.ps-thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ps-thread li { border-left: 3px solid var(--border-strong); padding: 2px 0 2px 10px; }
.ps-thread li.mine { border-left-color: var(--accent); }
.ps-entry-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ps-entry-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 3px; }
.ps-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ps-bars { display: grid; gap: 8px; }
.ps-bar-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(60px, 2fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.ps-bar-num { text-align: right; font-variant-numeric: tabular-nums; }
.ps-build .phase-bar { margin-top: 6px; }
@media (max-width: 640px) {
  .ps-cell { min-height: 48px; padding: 3px; }
  .ps-titles { display: none; }
  .ps-month { flex: 1 1 100%; justify-content: space-between; }
  .ps-month h3 { min-width: 0; font-size: 15px; }
  .ps-controls > .btn { width: 100%; justify-content: center; }
  .ps-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ps-bar-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'label num' 'bar bar'; row-gap: 4px; }
  .ps-bar-row .ps-bar-label { grid-area: label; }
  .ps-bar-row .ps-bar-num { grid-area: num; }
  .ps-bar-row .progress { grid-area: bar; }
}
/* Phones and touch screens: every control in these sections is at least 44 points tall. */
@media (max-width: 640px), (pointer: coarse) {
  .ps-cell { min-height: 48px; }
  .ps-section .btn, .ps-section .seg button { min-height: 44px; }
  .ps-section .btn.sm { min-width: 44px; justify-content: center; }
}

/* ------------------------------------------------------------ GoHighLevel */
/* GoHighLevel (read-only): GHL Pipeline, Bookings and the Connected Apps section. */
.ghl-card { cursor: pointer; }
.ghl-card .m { justify-content: space-between; align-items: center; }
.ghl-card .m strong { color: var(--text); }
.ghl-day { padding: 4px 16px 10px; }
.ghl-day + .ghl-day { border-top: 1px solid var(--border); }
.ghl-day-head { padding: 12px 0 2px; font-size: 13.5px; }
.ghl-booking { cursor: pointer; border-radius: 8px; padding-left: 6px; padding-right: 6px; }
.ghl-booking:hover { background: var(--surface-2); }
.ghl-booking:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.ghl-when { width: 92px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.ghl-cal { display: grid; gap: 0; min-width: 100%; }
.ghl-cal-head { height: 40px; padding: 8px 6px; font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghl-cal-head span { font-weight: 500; color: var(--muted); margin-left: 5px; }
.ghl-cal-head.today { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.ghl-cal-axis, .ghl-cal-col { position: relative; }
.ghl-cal-col { border-left: 1px solid var(--border); }
.ghl-cal-hour { position: absolute; right: 6px; font-size: 11px; color: var(--muted); transform: translateY(3px); white-space: nowrap; }
.ghl-cal-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.ghl-cal-event {
  position: absolute; display: flex; flex-direction: column; gap: 1px; text-align: left; overflow: hidden; cursor: pointer;
  border: 1px solid var(--accent); border-left-width: 3px; border-radius: 6px; background: var(--accent-soft); color: var(--text);
  padding: 2px 5px; font-size: 11.5px; line-height: 1.25; font-family: inherit;
}
.ghl-cal-event:hover { box-shadow: 2px 2px 0 var(--accent); z-index: 2; }
.ghl-cal-event:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 2; }
.ghl-cal-event.off { border-color: var(--border-strong); background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.ghl-cal-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.ghl-cal-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.ghl-cal-sub { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghl-conn { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.ghl-add { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.ghl-add > summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
@media (max-width: 720px) {
  .ghl-when { width: 74px; }
}
/* Touch screens: the fold-out sections and the booking rows are big enough for a thumb. */
@media (pointer: coarse) {
  .ghl-add > summary { padding-top: 12px; padding-bottom: 12px; }
  .ghl-booking { min-height: 44px; }
}

/* --------------------------- Remove test data, and QuickBooks: Check customer matches */
.td-gap { margin-bottom: 14px; }
.td-sub { font-size: 14px; margin: 14px 0 6px; }
.td-ticks { display: flex; flex-direction: column; gap: 2px; }
.td-tick { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; cursor: pointer; }
.td-tick input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; }
.td-tick > span { min-width: 0; overflow-wrap: anywhere; }
.td-tick-text { color: var(--text-2); }
.td-main { margin: 6px 0; }
.td-kv { margin-top: 8px; }
.td-refused { color: var(--critical-text); margin-top: 4px; }
.td-result { align-items: flex-start; }
.td-total { margin: 12px 0 4px; }
.td-blocks { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.td-block { border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; background: var(--surface); }
.td-block > summary { cursor: pointer; padding: 10px 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; list-style: none; }
.td-block > summary::-webkit-details-marker { display: none; }
.td-block > summary::before { content: '\25B8'; color: var(--muted); }
.td-block[open] > summary::before { content: '\25BE'; }
.td-block-title { font-weight: 600; }
.td-block-text { color: var(--text-2); font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.td-items { margin: 0 0 10px; padding-left: 18px; font-size: 13px; }
.td-items li { margin: 3px 0; overflow-wrap: anywhere; }
.td-note { margin: 10px 0; }
.td-steps { padding-left: 18px; }
.td-confirm { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 4px; }
.td-confirm .field { max-width: 260px; margin: 10px 0; }
.qm-gap { margin: 12px 0; }
.qm-help { padding-left: 18px; color: var(--text-2); }
.qm-summary { font-weight: 600; }
.qm-row { flex-wrap: wrap; align-items: flex-start; }
.qm-row .grow { flex: 1 1 260px; }
.qm-row .meta { margin-top: 2px; }
.qm-choice { flex: 0 1 340px; min-width: 0; }
.qm-choice select { width: 100%; }
.qbo-step { margin: 10px 0; }
.qbo-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  .qm-choice { flex: 1 1 100%; }
  .td-block > summary { min-height: 44px; align-items: center; }
  .td-tick { min-height: 44px; align-items: center; }
  .td-tick input { margin-top: 0; }
  .qbo-links a { display: inline-flex; align-items: center; min-height: 44px; }
  .td-confirm .field { max-width: none; }
}
