/* 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%;
  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;
}

/* 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(6, 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 2px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; align-items: center; justify-content: center; text-align: center;
    font-size: 12px; line-height: 1.15; padding: 6px 2px; min-height: 44px; color: var(--text-secondary);
    text-decoration: none; border-radius: 8px; }
  .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(150px, 1fr)); gap: 10px; }
.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 */
.org-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; align-items: start; }
.org-grid > *, .agent-row > * { min-width: 0; }
.agent-row { flex-wrap: wrap; }
.agent-main { flex: 1 1 180px; overflow-wrap: anywhere; }
.agent-row > .st, .agent-row > .shrink-0 { flex-wrap: wrap; margin-left: auto; }
.st { white-space: normal; }
@media (max-width: 759px) { .org-grid { grid-template-columns: 1fr; } }
.agent-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 8px; border-radius: 10px; border: 1px solid var(--border-subtle); background: var(--bg-surface); }
.agent-row.is-head { background: var(--accent-soft); }
.agent-main { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--text-primary); min-width: 0; min-height: 40px; }
.job-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border-radius: 8px; background: var(--bg-subtle); }

/* 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: 180px; }
.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(720px, calc(100vw - 32px)); max-height: 85vh; overflow-y: auto; }
.dk-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.only-mobile { display: none; }
@media (max-width: 1100px) { .only-mobile { display: inline-flex; } }
