/**
 * Twenty-inspired design system (twenty-ui light theme approximations)
 * Spacing: 4px grid · Radius: 4–8px · Font: Inter · Accent: indigo
 */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #fbfbfb;
  --bg-tertiary: #f1f1f1;
  --bg-quaternary: #ebebeb;
  --bg-page: #fafafa;

  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --text-light: #b3b3b3;

  --border-light: #f1f1f1;
  --border-medium: #ebebeb;
  --border-strong: #d6d6d6;

  --accent: #3e63dd;
  --accent-hover: #3a5ccc;
  --accent-soft: #edf2ff;
  --accent-border: #c5d0ff;

  --success: #30a46c;
  --success-soft: #e9f9ee;
  --warn: #e2a336;
  --warn-soft: #fff7e8;
  --danger: #e5484d;
  --danger-soft: #ffeff0;

  --drawer-width: 220px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --shadow-light: 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease: background 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.15s ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text-primary);
  background: var(--bg-page);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, a { font: inherit; }

.app {
  display: grid;
  grid-template-columns: var(--drawer-width) 1fr;
  min-height: 100vh;
}

/* ——— Navigation drawer (Twenty left rail) ——— */
.nav-drawer {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 8px 12px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-medium);
  z-index: 20;
}

.workspace-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  cursor: default;
  text-align: left;
  transition: var(--ease);
}

.workspace-chip:hover {
  background: var(--bg-tertiary);
}

.workspace-mark {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.workspace-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.workspace-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-plan {
  font-size: 11px;
  color: var(--text-tertiary);
}

.chev {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 4px;
}

.nav-label {
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--ease);
}

.nav-item svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.nav-item:hover:not(.is-disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active svg {
  color: var(--text-primary);
}

.nav-item.is-disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.nav-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.nav-footer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

/* ——— Page ——— */
.page {
  min-width: 0;
  padding: 16px 24px 40px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 16px;
  animation: fade-up 0.35s ease both;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.breadcrumb .sep { color: var(--text-light); }
.breadcrumb .current { color: var(--text-secondary); font-weight: 500; }

.top-bar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-sub {
  margin: 6px 0 0;
  max-width: 56ch;
  color: var(--text-secondary);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Chips / status — Twenty tag-like */
.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.chip.live {
  color: var(--success);
  background: var(--success-soft);
  border-color: transparent;
}

.chip.warn {
  color: #9a6700;
  background: var(--warn-soft);
  border-color: transparent;
}

.chip.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}

/* Buttons */
.btn {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--ease);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-light);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--text-light);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Record fields row — Twenty show page properties */
.record-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  animation: fade-up 0.4s ease 0.04s both;
}

.field-cell {
  padding: 10px 12px;
  border-right: 1px solid var(--border-light);
  min-width: 0;
  transition: background 0.1s ease;
}

.field-cell:last-child { border-right: 0; }

.field-cell:hover {
  background: var(--bg-secondary);
}

.field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.field-value {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

/* Content grid */
.page-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  align-items: start;
  animation: fade-up 0.45s ease 0.08s both;
}

.col-side, .col-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 4px 0 8px;
  box-shadow: var(--shadow-light);
}

.panel-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px 6px;
}

.panel-h h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.mono, .hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.pipeline {
  list-style: none;
  margin: 0;
  padding: 0 4px 4px;
}

.pipeline li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  margin: 0 4px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: var(--ease);
}

.step-index {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
  width: 18px;
}

.pipeline li.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.pipeline li.active .step-index {
  color: var(--accent);
}

.pipeline li.done {
  color: var(--text-primary);
}

.pipeline li.done .step-index {
  color: var(--success);
}

.pipeline li.fail {
  color: var(--danger);
  background: var(--danger-soft);
}

.prop-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
}

.prop-row span {
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 12px;
}

.prop-row strong {
  font-weight: 500;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.panel-hint {
  margin: 4px 12px 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  color: var(--text-tertiary);
  font-size: 12px;
}

.panel-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 3px;
}

#qaStatus.ok { color: var(--success); }
#qaStatus.bad { color: var(--danger); }

/* Activity / transcript */
.transcript-panel {
  min-height: 560px;
  display: flex;
  flex-direction: column;
}

.transcript {
  list-style: none;
  margin: 0;
  padding: 0 4px 8px;
  max-height: 620px;
  overflow: auto;
  flex: 1;
}

.transcript:not(:empty) + .transcript-empty {
  display: none;
}

.transcript-empty {
  margin: 24px 16px 32px;
  padding: 28px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}

.transcript li {
  padding: 10px 12px;
  margin: 0 4px 2px;
  border-radius: var(--radius-sm);
  transition: background 0.1s ease;
  animation: row-in 0.22s ease both;
}

.transcript li:hover {
  background: var(--bg-secondary);
}

.transcript .who {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  margin-bottom: 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.transcript .bot .who {
  color: var(--accent);
  background: var(--accent-soft);
}

.transcript .you .who {
  color: var(--text-primary);
  background: var(--bg-quaternary);
}

.transcript .sys {
  color: #9a6700;
  font-size: 12px;
}

.transcript .sys .who {
  color: #9a6700;
  background: var(--warn-soft);
}

.transcript li > div {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes row-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .nav-drawer { display: none; }
  .page-grid, .record-board { grid-template-columns: 1fr; }
  .field-cell { border-right: 0; border-bottom: 1px solid var(--border-light); }
  .top-bar { flex-direction: column; }
  .page { padding: 16px; }
}

