/* =========================================================================
   QA Portal — design tokens
   Two themes: light pastel earth tone (default) and dark walnut earth tone.
   Toggle via `<html data-theme="dark">` (handled in js/app.js).
   ========================================================================= */
:root {
  /* LIGHT (default) — pastel earth tone */
  --bg:           #f5ecdb;
  --surface:      #fbf6ea;
  --surface-2:    #ece2cb;
  --surface-3:    #ddd0b3;
  --border:       #c9b88f;
  --border-soft:  #e3d8be;
  --text:         #4a3d2a;
  --text-muted:   #8a7a5c;
  --text-dim:     #b0a081;
  --accent:       #c89272;
  --accent-2:     #a16a47;
  --accent-soft:  rgba(200,146,114,0.18);
  --green:        #9eb079;
  --red:          #c8857a;
  --amber:        #d6b367;
  --purple:       #b78ba0;
  --gray:         #8a7a5c;
  --shadow-sm:    0 1px 2px  rgba(74,61,42,.08);
  --shadow:       0 4px 14px rgba(74,61,42,.12);
  --shadow-lg:    0 12px 28px rgba(74,61,42,.18);
  --overlay:      rgba(74,61,42,0.45);
  --code-color:   var(--accent-2);

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --sidebar-w:    240px;

  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Sarabun", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  --bg:           #1f1a14;
  --surface:      #2a241c;
  --surface-2:    #34291f;
  --surface-3:    #443629;
  --border:       #5a4938;
  --border-soft:  #3d3127;
  --text:         #f0e5d1;
  --text-muted:   #b0a08a;
  --text-dim:     #8a7d6b;
  --accent:       #d4a574;
  --accent-2:     #b78854;
  --accent-soft:  rgba(212,165,116,0.18);
  --green:        #a8c187;
  --red:          #db8d7d;
  --amber:        #e3c07a;
  --purple:       #c9a4b5;
  --gray:         #8a7d6b;
  --shadow-sm:    0 1px 2px  rgba(0,0,0,.3);
  --shadow:       0 4px 14px rgba(0,0,0,.25);
  --shadow-lg:    0 12px 28px rgba(0,0,0,.35);
  --overlay:      rgba(15,10,5,.75);
  --code-color:   #e3c07a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, monospace;
  color: var(--code-color);
}

/* =========================================================================
   App shell — sidebar + topbar + content
   ========================================================================= */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.sidebar-brand .logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: white;
  display: grid; place-items: center;
  font-weight: 700; letter-spacing: 0.5px;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.sidebar-brand .brand-name {
  font-size: 15px; font-weight: 600;
}
.sidebar-brand .brand-sub {
  font-size: 11px; color: var(--text-muted);
}

/* Workspace switcher — between brand and sidenav */
.ws-switcher {
  position: relative;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-soft);
}
.ws-current {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
}
.ws-current:hover { background: var(--surface-3); }
.ws-icon { font-size: 16px; }
.ws-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ws-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 600;
}
.ws-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-caret { color: var(--text-muted); font-size: 12px; }
.ws-menu {
  position: absolute;
  top: 100%; left: 8px; right: 8px;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 60;
  overflow: hidden;
}
.ws-menu.hidden { display: none; }
.ws-menu-list { padding: 4px; max-height: 240px; overflow-y: auto; }
.ws-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}
.ws-menu-item:hover { background: var(--surface-2); }
.ws-menu-item.active { color: var(--accent-2); font-weight: 600; }
.ws-menu-item .check { width: 14px; color: var(--accent-2); }
.ws-menu-footer {
  border-top: 1px solid var(--border-soft);
  padding: 6px;
}
.ws-new {
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 12px;
  text-align: left;
  cursor: not-allowed;
  border-radius: 4px;
  font-family: inherit;
}
.ws-new:not(:disabled) { color: var(--accent-2); cursor: pointer; }
.ws-new:not(:disabled):hover { background: var(--surface-2); }

/* Workspace settings — members list */
.ws-member-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  gap: 10px;
  flex-wrap: wrap;
}
.ws-member-row code { background: transparent; padding: 0; font-size: 12px; }
.ws-member-actions { display: flex; gap: 6px; align-items: center; }
.ws-member-actions select { padding: 4px 8px; font-size: 12px; }

.sidenav {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 2px;
  flex: 1;
}

.navitem {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.12s, background 0.12s;
  text-decoration: none;
}
.navitem .ico { font-size: 15px; width: 20px; text-align: center; }
.navitem:hover { color: var(--text); background: var(--surface-2); }
.navitem.active {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}
.navitem.disabled { opacity: 0.5; }
.navitem.disabled .ico { filter: grayscale(1); }
.navitem.ghost { color: var(--text-dim); }
.navitem .badge {
  margin-left: auto;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 22px; text-align: center;
}
.navitem.active .badge { background: var(--accent-2); color: white; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border-soft);
}
.status-strip {
  padding: 8px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex; flex-direction: column; gap: 4px;
}
.status { display: flex; align-items: center; gap: 6px; }
.status b { color: var(--text); font-weight: 600; }

/* =========================================================================
   Main layout (no topbar — projects are the navigation)
   ========================================================================= */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.iconbtn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
}
.iconbtn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }

.menu-toggle { display: none; }
.menu-toggle.floating {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 80;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
}

/* =========================================================================
   Project breadcrumb / sub-nav inside project-scoped views
   ========================================================================= */
.project-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.crumb-back {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.crumb-back:hover { color: var(--accent); text-decoration: none; }
.crumb-sep { color: var(--text-dim); }
.crumb-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.crumb-env {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-left: auto;
  margin-right: 0;
}
.crumb-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius-sm);
}
.crumb-tab {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
}
.crumb-tab:hover { color: var(--text); }
.crumb-tab.active {
  background: var(--accent-2);
  color: white;
}

/* =========================================================================
   Content area
   ========================================================================= */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.view { display: none; }
.view.active { display: block; animation: fadein 0.2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: baseline; gap: 12px; flex: 1; min-width: 0; }
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 20px; font-weight: 600; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hidden { display: none !important; }

/* =========================================================================
   Panels
   ========================================================================= */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.panel-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* =========================================================================
   Form fields
   ========================================================================= */
.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.field {
  display: flex; flex-direction: column; gap: 4px;
}
.field > span {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
input, select, textarea, .control {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface-3);
}
textarea {
  font-family: ui-monospace, monospace;
  min-height: 80px;
  resize: vertical;
  width: 100%;
}
input[type=search] { min-width: 220px; }
select.control, input.control { min-width: 130px; }

.checkbox, .radio {
  display: flex; align-items: center; gap: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.checkbox input, .radio input { width: auto; padding: 0; }

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-3); border-color: var(--gray); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: white;
}
.btn.primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.btn.danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.btn.danger:hover { background: var(--red); color: white; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }

/* =========================================================================
   Cards / stats
   ========================================================================= */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--gray);
}
.stat.green::before  { background: var(--green); }
.stat.red::before    { background: var(--red); }
.stat.amber::before  { background: var(--amber); }
.stat.gray::before   { background: var(--gray); }
.stat.accent::before { background: var(--accent); }
.stat .label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.stat .value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.stat .delta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* =========================================================================
   Charts (bar progress)
   ========================================================================= */
.bar-chart { display: grid; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 70px;
  gap: 12px; align-items: center;
}
.bar-row .label { color: var(--text-muted); font-size: 12px; }
.bar-row .value { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.bar-outer {
  background: var(--surface-2);
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
}
.bar-outer span { display: block; height: 100%; }
.bar-passed { background: var(--green); }
.bar-failed { background: var(--red); }
.bar-skip   { background: var(--amber); }
.bar-notest { background: var(--gray); }

#feature-progress .row {
  display: grid;
  grid-template-columns: 200px 1fr 220px;
  gap: 12px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
#feature-progress .row:last-child { border-bottom: 0; }
#feature-progress .legend {
  font-size: 11px; color: var(--text-muted);
  display: flex; gap: 10px; justify-content: flex-end;
}
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.dot.green { background: var(--green); }
.dot.red   { background: var(--red); }
.dot.amber { background: var(--amber); }
.dot.gray  { background: var(--gray); }
.dot.blue  { background: var(--accent); }

/* =========================================================================
   Table
   ========================================================================= */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
tbody tr:hover { background: rgba(68,147,248,.05); }
tbody tr:last-child td { border-bottom: 0; }
.scenario-cell {
  max-width: 380px;
  white-space: pre-wrap;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.45;
}
.id-cell {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.pill-passed     { background: rgba(158,176,121,.25); color: #5a6e3a; }
.pill-failed     { background: rgba(200,133,122,.25); color: #8a3e35; }
.pill-skip       { background: rgba(214,179,103,.30); color: #7a5c1f; }
.pill-nottest    { background: rgba(138,122,92,.20);  color: #5a4f3a; }
.pill-must       { background: rgba(200,133,122,.20); color: #8a3e35; }
.pill-should     { background: rgba(214,179,103,.25); color: #7a5c1f; }
.pill-could      { background: rgba(138,122,92,.18);  color: #5a4f3a; }
.pill-frontend   { background: rgba(200,146,114,.22); color: #7a4828; }
.pill-backend    { background: rgba(183,139,160,.28); color: #6a3b54; }
.pill-integration{ background: rgba(158,176,121,.25); color: #5a6e3a; }
.pill-local      { background: rgba(138,122,92,.20);  color: #5a4f3a; }
.pill-firebase   { background: rgba(214,179,103,.30); color: #7a5c1f; }
.pill-gdrive     { background: rgba(158,176,121,.25); color: #5a6e3a; }
.pill-onedrive   { background: rgba(200,146,114,.22); color: #7a4828; }
.pill-api        { background: rgba(183,139,160,.28); color: #6a3b54; }

/* Dark-theme pill overrides — lighter text for legibility on dark bg. */
:root[data-theme="dark"] .pill-passed     { color: #c5d9a6; }
:root[data-theme="dark"] .pill-failed     { color: #ecaca0; }
:root[data-theme="dark"] .pill-skip       { color: #ecc878; }
:root[data-theme="dark"] .pill-nottest    { color: #d4c5ad; }
:root[data-theme="dark"] .pill-must       { color: #ecaca0; }
:root[data-theme="dark"] .pill-should     { color: #ecc878; }
:root[data-theme="dark"] .pill-could      { color: #d4c5ad; }
:root[data-theme="dark"] .pill-frontend   { color: #e5c69b; }
:root[data-theme="dark"] .pill-backend    { color: #d4adba; }
:root[data-theme="dark"] .pill-integration{ color: #c5d9a6; }
:root[data-theme="dark"] .pill-local      { color: #d4c5ad; }
:root[data-theme="dark"] .pill-firebase   { color: #ecc878; }
:root[data-theme="dark"] .pill-gdrive     { color: #c5d9a6; }
:root[data-theme="dark"] .pill-onedrive   { color: #e5c69b; }
:root[data-theme="dark"] .pill-api        { color: #d4adba; }

.pagination {
  display: flex; gap: 6px;
  padding: 14px 0;
  justify-content: center;
}
.pagination button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}
.pagination button.active {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: white;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* =========================================================================
   Quick filter chips
   ========================================================================= */
.quick-filters {
  display: flex; gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12.5px;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-2); }

/* =========================================================================
   Modal
   ========================================================================= */
.modal {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 200; padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(860px, 100%);
  max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal-card header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-card header h2 { margin: 0; font-size: 16px; font-weight: 600; }
#tc-form { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
#tc-form .actions { justify-content: flex-end; }

/* =========================================================================
   Dropzone
   ========================================================================= */
.dropzone {
  border: 2px dashed var(--border);
  padding: 28px 20px;
  border-radius: var(--radius-lg);
  text-align: center;
  background: var(--surface-2);
  margin-bottom: 12px;
  transition: border-color 0.12s, background 0.12s;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone .drop-icon { font-size: 32px; margin-bottom: 6px; }
.dropzone strong { font-size: 14px; }
.dropzone .hint { margin-top: 6px; }
.import-options {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: 13px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

/* =========================================================================
   Onboarding (welcome card)
   ========================================================================= */
.onboarding {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.onboarding.hidden { display: none; }
.onboarding-head h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.onboarding-steps {
  list-style: none; padding: 0; margin: 18px 0 0;
  display: grid; gap: 12px;
}
.onboarding-steps li {
  display: flex; gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  align-items: flex-start;
}
.onboarding-steps li.done {
  border-color: rgba(63,185,80,.4);
  background: rgba(63,185,80,.05);
}
.ob-num {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-muted);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.onboarding-steps li.done .ob-num {
  background: var(--green);
  color: white;
}
.onboarding-steps li.done .ob-num::before { content: '✓'; }
.onboarding-steps li.done .ob-num span,
.onboarding-steps li.done .ob-num { font-size: 14px; }
.onboarding-steps li.done .ob-num { color: white; }
.ob-body { flex: 1; }
.ob-body h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.ob-body p { margin: 0 0 8px; }
.ob-body .btn { margin-right: 6px; }

/* =========================================================================
   Subtabs (inside Projects editor)
   ========================================================================= */
.subtabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin: 12px 0 18px;
  flex-wrap: wrap;
}
.subtab {
  background: transparent;
  color: var(--text-muted);
  border: 0;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.subtab:hover { color: var(--text); }
.subtab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.subpane { display: none; padding: 4px 0 8px; }
.subpane.active { display: block; }

.provider-section {
  padding: 14px 0 0;
  border-top: 1px dashed var(--border);
  margin-top: 14px;
}
.provider-section.hidden { display: none; }
.provider-section h3 { font-size: 13px; margin: 0 0 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

#env-list, #db-list { display: grid; gap: 8px; margin: 10px 0; }
.env-row, .db-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1.5fr auto;
  gap: 10px; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.env-row .name, .db-row .name { font-weight: 600; }
.env-row .meta, .db-row .meta { color: var(--text-muted); font-size: 12px; word-break: break-all; }

.db-form {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

/* =========================================================================
   Project list cards
   ========================================================================= */
.proj-list { display: grid; gap: 10px; margin-bottom: 16px; }
.proj-card {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.proj-card:hover { border-color: var(--accent); }
.proj-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.proj-name { font-weight: 600; font-size: 14px; }
.proj-meta { color: var(--text-muted); font-size: 12px; display: flex; gap: 14px; margin-top: 4px; flex-wrap: wrap; }
.proj-card .actions { margin: 0; }

/* =========================================================================
   Log / pre
   ========================================================================= */
.log {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  min-height: 100px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--text);
}
pre.code-block {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  overflow: auto;
  color: var(--text);
  margin: 8px 0 0;
}

/* =========================================================================
   Quick mark area in Automation
   ========================================================================= */
.quick-mark {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center;
  padding: 12px 14px;
  margin: 14px 0;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.quick-mark .hint { margin: 0; flex: 1; min-width: 200px; }

/* =========================================================================
   Help / details
   ========================================================================= */
details.info {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 12px;
  font-size: 13px;
}
details.info summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
}
details.info[open] summary { color: var(--text); margin-bottom: 6px; }

.endpoint-list {
  list-style: none; padding: 0; margin: 0;
  font-size: 13px; line-height: 1.9;
}
.endpoint-list li { padding: 2px 0; }

.hint {
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 4px 0 12px;
  line-height: 1.55;
}

/* =========================================================================
   View lock (no active project → blocks access)
   ========================================================================= */
.view-lock { display: none; }
.view.locked > .view-lock {
  display: grid;
  place-items: center;
  padding: 60px 20px;
  min-height: 50vh;
}
.view.locked > *:not(.view-lock) { display: none !important; }
.lock-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  max-width: 460px;
  text-align: center;
  box-shadow: var(--shadow);
}
.lock-card h2 { margin: 12px 0 6px; font-size: 18px; }
.lock-card .hint { margin: 0 0 18px; font-size: 13px; }
.lock-card .btn { padding: 10px 18px; font-size: 14px; }
.lock-icon {
  font-size: 48px;
  display: inline-block;
  filter: grayscale(0.2);
}

/* =========================================================================
   Test Cases workspace — folder tree + card grid
   ========================================================================= */
.tc-workspace {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) { .tc-workspace { grid-template-columns: 1fr; } }

.folder-tree {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 10px 8px;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.folder-tree-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px 8px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.folder-tree-head .iconbtn {
  padding: 2px 8px;
  font-size: 16px;
  line-height: 1;
}
.folder-tree-body {
  display: flex; flex-direction: column;
  gap: 1px;
  font-size: 13px;
}
.tree-node {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  position: relative;
}
.tree-node .ficon { flex-shrink: 0; }
.tree-node .node-actions {
  display: none;
  margin-left: auto;
  gap: 2px;
}
.tree-node:hover .node-actions { display: flex; }
.node-actions .iconmini {
  background: transparent;
  border: 0;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-dim);
}
.node-actions .iconmini:hover { background: var(--surface-3); color: var(--text); }
.tree-node.editing { background: var(--surface-2); }
.tree-node .inline-edit {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 13px;
  font-family: inherit;
  min-width: 60px;
  outline: none;
}
.tree-node:hover { background: var(--surface-2); color: var(--text); }
.tree-node.active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}
.tree-node .twisty {
  width: 14px; flex-shrink: 0;
  font-size: 10px;
  color: var(--text-dim);
  cursor: pointer;
}
.tree-node .twisty.empty { visibility: hidden; }
.tree-node .label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-node .count {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.tree-node.active .count { color: var(--accent); }
.tree-children { padding-left: 12px; display: flex; flex-direction: column; gap: 1px; }
.tree-children.collapsed { display: none; }

/* =========================================================================
   Test Case cards
   ========================================================================= */
.tc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.tc-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.1s;
}
.tc-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.tc-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.tc-card-id {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.tc-card-feature {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.tc-card-folder {
  font-size: 11px;
  color: var(--text-dim);
}
.tc-card-fn {
  font-size: 12px;
  color: var(--text-muted);
}
.tc-card-scenario {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}
.tc-card-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.tc-card-meta .pill { margin: 0; }
.tc-card-actions {
  display: flex; gap: 4px;
  margin-top: 4px;
}
.tc-card-actions .btn { padding: 4px 10px; font-size: 12px; }

/* Empty-state CTA for the Projects view */
.proj-empty {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.proj-empty-icon { font-size: 48px; margin-bottom: 4px; }
.proj-empty h3 { margin: 0; font-size: 16px; font-weight: 600; }
.proj-empty .hint { margin: 0 0 14px; max-width: 420px; }
.proj-empty .btn { padding: 10px 18px; font-size: 14px; }

.tc-empty {
  grid-column: 1 / -1;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius);
}

/* =========================================================================
   Banner (migration / info)
   ========================================================================= */
.banner {
  background: linear-gradient(135deg, rgba(68,147,248,.15), rgba(188,140,255,.10));
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.banner.hidden { display: none; }
.banner-body { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 280px; }
.banner-icon { font-size: 28px; }
.banner-actions { display: flex; gap: 8px; }
.banner strong { color: var(--text); }
.banner b { color: var(--accent); }

/* =========================================================================
   Toast
   ========================================================================= */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 300;
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 380px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }

/* =========================================================================
   Scrollbars (subtle)
   ========================================================================= */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--gray); }

/* =========================================================================
   Backwards-compatible filter bar
   ========================================================================= */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 12px;
}

/* =========================================================================
   Mobile responsive — tablet (<900px) + phone (<640px)
   ========================================================================= */
@media (max-width: 640px) {
  .content { padding: 16px 12px; }
  .toolbar { gap: 8px; }
  .toolbar-right { width: 100%; justify-content: flex-start; }
  .toolbar-right .control,
  .toolbar-right input[type="search"] { width: 100%; min-width: 0; flex: 1 1 140px; }

  .page-title { font-size: 18px; }

  /* Project breadcrumb stacks: back+name on one row, tabs scroll horizontally */
  .project-bar { padding: 8px 10px; gap: 6px; }
  .crumb-env { width: 100%; margin: 4px 0 0; }
  .crumb-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
    margin-top: 6px;
  }
  .crumb-tab { white-space: nowrap; flex-shrink: 0; padding: 6px 10px; font-size: 12px; }

  /* Test cases workspace: tree collapses above grid */
  .tc-workspace { gap: 10px; }
  .folder-tree {
    position: static;
    max-height: 240px;
  }

  /* Card grid: smaller min width for single column on narrow phones */
  .tc-grid { grid-template-columns: 1fr; gap: 10px; }
  .tc-card { padding: 12px 14px; }
  .tc-card-actions .btn { flex: 1; justify-content: center; }

  /* Modal — fill the screen on phones */
  .modal { padding: 0; }
  .modal-card {
    width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; border: 0;
  }
  #tc-form { padding: 14px; }
  #tc-form .row { grid-template-columns: 1fr; }

  /* Project cards stack */
  .proj-card { flex-direction: column; align-items: stretch; gap: 10px; }
  .proj-card .actions { justify-content: flex-start; flex-wrap: wrap; }
  .proj-card .actions .btn { flex: 1 0 auto; }

  /* Sidebar slides almost full-width on phone */
  .sidebar { width: min(280px, 86vw); }

  /* Floating hamburger should not overlap content */
  .menu-toggle.floating { top: 8px; left: 8px; }

  /* Stat cards: 2 columns max */
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 22px; }

  /* Form rows in subpanes also collapse */
  .subpane .row { grid-template-columns: 1fr; }

  /* Bar chart label column shrinks */
  .bar-row { grid-template-columns: 100px 1fr 50px; gap: 8px; }
  #feature-progress .row { grid-template-columns: 1fr; gap: 6px; }
  #feature-progress .legend { justify-content: flex-start; }

  /* Buttons need bigger touch targets */
  .btn { padding: 9px 14px; min-height: 36px; }
  .iconbtn { min-height: 36px; min-width: 36px; }

  /* Tables fall back to horizontal scroll */
  .table-wrap { font-size: 12px; }

  /* Banner buttons wrap nicely */
  .banner { padding: 12px; }
  .banner-actions .btn { flex: 1; }

  /* Filter bar wraps + chips wrap */
  .filter-bar { gap: 6px; }
  .quick-filters { gap: 4px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .chip { white-space: nowrap; flex-shrink: 0; }
}

@media (max-width: 900px) {
  /* Test cases workspace switches to stacked (tree on top) at tablet too */
  .tc-workspace { grid-template-columns: 1fr; }
  .folder-tree {
    position: static;
    max-height: 280px;
  }
  /* Topbar already removed; the floating hamburger handles nav. */
}
