/*


 */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #f9fafb;     /* hover/zebra rows, kanban column bg */
  --surface-elevated: #f3f4f6;  /* table headers */

  --border: #e3e6ec;
  --border-strong: #cbd5e1;

  --text: #1f2933;
  --muted: #6b7280;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-bright: #3b82f6;
  --accent-bg: #eef2ff;
  --accent-fg: #3730a3;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --success: #047857;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;

  --warning: #92400e;

  --radius: 8px;
  --radius-sm: 4px;

  --font-mono: "SF Mono", ui-monospace, Menlo, Monaco, "Cascadia Mono", "Roboto Mono", monospace;

  /* Sidebar layout */
  --sidebar-width: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

code, kbd, samp, pre, .mono { font-family: var(--font-mono); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin-top: 0; }

.container {
  max-width: 1280px;
  margin: 20px auto;
  padding: 0 20px;
}

.muted { color: var(--muted); }

/* App shell + sidebar layout */
.app-shell { position: relative; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; }
.brand a { color: var(--text); }
.tenant-pill {
  display: inline-block;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.sidenav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidenav .nav-link {
  display: block;
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.sidenav .nav-link:hover {
  background: var(--accent-bg);
  color: var(--primary);
  text-decoration: none;
}
.sidenav .nav-link.active {
  background: var(--primary);
  color: #fff;
}
.sidenav .nav-link.active:hover {
  background: var(--primary-hover);
  color: #fff;
}

/* Nested child links (Meetings / To-Dos / Issues under Goals|OKR|EOS) */
.sidenav-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 14px;
  margin-top: 2px;
  border-left: 2px solid var(--border);
  margin-left: 12px;
}
.sidenav-children .nav-link {
  font-size: 13px;
  padding: 6px 10px;
  color: var(--muted);
}
.sidenav-children .nav-link:hover { color: var(--primary); }
.sidenav-children .nav-link.active {
  background: transparent;
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.sidebar-footer .user-email {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-footer form { margin: 0; }
.sidebar-footer .btn-link { padding: 0; text-align: left; }

.tenant-switcher {
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tenant-switcher form { margin: 0; flex: 1; }
.tenant-switcher select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  min-width: 0;
}
.tenant-switcher .btn-link {
  font-size: 12px;
  white-space: nowrap;
  padding: 4px 6px;
}

.user-menu { display: flex; align-items: center; gap: 12px; }

/* Main content area pushed over by the sidebar */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  max-width: 1280px;
}

/* Mobile-only top bar (sticky) — hidden on desktop */
.topbar-mobile { display: none; }

/* Backdrop while sidebar is open on mobile */
.sidebar-overlay { display: none; }

/* Forms */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=tel],
.field input[type=url],
.field input[type=search],
.field input[type=number],
.field input[type=date],
.field input[type=datetime-local],
.field input[type=time],
.field input[type=month],
.field input[type=week],
.field textarea,
.field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.4;
  background: var(--surface);
  color: inherit;
  font-family: inherit;
  box-sizing: border-box;
  /* Match the rendered height of text inputs across all types
     (date/number pickers come with native chrome of varying heights). */
  min-height: 38px;
  appearance: none;
  -webkit-appearance: none;
}
.field input[type=date]::-webkit-calendar-picker-indicator,
.field input[type=datetime-local]::-webkit-calendar-picker-indicator,
.field input[type=time]::-webkit-calendar-picker-indicator,
.field input[type=month]::-webkit-calendar-picker-indicator,
.field input[type=week]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}
.field input[type=date]::-webkit-calendar-picker-indicator:hover,
.field input[type=datetime-local]::-webkit-calendar-picker-indicator:hover,
.field input[type=time]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
/* Hide the spin buttons on number inputs — they're inconsistent across
   browsers and look out of place next to our other inputs. */
.field input[type=number] {
  -moz-appearance: textfield;
}
.field input[type=number]::-webkit-outer-spin-button,
.field input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
/* Re-enable native dropdown arrow on selects (we cleared appearance above). */
.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236b7280' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.field input::placeholder,
.field textarea::placeholder { color: rgba(0, 0, 0, 0.30); }
.field input:disabled,
.field textarea:disabled,
.field select:disabled {
  background: var(--surface-muted);
  color: var(--muted);
  cursor: not-allowed;
}
.field textarea { min-height: 90px; resize: vertical; }
.actions { margin-top: 20px; display: flex; gap: 8px; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { text-decoration: none; background: var(--surface-elevated); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}
.btn-link {
  background: transparent;
  border: none;
  color: var(--primary);
  padding: 0;
}
.btn-link:hover { text-decoration: underline; }

/* Auth card */
.auth-card {
  max-width: 420px;
  margin: 60px auto;
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}
.auth-card h2 { margin-bottom: 8px; }

/* Cards / sections */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

/* Tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.data th, table.data td {
  text-align: left;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
table.data th {
  background: var(--surface-elevated);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover { background: var(--surface-muted); }

/* Flash */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.flash-notice { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.flash-alert  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger); }

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat .num { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

/* Error messages */
#error_explanation {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
#error_explanation h2 { font-size: 14px; margin: 0 0 6px 0; }
#error_explanation ul { margin: 0; padding-left: 18px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Kanban */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px; /* room for scrollbar */
}
.kanban-col {
  flex: 0 0 260px;     /* fixed width per column, no shrink, never wrap */
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}
.kanban-cards {
  flex: 1;
  min-height: 80px;    /* gives empty stages a real drop target */
}
.kanban-col-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 4px;
}
.kanban-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.12s, background 0.12s;
}
.kanban-card:hover { border-color: var(--primary-bright); background: var(--surface-elevated); text-decoration: none; }
.kanban-name { font-weight: 600; }
.kanban-budget { color: var(--success); font-weight: 600; margin-top: 4px; }
.kanban-org, .kanban-assignees { font-size: 12px; margin-top: 2px; }

/* Stage list */
.stage-list { list-style: none; padding: 0; margin: 0; }
.stage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: var(--surface);
}
.stage-edit-form { display: flex; gap: 6px; flex: 1; }
.stage-edit-form input { flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.drag-handle { cursor: grab; color: var(--muted); user-select: none; padding: 0 6px; }

/* Dropzone */
.dropzone-area {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  background: var(--surface-muted);
  transition: background 0.15s, border-color 0.15s;
}
.dropzone-area.drag-over {
  background: var(--accent-bg);
  border-color: var(--primary-bright);
}
.upload-progress { list-style: none; padding: 0; margin: 12px 0 0 0; }
.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.upload-row .fname { flex: 1; }
.upload-row .fsize { color: var(--muted); font-size: 12px; }
.upload-row .bar-wrap {
  width: 120px;
  height: 6px;
  background: var(--surface-muted);
  border-radius: 3px;
  overflow: hidden;
}
.upload-row .bar { width: 0%; height: 100%; background: var(--primary); transition: width 0.2s; }
.upload-row.done .bar { background: var(--success); width: 100% !important; }
.upload-row.error { color: var(--danger); }

/* Comments */
.comment-list { list-style: none; padding: 0; margin: 12px 0 0 0; }
.comment {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.comment-meta strong { color: var(--text); }
.comment-body { font-size: 14px; }

.check-row { display: block; padding: 4px 0; }
.contact-row { padding: 4px 0; }

/* Pipeline filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.view-toggle { display: flex; gap: 6px; }
.stage-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex: 1;
}
.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.check-pill input { margin: 0; }
.check-pill:has(input:checked) {
  background: var(--accent-bg);
  border-color: var(--primary-bright);
  color: var(--accent-fg);
}
.status-pill.status-open:has(input:checked)  { background: var(--accent-bg);  border-color: var(--primary-bright); color: var(--accent-fg); }
.status-pill.status-won:has(input:checked)   { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.status-pill.status-lost:has(input:checked)  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger); }

.status-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-badge.status-open  { background: var(--accent-bg);  color: var(--accent-fg); }
.status-badge.status-won   { background: var(--success-bg); color: var(--success); }
.status-badge.status-lost  { background: var(--danger-bg);  color: var(--danger); }
.kanban-card .status-badge { float: right; margin-top: 2px; }

/* Timesheet quick-add bar */
.quick-add-form { width: 100%; }
.quick-add-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.quick-add-row .field {
  flex: 1;
  min-width: 120px;
  margin-bottom: 0;
}

/* Timer running state */
.timer-running {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.timer-display {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--success);
  min-width: 160px;
}
.running-row { background: rgba(251, 208, 101, 0.10); }

/* Invoices */
.invoice-header-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 16px;
  align-items: end;
}
@media (max-width: 700px) {
  .invoice-header-grid { grid-template-columns: 1fr 1fr; }
}
.invoice-number {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.invoice-lines th, .invoice-lines td { vertical-align: top; }
.invoice-lines input, .invoice-lines textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}
.invoice-lines .line-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.invoice-line-row td { padding: 8px 10px; }

.invoice-totals .totals-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}
@media (max-width: 700px) {
  .invoice-totals .totals-grid { grid-template-columns: 1fr; }
}
.totals-summary {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-variant-numeric: tabular-nums;
}
.totals-row.total {
  border-top: 1px solid var(--border);
  border-bottom: 2px solid var(--text);
  padding: 10px 0;
  font-weight: 700;
  font-size: 18px;
}
.totals-row.outstanding {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-weight: 700;
  color: var(--danger);
}
.status-badge.invoice-status-draft    { background: var(--surface-muted); color: var(--muted); }
.status-badge.invoice-status-sent     { background: var(--accent-bg);  color: var(--accent-fg); }
.status-badge.invoice-status-partial  { background: #fef3c7; color: #92400e; }
.status-badge.invoice-status-paid     { background: var(--success-bg); color: var(--success); }
.status-badge.invoice-status-overdue  { background: var(--danger-bg);  color: var(--danger); }
.status-badge.invoice-status-void     { background: var(--surface-muted); color: var(--muted); text-decoration: line-through; }

/* Settings sub-nav */
.settings-subnav {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.settings-subnav .nav-link {
  color: var(--text);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.settings-subnav .nav-link:hover { background: var(--surface-muted); color: var(--primary-bright); text-decoration: none; }
.settings-subnav .nav-link.active { background: var(--primary); color: #fff; }

/* Integration status badges */
.status-badge.status-connected    { background: var(--success-bg); color: var(--success); }
.status-badge.status-error        { background: var(--danger-bg);  color: var(--danger); }
.status-badge.status-disconnected { background: var(--surface-muted); color: var(--muted); }
.integration-card { margin-bottom: 16px; }
.integration-card code { background: var(--surface-muted); color: var(--accent-fg); padding: 1px 4px; border-radius: 3px; font-family: var(--font-mono); font-size: 12px; }

/* Milestone status badges */
.status-badge.milestone-status-milestone-completed { background: var(--success-bg); color: var(--success); }
.status-badge.milestone-status-milestone-overdue   { background: var(--danger-bg);  color: var(--danger); }
.status-badge.milestone-status-milestone-open      { background: var(--accent-bg);  color: var(--accent-fg); }
tr.milestone-completed { opacity: 0.6; }
tr.milestone-overdue { background: rgba(231, 106, 110, 0.08); }
tr.milestone-completed td:first-child,
tr.milestone-overdue td:first-child,
tr.milestone-open td:first-child {
  border-left: 3px solid transparent;
}
tr.milestone-completed td:first-child { border-left-color: var(--success); }
tr.milestone-overdue   td:first-child { border-left-color: var(--danger); }
tr.milestone-open      td:first-child { border-left-color: var(--primary-bright); }

/* Timeline */
.timeline-list { list-style:none; padding:0; margin:0; }
.timeline-item {
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-date { color: var(--muted); font-size: 12px; min-width: 200px; font-variant-numeric: tabular-nums; }

.status-badge.event-kind-deployment { background: #fee2e2; color: #b91c1c; }
.status-badge.event-kind-kickoff    { background: #dbeafe; color: #1d4ed8; }
.status-badge.event-kind-demo       { background: #fef3c7; color: #92400e; }
.status-badge.event-kind-review     { background: #e0e7ff; color: #3730a3; }
.status-badge.event-kind-release    { background: #d1fae5; color: #047857; }
.status-badge.event-kind-milestone  { background: #fce7f3; color: #9d174d; }
.status-badge.event-kind-other      { background: #f3f4f6; color: #374151; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* Kanban drag-drop affordances */
.kanban-card {
  position: relative;
  cursor: grab;
}
.kanban-card .drag-handle {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 12px;
}
.kanban-name-link {
  color: var(--text);
  font-weight: 600;
  display: block;
  padding-right: 16px;
}
.kanban-name-link:hover { color: var(--primary); text-decoration: none; }
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }

/* Sortable list headers */
table.data.sortable th a {
  color: var(--muted);
  text-decoration: none;
  display: block;
}
table.data.sortable th a:hover { color: var(--text); }

.inline-list { list-style: none; padding: 0; margin: 0 0 8px 0; }
.inline-row { padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; }
.inline-row .form-row { gap: 8px; margin-bottom: 6px; }
.inline-row input { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); width: 100%; }

/* ============================================================
 * Responsive layout — mobile + tablet
 * Breakpoints: < 480 phone · < 768 small tablet/large phone · < 1024 tablet
 * ============================================================ */

/* Hamburger button — hidden by default, shown on small screens */
.hamburger {
  display: none;
  background: transparent;
  border: 0;
  padding: 8px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  flex-direction: column;
  justify-content: space-around;
}
.hamburger span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  width: 100%;
  transition: transform 0.2s, opacity 0.2s;
}
.app-shell.is-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.app-shell.is-open .hamburger span:nth-child(2) { opacity: 0; }
.app-shell.is-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Container & general padding tightens on small screens */
@media (max-width: 900px) {
  .container { padding: 0 12px; margin-top: 12px; }
  .card { padding: 14px; }
  body { font-size: 14px; }

  /* Sidebar collapses to a drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.1);
  }
  .app-shell.is-open .sidebar { transform: translateX(0); }

  /* Main content takes full width */
  .main-content {
    margin-left: 0;
    padding: 16px;
  }

  /* Mobile-only topbar with hamburger */
  .topbar-mobile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .topbar-mobile .brand { flex: 1; }
  .hamburger { display: flex; }

  /* Backdrop overlay while drawer is open */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 90;
    border: none;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    cursor: pointer;
  }
  .app-shell.is-open .sidebar-overlay { opacity: 1; pointer-events: auto; }

  /* Page header — stack title and actions */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .page-header > div { display: flex; flex-wrap: wrap; gap: 8px; }
  .page-header h1 { font-size: 22px; }

  /* Forms always single-column on phones */
  .form-row { grid-template-columns: 1fr; }

  /* Tables — let them scroll horizontally inside their card */
  .card > table.data,
  .card table.data {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .card > table.data thead, .card > table.data tbody,
  .card table.data thead, .card table.data tbody { white-space: nowrap; }

  /* Kanban — narrower cards so two fit on a phone */
  .kanban-col { flex: 0 0 240px; }
  .kanban-card { font-size: 13px; }

  /* Timer running state — let stop button drop below */
  .timer-running { flex-wrap: wrap; }
  .timer-running .timer-display { min-width: 100%; text-align: center; font-size: 26px; }

  /* Filter bar / stage filter wrap better */
  .filter-bar { padding: 8px; gap: 8px; }
  .stage-filter { gap: 4px; }

  /* Stat tiles smaller */
  .stat .num { font-size: 22px; }

  /* Quick-add row stacks fields on phones */
  .quick-add-row { flex-direction: column; align-items: stretch; }
  .quick-add-row .field { min-width: 0; max-width: none; }

  /* Settings sub-nav wraps */
  .settings-subnav { flex-wrap: wrap; }

  /* Modal — full-width on phones */
  .modal-card { width: 95%; max-height: 90vh; }
  .invoice-totals .totals-grid { grid-template-columns: 1fr; }
  .invoice-header-grid { grid-template-columns: 1fr 1fr; }

  /* Auth card */
  .auth-card { margin: 24px 12px; padding: 24px; }

  /* Documents drag-drop */
  .upload-row { flex-wrap: wrap; }
  .upload-row .bar-wrap { width: 100%; }

  /* Comments */
  .comment-meta { flex-wrap: wrap; }
}

/* Tablet/desktop fine-tuning */
@media (min-width: 901px) and (max-width: 1280px) {
  .main-content { padding: 20px 24px; }
  .form-row { gap: 12px; }
  .kanban-col { flex: 0 0 240px; }
}

/* Extra-small phones */
@media (max-width: 480px) {
  .container { padding: 0 8px; }
  .card { padding: 12px; }
  .page-header h1 { font-size: 20px; }
  .invoice-header-grid { grid-template-columns: 1fr; }
  .timeline-item { flex-wrap: wrap; }
  .timeline-date { min-width: 0; flex-basis: 100%; }
  .auth-card { padding: 18px; margin: 16px 8px; }
  .btn { padding: 8px 12px; }
}

/* === "Suggest from documents" panel inside the close-won modal === */
.suggest-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.suggest-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
  padding: 8px 10px;
  background: var(--accent-bg);
  border: 1px solid rgba(76, 144, 240, 0.30);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--accent-fg);
}
.suggest-status-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}
.suggest-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary-bright);
  border-radius: 50%;
  animation: suggest-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes suggest-spin { to { transform: rotate(360deg); } }
.suggest-section {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.suggest-section > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  padding: 4px 0;
  color: var(--text);
}
.suggest-section > summary::-webkit-details-marker { display: none; }
.suggest-section > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s;
  color: var(--muted);
}
.suggest-section[open] > summary::before { transform: rotate(90deg); }
.suggest-count { color: var(--muted); font-weight: 400; margin-left: 4px; }
.suggest-list { margin-top: 8px; }
.suggest-items {
  list-style: none;
  margin: 0;
  padding: 0;
}
.suggest-items > li.suggest-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.suggest-items > li.suggest-item:last-child { border-bottom: 0; }
.suggest-item-head { line-height: 1.4; }
.suggest-item-desc { margin-top: 2px; font-size: 13px; }
.suggest-tickets {
  margin: 6px 0 0 18px;
  padding: 0;
  list-style: disc;
}
.suggest-tickets > li {
  font-size: 13px;
  padding: 2px 0;
}
.suggest-ticket-title { font-weight: 500; }

/* Wider modal for the close-won "Create new project" flow */
.modal-card-wide {
  max-width: 1024px;
  max-height: 90vh;
}

/* Editable suggested rows */
.suggest-rows {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}
.suggest-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.suggest-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.suggest-tickets-block {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.suggest-tickets-list {
  list-style: none;
  margin: 6px 0 0 0;
  padding: 0;
}
.suggest-ticket-row {
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}
.suggest-ticket-row:last-child { border-bottom: 0; }

@media (max-width: 768px) {
  .modal-card-wide { max-width: 95vw; }
}

/* ============================================================
 * Project tabs
 * ============================================================ */
.project-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.project-tabs .tab-button {
  background: transparent;
  border: 0;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
  border-radius: 0;
}
.project-tabs .tab-button:hover {
  color: var(--primary);
  background: var(--accent-bg);
  text-decoration: none;
}
.project-tabs .tab-button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Sub-tabs (used inside Calendar) */
.subtabs {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-elevated);
  padding: 2px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.subtab-button {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.subtab-button:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
.subtab-button.active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.subtab-pane { display: none; }
.subtab-pane.active { display: block; }

/* ============================================================
 * Calendar (month grid)
 * ============================================================ */
.cal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.cal-header h3 { flex: 1; text-align: center; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-dow {
  background: var(--surface-elevated);
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
}
.cal-day {
  background: var(--surface);
  min-height: 96px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-day.other-month { background: var(--surface-muted); color: var(--muted); }
.cal-day.is-today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-daynum { font-size: 12px; font-weight: 600; padding: 0 2px; font-variant-numeric: tabular-nums; }
.cal-day.is-today .cal-daynum { color: var(--primary); }
.cal-pill {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--accent-bg);
  color: var(--accent-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-pill.cal-milestone {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}
.cal-pill.event-kind-deployment { background: #fee2e2; color: #b91c1c; }
.cal-pill.event-kind-kickoff    { background: #dbeafe; color: #1d4ed8; }
.cal-pill.event-kind-demo       { background: #fef3c7; color: #92400e; }
.cal-pill.event-kind-review     { background: #e0e7ff; color: #3730a3; }
.cal-pill.event-kind-release    { background: #d1fae5; color: #047857; }
.cal-pill.event-kind-milestone  { background: #fce7f3; color: #9d174d; }
.cal-pill.event-kind-other      { background: #f3f4f6; color: #374151; }

@media (max-width: 768px) {
  .cal-day { min-height: 64px; }
  .cal-pill { font-size: 10px; padding: 1px 4px; }
}

/* ============================================================
 * Gantt chart
 * ============================================================ */
.gantt-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.gantt {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13px;
}
.gantt-axis {
  position: relative;
  height: 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-elevated);
  margin-left: 220px;   /* space for the label column */
}
.gantt-month {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-left: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}
.gantt-today {
  position: absolute;
  top: 0;
  bottom: -9999px;
  width: 2px;
  background: rgba(220, 38, 38, 0.5);
  z-index: 5;
  pointer-events: none;
}
.gantt-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  min-height: 32px;
}
.gantt-row:last-child { border-bottom: 0; }
.gantt-row:hover { background: var(--surface-muted); }
.gantt-row-project { background: var(--accent-bg); }
.gantt-row-project:hover { background: var(--accent-bg); }
.gantt-row-ticket { min-height: 26px; }
.gantt-label {
  width: 220px;
  flex-shrink: 0;
  padding: 4px 12px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}
.gantt-marker { color: #92400e; font-size: 12px; }
.gantt-track {
  position: relative;
  flex: 1;
  height: 100%;
  align-self: stretch;
  min-height: 32px;
}
.gantt-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 18px;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}
.gantt-bar-project   { background: var(--primary); height: 22px; }
.gantt-bar-milestone { background: #d97706; }
.gantt-bar-ticket    { background: #fde68a; color: #78350f; height: 12px; border-radius: 3px; }
.gantt-bar-resource  { background: #0d9488; }
.gantt-bar-vendor    { background: #7c3aed; }

/* Project color rotation (used by the global resourcing Gantt) */
.gantt-bar-project-0 { background: #2563eb; }
.gantt-bar-project-1 { background: #059669; }
.gantt-bar-project-2 { background: #d97706; }
.gantt-bar-project-3 { background: #dc2626; }
.gantt-bar-project-4 { background: #7c3aed; }
.gantt-bar-project-5 { background: #db2777; }
.gantt-bar-project-6 { background: #0d9488; }
.gantt-bar-project-7 { background: #6b7280; }

/* Same rotation for calendar event pills */
.cal-pill-project-0 { background: #dbeafe; color: #1d4ed8; }
.cal-pill-project-1 { background: #d1fae5; color: #047857; }
.cal-pill-project-2 { background: #fef3c7; color: #92400e; }
.cal-pill-project-3 { background: #fee2e2; color: #b91c1c; }
.cal-pill-project-4 { background: #ede9fe; color: #6d28d9; }
.cal-pill-project-5 { background: #fce7f3; color: #9d174d; }
.cal-pill-project-6 { background: #ccfbf1; color: #115e59; }
.cal-pill-project-7 { background: #f3f4f6; color: #374151; }
.gantt-bar-event.event-kind-deployment { background: #dc2626; }
.gantt-bar-event.event-kind-kickoff    { background: #2563eb; }
.gantt-bar-event.event-kind-demo       { background: #d97706; }
.gantt-bar-event.event-kind-review     { background: #6366f1; }
.gantt-bar-event.event-kind-release    { background: #059669; }
.gantt-bar-event.event-kind-milestone  { background: #db2777; }
.gantt-bar-event.event-kind-other      { background: #6b7280; }

@media (max-width: 900px) {
  .gantt-axis { margin-left: 140px; }
  .gantt-label { width: 140px; padding: 4px 8px; font-size: 12px; }
}

/* ============================================================
 * Goals — progress bars
 * ============================================================ */
.progress-wrap {
  position: relative;
  width: 140px;
  height: 8px;
  background: var(--surface-elevated);
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
.progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.2s;
}
.progress-expected {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: rgba(0,0,0,0.45);
}

/* ============================================================
 * EOS Scorecard grid
 * ============================================================ */
.scorecard-grid th.num,
.scorecard-grid td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 64px;
}
.scorecard-grid td.score-hit  { background: rgba(4, 120, 87, 0.12); color: var(--success); font-weight: 600; }
.scorecard-grid td.score-miss { background: rgba(220, 38, 38, 0.12); color: var(--danger);  font-weight: 600; }
.scorecard-grid td.score-blank { color: rgba(0, 0, 0, 0.25); }

/* ============================================================
 * Meeting agenda (live page)
 * ============================================================ */
.agenda-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.agenda-row:last-child { border-bottom: 0; }
.agenda-current {
  background: var(--accent-bg);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
}
.agenda-done { opacity: 0.55; }
.agenda-meta { display: flex; align-items: baseline; gap: 8px; }
.agenda-num {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  background: var(--surface-elevated);
  font-size: 12px;
  font-weight: 600;
}
.agenda-current .agenda-num { background: var(--primary); color: #fff; }
.agenda-clock { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 180px; text-align: right; }
.agenda-bar { width: 120px; height: 4px; background: var(--surface-elevated); border-radius: 2px; overflow: hidden; margin-top: 4px; margin-left: auto; }
.agenda-bar-fill { height: 100%; background: var(--primary); transition: width 0.4s; }

/* Reconciliation match suggestion row */
.match-suggestion-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 2px 4px 2px 0;
  background: var(--surface-elevated);
}
.match-score {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 28px;
  text-align: center;
}
.match-label { font-size: 13px; }

/* ============================================================
 * PDF viewer + signing field overlays
 * ============================================================ */
.pdf-viewer {
  background: #f3f4f6;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-height: 80vh;
  overflow: auto;
}
.pdf-page-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.pdf-page {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.pdf-page canvas { display: block; }
.pdf-page-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pdf-page-overlay > * { pointer-events: auto; }

/* Field box default styling */
.pdf-field {
  position: absolute;
  box-sizing: border-box;
  background: rgba(45, 114, 210, 0.18);
  border: 1.5px dashed rgba(45, 114, 210, 0.7);
  border-radius: 2px;
  font-size: 11px;
  color: #1d4ed8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.pdf-field-editable:hover { background: rgba(45, 114, 210, 0.28); }
.pdf-field-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: var(--primary);
  cursor: se-resize;
  border-top-left-radius: 4px;
}
.pdf-field-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

/* Signing-side variants */
.pdf-field-signable {
  background: rgba(251, 191, 36, 0.18);
  border: 1.5px solid rgba(217, 119, 6, 0.7);
  cursor: text;
}
.pdf-field-signable input[type=text],
.pdf-field-signable input[type=email],
.pdf-field-signable input[type=date] {
  font-family: inherit;
}
.sig-typed {
  width: 100%;
  height: 100%;
  font-family: "Segoe Script", "Snell Roundhand", "Apple Chancery", "Brush Script MT", cursive;
  font-size: clamp(16px, 60%, 28px);
  color: #1f2933;
  background: transparent;
  display: flex;
  align-items: center;
  padding: 0 4px;
  outline: none;
  overflow: hidden;
  white-space: nowrap;
}
.sig-typed:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  font-style: italic;
  font-family: -apple-system, sans-serif;
  font-size: 11px;
}
.sig-typed.active { background: rgba(255, 255, 255, 0.6); }

/* ===== Workflow canvas (drag-drop step graph) =================== */
.wf-canvas {
  position: relative;
  width: 100%;
  min-height: 520px;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 24px, rgba(0,0,0,0.04) 24px, rgba(0,0,0,0.04) 25px),
    repeating-linear-gradient(90deg, transparent, transparent 24px, rgba(0,0,0,0.04) 24px, rgba(0,0,0,0.04) 25px),
    #fafbfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  user-select: none;
}
.wf-canvas-toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 6px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(2px);
}
.wf-edges {
  position: absolute; inset: 0;
  pointer-events: none;
}
.wf-edges .wf-edge { pointer-events: stroke; }
.wf-edges .wf-edge:hover { stroke-width: 3.5; }

.wf-step {
  position: absolute;
  width: 200px;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  font-size: 13px;
}
.wf-step .wf-step-head {
  background: var(--accent-bg);
  padding: 6px 10px;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid var(--border);
  cursor: move;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wf-step .wf-step-body {
  padding: 8px 10px 12px;
}
.wf-step .wf-step-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  word-break: break-word;
}
.wf-step-actions {
  display: flex; gap: 4px;
  padding: 0 8px 8px;
  font-size: 11px;
}
.wf-step-actions a, .wf-step-actions button {
  font-size: 11px;
  padding: 2px 6px;
}

.wf-step-trigger    .wf-step-head { background: #ede9fe; color: #5b21b6; }
.wf-step-condition  .wf-step-head { background: #fef3c7; color: #92400e; }
.wf-step-llm_analyze .wf-step-head { background: #dcfce7; color: #14532d; }
.wf-step-action     .wf-step-head { background: #dbeafe; color: #1e3a8a; }

/* Connection ports — small circles on the card edges */
.wf-port {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--border-strong);
  cursor: crosshair;
  z-index: 2;
}
.wf-port-in {
  left: -8px; top: 50%;
  transform: translateY(-50%);
  border-color: #5a6fff;
}
.wf-port-out {
  right: -8px; top: 50%;
  transform: translateY(-50%);
  border-color: #5a6fff;
}
.wf-port-out-true {
  right: -8px; top: 35%;
  transform: translateY(-50%);
  border-color: #2a8a3a;
  font-size: 8px; line-height: 8px; color: #2a8a3a; text-align: center;
}
.wf-port-out-false {
  right: -8px; top: 70%;
  transform: translateY(-50%);
  border-color: #b03030;
  font-size: 8px; line-height: 8px; color: #b03030; text-align: center;
}
.wf-port:hover { transform: translateY(-50%) scale(1.25); }

/* ===== Workflow canvas shell (palette + viewport + edit panel) ==== */
.wf-canvas-card { padding: 0; overflow: hidden; }
.wf-canvas-shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  position: relative;
  height: 640px;
}
.wf-palette {
  border-right: 1px solid var(--border);
  background: #fbfbfd;
  padding: 10px;
  overflow: auto;
  user-select: none;
}
.wf-palette-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.wf-palette-item {
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 6px;
  cursor: grab;
  font-size: 12px;
  position: relative;
}
.wf-palette-item:active { cursor: grabbing; }
.wf-palette-item.wf-step-condition  { border-left: 3px solid #f59e0b; }
.wf-palette-item.wf-step-llm_analyze { border-left: 3px solid #16a34a; }
.wf-palette-item.wf-step-action     { border-left: 3px solid #3b82f6; }
.wf-palette-label { font-weight: 600; font-size: 12px; }
.wf-palette-hint  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.wf-palette-foot  { font-size: 10.5px; color: var(--muted); margin-top: 14px; line-height: 1.4; }

/* Floating ghost shown while dragging from palette */
.wf-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  background: white;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0.95;
}

/* Canvas viewport — clips and hosts the pannable "world" */
.wf-canvas {
  position: relative;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 24px, rgba(0,0,0,0.04) 24px, rgba(0,0,0,0.04) 25px),
    repeating-linear-gradient(90deg, transparent, transparent 24px, rgba(0,0,0,0.04) 24px, rgba(0,0,0,0.04) 25px),
    #fafbfd;
  cursor: grab;
  user-select: none;
}
.wf-canvas.is-panning { cursor: grabbing; }
.wf-canvas.is-drop-target { background-color: #eef2ff; }

.wf-world {
  position: absolute;
  top: 0; left: 0;
  width: 4000px;
  height: 3000px;
  transform-origin: 0 0;
}

/* Edge layer covers the world */
.wf-edges {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.wf-edges .wf-edge { pointer-events: stroke; }
.wf-edges .wf-edge:hover { stroke-width: 3.5; }

/* Step cards (used both in the world AND in palette previews) */
.wf-step {
  position: absolute;
  width: 200px;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  font-size: 13px;
  cursor: pointer;
}
.wf-step .wf-step-head {
  background: var(--accent-bg);
  padding: 6px 10px;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid var(--border);
  cursor: move;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wf-step .wf-step-body { padding: 8px 10px 10px; }
.wf-step .wf-step-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  word-break: break-word;
}
.wf-step.is-selected {
  outline: 2px solid #5a6fff;
  outline-offset: 2px;
}

.wf-step-trigger     .wf-step-head { background: #ede9fe; color: #5b21b6; }
.wf-step-condition   .wf-step-head { background: #fef3c7; color: #92400e; }
.wf-step-llm_analyze .wf-step-head { background: #dcfce7; color: #14532d; }
.wf-step-action      .wf-step-head { background: #dbeafe; color: #1e3a8a; }

/* Connection ports — circles on the card edges */
.wf-port {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--border-strong);
  cursor: crosshair;
  z-index: 2;
}
.wf-port-in        { left: -8px; top: 50%;  transform: translateY(-50%); border-color: #5a6fff; }
.wf-port-out       { right: -8px; top: 50%; transform: translateY(-50%); border-color: #5a6fff; }
.wf-port-out-true  { right: -8px; top: 35%; transform: translateY(-50%); border-color: #2a8a3a; font-size: 8px; line-height: 8px; color: #2a8a3a; text-align: center; }
.wf-port-out-false { right: -8px; top: 70%; transform: translateY(-50%); border-color: #b03030; font-size: 8px; line-height: 8px; color: #b03030; text-align: center; }
.wf-port:hover { transform: translateY(-50%) scale(1.3); }

/* Slide-out edit panel */
.wf-edit-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  background: white;
  border-left: 1px solid var(--border-strong);
  box-shadow: -4px 0 16px rgba(0,0,0,0.06);
  overflow: auto;
  z-index: 10;
}
.wf-edit-panel[hidden] { display: none; }
.wf-edit-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fbfbfd;
  position: sticky; top: 0;
}
.wf-edit-panel-body { padding: 12px 14px; }
.wf-edit-panel-body .card { box-shadow: none; padding: 8px 0; }
.wf-edit-panel-body .actions { display: flex; gap: 6px; }

/* ===== Wide layout opt-in (body.wide) ============================= */
body.wide .main-content { max-width: none; padding-right: 24px; }
body.wide .container    { max-width: none; }

/* ===== Workflow canvas — zoom toolbar + wider grid + wider panel ==== */
.wf-canvas-shell {
  grid-template-columns: 220px 1fr;
  height: calc(100vh - 240px);
  min-height: 560px;
}
.wf-canvas { position: relative; }

/* Zoom toolbar — floats over the canvas top-right */
.wf-zoom-bar {
  position: absolute;
  top: 10px; right: 14px;
  z-index: 6;
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.wf-zoom-bar button {
  width: 28px; height: 28px;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}
.wf-zoom-bar button:hover { background: var(--accent-bg); }
.wf-zoom-bar .wf-zoom-level {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 6px;
}

/* ===== Edit panel — wider + form formatting tweaks ================= */
.wf-edit-panel {
  width: 480px;
}
.wf-edit-panel-body .card {
  border: 0;
  padding: 10px 0;
  margin: 0 0 8px;
  background: transparent;
}
.wf-edit-panel-body .card + .card {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.wf-edit-panel-body h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.wf-edit-panel-body .field {
  margin-bottom: 10px;
}
.wf-edit-panel-body .field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 3px;
}
.wf-edit-panel-body .field input[type=text],
.wf-edit-panel-body .field input[type=email],
.wf-edit-panel-body .field input[type=number],
.wf-edit-panel-body .field select,
.wf-edit-panel-body .field textarea {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: white;
  box-sizing: border-box;
}
.wf-edit-panel-body .field textarea { font-family: inherit; resize: vertical; min-height: 60px; }
.wf-edit-panel-body .field p.muted   { margin: 4px 0 0; font-size: 11px; line-height: 1.4; }

/* Inside the panel, form-row stacks vertically (was a flex row designed
   for full-width pages). Override to stack so labels + inputs flow
   one per line. */
.wf-edit-panel-body .form-row {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.wf-edit-panel-body .form-row > .field {
  max-width: none !important;
  flex: 1 1 auto;
}
/* Exception: condition step's left/op/right row stays horizontal but
   sized to fit the narrower panel. */
.wf-edit-panel-body .condition-row {
  display: grid;
  grid-template-columns: 1fr 90px 1fr;
  gap: 8px;
}
.wf-edit-panel-body .condition-row .field { max-width: none; }

.wf-edit-panel-body .actions {
  display: flex;
  gap: 8px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}
.wf-edit-panel-body .actions input[type=submit],
.wf-edit-panel-body .actions .btn { padding: 6px 14px; }

/* Retry-policy disclosure inside panel */
.wf-edit-panel-body details summary {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

/* ===== Canvas "+ New workflow" button + modal ===================== */
.wf-new-workflow-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  justify-content: center;
  padding: 8px 10px;
  background: #7c3aed;
  color: white;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.wf-new-workflow-btn:hover { background: #6d28d9; }

.wf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wf-modal-overlay[hidden] { display: none; }
.wf-modal {
  width: min(560px, 92vw);
  max-height: 86vh;
  background: white;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wf-modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fbfbfd;
}
.wf-modal-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 12px 0;
  border-bottom: 1px solid var(--border);
  background: #fbfbfd;
}
.wf-tab {
  padding: 8px 14px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.wf-tab.is-active {
  color: #1e293b;
  border-bottom-color: #7c3aed;
}
.wf-modal-body {
  padding: 16px 18px 18px;
  overflow: auto;
}
.wf-modal-pane[hidden] { display: none; }
.wf-modal-body .field { margin-bottom: 12px; }
.wf-modal-body .field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}
.wf-modal-body .field input[type=text],
.wf-modal-body .field select,
.wf-modal-body .field textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-sizing: border-box;
  background: white;
  font-family: inherit;
}
.wf-modal-body textarea { resize: vertical; min-height: 70px; }
.wf-modal-actions {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ===== Tag chips ============================================== */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
}
.tag-chip:hover { background: #c7d2fe; }
.tag-chip-active {
  background: #4f46e5;
  color: white;
  border-color: #4338ca;
}
.tag-chip-active:hover { background: #4338ca; }
.tag-chip-sm {
  padding: 1px 7px;
  font-size: 11px;
  margin-right: 4px;
  margin-bottom: 2px;
}


/* ===== Compact table-row buttons (Edit / Remove / etc.) ============ */
.btn-row {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: white;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn-row:hover { background: #f1f5f9; text-decoration: none; }
.btn-row.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.btn-row.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-row.btn-danger {
  background: white;
  border-color: #fca5a5;
  color: #b91c1c;
}
.btn-row.btn-danger:hover { background: #fef2f2; border-color: #ef4444; color: #b91c1c; }
.btn-row.btn-success {
  background: white;
  border-color: #86efac;
  color: #166534;
}
.btn-row.btn-success:hover { background: #f0fdf4; border-color: #22c55e; }

/* Group of row buttons stays inline with even spacing */
.row-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}
.row-actions form { display: inline; margin: 0; }

/* ===== Nested contact cards on the org form ===================== */
.contact-card {
  background: #fafbfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px 6px;
  margin-bottom: 14px;
}
.contact-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.contact-card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.contact-card .form-row { gap: 12px; }
.contact-card .form-row + .form-row { margin-top: 4px; }
.contact-card .field { margin-bottom: 8px; flex: 1; min-width: 160px; }
.contact-card .field label {
  font-size: 11.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}
.contact-card .field input[type=text],
.contact-card .field input[type=email],
.contact-card .field input[type=tel] {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: white;
  box-sizing: border-box;
}

/* Bottom-anchored "+ Add another contact" button */
.contact-add-row {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}
