/* Kreta Software — Interactive SaaS Workspace Sandbox (Linear/Stripe + emil-design-eng + ui-ux-pro-max) */
:root {
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #efece6;
  --surface-hover: #e7e3da;
  --ink: #11181c;
  --ink-2: #2d3748;
  --muted: #5a6472;
  --border: #e4e0d7;
  --border-strong: #cfc9bc;
  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: #ecfdf5;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --ok-bg: #dcfce7;
  --ok-ink: #166534;
  --warn-bg: #fef3c7;
  --warn-ink: #92400e;
  --err-bg: #fee2e2;
  --err-ink: #991b1b;
  --chart-1: #059669;
  --chart-2: #4f46e5;
  --chart-3: #d97706;
  --chart-4: #e11d48;
  --radius: 14px;
  --radius-sm: 9px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow-sm: 0 2px 6px rgba(17, 24, 28, 0.05);
  --shadow-md: 0 12px 30px rgba(17, 24, 28, 0.09);
  --shadow-lg: 0 24px 52px rgba(17, 24, 28, 0.16);
  --font-sans: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.ws-topbar::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #059669 0%, #4f46e5 52%, #d97706 100%);
}

[data-theme="dark"] {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-2: #1a2234;
  --surface-hover: #222d44;
  --ink: #f8fafc;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --border: #243047;
  --border-strong: #334155;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.14);
  --accent: #14b8a6;
  --accent-soft: rgba(20, 184, 166, 0.14);
  --ok-bg: rgba(22, 163, 74, 0.18);
  --ok-ink: #86efac;
  --warn-bg: rgba(217, 119, 6, 0.2);
  --warn-ink: #fcd34d;
  --err-bg: rgba(220, 38, 38, 0.2);
  --err-ink: #fca5a5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: clip; font-family: var(--font-sans); background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Topbar */
.ws-topbar {
  position: sticky; top: 0; z-index: 40;
  min-height: 58px; padding: 8px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.ws-top-left, .ws-top-right { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-size: 0.84rem; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface);
  transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), transform 120ms var(--ease-out);
}
.back-link:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--ink); }
.back-link:active { transform: scale(0.97); }

.tb-select {
  height: 32px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 0.84rem; font-weight: 600; cursor: pointer;
  line-height: 30px; vertical-align: middle; max-width: 220px; text-overflow: ellipsis;
}
.tb-select:focus-visible, .btn:focus-visible, .nav-item:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

.seg-group { display: inline-flex; height: 32px; padding: 2px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.seg-btn {
  border: 0; background: transparent; color: var(--muted); font-family: inherit;
  font-size: 0.78rem; font-weight: 700; padding: 0 9px; border-radius: 6px; cursor: pointer;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  font-family: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: background-color 140ms var(--ease-out), transform 120ms var(--ease-out);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(0.97); }
.kbd-hint { font-family: var(--font-mono); font-size: 0.72rem; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.84rem; font-weight: 600; text-decoration: none;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap;
  transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), transform 120ms var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--err-bg); color: var(--err-ink); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 0.78rem; }

/* App Shell */
.ws-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.ws-sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px 12px; display: flex; flex-direction: column; gap: 12px;
  position: sticky; top: 58px; max-height: calc(100vh - 58px); overflow-y: auto;
}
.ws-brand-card {
  padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border);
}
.ws-brand-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; margin-bottom: 6px;
}
.ws-brand-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.ws-brand-name { font-size: 0.98rem; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.ws-brand-sub { font-size: 0.76rem; color: var(--muted); margin: 2px 0 0; }

.ws-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm); border: 0;
  background: transparent; color: var(--ink-2); font-family: inherit; font-size: 0.86rem; font-weight: 600;
  text-align: left; cursor: pointer;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.nav-item-left { display: inline-flex; align-items: center; gap: 9px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.nav-pill { font-size: 0.72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.nav-item[aria-current="page"] .nav-pill { background: var(--primary); color: #fff; }

.ws-side-footer {
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.own-chip {
  padding: 10px 11px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
  font-size: 0.77rem; color: var(--ink-2);
}
.own-chip strong { display: block; color: var(--ink); font-size: 0.84rem; margin-bottom: 2px; }

/* Main Workspace */
.ws-main { padding: 22px 26px 40px; max-width: 1320px; width: 100%; min-width: 0; margin: 0 auto; overflow-x: clip; }
.ws-view, .card, .table-wrap { min-width: 0; max-width: 100%; }
.ws-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.ws-header h1 { margin: 0; font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; }
.ws-header p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; max-width: 68ch; }
.ws-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Onboarding Tour Banner */
.tour-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius); background: var(--primary-soft); border: 1px solid var(--border);
  margin-bottom: 18px; font-size: 0.84rem;
}
.tour-steps { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tour-step {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 0.79rem; color: var(--ink-2);
}
.tour-step.done { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }

/* KPI Grid */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.kpi-val { font-size: 1.55rem; font-weight: 800; margin: 8px 0 4px; letter-spacing: -0.02em; }
.kpi-sub { font-size: 0.76rem; color: var(--muted); }
.kpi-sub.pos { color: var(--ok-ink); font-weight: 600; }
.kpi-sub.warn { color: var(--warn-ink); font-weight: 600; }

/* Cards & Charts */
.panel-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; margin-bottom: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.card-sub { font-size: 0.8rem; color: var(--muted); margin: 2px 0 0; }
.chart-box { position: relative; min-height: 210px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-bar-rect { cursor: pointer; transition: opacity 150ms var(--ease-out); }
.chart-bar-rect:hover { opacity: 0.82; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 0.78rem; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; }

/* Toolbar & Table */
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.search-input {
  height: 36px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 0.85rem; flex: 1 1 280px; max-width: 420px; min-width: 200px;
}
.filter-pills { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pill-btn {
  height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); font-family: inherit; font-size: 0.77rem; font-weight: 600; cursor: pointer;
}
.pill-btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th {
  text-align: left; padding: 10px 12px; background: var(--surface-2); color: var(--muted);
  font-size: 0.75rem; font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background-color 120ms var(--ease-out); }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: 0; }
.stage-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; white-space: nowrap;
}
.st-0 { background: var(--surface-2); color: var(--ink-2); }
.st-1 { background: var(--primary-soft); color: var(--primary); }
.st-2 { background: var(--warn-bg); color: var(--warn-ink); }
.st-3 { background: var(--ok-bg); color: var(--ok-ink); }

/* Kanban Board */
.kanban-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.kanban-col {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; min-height: 360px;
}
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 0.83rem; font-weight: 700; }
.kanban-cards { display: flex; flex-direction: column; gap: 9px; }
.k-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; box-shadow: var(--shadow-sm);
}
.k-card-title { font-weight: 700; font-size: 0.86rem; margin-bottom: 3px; }
.k-card-meta { font-size: 0.77rem; color: var(--muted); margin-bottom: 8px; }
.k-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); }

/* Audit & Architecture View */
.audit-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.audit-list { display: flex; flex-direction: column; gap: 10px; }
.audit-row {
  padding: 11px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
  font-size: 0.82rem;
}
.audit-hash { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); word-break: break-all; margin-top: 4px; }
.arch-list { display: grid; gap: 10px; }
.arch-item { padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.arch-item strong { display: block; font-size: 0.86rem; margin-bottom: 3px; }
.arch-item p { margin: 0; font-size: 0.8rem; color: var(--muted); }

/* Modal & Slide-over Drawer */
.backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(15, 23, 42, 0.48);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); padding: 20px 22px;
}
.modal-lg { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 1.12rem; font-weight: 800; }

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 75; background: rgba(15, 23, 42, 0.35);
  display: flex; justify-content: flex-end;
}
.drawer-backdrop[hidden] { display: none; }
.drawer {
  width: 100%; max-width: 420px; height: 100%; background: var(--surface);
  border-left: 1px solid var(--border); padding: 22px; overflow-y: auto; box-shadow: var(--shadow-lg);
}

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); }
.field input, .field select, .field textarea {
  height: 36px; padding: 0 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 0.87rem;
}
.field textarea { height: 74px; padding: 8px 11px; resize: vertical; }
.field-err { font-size: 0.77rem; color: var(--err-ink); font-weight: 600; min-height: 16px; }
.form-banner {
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.83rem; font-weight: 600;
  margin-bottom: 12px; display: none;
}
.form-banner.show { display: block; }
.form-banner.err { background: var(--err-bg); color: var(--err-ink); }
.form-banner.ok { background: var(--ok-bg); color: var(--ok-ink); }

/* ROI Box inside Modal */
.roi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.roi-summary {
  padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2); margin-bottom: 14px;
}
.roi-summary.positive { background: var(--ok-bg); border-color: transparent; color: var(--ok-ink); }
.roi-summary.advisory { background: var(--warn-bg); border-color: transparent; color: var(--warn-ink); }
.roi-big { font-size: 1.6rem; font-weight: 800; margin: 4px 0; }
.tier-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.tier-card {
  padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2);
}
.tier-card.featured { border-color: var(--primary); background: var(--primary-soft); }
.tier-card h4 { margin: 0 0 4px; font-size: 0.82rem; }
.tier-card .price { font-size: 1.15rem; font-weight: 800; }
.tier-card small { display: block; font-size: 0.74rem; color: var(--muted); margin-top: 3px; }

/* Command Palette (0ms open per emil-design-eng) */
.cmd-input { width: 100%; height: 42px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink); font-family: inherit; font-size: 0.94rem; margin-bottom: 10px; }
.cmd-list { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.cmd-item {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 9px 12px;
  border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--ink); font-family: inherit;
  font-size: 0.86rem; font-weight: 600; cursor: pointer; text-align: left;
}
.cmd-item:hover { background: var(--primary-soft); color: var(--primary); }

/* Toast */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 95;
  padding: 11px 16px; border-radius: var(--radius-sm); background: #0f172a; color: #ffffff;
  font-size: 0.85rem; font-weight: 600; box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Responsive */
.mobile-menu-btn { display: none; }
.sidebar-close-btn { display: none; }
.tour-bar-head { display: none; align-items: center; justify-content: space-between; width: 100%; gap: 8px; }
.tour-body { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; width: 100%; }
.tour-pill-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font-family: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.tour-dismiss-btn { width: 28px; height: 28px; font-size: 0.8rem; }
.webhook-preview {
  margin-top: 10px; padding: 12px; border-radius: var(--radius-sm);
  background: #0f172a; color: #e2e8f0; font-family: var(--font-mono); font-size: 0.74rem;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; border: 1px solid var(--border-strong);
}
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid, .audit-grid { grid-template-columns: 1fr; }
  .kanban-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  .ws-topbar { padding: 6px 10px; gap: 6px; }
  .ws-top-left, .ws-top-right { width: 100%; justify-content: space-between; gap: 6px; }
  .tb-select { flex: 1 1 120px; max-width: none; height: 34px; font-size: 0.82rem; }
  .kbd-hint { display: none; }
}
@media (max-width: 820px) {
  .mobile-menu-btn { display: inline-flex; }
  .sidebar-close-btn { display: inline-flex; width: 32px; height: 32px; flex-shrink: 0; }
  .ws-shell { grid-template-columns: 1fr; }
  .ws-sidebar { display: none; position: fixed; left: 0; top: 0; bottom: 0; width: 276px; max-height: 100vh; z-index: 65; box-shadow: var(--shadow-lg); padding-top: 14px; overflow-y: auto; }
  .ws-sidebar.open { display: flex; }
  .ws-main { padding: 10px 10px 28px; }
  .ws-header { gap: 8px; margin-bottom: 10px; }
  .ws-header h1 { font-size: 1.15rem; margin-bottom: 2px; }
  #ws-subtitle { display: block; font-size: 0.78rem; margin-top: 2px; }
  .ws-actions { width: 100%; display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 6px; padding-bottom: 2px; }
  .ws-actions .btn { flex: 0 0 auto; height: 34px; font-size: 0.76rem; padding: 0 10px; white-space: nowrap; }
  .kanban-grid, .tier-cards, .roi-grid, .form-grid { grid-template-columns: 1fr; }
  .search-input { max-width: 100%; width: 100%; }
  .back-link span { display: none; }
  #lbl-cmd { display: none; }
}
@media (max-width: 760px) {
  /* Compact collapsible onboarding checklist pill */
  .tour-banner { padding: 6px 10px; margin-bottom: 10px; flex-direction: column; align-items: stretch; gap: 8px; }
  .tour-bar-head { display: flex; }
  .tour-banner.is-collapsed-mobile .tour-body { display: none; }
  .tour-banner.is-dismissed { display: none !important; }
  /* Stacked mobile record cards (no 5-col table clipping on 390px) */
  table.mobile-cards thead { display: none; }
  table.mobile-cards, table.mobile-cards tbody, table.mobile-cards tr, table.mobile-cards td { display: block; width: 100%; }
  table.mobile-cards tbody { display: flex; flex-direction: column; gap: 10px; }
  table.mobile-cards tr {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px;
  }
  table.mobile-cards td {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 5px 0; border-bottom: 1px dashed var(--border); text-align: right; white-space: normal;
  }
  table.mobile-cards td:last-child { border-bottom: 0; padding-bottom: 0; }
  table.mobile-cards td::before {
    content: attr(data-label); font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); text-align: left; flex-shrink: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
@media print {
  .ws-topbar, .ws-sidebar, .ws-actions, .tour-banner, .toast { display: none !important; }
  .ws-shell { display: block; }
  .ws-main { padding: 0; }
}

/* Embedded Live App Mode (inside index.html Executive Modal) */
html[data-embed="1"] .ws-topbar { display: none !important; }
html[data-embed="1"] .ws-shell { min-height: 100vh; }
html[data-embed="1"] .ws-sidebar { top: 0; height: 100vh; width: 220px; }
html[data-embed="1"] .ws-main { padding: 18px 20px; }


/* v7 Studio-Grade Polish: Dark-Mode Contrast Fixes + Uniform Kanban Footers */
[data-theme="dark"] .tour-banner,
[data-theme="dark"] .tour-step {
  background: #1a2234 !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .tour-step.done {
  background: rgba(16, 185, 129, 0.2) !important;
  color: #6ee7b7 !important;
  border-color: rgba(16, 185, 129, 0.4) !important;
}
[data-theme="dark"] select,
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] #rbac-role,
[data-theme="dark"] #sla-threshold {
  background: #1e293b !important;
  color: #f8fafc !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .tour-banner button,
[data-theme="dark"] #btn-reset-demo {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #475569 !important;
}
.kb-col { min-height: 220px !important; }
.kb-card { display: flex; flex-direction: column; min-height: 142px; }
.kb-foot, .kb-actions { margin-top: auto; padding-top: 8px; }

/* v13 Clean Tools Popover Menu (Steve Jobs subtraction: 7 buttons -> 2) */
.tools-wrap { position: relative; display: inline-flex; }
.tools-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 80;
  min-width: 230px; padding: 6px; border-radius: var(--radius-md, 12px);
  background: var(--surface, #ffffff); border: 1px solid var(--border-strong, #cbd5e1);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  display: flex; flex-direction: column; gap: 2px;
}
.tools-menu[hidden] { display: none !important; }
.tools-item {
  width: 100%; text-align: left; padding: 8px 11px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink, #0f172a); font-family: inherit;
  font-size: 0.84rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.tools-item:hover, .tools-item:focus-visible {
  background: var(--primary-soft, #eff6ff); color: var(--primary, #1d4ed8); outline: none;
}
.tools-divider { height: 1px; background: var(--border, #e2e8f0); margin: 4px 6px; }
[data-theme="dark"] .tools-menu {
  background: #0f172a; border-color: #334155; box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}
[data-theme="dark"] .tools-item { color: #e2e8f0; }
[data-theme="dark"] .tools-item:hover { background: rgba(99, 102, 241, 0.18); color: #fff; }
[data-theme="dark"] .tools-divider { background: #334155; }
