/* Takt — Leader Command Center (/admin)
   Architectural Daylight + Dark Studio unified design system.
   Matches / (studio.css) and /wiki (wiki-studio.css): single-elevation hairlines,
   zero-pill metadata, Plus Jakarta Sans + IBM Plex Mono tabular numerals. */

:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --surface-hover: #e8eef6;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --panel-3: #eef2f7;
  --line: rgba(10, 37, 64, 0.08);
  --line-2: rgba(10, 37, 64, 0.15);
  --line-strong: rgba(10, 37, 64, 0.15);
  --ink: #0a2540;
  --ink-2: #334155;
  --muted: #52637a;
  --faint: #7b8ca3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-dim: rgba(79, 70, 229, 0.28);
  --accent-soft: rgba(79, 70, 229, 0.075);
  --accent-line: rgba(79, 70, 229, 0.28);
  --ok: #0f766e;
  --ok-soft: rgba(15, 118, 110, 0.08);
  --ok-line: rgba(15, 118, 110, 0.26);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.08);
  --warn-line: rgba(180, 83, 9, 0.26);
  --danger: #be123c;
  --danger-soft: rgba(190, 18, 60, 0.08);
  --danger-line: rgba(190, 18, 60, 0.26);
  --you-bg: #eef2ff;
  --you-line: rgba(79, 70, 229, 0.22);
  --agent-bg: #ffffff;
  --agent-line: rgba(10, 37, 64, 0.09);
  --glass-bg: rgba(255, 255, 255, 0.86);
  --shadow-xs: 0 1px 1px rgba(10, 37, 64, 0.03), 0 1px 2px rgba(10, 37, 64, 0.04);
  --shadow-sm: 0 1px 2px rgba(10, 37, 64, 0.05), 0 4px 12px -2px rgba(10, 37, 64, 0.04);
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --nav-w: 204px;
  --list-w: minmax(276px, 336px);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e17;
  --surface: #101624;
  --surface-2: #172033;
  --surface-hover: #1e2a42;
  --panel: #101624;
  --panel-2: #0d1320;
  --panel-3: #172033;
  --line: rgba(148, 163, 184, 0.13);
  --line-2: rgba(148, 163, 184, 0.24);
  --line-strong: rgba(148, 163, 184, 0.24);
  --ink: #f8fafc;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --faint: #64748b;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-dim: rgba(129, 140, 248, 0.34);
  --accent-soft: rgba(129, 140, 248, 0.12);
  --accent-line: rgba(129, 140, 248, 0.34);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.1);
  --ok-line: rgba(52, 211, 153, 0.3);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.1);
  --warn-line: rgba(251, 191, 36, 0.32);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --danger-line: rgba(251, 113, 133, 0.32);
  --you-bg: #172038;
  --you-line: rgba(129, 140, 248, 0.3);
  --agent-bg: #101624;
  --agent-line: rgba(148, 163, 184, 0.13);
  --glass-bg: rgba(16, 22, 36, 0.84);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.32);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.36);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

[data-theme="dark"] body {
  letter-spacing: 0.008em;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
.btn,
.nav-item,
.mob-tab,
.row,
.tabs button,
.period-bar button,
a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  background: var(--bg);
}

/* --- Unified 1-Row, 3-Zone Top Bar Contract (58px, frosted) ------------------ */
.studio-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 58px;
  padding: 0 24px;
  background: var(--glass-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 20;
}

.studio-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.025em;
  white-space: nowrap;
  flex-shrink: 0;
}

.studio-brand-mark {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  width: 26px;
  height: 26px;
  padding: 5.5px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 3px rgba(79, 70, 229, 0.28);
}

[data-theme="dark"] .studio-brand-mark {
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 6px rgba(99, 102, 241, 0.35);
}

.studio-brand-mark span {
  width: 3px;
  border-radius: 2px;
  background: #ffffff;
}
.studio-brand-mark span:nth-child(1) { height: 6px; opacity: 0.72; }
.studio-brand-mark span:nth-child(2) { height: 13px; }
.studio-brand-mark span:nth-child(3) { height: 9px; opacity: 0.88; }

.studio-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

.studio-nav-link {
  position: relative;
  padding: 6px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 150ms ease;
}

.studio-nav-link:hover,
.studio-nav-link.is-active {
  color: var(--ink);
}

.studio-nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.studio-hd-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-bar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.role-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

a.link {
  color: var(--accent);
  text-decoration: none;
}

a.link:hover {
  text-decoration: underline;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 100ms ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.icon-btn:active {
  transform: scale(0.96);
}

/* --- Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

[data-theme="dark"] .btn.primary {
  color: #0b0f17;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn.ghost:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* --- Banner ------------------------------------------------------------------ */
.sys {
  padding: 9px 24px;
  color: var(--warn);
  font-size: 12.5px;
  border-bottom: 1px solid var(--warn-line);
  background: var(--warn-soft);
  flex-shrink: 0;
}

/* --- Workspace & Nav Rail ---------------------------------------------------- */
.workspace {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.nav-rail {
  width: var(--nav-w);
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  overflow-y: auto;
}

.nav-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 4px 10px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item.on {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}

.nav-svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.78;
}

.nav-item.on .nav-svg,
.nav-item:hover .nav-svg {
  opacity: 1;
}

.nav-divider {
  height: 1px;
  background: var(--line);
  margin: 10px 8px;
}

/* --- Content Shell & List Panel ---------------------------------------------- */
.content-shell {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--list-w) minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
}

.content-shell.full-detail {
  grid-template-columns: minmax(0, 1fr);
}

.content-shell.full-detail .list-panel {
  display: none;
}

.list-panel {
  border-right: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.panel-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.panel-hd .label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.panel-hd .count {
  font-size: 12px;
  color: var(--muted);
}

.sub-tabs {
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  flex-shrink: 0;
}

.sub-tabs button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 9px 0;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -1px;
}

.sub-tabs button:hover {
  color: var(--ink);
}

.sub-tabs button.on {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.filter {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--faint);
  pointer-events: none;
}

.search-kbd {
  position: absolute;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg);
  color: var(--faint);
  font-size: 10.5px;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.search-field:focus-within .search-kbd {
  opacity: 0;
}

.filter input,
.org-filter {
  width: 100%;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 0 11px;
  font-size: 13px;
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search-field input {
  padding-left: 31px;
  padding-right: 32px;
}

.filter input::placeholder {
  color: var(--faint);
}

.filter input:focus,
.org-filter:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.org-filter {
  font-size: 12px;
  cursor: pointer;
}

.list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 140ms ease, border-color 140ms ease;
}

.row:hover {
  background: var(--surface);
  border-color: var(--line);
}

.row.on {
  background: var(--surface);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-sm);
}

.row .name {
  font-size: 13.5px;
  color: var(--ink);
  font-weight: 600;
}

.row .name.anon {
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
}

.row .meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}

.row .when {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  padding-top: 2px;
}

/* --- Main Detail Canvas ------------------------------------------------------ */
.detail {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  background: var(--surface);
}

.empty {
  display: grid;
  place-items: center;
  min-height: 360px;
  height: 100%;
  color: var(--muted);
  padding: 40px;
  text-align: center;
}

.empty .t {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.detail-inner {
  padding: 28px 36px 56px;
  max-width: 1040px;
  animation: detailIn 200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes detailIn {
  from { opacity: 0; transform: translateY(4px); }
}

.detail-hd {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-hd h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.detail-hd .sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 68ch;
  margin: 8px 0 0;
}

.detail-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Clean zero-pill readiness and origin indicators */
.report-readiness {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ok);
}

.report-readiness-draft {
  color: var(--warn);
}

.report-readiness-awaiting_roles {
  color: var(--accent);
}

.origin-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--muted);
  text-transform: uppercase;
  margin-left: 8px;
}

.origin-org_template { color: var(--warn); }
.origin-mixed { color: var(--accent); }

.kvrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.kvrow b {
  color: var(--faint);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  margin-right: 6px;
}

/* --- Tabs & Panels ----------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 20px;
  margin-top: 18px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 9px 0;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -1px;
}

.tabs button:hover {
  color: var(--ink);
}

.tabs button.on {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  margin-top: 18px;
}

.tab-panel.on {
  display: block;
}

/* --- Workflow Loop Cards ----------------------------------------------------- */
.loops {
  display: grid;
  gap: 14px;
}

.loop {
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 16px 18px;
}

.loop h3 {
  margin: 0 0 6px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
}

.loop .sum {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 12px;
  line-height: 1.55;
}

.loop dl {
  margin: 0;
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.loop dt {
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10.5px;
  font-weight: 700;
  margin-top: 4px;
}

.loop dd {
  margin: 0;
  color: var(--ink-2);
}

.loop ul {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--ink-2);
}

.loop .open {
  color: var(--warn);
}

pre.raw,
.md-preview {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

pre.raw {
  max-height: 460px;
}

.md-preview {
  white-space: pre-wrap;
}

/* --- Evidence & Conversation ------------------------------------------------- */
.conv-hd {
  margin: 22px 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.conversation {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding-right: 4px;
}

.conv-turn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--agent-bg);
}

.conv-turn.you {
  border-color: var(--you-line);
  background: var(--you-bg);
}

.conv-turn.agent {
  border-color: var(--agent-line);
  background: var(--bg);
}

.conv-turn.sys {
  align-self: center;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 11.5px;
  padding: 2px 0;
}

.conv-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--faint);
}

.conv-label {
  color: var(--accent);
  font-weight: 600;
}

.conv-turn.you .conv-label {
  color: var(--ink);
}

.conv-body {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.evidence-section {
  margin: 0 0 20px;
}

.evidence-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.evidence-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.evidence-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.evidence-link:hover {
  text-decoration: underline;
}

.evidence-meta {
  font-size: 11.5px;
  color: var(--muted);
}

/* --- Said-vs-Seen Validation Panel ------------------------------------------- */
.validation-panel {
  padding: 4px 0 20px;
}

.validation-score {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  margin-bottom: 18px;
  min-width: 140px;
}

.validation-score-val {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.validation-score-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
  color: var(--muted);
}

.readiness-high .validation-score-val { color: var(--ok); }
.readiness-mid .validation-score-val { color: var(--warn); }
.readiness-low .validation-score-val { color: var(--danger); }

.validation-summaries {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.validation-block {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}

.validation-block h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 8px;
  color: var(--muted);
}

.validation-block p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

.validation-hd {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}

.validation-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

.contradictions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contradiction {
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.contradiction.warning { border-left: 3px solid var(--warn); }
.contradiction.critical { border-left: 3px solid var(--danger); }
.contradiction.info { border-left: 3px solid var(--accent); }

.contradiction-topic {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}

.contradiction-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 6px 14px;
  font-size: 13px;
  align-items: baseline;
}

.contradiction-dl dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.contradiction-dl dd {
  margin: 0;
  color: var(--ink-2);
}

/* --- Analytics KPI Cards, Tables & Charts ------------------------------------ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.stat-val {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 6px;
}

.stat-sub {
  font-size: 11px;
  color: var(--faint);
  margin-top: 4px;
}

.effort-high { color: var(--ok); }
.effort-moderate { color: var(--muted); }
.effort-low { color: var(--warn); }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 22px;
  font-size: 13px;
}

.stats-table th,
.stats-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

.stats-table th {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-table td {
  color: var(--ink-2);
}

.chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-right: 10px;
}

.period-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 14px 0;
  flex-wrap: wrap;
}

.period-bar button {
  height: 30px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  border-radius: 6px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.period-bar button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.period-bar button.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.period-bar a {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.period-bar a:hover {
  text-decoration: underline;
}

.chart-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin: 14px 0 24px;
}

.chart-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px 12px;
}

.chart-card h3 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.chart {
  display: block;
  max-width: 100%;
  height: auto;
}

.chart text {
  font-family: var(--font-mono);
}

.role-select {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
  cursor: not-allowed;
  opacity: 0.7;
}

.idp-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* --- Cross-Role askWho Clarification Panel ---------------------------------- */
.clarify-admin-box {
  margin-top: 22px;
  padding: 18px 20px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.clarify-admin-hd h3 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
}

.clarify-admin-hd .sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.clarify-role-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clarify-role-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 15px;
}

.clarify-role-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.clarify-role-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.clarify-role-qs {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--ink-2);
}

.clarify-role-qs li + li {
  margin-top: 4px;
}

.clarify-link-slot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.clarify-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.clarify-link-input {
  flex: 1 1 240px;
  height: 34px;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 12px;
  color: var(--ink);
}

.clarify-resolved-list {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.clarify-resolved-list h4 {
  margin: 0 0 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ok);
}

.clarify-resolved-card {
  background: var(--surface);
  border: 1px solid var(--ok-line);
  border-left: 3px solid var(--ok);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}

.clarify-resolved-card + .clarify-resolved-card {
  margin-top: 8px;
}

.clarify-resolved-meta {
  font-size: 11.5px;
  color: var(--ok);
  font-weight: 600;
  margin-bottom: 6px;
}

.clarify-resolved-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-2);
}

/* --- Layer 6: Control Plane, Realized ROI & MCP Studio ----------------------- */
.cp-stack {
  display: grid;
  gap: 18px;
  max-width: 1120px;
}

.cp-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.cp-kpi {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}

.cp-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.cp-kpi-val {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.cp-kpi-val.is-ok { color: var(--ok); }
.cp-kpi-val.is-accent { color: var(--accent); }

.cp-kpi-sub {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--faint);
}

.cp-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 16px;
  align-items: start;
}

.cp-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  min-width: 0;
  max-width: 100%;
}

.cp-card h2 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.cp-card-sub {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.cp-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 12px;
}

.cp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.cp-field.is-full {
  grid-column: 1 / -1;
}

.cp-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.cp-field input,
.cp-field select,
.cp-field textarea {
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
}

.cp-field textarea {
  min-height: 64px;
  resize: vertical;
  line-height: 1.45;
}

.cp-field input:focus,
.cp-field select:focus,
.cp-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.cp-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.cp-outcome-list {
  display: grid;
  gap: 10px;
}

.cp-outcome-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface);
}

.cp-outcome-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.cp-outcome-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
}

.cp-status-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  text-transform: uppercase;
}

.cp-status-deployed { color: var(--ok); border-color: var(--ok); }
.cp-status-in_progress { color: var(--accent); border-color: var(--accent); }
.cp-status-planned { color: var(--warn); border-color: var(--warn); }
.cp-status-retired { color: var(--muted); border-color: var(--line); }

.cp-roi-bars {
  display: grid;
  gap: 10px;
}

.cp-bar-item {
  display: grid;
  gap: 4px;
}

.cp-bar-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
}

.cp-bar-tracks {
  display: grid;
  gap: 3px;
}

.cp-bar-track {
  height: 7px;
  border-radius: 4px;
  background: var(--surface);
  overflow: hidden;
  border: 1px solid var(--line);
}

.cp-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.cp-bar-est { background: var(--faint); }
.cp-bar-real { background: var(--ok); }

.cp-mcp-endpoint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.cp-mcp-endpoint input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--ink);
}

.cp-tool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.cp-tool-chip {
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

.cp-tool-chip.is-active,
.cp-tool-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cp-code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-2);
  overflow: auto;
  max-width: 100%;
  max-height: 260px;
  margin: 8px 0 0;
  white-space: pre;
}

@media (max-width: 960px) {
  .cp-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cp-grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .cp-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- Mobile Bottom Tab Bar & Master-Detail Back Button (Hidden on Desktop) --- */
.mobile-bottom-nav {
  display: none;
}

.mobile-back-btn {
  display: none;
}

/* --- Responsive Breakpoints -------------------------------------------------- */
@media (max-width: 1024px) and (min-width: 769px) {
  .workspace {
    flex-direction: column;
  }
  .nav-rail {
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 12px;
    gap: 4px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav-label,
  .nav-divider {
    display: none;
  }
  .nav-item {
    width: auto;
    white-space: nowrap;
    padding: 6px 10px;
  }
  .content-shell {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  }
  .detail-inner {
    padding: 20px 18px 36px;
  }
}

/* Dedicated Mobile Architecture (<= 768px):
   - Single-row 52px frosted header + 58px native bottom dock = 110px (13.0% of 844px)
   - True Master-Detail drill-down (100% list OR 100% detail with <- Wróć do listy)
   - 16px inputs, >= 44px touch targets, zero horizontal overflow */
@media (max-width: 768px) {
  .studio-hd {
    height: 52px;
    padding: 0 12px;
    gap: 8px;
  }
  .studio-brand {
    font-size: 15px;
    gap: 8px;
  }
  .studio-nav {
    gap: 12px;
  }
  .studio-nav-link {
    font-size: 13px;
    padding: 4px 0;
  }
  .studio-nav-link.is-active {
    display: none;
  }
  .user-bar {
    display: none !important;
  }
  .studio-hd-right {
    gap: 6px;
  }
  #refresh {
    width: 40px;
    height: 40px;
    padding: 0;
  }
  #refresh .btn-label {
    display: none;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
  }
  .nav-rail {
    display: none;
  }
  .workspace {
    flex-direction: column;
    min-height: 0;
  }
  .content-shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }
  .list-panel {
    flex: 1 1 auto;
    border-right: 0;
    border-bottom: 0;
    min-height: 0;
  }
  .detail {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
  }
  /* Master-Detail toggle: show ONLY detail when drilled in or on full-detail views */
  .workspace[data-mobile-detail="1"] .list-panel,
  .content-shell.full-detail .list-panel {
    display: none;
  }
  .workspace[data-mobile-detail="1"] .detail,
  .content-shell.full-detail .detail {
    display: block;
  }
  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 12px 0 8px;
    margin: 0 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
  }
  .mobile-back-btn:active {
    transform: scale(0.98);
  }
  .detail-inner {
    padding: 16px 14px 28px;
  }
  .search-kbd {
    display: none;
  }
  .filter input,
  .org-filter,
  .cp-field input,
  .cp-field select,
  .cp-field textarea,
  .cp-mcp-endpoint input {
    font-size: 16px;
    min-height: 42px;
  }
  .row {
    padding: 12px;
    min-height: 52px;
  }
  .sub-tabs button,
  .tabs button {
    min-height: 42px;
  }
  .btn {
    min-height: 40px;
  }
  .contradiction-dl {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .validation-summaries {
    grid-template-columns: 1fr;
  }
  .tabs {
    overflow-x: auto;
  }
  .tabs button {
    white-space: nowrap;
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  /* Native Glassmorphic Mobile Bottom Dock (58px + safe area) */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    min-height: calc(58px + env(safe-area-inset-bottom, 0px));
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--line);
    flex-shrink: 0;
    z-index: 25;
  }
  .mob-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    padding: 4px 2px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: color 140ms ease, background 140ms ease;
  }
  .mob-tab svg {
    width: 19px;
    height: 19px;
  }
  .mob-tab.on {
    color: var(--accent);
    background: var(--accent-soft);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
