/* AI Hub panel — light/dark tokens, layout and components. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e6e9ef;
  --border: #e1e4ea;
  --border-strong: #cdd2db;
  --text: #15181e;
  --muted: #5d6673;
  --faint: #8a929e;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --accent-text: #ffffff;
  --danger: #c8281c;
  --danger-soft: #fdecea;
  --warn: #9a4a05;
  --warn-soft: #fff4e2;
  --ok: #067647;
  --ok-soft: #e7f7ee;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-lg: 0 18px 44px rgb(16 24 40 / 22%);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: #16181f;
  --sidebar-text: #c9ced8;
  --sidebar-muted: #7d8595;
  --sidebar-active: #262a36;

  /* task states — reference status palette, always paired with a label */
  --st-todo: #8e8c85;
  --st-progress: #2a78d6;
  --st-blocked: #d03b3b;
  --st-review: #fab219;
  --st-done: #0ca30c;
  --series-1: #2a78d6;
  --viz-grid: #e9e8e4;
  --viz-axis: #c9c7c0;
  --viz-text: #52514e;

  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0d0f13;
    --surface: #15181e;
    --surface-2: #1b1f27;
    --surface-3: #252a34;
    --border: #2a303a;
    --border-strong: #3a414d;
    --text: #e8eaee;
    --muted: #9aa3af;
    --faint: #6f7783;
    --accent: #8f8bf8;
    --accent-hover: #a5a2fa;
    --accent-soft: #23234a;
    --accent-text: #0d0f13;
    --danger: #f97066;
    --danger-soft: #3a1714;
    --warn: #fdb022;
    --warn-soft: #33240b;
    --ok: #47cd89;
    --ok-soft: #10301f;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-lg: 0 18px 44px rgb(0 0 0 / 60%);
    --sidebar: #0a0b0f;
    --sidebar-active: #1d2029;
    --st-todo: #77756f;
    --st-progress: #3987e5;
    --series-1: #3987e5;
    --viz-grid: #2b2b28;
    --viz-axis: #45443f;
    --viz-text: #c3c2b7;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0d0f13;
  --surface: #15181e;
  --surface-2: #1b1f27;
  --surface-3: #252a34;
  --border: #2a303a;
  --border-strong: #3a414d;
  --text: #e8eaee;
  --muted: #9aa3af;
  --faint: #6f7783;
  --accent: #8f8bf8;
  --accent-hover: #a5a2fa;
  --accent-soft: #23234a;
  --accent-text: #0d0f13;
  --danger: #f97066;
  --danger-soft: #3a1714;
  --warn: #fdb022;
  --warn-soft: #33240b;
  --ok: #47cd89;
  --ok-soft: #10301f;
  --sidebar: #0a0b0f;
  --sidebar-active: #1d2029;
  --st-todo: #77756f;
  --st-progress: #3987e5;
  --series-1: #3987e5;
  --viz-grid: #2b2b28;
  --viz-axis: #45443f;
  --viz-text: #c3c2b7;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: -0.015em;
}

h2 {
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 20px 0 8px;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.82rem;
}

.grow {
  flex: 1;
  min-width: 0;
}

.pre-wrap {
  white-space: pre-wrap;
}

.clip {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

canvas.pixel {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

kbd {
  font: 600 0.72rem ui-monospace, 'SF Mono', Menlo, monospace;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid currentColor;
  opacity: 0.6;
}

code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ---- controls ----------------------------------------------------------------- */

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 560;
  text-decoration: none;
  color: var(--text);
  transition: background 120ms, border-color 120ms, transform 60ms;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover {
  background: var(--surface-2);
}

.btn.danger {
  color: var(--danger);
}

.btn.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.btn.block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:not([type='checkbox']):not([type='radio']),
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.45;
}

textarea.mono,
.copy-field input,
.copy-field textarea {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  min-width: 0;
}

.field-label {
  font-size: 0.84rem;
  font-weight: 620;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.stack {
  display: grid;
  gap: 6px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.form-error {
  color: var(--danger);
  font-size: 0.87rem;
  min-height: 1.2em;
  margin-bottom: 8px;
}

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.segmented.full {
  display: flex;
  margin: 10px;
}

.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  min-width: 200px;
}

.search-box input {
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  background: transparent !important;
  min-height: 36px !important;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 150ms;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform 150ms;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- tags, avatars, dots ----------------------------------------------------------- */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}

.avatar.lg {
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
}

.person {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.74rem;
  font-weight: 620;
  color: var(--muted);
  white-space: nowrap;
}

.tag .icon {
  width: 12px;
  height: 12px;
}

.tag.ghost {
  background: transparent;
}

.tag-high {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}

.tag-overdue {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}

.tag-wait {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: transparent;
}

.tag-label {
  background: transparent;
  border-style: dashed;
}

.tag.role-lead {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.tag.role-human {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: transparent;
}

.team-tag,
.team-chip {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}

.team-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.dot {
  display: inline-block;
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status, var(--st-todo));
}

.status-todo { --status: var(--st-todo); }
.status-in_progress { --status: var(--st-progress); }
.status-blocked { --status: var(--st-blocked); }
.status-review { --status: var(--st-review); }
.status-done { --status: var(--st-done); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 750;
}

.badge.warn {
  background: var(--st-review);
  color: #2b1d00;
}

.count-pill {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--muted);
}

.ref {
  display: inline;
  border: 0;
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-weight: 650;
  font-size: 0.92em;
  padding: 0 5px;
  border-radius: 5px;
  cursor: pointer;
}

.ref:hover {
  text-decoration: underline;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent);
}

.presence {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-3);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border);
}

.presence.on {
  background: var(--ok);
}

.presence-text {
  color: var(--muted);
}

.presence-text.on {
  color: var(--ok);
  font-weight: 650;
}

/* ---- app shell -------------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 12px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  overflow-y: auto;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 12px;
}

.side-brand .company-name {
  font-weight: 750;
  letter-spacing: -0.01em;
  color: #fff;
}

.side-brand.big .company-name {
  font-size: 1.4rem;
  color: var(--text);
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--sidebar-muted);
}

.logo {
  width: 30px;
  height: 30px;
  padding: 4px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  flex: none;
}

.side-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid #2a2e3a;
  background: #1d2029;
  color: var(--sidebar-muted);
  cursor: pointer;
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.side-search:hover {
  color: var(--sidebar-text);
  border-color: #3a3f4d;
}

.side-nav {
  display: grid;
  gap: 2px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 560;
  font-size: 0.93rem;
}

.side-link:hover {
  background: var(--sidebar-active);
  color: #fff;
}

.side-link.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.side-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  min-height: 38px;
  border-radius: 9px;
  border: 0;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
  cursor: pointer;
}

.side-new:hover {
  filter: brightness(1.08);
}

.side-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 12px 6px 0;
  border-top: 1px solid #23262f;
}

.me-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.me-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-foot .icon-btn {
  color: var(--sidebar-muted);
}

.side-foot .icon-btn:hover {
  background: var(--sidebar-active);
  color: #fff;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--sidebar-muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
}

.live.on .live-dot {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgb(34 197 94 / 25%);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 5px rgb(34 197 94 / 8%);
  }
}

.main {
  min-width: 0;
}

.mobile-bar {
  display: none;
}

.views {
  padding: 24px 28px 48px;
  max-width: 1500px;
  margin: 0 auto;
}

.route-office .views {
  max-width: none;
  padding: 0;
}

.scrim {
  display: none;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head p {
  margin-top: 4px;
  max-width: 78ch;
}

.section {
  margin-top: 26px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  cursor: default;
}

details > summary.section-title {
  cursor: pointer;
}

.section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.empty {
  color: var(--muted);
  font-size: 0.87rem;
  text-align: center;
  padding: 18px 8px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 28px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state.small {
  padding: 18px 12px;
  border: 0;
}

.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  margin-bottom: 18px;
}

.callout p {
  margin-top: 4px;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.notice.info {
  background: var(--accent-soft);
  color: var(--text);
}

.notice.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.tabs-row {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: none;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 620;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tab[aria-selected='true'] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.subhead {
  margin-top: 28px;
}

/* ---- board ---------------------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.filters select {
  width: auto;
  min-width: 140px;
}

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 10px;
  align-items: start;
}

.column {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 180px;
  transition: background 120ms, border-color 120ms;
}

.column.drop {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  font-weight: 680;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.column-head .count {
  margin-left: auto;
  color: var(--muted);
  font-weight: 620;
  font-size: 0.8rem;
}

.column-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.card {
  display: grid;
  gap: 7px;
  width: 100%;
  text-align: left;
  padding: 11px 12px 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: grab;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--team, var(--st-todo));
}

.card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.card.dragging {
  opacity: 0.5;
}

.card.overdue {
  border-color: color-mix(in srgb, var(--danger) 50%, var(--border));
}

.card-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-id {
  font-size: 0.74rem;
  font-weight: 720;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card-title {
  font-weight: 620;
  overflow-wrap: anywhere;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-tags:empty {
  display: none;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.82rem;
}

.more {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-track {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--st-done) 16%, var(--surface-3));
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--st-done);
}

.progress.big .progress-track {
  height: 8px;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---- tables ------------------------------------------------------------------------------ */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 650;
  background: var(--surface-2);
  white-space: nowrap;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.data-table tbody tr.overdue td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table.compact td,
.data-table.compact th {
  padding: 6px 10px;
}

.th-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

/* ---- messages ------------------------------------------------------------------------------- */

.messages {
  display: grid;
  grid-template-columns: minmax(270px, 360px) 1fr;
  gap: 16px;
  height: calc(100vh - 72px);
  min-height: 460px;
}

.thread-pane,
.conversation,
.doc-pane,
.doc-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 4px;
}

.thread-list {
  overflow-y: auto;
  flex: 1;
  border-top: 1px solid var(--border);
}

.thread-item {
  position: relative;
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}

.thread-item:hover {
  background: var(--surface-2);
}

.thread-item.active {
  background: var(--accent-soft);
}

.thread-top {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.thread-subject {
  font-weight: 620;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.thread-item.unread .thread-subject {
  font-weight: 760;
}

.thread-time {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}

.thread-people,
.thread-preview {
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 28px;
}

.thread-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
}

.conversation-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.conversation-empty .icon {
  margin: 0 auto 10px;
  opacity: 0.4;
}

.conv-thread {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.conv-head,
.compose-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.compose-head {
  padding: 0 0 12px;
  margin-bottom: 14px;
}

.conv-people {
  font-size: 0.82rem;
  color: var(--muted);
}

.back {
  display: none;
}

.msg-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.msg {
  max-width: min(720px, 92%);
  padding: 10px 13px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.msg.mine {
  justify-self: end;
  background: var(--accent-soft);
  border-color: transparent;
}

.msg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 5px;
}

.msg-head .person {
  color: var(--text);
  font-weight: 650;
}

.msg-body,
.rich {
  white-space: normal;
  overflow-wrap: anywhere;
}

.reply-form {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: grid;
  gap: 8px;
}

.reply-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.compose {
  padding: 18px;
  overflow-y: auto;
}

/* ---- docs -------------------------------------------------------------------------------- */

.docs {
  display: grid;
  grid-template-columns: minmax(270px, 340px) 1fr;
  gap: 16px;
  height: calc(100vh - 72px);
  min-height: 460px;
}

.doc-filters {
  display: grid;
  gap: 8px;
  padding: 8px 14px 12px;
}

.doc-list {
  flex: 1;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.doc-item {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}

.doc-item:hover {
  background: var(--surface-2);
}

.doc-item.active {
  background: var(--accent-soft);
}

.doc-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.doc-title {
  flex: 1;
  font-weight: 640;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-excerpt {
  font-size: 0.82rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-meta {
  font-size: 0.74rem;
  color: var(--faint);
}

.kind {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--muted);
}

.kind-report { background: color-mix(in srgb, var(--st-progress) 16%, transparent); color: var(--st-progress); }
.kind-decision { background: color-mix(in srgb, var(--st-blocked) 14%, transparent); color: var(--danger); }
.kind-process { background: color-mix(in srgb, var(--st-done) 15%, transparent); color: var(--ok); }
.kind-reference { background: var(--accent-soft); color: var(--accent); }

.pin {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 650;
}

.doc-main {
  overflow-y: auto;
}

.doc-view,
.doc-editor,
.doc-welcome {
  padding: 22px 26px;
}

.doc-head {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.doc-head h1 {
  margin: 6px 0 4px;
}

.doc-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 650;
}

.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.doc-body {
  max-width: 78ch;
}

.version-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  margin-bottom: 16px;
}

.versions {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.versions summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 620;
}

.versions ul {
  margin: 10px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.editor-col {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}

.doc-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: 300px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface-2);
}

.doc-welcome {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
}

.doc-welcome h2 {
  color: var(--text);
}

.doc-welcome p {
  max-width: 60ch;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  width: 100%;
  text-align: left;
}

.template {
  display: grid;
  gap: 6px;
  align-content: start;
  justify-items: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
}

.template:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

/* ---- markdown ------------------------------------------------------------------------------ */

.md {
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.md > * + * {
  margin-top: 0.7em;
}

.md h3,
.md h4,
.md h5,
.md h6,
.md h7,
.md h8 {
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 1.2em 0 0.4em;
}

.md h3 {
  font-size: 1.25rem;
}

.md h4 {
  font-size: 1.08rem;
}

.md h5,
.md h6 {
  font-size: 0.98rem;
}

.md ul,
.md ol {
  padding-left: 1.4em;
  margin: 0.4em 0;
}

.md li + li {
  margin-top: 0.2em;
}

.md blockquote {
  margin: 0.6em 0;
  padding: 0.3em 1em;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.md pre {
  overflow-x: auto;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.md pre code {
  background: none;
  padding: 0;
}

.md hr {
  border: 0;
  border-top: 1px solid var(--border);
}

.md-table {
  overflow-x: auto;
}

.md table {
  border-collapse: collapse;
  font-size: 0.9rem;
}

.md th,
.md td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.md th {
  background: var(--surface-2);
}

.md.compact {
  line-height: 1.5;
}

.md.compact > * + * {
  margin-top: 0.4em;
}

.md-check {
  vertical-align: -2px;
}

/* ---- dialogs ---------------------------------------------------------------------------------- */

dialog.modal {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

dialog.modal.wide {
  width: min(900px, calc(100vw - 32px));
}

dialog.modal::backdrop {
  background: rgb(8 10 14 / 50%);
  backdrop-filter: blur(2px);
}

dialog.modal[open] {
  animation: pop 140ms ease-out;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  overflow-wrap: anywhere;
}

.modal-head .muted {
  font-size: 0.86rem;
  margin-top: 2px;
}

.modal-body {
  padding: 16px 18px 20px;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0 12px;
}

.editable {
  position: relative;
  padding: 8px 40px 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  min-height: 38px;
}

.editable .edit-btn {
  position: absolute;
  top: 4px;
  right: 4px;
}

.editable textarea,
.editable input {
  margin-bottom: 8px;
}

.result-block {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
}

.review-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  margin-bottom: 14px;
}

.subtasks {
  display: grid;
  gap: 6px;
}

.subtask {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.subtask:hover {
  border-color: var(--accent);
}

.deps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.deps select {
  width: auto;
  max-width: 320px;
}

.dep {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.84rem;
}

.dep.waiting {
  background: var(--warn-soft);
  border-color: transparent;
}

.dep.ready {
  background: var(--ok-soft);
  border-color: transparent;
}

.history {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history li {
  display: grid;
  gap: 3px;
  font-size: 0.88rem;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

.history li.ev-comment,
.history li.ev-result {
  border-left-color: var(--accent);
}

.history .when {
  font-size: 0.78rem;
  color: var(--muted);
}

.steps {
  margin: 0 0 8px;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.steps.compact {
  gap: 2px;
  margin-bottom: 14px;
  color: var(--muted);
}

.copy-field {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.copy-field textarea {
  min-height: 120px;
}

.guide h3 {
  margin-top: 18px;
}

.guide .copy-field {
  margin-top: 6px;
}

.palette {
  margin-top: 12vh;
  width: min(640px, calc(100vw - 32px));
}

.palette-box {
  display: grid;
}

.palette-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.palette-input input {
  border: 0 !important;
  box-shadow: none !important;
  font-size: 1.05rem;
  padding: 6px 0 !important;
}

.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 56vh;
  overflow-y: auto;
}

.palette-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
}

.palette-list li.active {
  background: var(--accent-soft);
  color: var(--text);
}

.palette-label {
  display: block;
  color: var(--text);
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-detail {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- approvals ------------------------------------------------------------------------------------ */

.approval-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}

.approval-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.approval-card.pending {
  border-top: 3px solid var(--st-review);
}

.approval-card.review {
  border-top: 3px solid var(--st-progress);
}

.approval-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.approval-head h3 {
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text);
  font-size: 1rem;
  margin: 0 0 4px;
}

.approval-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--warn-soft);
  color: var(--warn);
  flex: none;
}

.approval-icon.review {
  background: var(--accent-soft);
  color: var(--accent);
}

.approval-details {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  max-height: 260px;
  overflow-y: auto;
}

.approval-card .row-actions {
  justify-content: flex-end;
}

.decision-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.decision {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.decision-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex: none;
  color: #fff;
  background: var(--st-done);
}

.decision.rejected .decision-mark {
  background: var(--st-blocked);
}

/* ---- automations ------------------------------------------------------------------------------------ */

.auto-list {
  display: grid;
  gap: 10px;
}

.auto-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.auto-card.paused {
  opacity: 0.65;
}

.auto-card h3 {
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text);
  font-size: 1rem;
  margin: 0 0 2px;
}

.auto-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}

.auto-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pb-grid,
.cowork-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.pb-card,
.cowork-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.pb-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.pb-head h3 {
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text);
  font-size: 1rem;
  margin: 0;
}

.pb-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
}

.pb-steps li span + span {
  margin-left: 6px;
}

.step-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.step {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.step-num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 0.85rem;
  flex: none;
}

.step-fields {
  display: grid;
  gap: 8px;
}

.step-tools {
  display: grid;
  align-content: start;
  gap: 2px;
}

/* ---- team ---------------------------------------------------------------------------------------- */

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.team-card {
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 14px 14px 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.team-stripe {
  width: 6px;
  background: var(--team);
  flex: none;
}

.team-info {
  flex: 1;
  display: grid;
  gap: 3px;
  align-content: start;
}

.team-info h3 {
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text);
  font-size: 1rem;
  margin: 0;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.agent-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-top: 3px solid var(--team, var(--border));
}

.agent-card.disabled {
  opacity: 0.6;
}

.agent-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-name {
  font-weight: 680;
}

.agent-id {
  font-size: 0.82rem;
  color: var(--muted);
}

.agent-tags,
.agent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.agent-status {
  font-style: italic;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.agent-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.pixel-avatar {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--team, var(--accent)) 26%, var(--surface)), var(--surface-2));
  overflow: hidden;
  flex: none;
}

.pixel-avatar canvas {
  width: 54px;
  height: auto;
  image-rendering: pixelated;
  margin-top: 6px;
}

.pixel-avatar.large {
  width: 110px;
  height: 120px;
  border-radius: 18px;
}

.pixel-avatar.large canvas {
  width: 90px;
}

.appearance {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.appearance-preview {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.appearance-fields {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0 12px;
  min-width: 260px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 15%);
}

.swatch.selected {
  border-color: var(--text);
}

.profile-head {
  display: flex;
  gap: 18px;
  align-items: center;
}

.profile-head > .grow {
  display: grid;
  gap: 8px;
}

/* ---- settings ---------------------------------------------------------------------------------------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  align-items: start;
}

.card-section {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.checklist li {
  display: flex;
  gap: 10px;
  align-items: center;
}

.check-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  flex: none;
}

.checklist li.ok .check-mark {
  background: var(--st-done);
  color: #fff;
}

/* ---- dashboard ---------------------------------------------------------------------------------------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  display: grid;
  gap: 4px;
  align-content: start;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

button.stat {
  cursor: pointer;
}

button.stat:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 560;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.stat.tone-critical {
  border-left: 4px solid var(--st-blocked);
}

.stat.tone-critical .stat-label {
  color: var(--danger);
}

.stat.tone-warning {
  border-left: 4px solid var(--st-review);
}

.stat.tone-good .stat-sub {
  color: var(--ok);
}

.viz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.viz-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
}

.viz-card.wide {
  grid-column: 1 / -1;
}

.viz-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.viz-body {
  position: relative;
}

svg.viz {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.viz-grid line,
.viz .viz-grid {
  stroke: var(--viz-grid);
  stroke-width: 1;
}

.viz .viz-axis {
  stroke: var(--viz-axis);
  stroke-width: 1;
}

.viz-tick,
.viz-label,
.viz-value {
  fill: var(--viz-text);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.viz-label {
  font-size: 12px;
  font-weight: 560;
}

.viz-value {
  font-weight: 650;
  fill: var(--text);
}

.viz-bar {
  fill: var(--series-1);
}

.viz-hit {
  fill: transparent;
}

.viz-mark {
  cursor: default;
  outline: none;
}

.viz-mark:hover .viz-bar,
.viz-mark:focus .viz-bar {
  filter: brightness(1.15);
}

.viz-mark:focus .viz-hit {
  fill: color-mix(in srgb, var(--series-1) 8%, transparent);
}

.viz-seg {
  outline: none;
}

.viz-seg:hover,
.viz-seg:focus {
  filter: brightness(1.12);
  stroke: var(--surface);
  stroke-width: 1;
}

.viz-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  min-width: 120px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  font-size: 0.82rem;
}

.viz-tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.viz-tip-label {
  opacity: 0.75;
}

.viz-key {
  width: 12px;
  height: 3px;
  border-radius: 2px;
}

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.spark {
  width: 92px;
  height: 22px;
  overflow: visible;
}

.spark-line {
  fill: none;
  stroke: var(--viz-axis);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spark-dot {
  fill: var(--series-1);
  stroke: var(--surface);
  stroke-width: 2;
}

.due-list,
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.due-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.due-item:hover {
  background: var(--surface-2);
}

.due-when {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.due-item.overdue .due-when {
  color: var(--danger);
}

.feed-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feed-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.88rem;
}

.feed-btn:hover {
  background: var(--surface-2);
}

.feed-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}

.feed-icon.k-message { background: var(--accent-soft); color: var(--accent); }
.feed-icon.k-task { background: color-mix(in srgb, var(--st-progress) 14%, transparent); color: var(--st-progress); }
.feed-icon.k-done { background: var(--ok-soft); color: var(--ok); }
.feed-icon.k-approval { background: var(--warn-soft); color: var(--warn); }
.feed-icon.k-doc { background: color-mix(in srgb, #7e3af2 14%, transparent); color: #8b5cf6; }

.feed-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-time {
  white-space: nowrap;
}

/* ---- login ------------------------------------------------------------------------------------------ */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 40%),
    radial-gradient(circle at 80% 90%, color-mix(in srgb, #0e9f6e 16%, transparent), transparent 40%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.login-card .side-brand {
  padding: 0 0 20px;
}

.login-card .brand-sub {
  color: var(--muted);
}

/* ---- toasts ---------------------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: grid;
  gap: 8px;
  max-width: min(400px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  animation: pop 160ms ease-out;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast-action {
  margin-left: auto;
  border: 0;
  background: rgb(255 255 255 / 18%);
  color: inherit;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

/* ---- responsive -------------------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .viz-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: min(280px, 84vw);
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .app.menu-open .sidebar {
    transform: none;
  }

  .app.menu-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgb(0 0 0 / 40%);
  }

  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .mobile-title {
    flex: 1;
    font-weight: 700;
  }

  .menu-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
  }

  .views {
    padding: 16px 16px 40px;
  }

  .messages,
  .docs {
    grid-template-columns: 1fr;
    height: calc(100vh - 92px);
  }

  .messages.has-open .thread-pane,
  .messages:not(.has-open) .conversation,
  .docs.has-open .doc-pane,
  .docs:not(.has-open) .doc-main {
    display: none;
  }

  .back {
    display: inline-grid;
  }

  .editor-split {
    grid-template-columns: 1fr;
  }

  .board {
    grid-auto-columns: minmax(260px, 84vw);
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .doc-view,
  .doc-editor,
  .doc-welcome {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---- pixel office ---------------------------------------------------------------- */

.office {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  height: 100vh;
  min-height: 480px;
}

.office-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #1d2029;
}

.office-canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: grab;
  touch-action: none;
  image-rendering: pixelated;
}

.office-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.speech {
  position: absolute;
  top: 0;
  left: 0;
  width: max-content;
  max-width: 220px;
  padding: 5px 9px;
  border-radius: 10px;
  background: #ffffff;
  color: #15181e;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: 0 2px 0 rgb(0 0 0 / 22%), 0 6px 16px rgb(0 0 0 / 24%);
  animation: speech-in 160ms ease-out;
}

.speech::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 2px;
  background: inherit;
  transform: rotate(45deg);
}

.speech.small {
  padding: 3px 7px;
  font-size: 11px;
  opacity: 0.94;
}

.speech.good {
  background: #dcfce7;
  color: #14532d;
}

.speech.bad {
  background: #fee2e2;
  color: #7f1d1d;
}

@keyframes speech-in {
  from {
    opacity: 0;
    margin-top: 6px;
  }
}

.office-tip {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 170px;
  max-width: 270px;
  padding: 8px 10px;
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 10px;
  background: rgb(17 19 26 / 94%);
  color: #f1f3f6;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: var(--shadow-lg);
}

.office-tip strong {
  display: block;
  font-size: 13px;
}

.office-tip .tip-meta {
  color: #a3abb8;
}

.office-tip .tip-status {
  margin-top: 4px;
  color: #d6dae2;
  font-style: italic;
}

.office-tip .tip-task {
  margin-top: 4px;
  padding-left: 8px;
  border-left: 2px solid var(--st-progress);
}

.office-tip .tip-task.bad {
  border-left-color: var(--st-blocked);
}

.office-hud {
  position: absolute;
  top: 12px;
  right: 290px;
  left: 14px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  pointer-events: none;
}

.office-title {
  color: #ffffff;
  font-size: 15px;
  font-weight: 750;
  text-shadow: 0 1px 2px rgb(0 0 0 / 60%);
}

.office-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.office-chip,
.office-tools {
  border: 1px solid rgb(255 255 255 / 10%);
  background: rgb(17 19 26 / 80%);
  color: #e8eaee;
  backdrop-filter: blur(6px);
}

.office-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  pointer-events: auto;
}

button.office-chip {
  cursor: pointer;
}

.office-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.office-chip.w-working .dot {
  background: #3b82f6;
}

.office-chip.w-idle .dot {
  background: #22c55e;
}

.office-chip.w-asleep .dot {
  background: #a5b4fc;
}

.office-chip.w-offline .dot {
  background: #6b7280;
}

.office-chip.alert {
  border-color: transparent;
  background: #b42318;
  color: #ffffff;
}

.office-chip.review {
  border-color: transparent;
  background: #8a5a00;
  color: #ffffff;
}

.office-tools {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 3;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
}

.office-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.office-tool:hover {
  background: rgb(255 255 255 / 12%);
}

.office-tool:focus-visible,
.office-chip:focus-visible {
  outline: 2px solid #8f8bf8;
  outline-offset: 1px;
}

.office-legend {
  position: absolute;
  top: 56px;
  right: 12px;
  z-index: 4;
  width: min(360px, calc(100% - 24px));
  max-height: calc(100% - 72px);
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.office-legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.office-legend-head .office-tool {
  color: var(--muted);
}

.office-legend-head .office-tool:hover {
  background: var(--surface-2);
}

.office-legend dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0 0 10px;
  font-size: 13px;
}

.office-legend dt {
  font-weight: 650;
  white-space: nowrap;
}

.office-legend dd {
  margin: 0;
  color: var(--muted);
}

.office-legend p {
  margin: 0;
}

.office-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: min(440px, calc(100% - 32px));
  padding: 20px 22px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -50%);
}

.office-empty strong {
  font-size: 17px;
}

.office-empty p {
  margin: 8px 0 14px;
  color: var(--muted);
}

.office-empty .row {
  justify-content: center;
}

.office-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.office-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 6px;
}

.office-side-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.office-people {
  flex: 0 1 auto;
  max-height: 46%;
  margin: 0;
  padding: 0 8px 8px;
  overflow: auto;
  border-bottom: 1px solid var(--border);
  list-style: none;
}

.office-person {
  display: flex;
  align-items: center;
  gap: 2px;
}

.office-person-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.office-person-main:hover {
  background: var(--surface-2);
}

.office-avatar {
  display: grid;
  flex: none;
  place-items: start center;
  width: 40px;
  height: 40px;
  padding-top: 2px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-2);
}

.office-avatar canvas {
  image-rendering: pixelated;
}

.office-avatar.w-offline canvas {
  opacity: 0.5;
  filter: grayscale(0.6);
}

.office-avatar.w-asleep canvas {
  opacity: 0.8;
}

.office-person-text {
  display: grid;
  min-width: 0;
}

.office-person-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
}

.office-person-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.office-flag {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--st-blocked);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.work-pill {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.work-pill.w-working {
  background: color-mix(in srgb, var(--st-progress) 15%, transparent);
  color: var(--st-progress);
}

.work-pill.w-idle {
  background: var(--ok-soft);
  color: var(--ok);
}

.work-pill.w-asleep {
  background: var(--accent-soft);
  color: var(--accent);
}

.office-person-open {
  display: grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}

.office-person-open:hover {
  background: var(--surface-2);
  color: var(--text);
}

.office-feed {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0 8px 12px;
  overflow: auto;
}

.office-feed-empty {
  padding: 8px;
  list-style: none;
}

@media (max-width: 1200px) {
  .office {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .office-hud {
    right: 250px;
  }

  .office-tool-label {
    display: none;
  }
}

@media (max-width: 900px) {
  .office {
    grid-template-rows: minmax(360px, 64vh) auto;
    grid-template-columns: 1fr;
    height: auto;
  }

  .office-side {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .office-people {
    max-height: none;
  }

  .office-feed {
    max-height: 420px;
  }

  .office-hud {
    top: 56px;
    right: 12px;
  }
}

.name-tag {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: calc(var(--z, 1) * 62px);
  padding: 0 5px;
  border-radius: 5px;
  background: rgb(17 15 28 / 74%);
  color: #ffffff;
  font-size: min(12px, calc(8px + var(--z, 1) * 1.5px));
  font-weight: 650;
  line-height: 1.45;
  white-space: nowrap;
}

.name-tag .nm {
  overflow: hidden;
  text-overflow: ellipsis;
}

.name-tag.human {
  background: rgb(15 23 42 / 90%);
}

.name-tag.active {
  background: rgb(79 70 229 / 94%);
}

.name-tag.w-offline {
  opacity: 0.7;
}

.name-tag .crown {
  font-size: 0.85em;
}

.name-tag .flag {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.15em;
  height: 1.15em;
  border-radius: 3px;
  background: #dc2626;
  font-size: 0.85em;
  font-weight: 800;
}

.name-tag .typing {
  display: inline-flex;
  flex: none;
  gap: 2px;
}

.name-tag .typing i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #93c5fd;
  animation: typing 1s infinite;
}

.name-tag .typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.name-tag .typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.3;
  }

  30% {
    opacity: 1;
  }
}

.room-tag {
  position: absolute;
  top: 0;
  left: 0;
  padding: 1px 9px;
  border: 1px solid rgb(0 0 0 / 25%);
  border-radius: 999px;
  background: var(--tag, #64748b);
  color: #ffffff;
  font-size: min(12px, calc(8px + var(--z, 1) * 1.8px));
  font-weight: 750;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgb(0 0 0 / 25%);
}

/* ---- shared additions (v0.3) ------------------------------------------------------ */

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.segmented button .count-pill {
  margin-left: 6px;
  height: 18px;
  min-width: 18px;
  padding: 0 6px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1 1 240px;
  max-width: 360px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 16px;
}

.form-grid > .field:has(textarea),
.form-grid > .modal-foot,
.form-grid > p {
  grid-column: 1 / -1;
}

.plain-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-line {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.task-line:hover {
  background: var(--surface-2);
}

.clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pre-wrap {
  white-space: pre-wrap;
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.danger-text {
  color: var(--danger);
}

.ok-text {
  color: var(--ok);
}

.skill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.skill {
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.tag.brain-tag {
  border-color: transparent;
  background: color-mix(in srgb, #7c3aed 14%, var(--surface));
  color: #7c3aed;
}

.check-field {
  display: flex;
  flex: 1;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.check-field input {
  margin-top: 3px;
}

.check-field span {
  display: grid;
  gap: 2px;
}

.lang-switch {
  min-width: 34px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid color-mix(in srgb, var(--sidebar-text) 30%, transparent);
  border-radius: 7px;
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.lang-switch:hover {
  background: var(--sidebar-active);
}

.login-card .lang-switch {
  border-color: var(--border);
  color: var(--muted);
}

.login-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.me-name {
  display: grid;
  min-width: 0;
}

.me-access {
  color: var(--sidebar-muted);
  font-size: 0.7rem;
  font-weight: 600;
}

/* ---- brain ------------------------------------------------------------------------- */

.brain-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.brain-card,
.brain-panel {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brain-card {
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, #7c3aed 10%, transparent), transparent 60%),
    var(--surface);
}

.brain-id {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.brain-orb {
  display: grid;
  place-items: center;
  padding: 4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #7c3aed, #22d3ee, #a78bfa, #7c3aed);
  animation: orb 6s linear infinite;
}

.brain-orb-inner {
  display: grid;
  justify-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface);
}

.brain-orb-inner canvas {
  margin-top: 4px;
  image-rendering: pixelated;
}

@keyframes orb {
  to {
    filter: hue-rotate(360deg);
  }
}

.brain-stats {
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
}

.brain-note {
  margin: 12px 0 0;
}

.ask-form {
  display: grid;
  gap: 10px;
}

.ask-form textarea {
  width: 100%;
  resize: vertical;
}

.ask-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ask-row .field {
  margin: 0;
}

.ask-more summary {
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.ask-more textarea {
  margin-top: 8px;
}

.ask-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brain-memory {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 220px;
  transition: opacity 0.2s;
}

.brain-memory.loading {
  opacity: 0.55;
}

.brain-memory h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.9rem;
}

.memory-list,
.expert-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.memory-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.memory-item:hover {
  background: var(--surface-2);
}

.memory-item > .grow {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.memory-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
}

.memory-icon.k-client {
  background: color-mix(in srgb, #d97706 14%, var(--surface));
  color: #b45309;
}

.memory-icon.k-ask {
  background: color-mix(in srgb, #7c3aed 14%, var(--surface));
  color: #7c3aed;
}

.memory-icon.k-page {
  background: color-mix(in srgb, #0891b2 14%, var(--surface));
  color: #0e7490;
}

.memory-title {
  font-weight: 600;
}

.memory-excerpt {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.expert-box {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.expert-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}

.expert-list .grow {
  display: grid;
  min-width: 0;
}

.expert-why {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ask-list {
  display: grid;
  gap: 12px;
}

.ask-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-left: 4px solid #a78bfa;
  border-radius: var(--radius);
  background: var(--surface);
}

.ask-card.s-answered {
  border-left-color: var(--st-done);
}

.ask-card.s-closed {
  border-left-color: var(--border-strong);
  opacity: 0.8;
}

.ask-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ask-question {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 1.02rem;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.ask-question:hover {
  color: var(--accent);
}

.ask-status {
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
}

.ask-status.s-open {
  background: color-mix(in srgb, #7c3aed 14%, var(--surface));
  color: #7c3aed;
}

.ask-status.s-answered {
  background: var(--ok-soft);
  color: var(--ok);
}

.ask-status.s-closed {
  background: var(--surface-3);
  color: var(--muted);
}

.chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.chain .avatar {
  width: 22px;
  height: 22px;
  font-size: 0.65rem;
}

.hops {
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.72rem;
  font-weight: 700;
}

.ask-children {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.ask-children ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ask-children li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.88rem;
}

.ask-answer {
  padding: 12px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--st-done) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--st-done) 25%, var(--border));
}

.ask-answer.compact {
  padding: 8px 10px;
  font-size: 0.9rem;
}

.ask-answer-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--ok);
  font-weight: 700;
}

.ask-answer > :last-child {
  margin-bottom: 0;
}

.expertise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.expertise-col {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.expertise-col h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.expertise-person {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ask-detail-q {
  margin: 10px 0;
  font-size: 1.2rem;
  line-height: 1.35;
}

.ask-context {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.chain-timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chain-timeline li {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 0 0 14px;
}

.chain-timeline li:not(:last-child)::before {
  content: '';
  position: absolute;
  top: 26px;
  bottom: 0;
  left: 12px;
  width: 2px;
  background: var(--border);
}

.chain-dot {
  display: grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}

.ev-asked .chain-dot {
  background: color-mix(in srgb, #7c3aed 14%, var(--surface));
  color: #7c3aed;
}

.ev-forwarded .chain-dot {
  background: var(--warn-soft);
  color: var(--warn);
}

.ev-answered .chain-dot {
  background: var(--ok-soft);
  color: var(--ok);
}

.sub-ask {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.sub-ask-q {
  font-weight: 600;
}

.ask-act {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.ask-act textarea {
  width: 100%;
}

.forward-row {
  flex-wrap: wrap;
  align-items: center;
}

.forward-row select,
.forward-row input {
  flex: 1 1 180px;
  min-width: 0;
}

/* ---- clients ------------------------------------------------------------------------- */

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.client-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.client-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.client-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.client-top .grow {
  min-width: 0;
}

.client-logo {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 80%, #fff), color-mix(in srgb, #0891b2 80%, #fff));
  color: #fff;
  font-weight: 800;
}

.client-status {
  flex: none;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}

.client-status.c-lead {
  background: var(--warn-soft);
  color: var(--warn);
}

.client-status.c-active {
  background: var(--ok-soft);
  color: var(--ok);
}

.client-status.c-paused,
.client-status.c-former {
  background: var(--surface-3);
  color: var(--muted);
}

.client-counts {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.client-counts > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.client-head h1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.client-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
}

.client-side .section,
.client-main .section {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.client-profile {
  display: grid;
  gap: 12px;
}

.ask-mini-list {
  display: grid;
  gap: 6px;
}

.ask-mini {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-left: 3px solid #a78bfa;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ask-mini.s-answered {
  border-left-color: var(--st-done);
}

.results li {
  display: grid;
}

.result-snippet {
  margin: -2px 8px 6px 34px;
  color: var(--muted);
}

.crawl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin-bottom: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.crawl-row:hover {
  background: var(--surface-2);
}

.running {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
}

.crawl-report {
  display: grid;
  gap: 14px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.kpi {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.issue-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.issue {
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.8rem;
  font-weight: 600;
}

.issue.severe {
  background: var(--danger-soft);
  color: var(--danger);
}

.issue-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.75rem;
  font-weight: 700;
}

.issue-count.severe {
  background: var(--danger-soft);
  color: var(--danger);
}

.crawl-table {
  table-layout: fixed;
}

.crawl-table td.clip {
  max-width: 0;
}

.crawl-table th:nth-child(1) {
  width: 34%;
}

.crawl-table th:nth-child(3) {
  width: 32%;
}

.crawl-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tr.clickable {
  cursor: pointer;
}

.crawl-page:empty {
  display: none;
}

.crawl-page {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.crawl-page h3 {
  margin: 0;
}

.page-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 0;
  font-size: 0.9rem;
}

.page-meta dt {
  color: var(--muted);
}

.page-meta dd {
  margin: 0;
}

.headings {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 0.88rem;
}

.page-text {
  max-height: 260px;
  margin: 6px 0 0;
  overflow: auto;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.office-chip.question {
  border-color: transparent;
  background: #6d28d9;
  color: #ffffff;
}

@media (max-width: 1100px) {
  .brain-hero,
  .client-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .form-grid,
  .ask-row {
    grid-template-columns: 1fr;
  }
}

/* ---- links to outside systems, client rules, webhooks, packs (v0.4) ------------------ */
.tag-ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: transparent;
}

.tag-link {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.links-section {
  display: grid;
  gap: 10px;
}

.link-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.link-chip {
  --sys: var(--faint);
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8rem;
}

.link-chip > a,
.link-chip > .link-noaddr {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 3px 10px;
  color: var(--text);
  text-decoration: none;
}

.link-chip > a:hover .link-sys {
  text-decoration: underline;
}

.link-chip .icon {
  flex: none;
  width: 12px;
  height: 12px;
  color: var(--muted);
}

.link-chip .link-sys {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 620;
  white-space: nowrap;
}

.link-chip .link-sys::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sys);
}

.link-chip .link-label {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-chip .link-status {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.link-chip code {
  font-size: 0.72rem;
  color: var(--muted);
}

.link-chip > .icon-btn {
  margin-right: 4px;
  width: 22px;
  height: 22px;
}

.link-chip.sys-clickup { --sys: #7b68ee; }
.link-chip.sys-drive { --sys: #1fa463; }
.link-chip.sys-gamma { --sys: #8b5cf6; }
.link-chip.sys-localfalcon { --sys: #f26b1d; }
.link-chip.sys-gbp { --sys: #4285f4; }
.link-chip.sys-ads { --sys: #e8a600; }
.link-chip.sys-meta { --sys: #0866ff; }
.link-chip.sys-highlevel { --sys: #188bf6; }
.link-chip.sys-descript { --sys: #2c6ef2; }
.link-chip.sys-loom { --sys: #625df5; }

.link-add {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.link-add input[type='url'] {
  flex: 2 1 220px;
}

.link-add input:not([type='url']) {
  flex: 1 1 140px;
}

.rules-box {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: var(--radius);
  background: var(--warn-soft);
}

.rules-box .rules-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--warn);
}

.rules-box .md > :first-child,
.rules-box p:first-of-type {
  margin-top: 0;
}

.pack-card {
  display: grid;
  gap: 10px;
  margin: 20px 0 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 60%);
}

.pack-card h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.pack-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.pack-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
}

.pack-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  color: var(--muted);
}

.pack-list li.done {
  color: var(--text);
}

.pack-list li.done .icon {
  width: 12px;
  height: 12px;
  color: var(--ok);
}

.hook-card.off {
  opacity: 0.65;
}

.hook-card code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.account-card h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
