/* Workspace — 3-panel VS Code-style layout */

/* --- Tab Bar --- */
.tab-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 12px;
  background: rgba(7, 12, 23, 0.7);
  border-bottom: 1px solid var(--line);
  min-height: 36px;
  overflow-x: auto;
}
.tab-bar .tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab-bar .tab:hover { color: var(--text); }
.tab-bar .tab:focus-visible { outline: none; box-shadow: inset 0 -2px 0 var(--brand); }
.tab-bar .tab.active {
  color: var(--text);
  border-bottom-color: var(--brand);
}
.tab-bar .tab .tab-close {
  font-size: 0.7rem;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
}
.tab-bar .tab .tab-close:hover { color: var(--text); background: rgba(255,255,255,0.1); }
.tab-bar .tab-add {
  padding: 7px 12px;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}
.tab-bar .tab-add:hover { color: var(--text); }

/* --- Workspace Grid --- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: calc(100vh - 36px - 50px); /* viewport - tab bar - header */
  overflow: hidden;
  transition: grid-template-columns 0.2s ease;
}
.workspace.chat-open {
  grid-template-columns: minmax(0, 1fr) 380px;
}

/* --- Center Panel --- */
.workspace-center {
  overflow-y: auto;
  padding: 20px 24px;
}
.workspace-center .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.workspace-center .panel h2 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Stats panel styles (extracted from app.html) */
.ws-app-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ws-app-header .status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ws-app-header h1 { font-size: 1.4rem; font-weight: 700; }
.ws-app-header .meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ws-site-links { display: flex; gap: 8px; }
.ws-site-link {
  color: var(--brand);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: nowrap;
}
.ws-site-link:hover { border-color: var(--brand); }
.ws-site-link:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(74,168,255,0.4); }

.ws-app-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ws-archive-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s;
}
.ws-archive-btn:hover {
  color: var(--text);
  border-color: rgba(159,177,209,0.4);
  background: rgba(255,255,255,0.05);
}
.ws-archive-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.ws-grafana-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.ws-grafana-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.ws-grafana-panel iframe { width: 100%; height: 280px; border: none; }
.ws-grafana-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 280px;
  color: var(--muted);
  font-size: 0.85rem;
}

.ws-chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ws-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.ws-chart-card {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ws-chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ws-chart-title {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.ws-chart-trend {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}
.ws-chart-value {
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 800;
}
.ws-chart-spark {
  width: 100%;
  height: 56px;
  margin-top: auto;
}
.ws-chart-empty-line {
  height: 56px;
  border-bottom: 1px solid var(--line);
  opacity: 0.6;
}
.ws-chart-placeholder {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 20px 0;
  text-align: center;
}

.ws-crd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ws-crd-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  transition: border-color 0.15s, transform 0.15s;
}
.ws-crd-card:hover {
  border-color: rgba(74,168,255,0.25);
  transform: translateY(-1px);
}
.ws-crd-card h3 { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.03em; }
.ws-crd-field { display: flex; justify-content: space-between; padding: 3px 0; font-size: 0.82rem; }
.ws-crd-field .label { color: var(--muted); }
.ws-crd-field .value { font-weight: 600; }

/* Ops panel */
.ws-ops-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

/* --- Chat Panel (right) --- */
.chat-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: rgba(7, 12, 23, 0.5);
  overflow: hidden;
}
.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.chat-panel-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}
.chat-panel-header .cp-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.chat-panel-header .cp-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}
.chat-panel-header .cp-btn:hover { color: var(--text); border-color: var(--muted); }
.cp-session-select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 2px 4px;
  border-radius: 4px;
  max-width: 140px;
  cursor: pointer;
}
.cp-session-select:focus { border-color: var(--brand); outline: none; }

.chat-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-panel-messages .chat-msg {
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 95%;
  word-wrap: break-word;
}
.chat-panel-messages .chat-msg.user {
  background: var(--brand);
  color: #0a1323;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-panel-messages .chat-msg.assistant {
  background: var(--panel);
  border: 1px solid var(--line);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-panel-messages .chat-msg pre {
  background: #0a1323;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  overflow-x: auto;
  margin: 6px 0;
  font-size: 0.78rem;
}
.chat-panel-messages .chat-msg code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.8rem;
}
.chat-panel-messages .chat-msg pre code {
  background: none;
  padding: 0;
}
.chat-panel-messages .tool-badge {
  display: inline-block;
  background: rgba(53, 196, 111, 0.15);
  color: var(--good);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  margin: 3px 3px 0 0;
}
.chat-panel-messages .tool-badge-fail {
  background: rgba(255, 107, 107, 0.15);
  color: var(--bad);
}

.chat-panel-input {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.chat-panel-input input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
}
.chat-panel-input input:focus { border-color: var(--brand); }
.chat-panel-input button {
  background: var(--brand);
  color: #0a1323;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.chat-panel-input button:hover { opacity: 0.9; }
.chat-panel-input button:disabled { opacity: 0.5; cursor: default; }

/* --- Flags panel (rich toggle) --- */
.ws-flags-grid { display: flex; flex-direction: column; gap: 12px; }
.ws-flag-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s;
}
.ws-flag-card:hover { border-color: rgba(74,168,255,0.25); }
.ws-flag-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ws-flag-name { font-size: 0.95rem; font-weight: 700; }
.ws-flag-status { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 4px; }
.ws-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.ws-switch input { opacity: 0; width: 0; height: 0; }
.ws-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #33425d;
  transition: 0.2s;
  border-radius: 999px;
}
.ws-slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; top: 3px;
  background-color: #f1f5ff;
  transition: 0.2s;
  border-radius: 50%;
}
.ws-switch input:checked + .ws-slider { background: var(--good); }
.ws-switch input:checked + .ws-slider:before { transform: translateX(20px); }
.ws-metadata-input {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1728;
  color: var(--text);
  padding: 8px;
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  resize: vertical;
}
.ws-flag-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ws-flag-actions button { width: auto; padding: 6px 16px; font-size: 0.8rem; }
.ws-flag-actions .ws-flag-result { font-size: 0.78rem; }
.ws-meta-label { color: var(--muted); font-size: 0.78rem; }

/* --- Ticket create form --- */
.ws-ticket-form { display: flex; flex-direction: column; gap: 10px; }
.ws-ticket-form-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.ws-ticket-form label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.ws-ticket-form input,
.ws-ticket-form select {
  width: 100%;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
}
.ws-ticket-form button { width: auto; padding: 8px 20px; }

/* --- Specs panel --- */
.ws-specs-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 500px;
}
.ws-specs-sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 12px 0;
  overflow-y: auto;
}
.ws-specs-sidebar h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 12px;
  margin-bottom: 8px;
}
.ws-spec-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.ws-spec-item:hover { background: rgba(255,255,255,0.04); }
.ws-spec-item.active { background: rgba(74,168,255,0.08); border-left-color: var(--brand); }
.ws-spec-item .name { font-size: 0.82rem; font-weight: 600; flex: 1; }
.ws-spec-icon {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem;
}
.ws-spec-num {
  width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700; color: var(--muted);
  background: rgba(255,255,255,0.06); border: 1px solid var(--line);
}
.ws-spec-item.active .ws-spec-num { background: rgba(74,168,255,0.15); color: var(--brand); border-color: var(--brand); }
.ws-spec-item .tier {
  font-size: 0.62rem;
  padding: 1px 5px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.ws-specs-content { padding: 16px; overflow-y: auto; }
.ws-specs-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 0.9rem;
}
/* Spec header + body */
.ws-spec-header { padding: 0 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.ws-spec-body h2 { font-size: 1.1rem; font-weight: 700; margin: 20px 0 8px; }
.ws-spec-body h2:first-child { margin-top: 0; }
.ws-spec-body h3 { font-size: 0.88rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin: 16px 0 6px; }
.ws-spec-body p { font-size: 0.88rem; line-height: 1.6; margin-bottom: 6px; }
.ws-spec-body ul { padding-left: 18px; margin: 4px 0 10px; }
.ws-spec-body li { font-size: 0.85rem; line-height: 1.6; margin-bottom: 2px; }
.ws-spec-body code { background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 3px; font-size: 0.82rem; }
.ws-spec-body pre { background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 8px 0; overflow-x: auto; }
.ws-spec-body pre code { background: none; padding: 0; font-size: 0.8rem; line-height: 1.5; }
.ws-spec-body strong { color: var(--text); }
.ws-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--muted);
  margin-right: 4px;
  margin-bottom: 4px;
}
.ws-chip.brand { border-color: var(--brand); color: var(--brand); }
.ws-chip.good { border-color: var(--good); color: var(--good); }
.ws-chip.warn { border-color: var(--warn); color: var(--warn); }
/* Spec toolbar */
.ws-spec-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 0 10px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.ws-spec-edit-btn, .ws-spec-save-btn, .ws-spec-cancel-btn {
  padding: 4px 12px; border-radius: 6px; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  transition: background 0.1s;
}
.ws-spec-edit-btn:hover, .ws-spec-cancel-btn:hover { background: rgba(255,255,255,0.08); }
.ws-spec-save-btn { background: var(--brand); color: #fff; border-color: var(--brand); }
.ws-spec-save-btn:hover { opacity: 0.9; }
.ws-spec-save-btn:disabled { opacity: 0.5; cursor: default; }
/* Spec editor */
.ws-spec-editor {
  width: 100%; min-height: 400px; padding: 12px;
  font-family: ui-monospace, "SF Mono", monospace; font-size: 0.82rem; line-height: 1.6;
  background: rgba(0,0,0,0.25); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  resize: vertical; tab-size: 2;
}
.ws-spec-editor:focus { outline: none; border-color: var(--brand); }
/* Checkbox items */
.ws-spec-check { list-style: none; margin-left: -18px; padding-left: 0; }
.ws-spec-check::before { content: '\u2610 '; color: var(--muted); }
.ws-spec-check.done::before { content: '\u2611 '; color: var(--good); }
.ws-spec-check.done { text-decoration: line-through; color: var(--muted); }
/* Table rows */
.ws-spec-table-row {
  display: flex; gap: 0; border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}
.ws-spec-table-cell {
  flex: 1; padding: 4px 8px;
  border-right: 1px solid var(--line);
}
.ws-spec-table-cell:last-child { border-right: none; }
.ws-flow-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.ws-flow-step {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.78rem;
}
.ws-flow-step .action { color: var(--muted); font-size: 0.7rem; display: block; }
.ws-flow-arrow { color: var(--muted); font-size: 0.9rem; }
.ws-swatch-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.ws-swatch {
  width: 24px; height: 24px; border-radius: 4px;
  border: 1px solid var(--line); display: inline-block;
}
.ws-swatch-label { font-size: 0.75rem; color: var(--muted); margin-right: 8px; }
.ws-implication {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  margin-top: 8px;
  overflow-x: auto;
}
.ws-implication pre { font-size: 0.72rem; color: var(--muted); white-space: pre-wrap; word-break: break-word; margin: 0; }
.ws-implication-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; color: var(--brand); margin-bottom: 4px; letter-spacing: 0.04em; }
.ws-method-badge {
  display: inline-block; padding: 1px 5px; border-radius: 3px;
  font-size: 0.68rem; font-weight: 700; font-family: monospace;
}
.ws-method-GET { background: rgba(53,196,111,0.15); color: var(--good); }
.ws-method-POST { background: rgba(74,168,255,0.15); color: var(--brand); }
.ws-method-PUT { background: rgba(243,178,61,0.15); color: var(--warn); }
.ws-method-DELETE { background: rgba(240,93,93,0.15); color: var(--bad); }

/* Research panel */
.research-card { background: rgba(255,255,255,0.02); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.research-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.research-card-header h3 { color: var(--text); font-size: 0.9rem; margin: 0; }
.research-summary-text { color: var(--muted); font-size: 0.85rem; margin: 0 0 8px; line-height: 1.4; }
.research-insights { margin: 0 0 8px; padding-left: 18px; font-size: 0.83rem; color: var(--muted); }
.research-insights li { margin-bottom: 3px; }
.research-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.research-meta { font-size: 0.8rem; color: var(--muted); }
.research-link { font-size: 0.8rem; color: var(--brand); text-decoration: none; }
.research-link:hover { text-decoration: underline; }
.sub-tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.sub-tab { padding: 8px 16px; cursor: pointer; font-size: 0.85rem; color: var(--muted); border-bottom: 2px solid transparent; }
.sub-tab:hover { color: var(--text); }
.sub-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.badge-craft { background: rgba(74,168,255,0.15); color: var(--brand); }
.badge-opportunity { background: rgba(53,196,111,0.15); color: var(--good); }
.badge-operations { background: rgba(243,178,61,0.15); color: var(--warn); }
.badge-domain { background: rgba(159,177,209,0.15); color: var(--muted); }

/* === 3-Pane Shell Layout === */
.shell-layout {
  --activity-w: 48px;
  --sidebar-w: 220px;
  --chat-w: 0px;
  --gutter-w: 4px;
  display: grid;
  grid-template-columns: var(--activity-w) var(--sidebar-w) var(--gutter-w) minmax(0, 1fr) var(--gutter-w) var(--chat-w);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}
.shell-layout.dragging { user-select: none; cursor: col-resize; }
.shell-layout.chat-open { --chat-w: 380px; }

/* Drag handles between panels — narrow strips with hover affordance. */
.shell-gutter {
  grid-row: 2;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 50;
}
.shell-gutter:hover, .shell-layout.dragging .shell-gutter-active {
  background: var(--brand);
  opacity: 0.6;
}
.shell-gutter-left { grid-column: 3; }
.shell-gutter-right { grid-column: 5; }
.shell-layout:not(.chat-open) .shell-gutter-right { display: none; }
.shell-layout:not(.chat-open) {
  grid-template-columns: var(--activity-w) var(--sidebar-w) var(--gutter-w) minmax(0, 1fr) 0 0;
}
.shell-layout.sidebar-collapsed,
.shell-layout.sidebar-collapsed.chat-open {
  grid-template-columns: var(--activity-w) 0 0 minmax(0, 1fr) var(--gutter-w) var(--chat-w);
}
.shell-layout.sidebar-collapsed:not(.chat-open) {
  grid-template-columns: var(--activity-w) 0 0 minmax(0, 1fr) 0 0;
}
.shell-layout.sidebar-collapsed .shell-sidebar,
.shell-layout.sidebar-collapsed .shell-gutter-left {
  display: none;
}

/* Activity bar far left (col 1), then sidebar (col 2), gutter (col 3),
   center (col 4), gutter (col 5), chat (col 6). Header spans 1/-1. */
.shell-activity { grid-column: 1; grid-row: 2; }
.shell-sidebar { grid-column: 2; }
.shell-center { grid-column: 4; }
.shell-chat { grid-column: 6; }

/* === Activity Bar === */
.shell-activity {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(7, 12, 23, 0.85);
  border-right: 1px solid var(--line);
  padding: 8px 0;
  gap: 4px;
}
.shell-activity .ab-spacer { flex: 1; }
.ab-item {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  color: var(--muted);
  background: none;
  border: none;
  border-left: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  margin: 0 7px;
  padding: 0;
  position: relative;
}
.ab-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.ab-item.active {
  color: var(--text);
  border-left-color: var(--brand);
  background: rgba(74, 168, 255, 0.08);
}
.ab-item svg { width: 20px; height: 20px; display: block; flex: 0 0 auto; }
.ab-item .ab-tooltip {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 1000;
}
.ab-item:hover .ab-tooltip { opacity: 1; }

/* --- Shell Header --- */
.shell-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 12, 23, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
}
.shell-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: min(48vw, 480px);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}
.shell-header .shell-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.shell-header .shell-actions button {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.shell-header .shell-actions button:hover { color: var(--text); border-color: var(--muted); }
.shell-header .shell-actions .icon-btn {
  padding: 6px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.shell-header .shell-actions .icon-btn.active { color: var(--text); border-color: var(--brand); }
/* Right-panel toggle: right-half filled when chat is open (.active), hollow when closed. */
.chat-toggle-btn .right-panel-fill { opacity: 1; }
.chat-toggle-btn:not(.active) .right-panel-fill { opacity: 0; }

/* --- User menu (activity bar, bottom-left, above Settings) --- */
.ab-user-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
}
.ab-user-slot .user-menu-trigger {
  width: 28px !important;
  height: 28px !important;
}
.ab-user-slot .user-menu-dropdown {
  top: auto;
  bottom: 0;
  left: calc(100% + 8px);
  right: auto;
}
.user-menu-trigger {
  background: none !important;
  border: 1px solid var(--line) !important;
  padding: 2px !important;
  width: 32px;
  height: 32px;
  border-radius: 50% !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.user-menu-trigger:hover { border-color: var(--muted) !important; }
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  overflow: hidden;
}
.user-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-avatar-letters { line-height: 1; }
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 6px 0;
  z-index: 1000;
}
.user-menu-id { padding: 10px 14px 6px; }
.user-menu-name { color: var(--text); font-size: 0.9rem; font-weight: 600; }
.user-menu-email { color: var(--muted); font-size: 0.78rem; margin-top: 2px; word-break: break-all; }
.user-menu-sep { border-top: 1px solid var(--line); margin: 6px 0; }
.user-menu-item {
  display: block;
  padding: 8px 14px;
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}
.user-menu-item:hover { background: rgba(255,255,255,0.04); }

/* --- Tenant brand label --- */
.shell-header .brand .tenant-label {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85em;
  margin-left: 6px;
}
.shell-header .brand .tenant-separator {
  color: var(--muted);
  font-weight: 600;
}
.shell-header .brand .tenant-switcher {
  min-width: 120px;
  max-width: min(34vw, 260px);
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  padding: 0 8px;
}
.shell-header .brand .tenant-switcher:focus {
  outline: 2px solid rgba(74, 168, 255, 0.45);
  outline-offset: 1px;
}

/* --- Sidebar --- */
.shell-sidebar {
  display: flex;
  flex-direction: column;
  background: rgba(7, 12, 23, 0.6);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 8px 0;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.sb-item:focus-visible { outline: none; box-shadow: inset 0 0 0 2px rgba(74,168,255,0.4); }
.sb-item.active {
  background: rgba(74,168,255,0.08);
  border-left-color: var(--brand);
  color: var(--text);
}
.sb-icon {
  font-size: 1rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.sb-svg { width: 16px; height: 16px; display: block; }
.sb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sb-mode-icon {
  font-size: 0.75rem;
  flex-shrink: 0;
  line-height: 1;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.sb-mode-live { color: var(--good); }
.sb-mode-preview { color: var(--brand); }
.sb-mode-archived { color: var(--muted); }
.sb-item.archived { opacity: 0.72; }
.sb-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.sb-maint {
  font-size: 0.7rem;
  flex-shrink: 0;
  opacity: 0.8;
}
.sb-rollout {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--warn);
  flex-shrink: 0;
}
.sb-rollout-spin {
  display: inline-block;
  animation: sb-spin 1.2s linear infinite;
}
@keyframes sb-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.sb-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sb-divider {
  height: 1px;
  background: var(--line);
  margin: 6px 16px;
}
.sb-empty {
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
}
.sb-quota {
  padding: 6px 16px 8px 19px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* --- Center Panel (shell) --- */
.shell-center {
  overflow-y: auto;
  padding: 20px 24px;
}
.shell-center .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.shell-center .panel h2 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 12px;
}
.home-wrap {
  display: grid;
  gap: 16px;
}
.home-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
}
.home-copy {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.home-kpis {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.home-kpi {
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.02);
}
.home-kpi .value {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}
.home-kpi .label {
  display: block;
  margin-top: 3px;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
}
.home-app-list {
  display: grid;
  gap: 8px;
}
.home-app-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255,255,255,0.02);
}
.home-app-main {
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}
.home-app-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}
.home-app-phase {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}
.home-app-phase.archived { color: var(--warn); }
.home-app-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.home-delete { color: var(--bad); }

.desktop-wrap {
  display: grid;
  gap: 16px;
}
.desktop-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px 2px;
}
.desktop-title {
  min-width: 0;
}
.desktop-title h1 {
  margin: 0;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
}
.desktop-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.desktop-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.desktop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 14px;
  align-items: stretch;
}
.desktop-app-card {
  min-width: 0;
  min-height: 172px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.025);
  padding: 12px;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.desktop-app-card:hover {
  border-color: rgba(74,168,255,0.32);
  background: rgba(255,255,255,0.04);
  transform: translateY(-1px);
}
.desktop-app-card.archived {
  opacity: 0.72;
}
.desktop-app-open {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.desktop-app-open:focus-visible,
.desktop-visit-btn:focus-visible,
.desktop-workspace-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(74,168,255,0.45);
}
.desktop-app-icon {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: linear-gradient(135deg, rgba(74,168,255,0.24), rgba(53,196,111,0.18));
  border: 1px solid rgba(159,177,209,0.25);
  font-weight: 900;
  font-size: 1rem;
}
.desktop-app-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 800;
}
.desktop-app-phase {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}
.desktop-app-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.desktop-app-actions .btn-sm {
  width: 100%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  line-height: 1.35;
}
.desktop-surface {
  min-height: calc(100vh - 142px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(480px, 100%), 1fr));
  gap: 16px;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(159,177,209,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(159,177,209,0.06) 1px, transparent 1px),
    rgba(7,12,23,0.32);
  background-size: 32px 32px;
  overflow: auto;
}
.desktop-surface .desktop-empty {
  width: 100%;
  min-height: calc(100vh - 178px);
  border-style: dashed;
  background: rgba(7,12,23,0.34);
  flex-direction: column;
  gap: 10px;
}
.desktop-window {
  width: 100%;
  min-width: 0;
  min-height: min(560px, calc(100vh - 190px));
  max-height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(159,177,209,0.32);
  border-radius: 8px;
  background: rgba(12,19,34,0.98);
  box-shadow: 0 24px 60px rgba(0,0,0,0.34);
}
.desktop-window:focus {
  outline: none;
}
.desktop-window.focused {
  border-color: rgba(74,168,255,0.72);
  box-shadow: 0 0 0 2px rgba(74,168,255,0.25), 0 24px 60px rgba(0,0,0,0.34);
}
.desktop-window.archived { opacity: 0.72; }
.desktop-window-titlebar {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
}
.desktop-window-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.desktop-window-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid rgba(159,177,209,0.28);
  background: rgba(74,168,255,0.16);
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 900;
}
.desktop-window-name {
  min-width: 0;
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 800;
}
.desktop-window-phase {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}
.desktop-window-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.desktop-window-actions .btn-sm {
  text-decoration: none;
  white-space: nowrap;
}
.desktop-window-close {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.desktop-window-close:hover {
  color: var(--text);
  border-color: rgba(159,177,209,0.45);
  background: rgba(255,255,255,0.06);
}
.desktop-window-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(74,168,255,0.45);
}
.desktop-window-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.desktop-window-canvas {
  min-height: 100%;
}
.desktop-window-canvas .panel {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.desktop-window-canvas .ws-canvas-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.desktop-empty {
  grid-column: 1 / -1;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}
.inner-life-grid {
  display: grid;
  gap: 14px;
}
.inner-life-pulse {
  display: grid;
  gap: 12px;
}
.il-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  gap: 8px;
}
.il-kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
.il-kpi-value {
  display: block;
  color: var(--text);
  font-weight: 800;
  font-size: 0.96rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.il-kpi-label {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}
.il-last {
  display: grid;
  gap: 4px;
  padding: 2px 0;
}
.il-last span,
.inner-life-heading {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}
.il-last strong {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.4;
}
.inner-life-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.il-events {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}
.il-event {
  display: grid;
  gap: 4px;
  padding: 0 0 8px;
  border-bottom: 1px solid rgba(159,177,209,0.14);
}
.il-event:last-child { border-bottom: 0; padding-bottom: 0; }
.il-event-top,
.il-fact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.il-event-type {
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 800;
}
.il-event-time,
.il-event-meta,
.il-empty,
.il-fact span {
  color: var(--muted);
  font-size: 0.76rem;
}
.il-event-summary {
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.4;
}
.il-facts {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.il-fact strong {
  color: var(--text);
  font-size: 0.8rem;
  text-align: right;
}
.new-app-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  margin-bottom: 12px;
}
.new-app-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}
.new-app-fields input,
.new-app-fields select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1728;
  color: var(--text);
  font-size: 0.9rem;
}

/* --- Chat Panel (shell) --- */
.shell-chat {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: rgba(7, 12, 23, 0.5);
  overflow: hidden;
}

/* --- Embedded workspace (within shell center) --- */
.workspace-embedded {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 80px);
}
.shell-center-embedded { padding: 0; }

/* --- App Header Bar (workspace) --- */
.ws-header-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 12, 23, 0.5);
  flex-shrink: 0;
}
.ws-header-bar .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ws-header-bar .ws-app-name {
  font-size: 1.1rem;
  font-weight: 700;
}
.ws-header-bar .meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Horizontal Tab Bar (workspace) --- */
.ws-tab-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 12, 23, 0.3);
  flex-shrink: 0;
  overflow-x: auto;
}
.ws-tab {
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.ws-tab:hover { color: var(--text); }
.ws-tab:focus-visible { outline: none; box-shadow: inset 0 -2px 0 var(--brand); }
.ws-tab.active {
  color: var(--text);
  border-bottom-color: var(--brand);
}

/* === System Panel Styles === */
.sys-row { display: flex; gap: 10px; flex-wrap: wrap; }
.sys-kpi {
  min-width: 180px; flex: 1;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: 10px; padding: 10px;
  transition: border-color 0.15s, transform 0.15s;
}
.sys-kpi:hover {
  border-color: rgba(74,168,255,0.25);
  transform: translateY(-1px);
}
.sys-kpi .label { color: var(--muted); font-size: 0.8rem; }
.sys-kpi .value { margin-top: 6px; font-size: 1.2rem; font-weight: 700; }
.sys-pre {
  margin: 0; max-height: 260px; overflow: auto;
  background: #0a1323; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; font-size: 0.8rem; word-break: break-all;
}
.sys-two { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.sys-three { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.sys-small { color: var(--muted); font-size: 0.8rem; }

/* System Grafana charts (2x2 grid) */
.sys-grafana-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.sys-grafana-grid .ws-grafana-panel iframe { width: 100%; height: 220px; border: none; }

/* Infrastructure Health panel */
.infra-summary-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.infra-summary-row .sys-kpi { min-width: 140px; }
.infra-degraded {
  background: rgba(240, 93, 93, 0.08);
  border: 1px solid rgba(240, 93, 93, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.infra-degraded .infra-app-name { font-weight: 700; font-size: 0.9rem; }
.infra-degraded .infra-detail { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.infra-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.infra-bar-label { font-size: 0.8rem; color: var(--muted); min-width: 60px; }
.infra-bar {
  flex: 1;
  height: 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 7px;
  overflow: hidden;
}
.infra-bar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.3s ease;
}
.infra-bar-fill.ok { background: var(--good); }
.infra-bar-fill.warn { background: var(--warn); }
.infra-bar-fill.bad { background: var(--bad); }
.infra-bar-value { font-size: 0.8rem; font-weight: 600; min-width: 40px; text-align: right; }

/* Section tabs (system panel) */
.section-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.section-tab {
  padding: 8px 18px; font-size: 0.85rem; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s;
}
.section-tab:hover { color: var(--text); }
.section-tab:focus-visible { outline: none; box-shadow: inset 0 -2px 0 var(--brand); }
.section-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.section-content { display: none; }
.section-content.active { display: block; }

/* Flag toggle switches (shared by system panel + workspace) */

/* === Tickets Panel Styles === */
.tp-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.tp-field-grid label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
.tp-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}
.tp-filters button { width: auto; }
.tp-table-wrapper { overflow-x: auto; }
.tp-empty { text-align: center; padding: 30px 0; color: var(--muted); }
.tp-summary { font-weight: 600; margin-bottom: 12px; cursor: pointer; }
.tp-last-updated { text-align: right; color: var(--muted); font-size: 0.78rem; margin-top: 8px; }
.tp-actions button {
  border: 1px solid transparent; border-radius: 8px; padding: 4px 10px;
  font-size: 0.8rem; font-weight: 700; cursor: pointer; margin-right: 4px;
}
.tp-actions button:last-child { margin-right: 0; }
.tp-approve { background: #2ecc71; color: #061020; }
.tp-reject { background: #e74c3c; color: #061020; }

.pp-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.pp-filters label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
.pp-table-wrapper { overflow-x: auto; }
.pp-empty { text-align: center; padding: 30px 0; color: var(--muted); }
.pp-last-updated { text-align: right; color: var(--muted); font-size: 0.78rem; margin-top: 8px; }
.pp-row { cursor: pointer; }
.pp-row:hover { background: rgba(255, 255, 255, 0.03); }
.pp-row-archived { opacity: 0.55; }
.pp-name { font-weight: 600; }
.pp-workspace { color: var(--muted); font-size: 0.85rem; }

/* Userspaces */
.userspaces-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}
.userspaces-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.userspaces-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
  gap: 14px;
  align-items: start;
}
.userspaces-list {
  overflow-x: auto;
}
.userspaces-table {
  width: 100%;
}
.userspaces-table tr.usp-row {
  cursor: pointer;
}
.userspaces-table tr.usp-row.active {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.usp-id {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}
.usp-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  border: 1px solid var(--line);
}
.usp-status.good {
  color: var(--good);
  background: color-mix(in srgb, var(--good) 10%, transparent);
}
.usp-status.warn {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}
.usp-status.bad {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
}
.userspaces-detail h3 {
  margin: 16px 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--muted);
}
.usp-detail-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.usp-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.usp-detail-row span,
.usp-muted {
  color: var(--muted);
}
.usp-detail-row strong {
  text-align: right;
  overflow-wrap: anywhere;
}
.usp-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.usp-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}
.usp-events {
  display: grid;
  gap: 8px;
}
.usp-event {
  display: grid;
  grid-template-columns: minmax(88px, 0.7fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.usp-event-kind {
  font-weight: 650;
}
.usp-event-subject {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.usp-event-status {
  font-size: 0.78rem;
  color: var(--muted);
}
.usp-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .userspaces-summary {
    align-items: stretch;
    flex-direction: column;
  }
  .userspaces-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .usp-event {
    grid-template-columns: minmax(0, 1fr);
  }
}
.pp-ready, .pp-age { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.85rem; }
.tp-complete { background: #35c46f; color: #061020; }
.tp-child td:first-child { padding-left: 32px; }
.tp-child td:nth-child(3)::before { content: "\2514\00a0"; color: var(--muted); }
.tp-badge-children {
  background: rgba(74,168,255,0.15); color: var(--brand);
  font-size: 0.7rem; padding: 1px 6px; border-radius: 999px; margin-left: 6px;
}
.tp-agent {
  display: inline-block;
  max-width: 150px;
  color: var(--brand);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.tp-agent-empty { color: var(--muted); font-family: inherit; }
.tp-progress {
  display: grid;
  gap: 4px;
  min-width: 180px;
  max-width: 260px;
}
.tp-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.78rem;
}
.tp-stage {
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tp-progress-pct {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
.tp-progress-track {
  height: 6px;
  min-width: 120px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(159,177,209,0.13);
}
.tp-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}
.tp-progress-meta {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
}
.tp-progress-done .tp-progress-fill { background: var(--good); }
.tp-progress-active .tp-progress-fill { background: var(--brand); }
.tp-progress-queued .tp-progress-fill { background: var(--warn); }
.tp-progress-blocked .tp-progress-fill,
.tp-progress-closed .tp-progress-fill { background: var(--bad); }
.badge-priority-P0,
.badge-status-rejected,
.badge-status-failed,
.badge-status-blocked { background: rgba(240,93,93,0.15); color: var(--bad); }
.badge-priority-P1,
.badge-status-proposed,
.badge-status-pending { background: rgba(243,178,61,0.15); color: var(--warn); }
.badge-priority-P2,
.badge-status-in_progress,
.badge-status-approved,
.badge-status-claimed,
.badge-status-running { background: rgba(74,168,255,0.1); color: var(--brand); }
.badge-priority-P3,
.badge-status-completed,
.badge-status-resolved,
.badge-status-done,
.badge-status-closed { background: rgba(159,177,209,0.1); color: var(--muted); }

/* === Settings Panel Styles === */
.sp-panel { max-width: 720px; }
.sp-token-form {
  display: flex; gap: 8px; align-items: center; margin-bottom: 12px;
}
.sp-token-form input { flex: 1; max-width: 340px; }
.sp-token-form button { width: auto; }
.sp-btn-clear {
  background: transparent !important; color: var(--muted) !important;
  border: 1px solid var(--line) !important;
}
.sp-token-status { font-size: 0.82rem; color: var(--muted); }
.sp-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px;
}
.sp-dot-set { background: var(--good); }
.sp-dot-unset { background: var(--muted); }
.sp-conn-grid { display: grid; gap: 10px; }
.sp-conn-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: rgba(255,255,255,0.02);
  border: 1px solid var(--line); border-radius: 8px; font-size: 0.85rem;
  transition: border-color 0.15s;
}
.sp-conn-row:hover { border-color: rgba(74,168,255,0.25); }
.sp-conn-label {
  font-weight: 600; font-family: ui-monospace, "SF Mono", monospace; font-size: 0.82rem;
}
.sp-conn-value {
  font-size: 0.8rem; color: var(--muted); max-width: 300px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sp-conn-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.sp-conn-ok { background: rgba(53,196,111,0.15); color: var(--good); }
.sp-conn-missing { background: rgba(159,177,209,0.15); color: var(--muted); }

.sp-desc { color: var(--muted); font-size: 0.85rem; margin: 6px 0 12px; }
.sp-mcp-actions { margin-bottom: 12px; }
.sp-mcp-actions button { width: auto; }
.sp-mcp-result { margin-top: 12px; }
.sp-mcp-warn {
  background: rgba(255,180,0,0.1); color: #ffb400;
  border: 1px solid rgba(255,180,0,0.35);
  padding: 8px 12px; border-radius: 6px;
  font-size: 0.82rem; margin-bottom: 10px;
}
.sp-mcp-json {
  background: #0b0d12; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem; line-height: 1.45; color: #d7e3f7;
  overflow-x: auto; max-height: 320px; white-space: pre;
}
.sp-mcp-copied { color: var(--good); font-size: 0.82rem; margin-left: 10px; }
.sp-mcp-error {
  margin-top: 10px; color: var(--bad); font-size: 0.82rem;
  background: rgba(255,80,80,0.08);
  border: 1px solid rgba(255,80,80,0.3);
  padding: 8px 12px; border-radius: 6px;
}

/* === Utility Classes (extracted from inline styles) === */
.mt-sm { margin-top: 6px; }
.mt-md { margin-top: 10px; }
.mb-md { margin-bottom: 10px; }
.mb-lg { margin-bottom: 12px; }
.col-span-2 { grid-column: span 2; }
.flex-end { display: flex; align-items: flex-end; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center-gap { display: flex; align-items: center; gap: 10px; }
.hidden { display: none; }
.mono-sm { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.82rem; }
.th-action { width: 80px; }
.sync-value { font-size: 0.9rem; }
.sync-kpi { min-width: 0; flex: 1; }
.sync-btn { flex: 0 0 auto; width: auto; padding: 8px 20px; }
.panel-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-header-row h2 { margin-bottom: 0; }
.ws-ops-result {
  margin-top: 12px; max-height: 200px; overflow: auto;
  background: #0a1323; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; font-size: 0.8rem; color: var(--text);
}
.ws-ticket-actions { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.ws-ticket-result { font-size: 0.8rem; }
.secrets-placeholder {
  color: var(--muted);
  font-size: 0.85rem;
}
.secrets-message {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 9px 10px;
  font-size: 0.85rem;
}
.secrets-message.bad {
  border-color: rgba(240,93,93,0.35);
  color: var(--bad);
}
.secrets-message.warn {
  border-color: rgba(243,178,61,0.35);
  color: var(--warn);
}
.secrets-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}
.secrets-summary strong {
  color: var(--text);
}
.secrets-section {
  margin-bottom: 16px;
}
.secrets-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.secrets-section-header h3 {
  color: var(--text);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  margin: 0;
  text-transform: uppercase;
}
.secrets-section-header span {
  color: var(--muted);
  font-size: 0.78rem;
}
.secrets-request-list,
.secrets-extra-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.secrets-request-row,
.secrets-extra-row {
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.secrets-request-row {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
}
.secrets-extra-row {
  grid-template-columns: minmax(0, 1fr) auto;
}
.secrets-request-row:last-child,
.secrets-extra-row:last-child {
  border-bottom: 0;
}
.secrets-request-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}
.secrets-request-main code,
.secrets-extra-row code {
  white-space: normal;
  overflow-wrap: anywhere;
}
.secrets-env {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
}
.secrets-request-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  min-width: 0;
}
.secrets-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.secrets-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.secrets-field {
  flex: 1;
  min-width: 0;
}
.secrets-status {
  min-height: 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}
.secrets-status.bad {
  color: var(--bad);
}

@media (max-width: 720px) {
  .secrets-request-row,
  .secrets-extra-row,
  .secrets-form {
    grid-template-columns: 1fr;
  }
  .secrets-request-row {
    display: grid;
  }
  .secrets-extra-row {
    justify-items: stretch;
  }
  .secrets-actions {
    justify-content: flex-start;
  }
  .secrets-form {
    display: grid;
  }
  .secrets-form .btn-inline,
  .secrets-extra-row .btn-inline {
    width: 100%;
  }
}

/* === New App Button (sidebar) === */
.sb-new-app {
  color: var(--brand) !important;
  border-left-color: transparent !important;
}
.sb-new-app .sb-icon {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--brand);
  width: 18px;
  text-align: center;
}
.sb-new-app:hover {
  background: rgba(74,168,255,0.08) !important;
}

/* === Modal Overlay === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 28px;
  min-width: 380px;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-box h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.modal-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}
.modal-warn {
  color: var(--bad);
}
.modal-input {
  width: 100%;
  padding: 10px 12px;
  background: #0d1728;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  box-sizing: border-box;
}
.modal-input:focus {
  border-color: var(--brand);
}
.modal-error {
  color: var(--bad);
  font-size: 0.82rem;
  margin-top: 8px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.modal-btn {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.modal-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.modal-btn-cancel {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
.modal-btn-cancel:hover { color: var(--text); border-color: var(--muted); }
.modal-btn-primary {
  background: var(--brand);
  color: #0a1323;
}
.modal-btn-primary:hover { opacity: 0.9; }
.modal-btn-danger {
  background: var(--bad);
  color: #fff;
}
.modal-btn-danger:hover { opacity: 0.9; }
.modal-box-danger {
  border-color: rgba(240, 93, 93, 0.4);
}

/* === New App Panel === */
.new-app-panel {
  padding: 20px 24px;
}
.new-app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.new-app-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}
.badge-new {
  background: rgba(74,168,255,0.15);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.new-app-hint {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}
.new-app-spec-input {
  width: 100%;
  min-height: 350px;
  background: #0d1728;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 14px;
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
.new-app-spec-input:focus {
  border-color: var(--brand);
}
.new-app-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.new-app-result {
  font-size: 0.82rem;
}

/* === Delete App Button (workspace header) === */
.ws-delete-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1;
  transition: all 0.15s;
}
.ws-delete-btn:hover {
  color: var(--bad);
  border-color: rgba(240, 93, 93, 0.3);
  background: rgba(240, 93, 93, 0.08);
}
.ws-delete-icon {
  font-size: 0.85rem;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .workspace, .workspace.chat-open {
    grid-template-columns: minmax(0, 1fr) 0;
  }
  .workspace.chat-open {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
  .ws-grafana-row { grid-template-columns: 1fr; }
  .ws-chart-grid { grid-template-columns: 1fr; }
  .ws-crd-grid { grid-template-columns: 1fr; }
  .ws-ops-form { grid-template-columns: 1fr; }
  .home-summary { grid-template-columns: 1fr; }
  .home-kpis { flex-wrap: wrap; }
  .desktop-top { align-items: flex-start; flex-direction: column; }
  .desktop-actions { width: 100%; }
  .desktop-actions .desktop-new-app { flex: 1; }
  .desktop-grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
  .il-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .new-app-fields { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .workspace, .workspace.chat-open {
    grid-template-columns: minmax(0, 1fr) 0;
  }
  .ws-tab-bar { padding: 0 6px; }
  .ws-tab { padding: 6px 10px; font-size: 0.78rem; }
  .desktop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desktop-app-card { min-height: 158px; padding: 10px; }
  .desktop-app-icon { width: 46px; height: 46px; }
  .il-kpis { grid-template-columns: 1fr; }
  .il-event-top,
  .il-fact { align-items: flex-start; flex-direction: column; gap: 4px; }
  .il-fact strong { text-align: left; }
}

/* Shell responsive */
@media (max-width: 1100px) {
  .shell-layout, .shell-layout.chat-open {
    grid-template-columns: var(--activity-w) 180px var(--gutter-w) minmax(0, 1fr) 0 0;
  }
  .shell-layout.chat-open {
    grid-template-columns: var(--activity-w) 180px var(--gutter-w) minmax(0, 1fr) var(--gutter-w) 300px;
  }
  .shell-layout.sidebar-collapsed,
  .shell-layout.sidebar-collapsed.chat-open {
    grid-template-columns: var(--activity-w) 0 0 minmax(0, 1fr) var(--gutter-w) 300px;
  }
  .shell-layout.sidebar-collapsed:not(.chat-open) {
    grid-template-columns: var(--activity-w) 0 0 minmax(0, 1fr) 0 0;
  }
}
@media (max-width: 768px) {
  /* Mobile: single-column, toggle between center and chat */
  .shell-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .shell-layout .shell-chat {
    display: none;
    border-left: none;
  }
  .shell-layout.chat-open .shell-center {
    display: none;
  }
  .shell-layout.chat-open .shell-chat {
    display: flex;
  }
  .shell-layout.chat-open {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Sidebar: hidden by default, slide-over overlay when open */
  .shell-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    z-index: 1001;
    background: var(--panel);
    border-right: 1px solid var(--line);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    padding-top: 50px;
  }
  .shell-sidebar.mobile-open {
    display: flex;
  }

  /* Overlay behind sidebar */
  .mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
  }
  .mobile-sidebar-overlay.open {
    display: block;
  }

  /* Hamburger button */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 1.2rem;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
  }
  .mobile-menu-btn:hover { color: var(--text); border-color: var(--muted); }

  /* Chat toggle button highlight when active */
  .shell-header .shell-actions #chat-toggle.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
  }

  /* Panels collapse to 1 col */
  .sys-two, .sys-three { grid-template-columns: 1fr; }
  .sys-grafana-grid { grid-template-columns: 1fr; }
  .sp-token-form { flex-direction: column; align-items: stretch; }
  .sp-token-form input { max-width: 100%; }

  /* Shell center padding tighter */
  .shell-center { padding: 12px; }

  /* Workspace: single-column, no side chat */
  .workspace, .workspace.chat-open {
    grid-template-columns: minmax(0, 1fr);
  }
  .workspace-center { padding: 12px; }
}

/* Hide hamburger on desktop */
@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
  .mobile-sidebar-overlay { display: none !important; }
}

/* Gradient panel */
.gradient-goals { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.gradient-goal { background: rgba(255,255,255,0.02); border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-width: 180px; }
.gradient-goal.met { border-color: var(--good); }
.gradient-goal.unmet { border-color: var(--bad); }
.goal-metric { font-weight: 600; color: var(--text); font-size: 0.9rem; }
.goal-target { font-size: 0.8rem; color: var(--muted); }
.goal-current { font-size: 0.85rem; color: var(--text); margin: 4px 0; }

.gradient-loss { text-align: center; margin: 16px 0; }
.loss-value { font-size: 2.5rem; font-weight: 700; }
.loss-value.good { color: var(--good); }
.loss-value.warn { color: var(--warn); }
.loss-value.bad { color: var(--bad); }
.loss-label { display: block; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; }

.gradient-bars { margin: 16px 0; }
.gradient-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.gradient-bar-label { flex: 0 0 280px; font-size: 0.8rem; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gradient-bar-track { flex: 1; height: 18px; background: rgba(255,255,255,0.03); border-radius: 4px; overflow: hidden; }
.gradient-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.gradient-bar-fill.bad { background: var(--bad); }
.gradient-bar-fill.warn { background: var(--warn); }
.gradient-bar-fill.good { background: var(--good); }
.gradient-bar-value { flex: 0 0 50px; font-size: 0.85rem; color: var(--text); font-weight: 600; }

.gradient-simulate { background: rgba(255,255,255,0.02); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-top: 16px; }
.gradient-simulate h3 { margin: 0 0 12px; font-size: 0.9rem; color: var(--text); }
.sim-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sim-row label { flex: 0 0 200px; font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-row input { flex: 1; max-width: 120px; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 4px 8px; border-radius: 4px; font-size: 0.85rem; }
.sim-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Trigger Dry-Run modal */
.gradient-hint-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.hint-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.hint-modal-card { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(640px, 92vw); max-height: 86vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.hint-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.hint-modal-header h3 { margin: 0; font-size: 1rem; color: var(--text); }
.hint-modal-body { display: flex; flex-direction: column; gap: 12px; }
.hint-modal-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }
.hint-row { display: flex; align-items: flex-start; gap: 12px; }
.hint-row label { flex: 0 0 120px; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding-top: 4px; }
.hint-row span { flex: 1; font-size: 0.9rem; color: var(--text); }
.hint-row select { flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 4px 8px; border-radius: 4px; font-size: 0.85rem; }
.hint-row-narration { flex-direction: column; align-items: stretch; }
.hint-row-narration label { flex: 0 0 auto; padding-top: 0; }
.hint-row textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 8px; border-radius: 4px; font-size: 0.9rem; font-family: inherit; resize: vertical; }
.hint-success { background: rgba(100, 200, 100, 0.08); border: 1px solid rgba(100, 200, 100, 0.3); padding: 16px; border-radius: 6px; color: var(--text); line-height: 1.5; }

/* === Chart Data (Metrics) Panel === */
.cd-range-select { background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 4px 8px; border-radius: 4px; font-size: 0.85rem; margin-right: 8px; }
.cd-meta { margin-bottom: 12px; }
.cd-table { width: 100%; border-collapse: collapse; }
.cd-table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 6px 12px; border-bottom: 1px solid var(--line); }
.cd-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.cd-metric-name { text-transform: capitalize; }
.cd-metric-value { font-variant-numeric: tabular-nums; font-weight: 500; }
.cd-trend-up { color: var(--good, #50c878); }
.cd-trend-down { color: var(--bad, #f05d5d); }
.cd-trend-flat { color: var(--muted); }
.cd-sparkline { vertical-align: middle; }

/* === Canvas (displayd) Panel === */
.ws-canvas-status {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.ws-canvas-status-live { color: var(--good, #50c878); }
.ws-canvas-status-warn { color: var(--warn, #f3b23d); }
.ws-canvas-status-error { color: var(--bad, #f05d5d); }
.ws-canvas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}
.ws-canvas-empty {
  grid-column: 1 / -1;
  min-width: 0;
}
.ws-canvas-blank-frame {
  position: relative;
  min-height: 260px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid rgba(159,177,209,0.28);
  border-radius: 8px;
  background:
    linear-gradient(rgba(148,163,184,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,0.08) 1px, transparent 1px),
    #05070b;
  background-size: 28px 28px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.035);
}
.ws-canvas-blank-menu {
  height: 24px;
  border-bottom: 1px solid rgba(159,177,209,0.2);
  background: rgba(248,250,252,0.08);
}
.ws-canvas-blank-center {
  position: absolute;
  inset: 24px 0 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: rgba(226,232,240,0.74);
}
.ws-canvas-blank-icon {
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(159,177,209,0.35);
  border-radius: 8px;
  background: rgba(15,23,42,0.82);
  color: #f8fafc;
  font-weight: 900;
  font-size: 1.05rem;
}
.ws-canvas-blank-name {
  max-width: min(70%, 360px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: rgba(203,213,225,0.78);
}
.ws-canvas-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ws-canvas-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.ws-canvas-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ws-canvas-img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}
.ws-canvas-tile-error .ws-canvas-img { opacity: 0.2; }
.ws-canvas-tile-error .ws-canvas-frame::after {
  content: 'no frame yet';
  position: absolute;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* LauncherPanel — NeXTSTEP-style tile grid of installable apps. */
.lp-filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.lp-filters label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
.lp-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lp-mode {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  line-height: 1;
  min-height: 30px;
  padding: 0 10px;
}
.lp-mode:hover,
.lp-mode:focus-visible {
  background: rgba(255, 255, 255, 0.07);
  color: var(--fg);
}
.lp-mode.active {
  border-color: rgba(126, 201, 240, 0.45);
  color: #7ec9f0;
}
.lp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.lp-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}
.lp-tile {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 76px 12px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  position: relative;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.lp-tile:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}
.lp-tile:active { transform: translateY(1px); }
.lp-tile-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}
.lp-tile-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.lp-tile-initials {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.lp-tile-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.lp-tile-name {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lp-tile-category {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.lp-tile-desc {
  font-size: 0.78rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lp-facets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.lp-facet {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1;
  padding: 3px 6px;
  text-transform: uppercase;
}
.lp-tile-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid var(--line);
}
.lp-tile-badge-external { color: #f0b97a; border-color: rgba(240, 185, 122, 0.35); }
.lp-tile-badge-internal { color: #7ec9f0; border-color: rgba(126, 201, 240, 0.35); }
