/* Command Central
   An executive operating system: a dark ink sidebar that anchors navigation,
   a quiet light canvas for the work, cobalt for the active thing, amber for
   what is waiting on a decision, red only for what is late. */

:root {
  --canvas: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eef0f4;
  --ink: #0b1220;
  --ink-soft: #4a5468;
  --ink-faint: #8a93a5;
  --line: #e4e7ec;
  --line-strong: #d3d8e0;

  --side: #0b1220;
  --side-2: #131c2e;
  --side-ink: #aeb7c8;
  --side-ink-strong: #ffffff;
  --side-line: #1d273a;

  --accent: #3d5afe;
  --accent-ink: #2b45d8;
  --accent-soft: #eef1ff;
  --attn: #b7791f;
  --attn-strong: #e8a317;
  --attn-soft: #fff6e2;
  --danger: #d93f45;
  --danger-soft: #fdeeee;
  --ok: #24935f;
  --ok-soft: #e7f6ee;
  --warn: #b7791f;
  --warn-soft: #fff6e2;

  --q1: #d93f45;
  --q2: #3d5afe;
  --q3: #e8a317;
  --q4: #8a93a5;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.05);
  --shadow: 0 1px 2px rgba(11, 18, 32, 0.04), 0 8px 24px rgba(11, 18, 32, 0.06);
  --shadow-lg: 0 18px 50px rgba(11, 18, 32, 0.18);
  --tap: 44px;
  --side-w: 248px;
  --font: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0a0f1a;
    --surface: #111827;
    --surface-2: #161f31;
    --surface-3: #1c2639;
    --ink: #e9edf4;
    --ink-soft: #a6afc0;
    --ink-faint: #6e788b;
    --line: #222c40;
    --line-strong: #2d384f;
    --side: #070b14;
    --side-2: #111a2b;
    --side-line: #151e30;
    --accent: #6d84ff;
    --accent-ink: #8b9dff;
    --accent-soft: #1a2349;
    --attn: #f0b544;
    --attn-strong: #f0b544;
    --attn-soft: #2c2310;
    --danger: #f06a6f;
    --danger-soft: #34161a;
    --ok: #4cc38a;
    --ok-soft: #12291f;
    --warn: #f0b544;
    --warn-soft: #2c2310;
    --q1: #f06a6f;
    --q2: #6d84ff;
    --q3: #f0b544;
    --q4: #6e788b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.82rem; }
a { color: var(--accent-ink); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--side-w);
  background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column;
  padding: calc(16px + env(safe-area-inset-top)) 12px 12px;
  overflow-y: auto; z-index: 30;
  scrollbar-width: thin; scrollbar-color: var(--side-line) transparent;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.side-brand img { width: 38px; height: 38px; border-radius: 9px; }
.side-brand span { color: var(--side-ink-strong); font-weight: 650; font-size: 1.1rem; letter-spacing: -0.01em; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  color: var(--side-ink); font-size: 0.92rem; font-weight: 520;
  padding: 8px 10px; min-height: 38px; border-radius: 8px;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--side-2); color: var(--side-ink-strong); }
.nav-item.active { background: var(--side-2); color: var(--side-ink-strong); box-shadow: inset 2px 0 0 var(--accent); }
.nav-ic { width: 18px; height: 18px; flex: 0 0 auto; opacity: 0.9; }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-label { margin: 18px 10px 6px; font-size: 0.74rem; color: #6f7a8e; font-weight: 600; letter-spacing: 0.02em; }
.nav-sub { padding-left: 10px; }
.nav-badge { background: var(--attn-strong); color: #1d1405; font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: #f06a6f; flex: 0 0 auto; }
.side-foot { border-top: 1px solid var(--side-line); padding: 12px 6px 2px; margin-top: 12px; }
.side-user { display: flex; align-items: center; gap: 10px; }
.side-user-text { display: flex; flex-direction: column; line-height: 1.25; }
.side-user-name { color: var(--side-ink-strong); font-weight: 600; font-size: 0.9rem; }
.side-user-role { color: #6f7a8e; font-size: 0.78rem; }

/* Initials avatars */
.av {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 7px; flex: 0 0 auto;
  background: var(--accent); color: #fff; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em;
}
.av-user { width: 32px; height: 32px; border-radius: 50%; background: var(--side-2); color: var(--side-ink-strong); font-size: 0.78rem; border: 1px solid var(--side-line); }

/* ---------- Mobile app bar ---------- */
.appbar {
  display: none;
  position: sticky; top: 0; z-index: 20;
  align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--side); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon { width: 34px; height: 34px; border-radius: 8px; }
.appbar h1 { font-size: 1rem; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.date-line { margin: 0; font-size: 0.74rem; color: var(--side-ink); }
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.whoami { display: none; }
.net-pill { font-size: 0.7rem; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: rgba(76, 195, 138, 0.16); color: #6fd6a3; white-space: nowrap; }
.net-pill.offline { background: var(--danger); color: #fff; }
.nav-toggle {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 38px; height: 38px; border: 1px solid var(--side-line); border-radius: 9px;
  background: var(--side-2); padding: 0 10px; cursor: pointer; flex: 0 0 auto;
}
.nav-toggle span { display: block; height: 2px; background: #fff; border-radius: 1px; }
.nav-scrim { display: none; }

.demo-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #fff4d6; color: #5c4300; border-bottom: 1px solid #f0d88a; padding: 9px 16px; font-size: 0.88rem; margin-left: var(--side-w); }
.demo-banner p { margin: 0; }
.demo-banner .link-btn { color: #5c4300; font-weight: 600; text-decoration: underline; }
.offline-banner { background: #7a2e0e; color: #fff; padding: 9px 16px; font-size: 0.88rem; margin-left: var(--side-w); }
.install-card { margin: 12px 16px 0 calc(var(--side-w) + 16px); }
.install-card ol { margin: 8px 0 12px 20px; padding: 0; }

/* ---------- Main canvas ---------- */
main { margin-left: var(--side-w); padding: 32px 40px 110px; max-width: calc(1180px + var(--side-w)); }

@media (max-width: 900px) {
  .appbar { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(5, 8, 15, 0.5); z-index: 25; }
  main { margin-left: 0; padding: 18px 16px 110px; }
  .offline-banner, .install-card, .demo-banner { margin-left: 0; }
  .install-card { margin: 12px 16px 0; }
}
body.signed-out .sidebar, body.signed-out .nav-toggle, body.signed-out .net-pill { display: none !important; }
body.signed-out main { margin-left: 0; max-width: none; }
body.signed-out .appbar { display: none; }

/* ---------- Type ---------- */
.home-head { margin: 0 0 24px; }
.home-greeting, .ws-title, .view-head h2 {
  margin: 0; font-size: clamp(1.6rem, 3vw, 2rem); font-weight: 650; letter-spacing: -0.025em; line-height: 1.15;
}
.home-date { margin: 4px 0 0; color: var(--ink-soft); }
.section-title { font-size: 1rem; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 12px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.view > .muted { margin: 0 0 18px; max-width: 70ch; }

/* ---------- Buttons ---------- */
.btn {
  font-size: 0.9rem; font-weight: 600; border: 1px solid transparent; border-radius: var(--radius-sm);
  min-height: 40px; padding: 8px 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover { background: #1e293b; }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-small { min-height: 34px; padding: 5px 12px; font-size: 0.84rem; background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-small:hover { background: var(--surface-2); }
.btn-block { width: 100%; margin-top: 8px; }
.btn-approve { background: var(--ok); color: #fff; }
.btn-approve:hover { filter: brightness(1.05); }
.btn-icon {
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-soft);
  border-radius: 50%; width: 36px; height: 36px; min-width: 36px; min-height: 36px; padding: 0; font-size: 1.2rem;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.link-btn { background: none; border: 0; padding: 4px 0; min-height: 32px; color: var(--accent-ink); font-weight: 600; font-size: 0.88rem; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); margin-left: auto; }
@media (prefers-color-scheme: dark) {
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-primary:hover { background: var(--accent-ink); }
  .btn-approve { color: #06150e; }
}

/* ---------- Cards and surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.card h2 { margin: 0 0 6px; font-size: 1rem; font-weight: 650; }
.empty { text-align: center; color: var(--ink-soft); padding: 40px 16px; }
.empty p { margin: 0 0 4px; }

/* ---------- Overview: KPI cards ---------- */
.pulse { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.pulse-item {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); min-width: 0;
}
.pulse-label { order: -1; font-size: 0.84rem; color: var(--ink-soft); font-weight: 550; margin-bottom: 8px; }
.pulse-num { line-height: 1.1; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: clamp(1.35rem, 5.4vw, 2rem); }
.pulse-num.pulse-empty { font-size: 1.05rem; color: var(--ink-faint); font-weight: 550; letter-spacing: 0; padding: 8px 0 4px; }
.pulse-note { font-size: 0.78rem; color: var(--ink-faint); margin-top: 6px; }
.pulse-item.gold { background: var(--attn-soft); border-color: transparent; }
.pulse-item.gold .pulse-num { color: var(--attn); }
.pulse-item.alert .pulse-num { color: var(--danger); }
.pulse-item.warn .pulse-num { color: var(--warn); }
@media (max-width: 1000px) { .pulse { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 380px) { .pulse { gap: 10px; } .pulse-item { padding: 12px 14px; } .pulse-num { font-size: 1.6rem; } }

/* ---------- Overview: attention + businesses ---------- */
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1150px) { .overview-grid { grid-template-columns: 1fr; } }
.attention, .biz { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 8px; box-shadow: var(--shadow-sm); }
.attn-group { border-top: 1px solid var(--line); }
.attn-group:first-of-type { border-top: 0; }
.attn-group > summary {
  list-style: none; display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; min-height: 46px; font-weight: 600; font-size: 0.93rem;
}
.attn-group > summary::-webkit-details-marker { display: none; }
.attn-count { min-width: 26px; text-align: center; border-radius: 999px; padding: 0 8px; font-size: 0.78rem; font-weight: 650; line-height: 22px; background: var(--surface-3); color: var(--ink-faint); }
.attn-count.on { background: var(--ink); color: var(--surface); }
.attn-empty { margin: 0 0 12px; }
.attn-group .decision-list { margin-bottom: 12px; }
.attn-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; text-align: left;
  background: var(--surface-2); border: 0; border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 6px; color: var(--ink); cursor: pointer;
  box-shadow: inset 3px 0 0 var(--line-strong);
}
button.attn-row:hover { background: var(--surface-3); }
.attn-row.alert { box-shadow: inset 3px 0 0 var(--danger); }
.attn-row.warn { box-shadow: inset 3px 0 0 var(--warn); cursor: default; }
.attn-ws { grid-column: 1 / -1; font-size: 0.74rem; color: var(--ink-faint); font-weight: 550; }
.attn-title { font-weight: 560; font-size: 0.9rem; overflow-wrap: anywhere; }
.attn-when { font-size: 0.8rem; color: var(--ink-soft); white-space: nowrap; align-self: end; }
.attn-row.alert .attn-when { color: var(--danger); font-weight: 600; }

.ws-list { display: flex; flex-direction: column; }
.ws-row {
  display: flex; flex-direction: column; gap: 8px; text-align: left; width: 100%;
  background: none; border: 0; border-top: 1px solid var(--line);
  padding: 14px 4px; color: var(--ink); cursor: pointer;
}
.ws-row:first-child { border-top: 0; padding-top: 4px; }
.ws-row:hover .ws-name > span:not(.av):not(.private-tag) { color: var(--accent-ink); }
.ws-name { display: flex; align-items: center; gap: 10px; font-size: 1rem; font-weight: 650; letter-spacing: -0.01em; }
.ws-name .av { width: 28px; height: 28px; border-radius: 8px; font-size: 0.72rem; }
.ws-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.84rem; color: var(--ink-soft); padding-left: 38px; }
.ws-stat b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.ws-stat.alert, .ws-stat.alert b { color: var(--danger); }
.ws-stat.gold, .ws-stat.gold b { color: var(--attn); }
.kpi-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 38px; }
.kpi-chip { display: inline-flex; gap: 6px; font-size: 0.78rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.kpi-chip-name { color: var(--ink-soft); }
.kpi-chip-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-chip.stale { background: var(--warn-soft); border-color: transparent; }
.ws-kpi-note { font-size: 0.78rem; color: var(--ink-faint); padding-left: 38px; }
.ws-kpi-note.warn { color: var(--warn); }
.private-tag { font-size: 0.7rem; font-weight: 600; color: var(--ink-soft); background: var(--surface-3); border-radius: 999px; padding: 1px 8px; letter-spacing: 0; }

/* ---------- Decisions and approvals ---------- */
.decision-list, .approval-list { display: flex; flex-direction: column; gap: 8px; }
.decision, .approval {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; box-shadow: inset 3px 0 0 var(--attn-strong);
}
.attention .decision { background: var(--attn-soft); border-color: transparent; }
.decision { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.decision-text { flex: 1 1 240px; min-width: 0; }
.decision-title { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.decision-meta { margin: 2px 0 0; font-size: 0.8rem; color: var(--ink-soft); }
.decision-detail { margin: 6px 0 0; font-size: 0.86rem; overflow-wrap: anywhere; }
.decision-actions { display: flex; gap: 8px; margin-top: 10px; }
.decision .decision-actions { margin-top: 0; }
.decision-actions .btn { min-height: 36px; padding: 6px 14px; }
.approval.approved { box-shadow: inset 3px 0 0 var(--ok); }
.approval.declined { box-shadow: inset 3px 0 0 var(--danger); }
.approval.withdrawn { box-shadow: inset 3px 0 0 var(--line-strong); opacity: 0.8; }
.approval-status { margin: 8px 0 0; font-size: 0.84rem; font-weight: 600; }
.approval-status.approved { color: var(--ok); }
.approval-status.declined { color: var(--danger); }
.approval-status.withdrawn { color: var(--ink-soft); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.seg-btn { border: 0; background: none; color: var(--ink-soft); font-weight: 600; font-size: 0.86rem; padding: 6px 14px; min-height: 32px; border-radius: 8px; cursor: pointer; }
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Business workspace ---------- */
.ws-head { margin: 0 0 14px; }
.ws-title { display: flex; align-items: center; gap: 12px; }
.ws-title .av { width: 36px; height: 36px; border-radius: 10px; font-size: 0.85rem; }
.ws-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 22px; overflow-x: auto; scrollbar-width: none; }
.ws-tab {
  border: 0; background: none; color: var(--ink-soft); font-weight: 600; font-size: 0.9rem;
  padding: 10px 12px; min-height: 42px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; white-space: nowrap;
}
.ws-tab:hover { color: var(--ink); }
.ws-tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.ws-section { margin-bottom: 26px; }
.ws-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.ws-section-head .section-title { margin: 0; }
.ws-tasks-title { margin-top: 6px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.kpi.stale { border-color: var(--warn-soft); }
.kpi-name { margin: 0; font-size: 0.84rem; color: var(--ink-soft); font-weight: 550; }
.kpi-value { margin: 6px 0 2px; font-size: 1.75rem; line-height: 1.1; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-value.empty { font-size: 1rem; color: var(--ink-faint); font-weight: 550; letter-spacing: 0; padding: 6px 0; }
.kpi-target { margin: 0; font-size: 0.8rem; color: var(--ink-soft); }
.kpi-bar { height: 6px; background: var(--surface-3); border-radius: 999px; margin: 8px 0 4px; overflow: hidden; }
.kpi-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.4s ease; }
.kpi-fresh { margin: 8px 0 0; font-size: 0.78rem; color: var(--ink-soft); }
.kpi.stale .kpi-fresh { color: var(--warn); font-weight: 600; }
.kpi-source { margin: 2px 0 10px; font-size: 0.74rem; color: var(--ink-faint); overflow-wrap: anywhere; }
.kpi .btn-small { margin-top: auto; }

.prio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.prio { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.prio-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.prio-head h4 { margin: 0; font-size: 0.92rem; font-weight: 650; }
.prio-line { margin: 8px 0; font-size: 0.88rem; overflow-wrap: anywhere; }
.prio-line.alert { color: var(--danger); }

.status-pill { display: inline-block; font-size: 0.7rem; font-weight: 650; border-radius: 999px; padding: 1px 8px; white-space: nowrap; vertical-align: 1px; }
.status-pill.on_track { background: var(--ok-soft); color: var(--ok); }
.status-pill.at_risk { background: var(--warn-soft); color: var(--warn); }
.status-pill.off_track { background: var(--danger-soft); color: var(--danger); }
.status-pill.done { background: var(--surface-3); color: var(--ink-soft); }

.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.project { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.project.done { opacity: 0.75; }
.project.off_track .kpi-bar span, .project.overdue .kpi-bar span { background: var(--danger); }
.project.at_risk .kpi-bar span { background: var(--warn); }
.project.on_track .kpi-bar span { background: var(--ok); }
.project-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.project-kind { font-size: 0.76rem; color: var(--ink-faint); font-weight: 550; }
.project-title { margin: 8px 0 2px; font-weight: 650; overflow-wrap: anywhere; }
.project-meta { margin: 0; font-size: 0.8rem; color: var(--ink-soft); }
.project.overdue .project-meta { color: var(--danger); }
.project-notes { font-size: 0.84rem; margin: 8px 0 10px; color: var(--ink-soft); overflow-wrap: anywhere; }
.goal-ws { margin-bottom: 30px; }

.doc-form { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin: 12px 0 16px; }
.doc-form input { padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); min-height: 38px; min-width: 0; font-size: 0.92rem; }
@media (max-width: 640px) { .doc-form { grid-template-columns: 1fr; } }
.doc-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.doc-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 12px 16px; border-top: 1px solid var(--line); }
.doc-list li:first-child { border-top: 0; }
.doc-list a { color: var(--ink); font-weight: 600; text-decoration: none; }
.doc-list a:hover { color: var(--accent-ink); text-decoration: underline; }

/* ---------- Tasks ---------- */
.day-nav { display: flex; align-items: center; justify-content: space-between; margin: 0 0 18px; }
.day-nav h2 { margin: 0; font-size: 1.5rem; font-weight: 650; letter-spacing: -0.02em; }
.task-list { display: block; }
.cat-block { margin-bottom: 22px; }
.cat-title { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; margin: 22px 2px 6px; }
.quad-block { margin-bottom: 10px; }
.quad-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 14px 2px 8px; }
.quad-title .qnum { font-weight: 650; font-size: 0.84rem; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.quad-title .qnum::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--q2); }
.quad-block.qn1 .qnum::before { background: var(--q1); }
.quad-block.qn2 .qnum::before { background: var(--q2); }
.quad-block.qn3 .qnum::before { background: var(--q3); }
.quad-block.qn4 .qnum::before { background: var(--q4); }
.quad-title .qmean { color: var(--ink-faint); font-size: 0.8rem; }

.task {
  position: relative; display: flex; gap: 8px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 48px 12px 8px; margin-bottom: 8px; box-shadow: var(--shadow-sm);
  transition: border-color 0.12s;
}
.task:hover { border-color: var(--line-strong); }
.task.done { opacity: 0.6; }
.task.done .task-title { text-decoration: line-through; }
.check { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; cursor: pointer; border-radius: 10px; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-ui {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.12s, border-color 0.12s;
}
.check:hover .check-ui { border-color: var(--ok); }
.check-ui::after { content: ""; width: 10px; height: 6px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.check input:checked + .check-ui { background: var(--ok); border-color: var(--ok); }
.check input:checked + .check-ui::after { opacity: 1; }
.check input:focus-visible + .check-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.check input:disabled + .check-ui { opacity: 0.5; }
.task-body { flex: 1; min-width: 0; padding-top: 7px; }
.task-title { font-weight: 600; font-size: 0.95rem; margin: 0; overflow-wrap: anywhere; line-height: 1.35; }
.task-detail { font-size: 0.85rem; color: var(--ink-soft); margin: 3px 0 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.badge { font-size: 0.7rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-soft); white-space: nowrap; line-height: 18px; }
.badge.quick { background: var(--accent-soft); color: var(--accent-ink); }
.badge.status-delayed { background: var(--attn-soft); color: var(--attn); }
.badge.status-delegated { background: var(--accent-soft); color: var(--accent-ink); }
.badge.overdue { background: var(--danger-soft); color: var(--danger); }
.badge.sample { opacity: 0.75; }
.source-link { display: inline-block; margin-top: 6px; font-size: 0.8rem; color: var(--accent-ink); text-decoration: none; font-weight: 600; }
.source-link:hover { text-decoration: underline; }

.qseg { display: inline-flex; gap: 2px; margin-top: 10px; background: var(--surface-3); border-radius: 9px; padding: 2px; }
.qseg-btn { border: 0; background: none; padding: 4px 12px; min-height: 28px; font-size: 0.76rem; font-weight: 600; border-radius: 7px; color: var(--ink-soft); cursor: pointer; }
.qseg-btn:hover { color: var(--ink); }
.qseg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.qreason { font-size: 0.78rem; color: var(--ink-faint); margin: 6px 0 0; }
.notes { margin-top: 6px; font-size: 0.82rem; }
.notes > summary { cursor: pointer; color: var(--ink-soft); font-weight: 600; }
.notes ul { margin: 6px 0 0; padding-left: 18px; }
.notes li { margin-bottom: 4px; }
.more-do { margin: 4px 0 8px; }
.more-do > summary {
  list-style: none; cursor: pointer; min-height: 40px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--ink-soft); font-weight: 600; font-size: 0.86rem;
}
.more-do > summary::-webkit-details-marker { display: none; }
.more-do[open] > summary { margin-bottom: 8px; }

.task-menu { position: absolute; top: 8px; right: 8px; z-index: 5; }
.menu-btn { list-style: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--ink-faint); font-size: 1.1rem; cursor: pointer; user-select: none; }
.menu-btn::-webkit-details-marker { display: none; }
.menu-btn:hover, .task-menu[open] .menu-btn { background: var(--surface-3); color: var(--ink); }
.menu-pop { position: absolute; top: 38px; right: 0; min-width: 170px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 4px; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink); font-size: 0.9rem; font-weight: 500; min-height: 38px; padding: 8px 12px; border-radius: 7px; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }

.add-bar { position: sticky; bottom: calc(16px + env(safe-area-inset-bottom)); margin-top: 18px; display: flex; justify-content: flex-end; }
.add-bar .btn { width: auto; min-width: 160px; box-shadow: var(--shadow-lg); border-radius: 999px; padding: 10px 22px; }
@media (max-width: 900px) { .add-bar .btn { width: 100%; } }
.summary-strip { display: none; }

/* ---------- Sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(5, 8, 15, 0.5); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } }
.sheet {
  background: var(--surface); color: var(--ink); border-radius: 16px 16px 0 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
@media (min-width: 640px) { .sheet { border-radius: 16px; } }
.sheet h2 { margin: 0 0 14px; font-size: 1.12rem; font-weight: 650; letter-spacing: -0.01em; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.field input[type="text"], .field input[type="password"], .field input[type="date"], .field input[type="email"],
.field input[type="number"], .field input[type="url"], .field textarea, .field select {
  width: 100%; font-size: 0.95rem; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); min-height: 40px;
}
.field input:focus, .field textarea:focus, .field select:focus, .doc-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 0.92rem; min-height: 40px; margin-bottom: 10px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet-actions .btn { flex: 1; }
.notify-heading { font-size: 0.95rem; margin: 18px 0 6px; }
.notify-preview { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.88rem; }

/* ---------- Settings, team, briefs, activity ---------- */
.checklist { list-style: none; margin: 10px 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 0.92rem; }
.check-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); flex: 0 0 auto; }
li.done .check-dot { background: var(--ok); border-color: var(--ok); }
li.done { color: var(--ink-soft); }
.quad-legend { margin: 0; }
.quad-legend dt { font-weight: 650; margin-top: 8px; font-size: 0.92rem; }
.quad-legend dd { margin: 0 0 4px; color: var(--ink-soft); font-size: 0.88rem; }
#cleanResult ul { margin: 8px 0; padding-left: 18px; }
#cleanResult:not(:empty) { margin: 8px 0; }

#view-people .member { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.member summary { cursor: pointer; display: flex; flex-direction: column; gap: 2px; list-style: none; min-height: 40px; justify-content: center; }
.member summary::-webkit-details-marker { display: none; }
.member-name { font-weight: 650; }
.member-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.perm-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.88rem; }
.perm-table th, .perm-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.perm-table th[scope="row"], .perm-table thead th:first-child { text-align: left; font-weight: 600; }
.perm-table thead th { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; }
.perm-table input { width: 18px; height: 18px; accent-color: var(--accent); }

.brief { margin-bottom: 12px; }
.brief h3 { margin: 0 0 6px; font-size: 1rem; font-weight: 650; }
.brief .slot { font-size: 0.8rem; color: var(--ink-soft); margin: 0 0 6px; }
.brief ul { margin: 6px 0 8px 18px; padding: 0; font-size: 0.9rem; }
.brief li { margin-bottom: 3px; }
.brief details { margin-top: 6px; }
.brief summary { cursor: pointer; color: var(--ink-soft); font-size: 0.86rem; font-weight: 600; }
.brief pre { white-space: pre-wrap; font-family: inherit; font-size: 0.86rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; max-height: 260px; overflow-y: auto; }

.activity { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.activity-day { font-weight: 650; font-size: 0.86rem; padding: 10px 16px; background: var(--surface-2); color: var(--ink-soft); border-top: 1px solid var(--line); }
.activity-day:first-child { border-top: 0; }
.activity-row { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 0.88rem; }
.activity-time { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.activity-detail { color: var(--ink-soft); }

/* ---------- Sign in ---------- */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 90, 254, 0.22), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(232, 163, 23, 0.12), transparent 60%),
    var(--side);
}
.login-card { width: 100%; max-width: 400px; padding: 30px 28px; border-radius: 16px; box-shadow: var(--shadow-lg); border: 0; }
.login-icon { border-radius: 12px; display: block; margin-bottom: 18px; }
.login-card h2 { margin: 0 0 4px; font-size: 1.4rem; letter-spacing: -0.02em; }
.login-card > .muted { margin: 0 0 18px; }
.login-card .btn-primary { min-height: 44px; margin-top: 12px; }
.login-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.86rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 550; z-index: 100; max-width: 90vw; text-align: center; box-shadow: var(--shadow-lg);
}
@media (min-width: 901px) { .toast { left: calc(50% + var(--side-w) / 2); } }

/* Owner-only controls are hidden for team members; the server enforces the same rule. */
body:not(.is-owner) .owner-only { display: none !important; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Schedule (My Day) ---------- */
.agenda { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 8px; box-shadow: var(--shadow-sm); margin-bottom: 22px; }
.agenda-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.agenda-head .section-title { margin-bottom: 8px; }
.agenda-list { list-style: none; margin: 0; padding: 0; }
.agenda-item { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.agenda-item:first-child { border-top: 0; }
.agenda-item.past { opacity: 0.55; }
.agenda-time { font-size: 0.84rem; font-weight: 600; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.agenda-main { display: flex; flex-direction: column; min-width: 0; }
.agenda-title { font-weight: 600; overflow-wrap: anywhere; }
.agenda-title a { color: var(--ink); text-decoration: none; }
.agenda-title a:hover { color: var(--accent-ink); text-decoration: underline; }
.agenda-meta { font-size: 0.8rem; color: var(--ink-faint); }
@media (max-width: 560px) { .agenda-item { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- Inbox ---------- */
.nav-badge-blue { background: var(--accent); color: #fff; }
.inbox-list { display: flex; flex-direction: column; gap: 8px; }
.inbox-item {
  display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.inbox-item.actionable { box-shadow: inset 3px 0 0 var(--accent), var(--shadow-sm); }
.inbox-item.tasked, .inbox-item.dismissed { opacity: 0.6; }
.inbox-kind { flex: 0 0 auto; align-self: flex-start; font-size: 0.7rem; font-weight: 700; border-radius: 6px; padding: 2px 8px; background: var(--surface-3); color: var(--ink-soft); }
.inbox-kind.kind-email { background: #fdecea; color: #c5221f; }
.inbox-kind.kind-slack { background: #f3e8f6; color: #611f69; }
.inbox-kind.kind-clickup { background: #eee9ff; color: #5b3fd6; }
.inbox-kind.kind-crm { background: #e3f1ff; color: #0b5cad; }
@media (prefers-color-scheme: dark) {
  .inbox-kind.kind-email { background: #3a1717; color: #f28b82; }
  .inbox-kind.kind-slack { background: #2e1a33; color: #d9a6e3; }
  .inbox-kind.kind-clickup { background: #231c42; color: #b4a3ff; }
  .inbox-kind.kind-crm { background: #10263f; color: #8cc4ff; }
}
.inbox-body { flex: 1; min-width: 0; }
.inbox-top { margin: 0; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.inbox-from { font-weight: 650; }
.inbox-subject { margin: 2px 0 0; font-weight: 560; overflow-wrap: anywhere; }
.inbox-snippet { margin: 4px 0 0; font-size: 0.86rem; color: var(--ink-soft); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.inbox-suggest { margin: 8px 0 0; font-size: 0.84rem; color: var(--accent-ink); font-weight: 560; }
.inbox-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.inbox-actions .link-btn { margin-left: auto; text-decoration: none; }
.btn-dark { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn-dark:hover { background: #1e293b; }
@media (prefers-color-scheme: dark) { .btn-dark { background: var(--accent); border-color: var(--accent); color: #fff; } }

/* ---------- Connections ---------- */
.conn-ai { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--ink-soft); font-size: 0.88rem; }
.conn-ai.on { background: var(--ok-soft); color: var(--ok); font-weight: 560; }
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.conn-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px; }
.conn-card.has { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.conn-head { display: flex; gap: 12px; align-items: center; }
.conn-head h3 { margin: 0; font-size: 1rem; font-weight: 650; }
.conn-head p { margin: 2px 0 0; }
.conn-logo { width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex: 0 0 auto; background: var(--ink-faint); }
.conn-google { background: #4285f4; }
.conn-slack { background: #4a154b; }
.conn-quickbooks { background: #2ca01c; }
.conn-clickup { background: #7b68ee; }
.conn-crm { background: #188bf6; }
.conn-acct { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.conn-acct.error { border-color: var(--danger); background: var(--danger-soft); }
.conn-acct-top { display: flex; align-items: center; gap: 8px; }
.conn-acct-name { font-weight: 600; overflow-wrap: anywhere; }
.conn-file { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.conn-file select { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); min-height: 34px; font-size: 0.88rem; }
.conn-sync { margin: 8px 0 0; }
.conn-actions { margin-top: auto; }
.conn-actions .btn { text-decoration: none; }
.conn-setup summary { cursor: pointer; font-weight: 600; font-size: 0.88rem; color: var(--ink-soft); }
.conn-setup ol { padding-left: 18px; margin: 8px 0 0; }
.conn-setup li { margin-bottom: 6px; overflow-wrap: anywhere; }
.conn-keys { display: grid; gap: 8px; margin: 10px 0 6px; }
.conn-keys label { display: grid; gap: 4px; }
.conn-keys input { width: 100%; font: inherit; font-size: 0.85rem; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.conn-keys button { justify-self: start; }
.conn-manage { margin-top: 10px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82em; background: var(--surface-3); border-radius: 4px; padding: 1px 5px; }
