/* LinkOps AI — Next-Gen AI Workspace Design System (ChatGPT Canvas × Linear × Stripe) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-canvas: #f6f7f9;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f3f7;
  --bg-subtle: #f8f9fb;
  --bg-hover: #eef1f6;
  --border-subtle: rgba(15, 23, 42, 0.075);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-primary: #059669;
  --accent-primary-hover: #047857;
  --accent-soft: rgba(5, 150, 105, 0.08);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.03), 0 4px 16px -4px rgba(15, 23, 42, 0.04);
  --shadow-card-hover: 0 4px 12px rgba(15, 23, 42, 0.05), 0 12px 28px -6px rgba(15, 23, 42, 0.07);
  --shadow-copilot: 0 4px 20px -2px rgba(5, 150, 105, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
}

html.dark,
html[data-theme="dark"] {
  --bg-canvas: #0a0d12;
  --bg-surface: #11161f;
  --bg-elevated: #171e2b;
  --bg-subtle: #141a25;
  --bg-hover: #1d2636;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent-primary: #10b981;
  --accent-primary-hover: #059669;
  --accent-soft: rgba(16, 185, 129, 0.12);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.32);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-copilot: 0 6px 28px rgba(0, 0, 0, 0.5);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}

h1, h2, h3, .font-heading {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  letter-spacing: -0.02em;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

code, pre, .font-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Surfaces & Cards */
.surface-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.surface-card:hover {
  box-shadow: var(--shadow-card-hover);
}

/* ChatGPT-Style Copilot Command Shell */
.copilot-shell {
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-subtle) 100%);
  border: 1px solid rgba(5, 150, 105, 0.22);
  border-radius: 20px;
  box-shadow: var(--shadow-copilot);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.copilot-shell:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12), var(--shadow-copilot);
}

.prompt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.16s ease;
}

.prompt-chip:hover {
  color: var(--accent-primary);
  border-color: rgba(5, 150, 105, 0.35);
  background-color: var(--accent-soft);
  transform: translateY(-1px);
}

/* ChatGPT Canvas / Notion Document Sheet */
.doc-canvas {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 22px 26px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 1px 3px rgba(15, 23, 42, 0.03);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.72;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* Sidebar Navigation */
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--accent-soft);
  color: var(--accent-primary);
  font-weight: 600;
}

html.dark .nav-item.active {
  color: #34d399;
}

/* Segmented Control Pills (Fixes both .subtab-pill and .subnav-pill) */
.subtab-pill,
.subnav-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.16s ease;
}

.subtab-pill:hover,
.subnav-pill:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.subtab-pill.active,
.subnav-pill.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  border-color: var(--border-subtle);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

/* Soft Modern Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9.5px;
  border-radius: 9999px;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-emerald { background: #ecfdf5; color: #047857; border: 1px solid rgba(16, 185, 129, 0.25); }
.badge-amber   { background: #fffbeb; color: #b45309; border: 1px solid rgba(245, 158, 11, 0.28); }
.badge-cyan    { background: #f0f9ff; color: #0369a1; border: 1px solid rgba(14, 165, 233, 0.25); }
.badge-indigo  { background: #eef2ff; color: #4338ca; border: 1px solid rgba(99, 102, 241, 0.25); }
.badge-rose    { background: #fff1f2; color: #be123c; border: 1px solid rgba(244, 63, 94, 0.25); }
.badge-neutral { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-subtle); }

html.dark .badge-emerald { background: rgba(16, 185, 129, 0.14); color: #34d399; border-color: rgba(16, 185, 129, 0.28); }
html.dark .badge-amber   { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border-color: rgba(245, 158, 11, 0.28); }
html.dark .badge-cyan    { background: rgba(6, 182, 212, 0.14); color: #38bdf8; border-color: rgba(6, 182, 212, 0.28); }
html.dark .badge-indigo  { background: rgba(99, 102, 241, 0.14); color: #818cf8; border-color: rgba(99, 102, 241, 0.28); }
html.dark .badge-rose    { background: rgba(244, 63, 94, 0.14); color: #fb7185; border-color: rgba(244, 63, 94, 0.28); }
html.dark .badge-neutral { background: rgba(148, 163, 184, 0.12); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.2); }

/* Clean Data Tables */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-subtle);
  text-align: left;
}

.data-table td {
  padding: 14px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background-color: var(--bg-subtle);
}

/* Form Inputs & Buttons */
.input-field {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8.5px 12px;
  font-size: 13.5px;
  color: var(--text-primary);
  width: 100%;
  max-width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.13);
}

.btn-primary {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  padding: 8.5px 15px;
  border-radius: 10px;
  border: 1px solid rgba(4, 120, 87, 0.4);
  box-shadow: 0 1px 2px rgba(5, 150, 105, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #059669 0%, #047857 100%);
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.26);
  transform: translateY(-0.5px);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 12.5px;
  padding: 7.5px 13px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background-color: #fff1f2;
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #be123c;
  font-weight: 600;
  font-size: 12.5px;
  padding: 7.5px 13px;
  border-radius: 10px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.btn-danger:hover {
  background-color: #ffe4e6;
}

html.dark .btn-danger {
  background-color: rgba(244, 63, 94, 0.14);
  color: #fb7185;
}

/* Visual Progress Bar & Stepper */
.progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--bg-elevated);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #10b981, #059669);
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.pulse-dot {
  animation: pulse-ring 2s infinite;
}

/* ==========================================================================
   Phase 5 shell — concept-ui direction (quiet teal, task destinations).
   Tokens below are aliases over the legacy emerald scale so the older partials
   inherit the teal palette without being rewritten.
   ========================================================================== */
:root {
  --accent-primary: #0f766e;
  --accent-primary-hover: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.09);
  --accent-ink: #0b4f4a;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --st-good: #15803d;
  --st-warn: #b45309;
  --st-bad: #b91c1c;
  --st-info: #0369a1;
  --st-muted: #64748b;
  --shell-nav-active: rgba(15, 118, 110, 0.1);
  --focus-ring: #0f766e;
}
html.dark,
html[data-theme="dark"] {
  --accent-primary: #2dd4bf;
  --accent-primary-hover: #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.14);
  --accent-ink: #99f6e4;
  --series-1: #3987e5;
  --series-2: #d95926;
  --st-good: #4ade80;
  --st-warn: #fbbf24;
  --st-bad: #f87171;
  --st-info: #38bdf8;
  --st-muted: #94a3b8;
  --shell-nav-active: rgba(45, 212, 191, 0.14);
  --focus-ring: #2dd4bf;
}

/* Readability floors: never below 12px, 44px touch targets on touch screens. */
.text-\[10px\], .text-\[10\.5px\], .text-\[11px\], .text-\[11\.5px\] { font-size: 12px !important; }
@media (max-width: 760px), (pointer: coarse) {
  .btn-primary, .btn-secondary, .nav-item, .tabbar a, .subtab-pill, .input-field,
  select, input[type="checkbox"], input[type="submit"] { min-height: 44px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 8px;
}
/* Tiêu đề tab nhận focus bằng code để đọc màn hình; không phải điều khiển ⇒ không vẽ viền đè phụ đề. */
:where(h1, h2, h3)[tabindex="-1"]:focus-visible { outline: none; }

/* Navigation */
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); text-decoration: none; cursor: pointer; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item[aria-current="page"] { background: var(--shell-nav-active); color: var(--accent-ink); font-weight: 650; }

.tabbar { display: none; }
@media (max-width: 759px) {
  .tabbar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 40; background: var(--bg-surface); border-top: 1px solid var(--border-subtle);
    padding: 4px 1px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; align-items: center; justify-content: center; text-align: center;
    font-size: 11px; line-height: 1.1; padding: 6px 1px; min-height: 44px; min-width: 0; overflow-wrap: anywhere;
    color: var(--text-secondary); text-decoration: none; border-radius: 6px; }
  .tabbar a[aria-current="page"] { color: var(--accent-ink); font-weight: 700; background: var(--shell-nav-active); }
}

.conn-banner { padding: 8px 12px; border-radius: 10px; font-size: 12px; font-weight: 600;
  background: rgba(180, 83, 9, 0.12); color: var(--st-warn); border: 1px solid rgba(180, 83, 9, 0.25); }

/* Inbox master/detail */
.inbox-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
.inbox-grid > *, .inbox-list { min-width: 0; }
.inbox-row { flex-wrap: wrap; }
.inbox-row > .flex-1 { flex-basis: 140px; }
.inbox-row .truncate { white-space: normal; overflow-wrap: anywhere; }
.inbox-row .badge { white-space: normal; }
.inbox-row > .shrink-0 { margin-left: auto; }
#toast-container { bottom: calc(72px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) { #toast-container { bottom: 20px; } }
@media (max-width: 759px) {
  header { height: auto !important; min-height: 64px; flex-wrap: wrap; padding-block: 8px; gap: 8px !important; }
  header > div:last-child { flex-wrap: wrap; min-width: 0; }
  #outbound-pause-btn { white-space: normal; flex-shrink: 0; max-width: 100%; }
  header kbd { display: none; }
}
@media (max-width: 1100px) {
  .inbox-grid { grid-template-columns: 1fr; }
  .inbox-pane-detail { display: none; }
  .inbox-grid.show-detail .inbox-pane-list { display: none; }
  .inbox-grid.show-detail .inbox-pane-detail { display: block; }
}
.inbox-list { display: flex; flex-direction: column; gap: 6px; }
.inbox-row { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border-subtle);
  background: var(--bg-surface); cursor: pointer; color: var(--text-primary); }
.inbox-row:hover { background: var(--bg-hover); }
.inbox-row.is-selected { border-color: var(--accent-primary); box-shadow: 0 0 0 1px var(--accent-primary) inset; }
.sev { width: 4px; align-self: stretch; border-radius: 4px; background: var(--st-muted); flex: none; }
.sev-high { background: var(--st-bad); }
.sev-mid { background: var(--st-warn); }
.sev-low { background: var(--st-info); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 10px; }
.detail-grid > * { min-width: 0; }
fieldset { min-width: 0; }
.lbl { font-size: 12px; color: var(--text-muted); }
.val { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.subcard { padding: 12px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg-subtle); }

/* Status pills: colour + label ("●" is decorative, the text carries the state). */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--bg-subtle); }
.st-good { color: var(--st-good); } .st-info { color: var(--st-info); } .st-warn { color: var(--st-warn); }
.st-bad { color: var(--st-bad); } .st-muted { color: var(--st-muted); }

/* Org chart & Agent Workspace */
.ag-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.ag-kpi-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  min-width: 0;
  max-width: 100%;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.ag-kpi-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.ag-kpi-card.is-active {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-primary) inset;
}
.ag-kpi-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
}
.ag-kpi-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 8px;
  background: var(--st-muted);
}
.ag-kpi-dot.dot-all { background: var(--accent-primary); }
.ag-kpi-dot.dot-working { background: var(--st-info); }
.ag-kpi-dot.dot-waiting { background: var(--st-warn); }
.ag-kpi-dot.dot-alert { background: var(--st-bad); }
.ag-kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 0;
  overflow-wrap: anywhere;
}
.ag-kpi-card.is-active .ag-kpi-label {
  color: var(--accent-ink);
}
.ag-kpi-num {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.org-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.org-tree-top {
  width: min(100%, 780px);
}
.org-tree-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  pointer-events: none;
}
.org-tree-stem {
  width: 2px;
  height: 14px;
  background: var(--border-strong);
}
.org-bus {
  width: 64%;
  height: 12px;
  border-top: 2px solid var(--border-strong);
  border-left: 2px solid var(--border-strong);
  border-right: 2px solid var(--border-strong);
  border-radius: 8px 8px 0 0;
}

.org-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
  width: 100%;
}
.org-grid > *, .agent-row > * { min-width: 0; }

.dept-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 3px solid var(--accent-primary);
  min-width: 0;
  max-width: 100%;
}
.dept-card-exec {
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-subtle) 100%);
}
.dept-accent-emerald { border-top-color: #10b981; }
.dept-accent-sky     { border-top-color: #0284c7; }
.dept-accent-amber   { border-top-color: #d97706; }
.dept-accent-violet,
.dept-accent-indigo  { border-top-color: #6366f1; }
.dept-accent-rose    { border-top-color: #e11d48; }

.dept-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.dept-head-info {
  flex: 1 1 200px;
  min-width: 0;
}
.dept-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.dept-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.dept-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-top: 3px;
}
.dept-run-btn {
  padding: 6px 11px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  white-space: normal;
  max-width: 100%;
}

.dept-specialists {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dept-specialists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 10px;
}

.agent-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.agent-row:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.agent-row.is-head {
  background: var(--accent-soft);
  border-color: rgba(15, 118, 110, 0.28);
}
.agent-row.is-inactive {
  opacity: 0.68;
}
.agent-main {
  flex: 1 1 190px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--text-primary);
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
}
.agent-main * {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}
.ag-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1px solid var(--border-subtle);
}
.ag-avatar-lg {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  font-size: 14px;
  border-radius: 12px;
}
.ag-code {
  white-space: nowrap !important;
  line-height: 1;
}
.ag-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid var(--bg-surface);
  background: var(--st-muted);
}
.tone-good .ag-dot { background: var(--st-good); }
.tone-info .ag-dot { background: var(--st-info); }
.tone-warn .ag-dot { background: var(--st-warn); }
.tone-bad  .ag-dot { background: var(--st-bad); }
.tone-bad  .ag-avatar, .ag-avatar.tone-bad { background: rgba(185, 28, 28, 0.1); color: var(--st-bad); }
.tone-warn .ag-avatar, .ag-avatar.tone-warn { background: rgba(180, 83, 9, 0.1); color: var(--st-warn); }

.ag-body {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}
.ag-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.ag-name {
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--text-primary);
}
.ag-role-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.ag-role-tag.is-lead {
  background: var(--bg-surface);
  color: var(--accent-ink);
  border-color: rgba(15, 118, 110, 0.3);
}
.ag-role-tag.is-physical {
  background: rgba(3, 105, 161, 0.1);
  color: var(--st-info);
  border-color: rgba(3, 105, 161, 0.25);
}
.ag-spec {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}
.ag-meta {
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
}
.ag-status-col {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.st { white-space: normal; }
.dept-card .badge, .cap-box .badge, .ag-dossier-head .badge, .prompt-chip {
  white-space: normal;
  max-width: 100%;
}

/* Workbench & Dossier Modal */
.workbench-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.workbench-grid > * { min-width: 0; }
.workbench-card-span {
  grid-column: 1 / -1;
}

.ag-dossier-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.ag-dossier-identity {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1 1 240px;
  min-width: 0;
}
.ag-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}
.cap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.cap-grid > * { min-width: 0; }
.cap-box {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}
.cap-allow {
  background: var(--accent-soft);
  border-color: rgba(15, 118, 110, 0.22);
}
.cap-guard {
  background: rgba(185, 28, 28, 0.06);
  border-color: rgba(185, 28, 28, 0.2);
}
.job-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 10px; background: var(--bg-surface); border: 1px solid var(--border-subtle); }

@media (max-width: 960px) {
  .ag-kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ag-kpi-card { padding: 10px 12px; }
  .org-tree { gap: 14px; }
  .org-tree-connector { display: none; }
  .org-tree-top { width: 100%; }
  .org-grid, .workbench-grid, .cap-grid { grid-template-columns: 1fr; }
}

/* Tables, filters, bulk bar */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted);
  padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--bg-hover); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar .input-field { min-width: min(180px, 100%); }
.kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kpi-strip > * { min-width: 0; }
@media (max-width: 960px) { .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .kpi-strip { grid-template-columns: 1fr; } }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px;
  border: 1px solid var(--accent-primary); border-radius: 12px; background: var(--accent-soft); }
.empty-state { padding: 20px; text-align: center; font-size: 13px; color: var(--text-muted); }
.alert { padding: 10px 12px; border-radius: 10px; font-size: 12px; font-weight: 500; border: 1px solid var(--border-subtle); }
.alert-warn { background: rgba(180, 83, 9, 0.1); color: var(--st-warn); border-color: rgba(180, 83, 9, 0.25); }

/* Finance */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.2; margin: 2px 0; }
.finance-chart { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding: 8px 4px 0;
  border-bottom: 1px solid var(--border-subtle); overflow-x: auto; }
.bar-group { display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  gap: 6px; min-width: 54px; height: 100%; }
.bar-pair { display: flex; align-items: flex-end; gap: 2px; height: 100%; flex: 1; }
.bar { width: 16px; min-height: 2px; border-radius: 4px 4px 0 0; position: relative; }
.bar-1 { background: var(--series-1); }
.bar-2 { background: var(--series-2); }
.bar:hover, .bar:focus-visible { filter: brightness(1.08); }
.bar::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  display: none; white-space: nowrap; font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 8px;
  background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-strong); z-index: 5; }
.bar:hover::after, .bar:focus-visible::after { display: block; }
.bar-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch-1 { background: var(--series-1); }
.swatch-2 { background: var(--series-2); }

/* Dialogs */
.dk-dialog { border: 1px solid var(--border-strong); border-radius: 16px; background: var(--bg-surface);
  color: var(--text-primary); padding: 20px; width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow-card-hover); }
.dk-dialog-wide { width: min(740px, calc(100vw - 32px)); max-height: 86vh; overflow-y: auto; }
@media (max-width: 480px) { .dk-dialog { padding: 14px; width: calc(100vw - 16px); } }
.dk-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.only-mobile { display: none; }
@media (max-width: 1100px) { .only-mobile { display: inline-flex; } }
