:root {
  --bg: #12141a;
  --surface: #191c24;
  --surface-2: #21242f;
  --border: #2a2e3a;
  --text: #e6e8ee;
  --text-muted: #8b8fa3;
  --text-dim: #565b6e;

  --new: #a78bfa;
  --todo: #6b7280;
  --doing: #f0a63c;
  --done: #4fd1a5;
  --failed: #f0555a;

  --engine-claude: #7c93f0;
  --engine-codex: #43c6d1;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  height: 100%;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-left { display: flex; align-items: center; gap: 10px; }
.organization-switcher {
  max-width: 180px; border: 1px solid var(--border); border-radius: 6px; padding: 5px 24px 5px 8px;
  background: var(--surface-2); color: var(--text-muted); font: 11px var(--font-mono); cursor: pointer;
}
.organization-switcher:disabled { cursor: default; opacity: .85; }
.project-filter {
  max-width: 180px; border: 1px solid var(--border); border-radius: 6px; padding: 5px 24px 5px 8px;
  background: var(--surface-2); color: var(--text-muted); font: 11px var(--font-mono); cursor: pointer;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--text);
}

.rail-dot--live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--doing);
  box-shadow: 0 0 0 0 rgba(240,166,60,0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(240,166,60,0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(240,166,60,0); }
  100% { box-shadow: 0 0 0 0 rgba(240,166,60,0); }
}

.topbar-counts {
  display: flex;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}
.topbar-counts span.count-chip { display: inline-flex; align-items: center; gap: 5px; }

.topbar-clock {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.knowledge-button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 5px 10px;
  white-space: nowrap;
}
.knowledge-button:hover { color: var(--text); border-color: var(--text-dim); }
.knowledge-button.drop-target {
  color: var(--text);
  border-color: var(--failed);
  background: color-mix(in srgb, var(--failed) 12%, transparent);
}
.account-button {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; height: 32px; padding: 3px 8px 3px 4px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
  cursor: pointer; font: 11px var(--font-mono); transition: border-color .15s ease, background .15s ease;
}
.account-button:hover { background: #282c38; border-color: rgba(240,166,60,.52); color: var(--text); }
.account-button-avatar {
  display: grid; place-items: center; width: 23px; height: 23px; border-radius: 6px;
  background: rgba(240,166,60,.16); color: #f6c871; font-size: 10px; font-weight: 700;
}
.account-button-label { max-width: 116px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-button-chevron { color: var(--text-dim); font-size: 14px; line-height: 1; transform: translateY(-1px); }

/* ---------- runners ---------- */

.runners {
  display: flex;
  gap: 10px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-wrap: wrap;
}

.runner-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 8px 6px 14px;
  font-size: 12.5px;
}

.runner-name { color: var(--text); font-weight: 600; }
.runner-state { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }

.runner-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
}
.runner-dot--on {
  background: var(--done);
  box-shadow: 0 0 0 0 rgba(79,209,165,0.6);
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(79,209,165,0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(79,209,165,0); }
  100% { box-shadow: 0 0 0 0 rgba(79,209,165,0); }
}

.runner-btn {
  border: none;
  border-radius: 100px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.runner-btn--start { background: var(--done); color: #05261a; }
.runner-btn--stop { background: var(--failed); color: #2a0808; }
.runner-btn:disabled { opacity: 0.5; cursor: default; }
.worker-empty { color: var(--text-dim); font-size: 12px; padding: 7px 0; }

/* ---------- analytics ---------- */

.analytics {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(240px, 1fr);
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.analytics-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.metric, .priority-breakdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.metric { min-width: 0; padding: 10px 12px; }
.metric-value { display: block; font-family: var(--font-mono); font-size: 16px; font-weight: 600; }
.metric-label { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10.5px; }
.metric-detail { display: block; margin-top: 5px; color: var(--text-dim); font-family: var(--font-mono); font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.priority-breakdown { padding: 9px 12px; }
.priority-heading { display: block; margin-bottom: 7px; color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.priority-row { display: grid; grid-template-columns: 50px 1fr auto; align-items: center; gap: 7px; margin-top: 5px; }
.priority-name, .priority-detail { font-family: var(--font-mono); font-size: 10px; }
.priority-name--high { color: #ff9398; }
.priority-name--medium { color: #f0c56a; }
.priority-name--low { color: #91b6e8; }
.priority-track { height: 5px; overflow: hidden; border-radius: 5px; background: var(--surface-2); }
.priority-fill { display: block; height: 100%; min-width: 2px; border-radius: inherit; }
.priority-fill--high { background: var(--failed); }
.priority-fill--medium { background: var(--doing); }
.priority-fill--low { background: var(--engine-claude); }
.priority-detail { color: var(--text-dim); white-space: nowrap; }

/* ---------- board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  padding: 20px 24px 240px;
  align-items: start;
}
.column { min-width: 0; }

.column-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0 0 10px 2px;
}

.col-count {
  margin-left: auto;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot--new { background: var(--new); }
.dot--todo { background: var(--todo); }
.dot--doing { background: var(--doing); }
.dot--awaiting-answer { background: #efb856; }
.dot--awaiting-merge { background: #52b8db; }
.dot--awaiting-deploy { background: #b38cff; }
.dot--done { background: var(--done); }
.dot--failed { background: var(--failed); }

.cards { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }
.repo-group { display: flex; flex-direction: column; gap: 8px; }
.repo-group + .repo-group { margin-top: 8px; }
.repo-group-title {
  margin: 0;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--todo);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.card:hover { background: var(--surface-2); transform: translateY(-1px); }

.card[data-status="new"] { border-left-color: var(--new); }
.card[data-status="doing"] { border-left-color: var(--doing); }
.card[data-status="awaiting_answer"] { border-left-color: #efb856; }
.card[data-status="awaiting_merge"] { border-left-color: #52b8db; }
.card[data-status="awaiting_deploy"] { border-left-color: #b38cff; }
.card[data-status="done"] { border-left-color: var(--done); }
.card[data-status="failed"] { border-left-color: var(--failed); }

.card--draggable { cursor: grab; }
.card--draggable.dragging { opacity: 0.5; cursor: grabbing; }

.column.drop-target .cards {
  outline: 2px dashed var(--todo);
  outline-offset: 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--todo) 8%, transparent);
}

.card-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-repo {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  word-break: break-word;
}

.card-worker {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.tag--claude { color: var(--engine-claude); border-color: rgba(124,147,240,0.35); }
.tag--codex { color: var(--engine-codex); border-color: rgba(67,198,209,0.35); }
.tag--est { color: var(--text-dim); }
.tag--priority { font-weight: 600; }
.tag--priority-high { color: #ff9398; border-color: rgba(240,85,90,0.45); }
.tag--priority-medium { color: #f0c56a; border-color: rgba(240,166,60,0.45); }
.tag--priority-low { color: #91b6e8; border-color: rgba(124,147,240,0.4); }
.tag--automation { color: #8cd8f2; border-color: rgba(82,184,219,.45); }
.tag--scheduled { color: #c9a7f0; border-color: rgba(151,109,224,.45); }

.card[data-status="doing"] .card-id::before {
  content: "● ";
  color: var(--doing);
  animation: blink 1.2s infinite;
}

@keyframes blink { 50% { opacity: 0.25; } }

.empty-hint {
  font-size: 12px;
  color: var(--text-dim);
  padding: 10px 4px;
  font-style: italic;
}

/* ---------- fab ---------- */

.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  height: 50px;
  border-radius: 999px;
  border: none;
  background: var(--doing);
  color: #1a1200;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(240,166,60,0.35);
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px 0 14px;
}
.fab span { font-size: 24px; font-weight: 400; margin-top: -1px; }
.fab:hover { filter: brightness(1.08); }
.fab[hidden] { display: none; }

/* ---------- console (mission log) ---------- */

.console {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #0c0e12;
  border-top: 1px solid var(--border);
  z-index: 15;
  max-height: 200px;
  display: flex;
  flex-direction: column;
}
.console.collapsed { max-height: 40px; }

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.console-title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.console-hint { font-size: 11px; color: var(--text-dim); }

.console-body {
  overflow-y: auto;
  padding: 10px 20px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #9fe6c0;
  line-height: 1.6;
}
.console-body .line { white-space: pre-wrap; word-break: break-word; }
.console-body .line:first-child::after {
  content: "▍";
  animation: blink 1s steps(1) infinite;
  color: var(--doing);
}
.console-body .line--marker { color: var(--doing); }
.console-body .line--fail { color: var(--failed); }
.console-body .line--ok { color: var(--done); }

/* ---------- drawer ---------- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  z-index: 25;
}
.overlay.show { display: block; }

.drawer {
  position: fixed;
  top: 0; right: -480px;
  width: 460px; height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 30;
  transition: right 0.2s ease;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}
.drawer.open { right: 0; }
.knowledge-drawer { z-index: 32; }
.knowledge-pane { min-height: 0; }

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.drawer-id { font-family: var(--font-mono); font-size: 15px; font-weight: 600; }
.drawer-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.drawer-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer;
}

.drawer-section { margin-bottom: 16px; }
.drawer-section h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin: 0 0 6px;
}
.drawer-section p { font-size: 13px; line-height: 1.5; margin: 0; color: var(--text); }
.drawer-answer-context { white-space: pre-wrap; }
.answer-section { padding: 13px; border: 1px solid rgba(240,166,60,.42); border-radius: 8px; background: rgba(240,166,60,.06); }
.answer-section h3 { color: #f6c871; }
.answer-section label { display: block; margin-top: 12px; color: var(--text-muted); font-size: 11px; }
.answer-section textarea { width: 100%; min-height: 82px; margin-top: 6px; border: 1px solid var(--border); border-radius: 6px; padding: 9px; color: var(--text); background: #12151d; font: 12px var(--font-ui); resize: vertical; }
.answer-section .btn-primary { width: 100%; margin-top: 10px; }
.drawer-actions { margin: -2px 0 16px; }
.drawer-actions .btn-primary { width: 100%; padding: 10px 12px; }

.image-gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.image-gallery:empty { display: none; }
.image-thumb { position: relative; width: 72px; height: 72px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; height: 100%; padding: 4px; box-sizing: border-box; text-decoration: none; color: var(--text-muted);
  background: var(--panel-alt, rgba(255,255,255,.04));
}
.file-thumb-icon { font-size: 20px; line-height: 1; }
.file-thumb-name { font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.image-thumb-remove {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; line-height: 16px; text-align: center;
  background: rgba(10,11,15,.75); color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; padding: 0;
}
.image-thumb-remove:hover { background: rgba(240,85,90,.85); }
.image-upload-label { display: inline-block; font-size: 11px; color: var(--text-muted); }
.image-upload-label input { display: block; margin-top: 6px; font-size: 11px; color: var(--text-muted); }

.drawer-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tab {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  font-size: 12px; padding: 5px 12px; border-radius: 6px; cursor: pointer;
}
.tab.active { background: var(--surface-2); color: var(--text); border-color: var(--text-dim); }

.drawer-pane {
  flex: 1;
  background: #0c0e12;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #c7cbd6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  min-height: 200px;
}
.artifacts-pane { display: flex; flex-direction: column; gap: 7px; white-space: normal; }

/* ---------- raport final (markdown) ---------- */
.markdown-body {
  white-space: normal;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.6;
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  color: var(--text);
  font-weight: 600;
  line-height: 1.3;
  margin: 20px 0 10px;
}
.markdown-body h1 { font-size: 19px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 16px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 14px; }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 13px; color: var(--text-muted); }
.markdown-body p { margin: 0 0 12px; }
.markdown-body a { color: var(--engine-claude); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body strong { color: var(--text); font-weight: 600; }
.markdown-body em { color: inherit; }
.markdown-body del { color: var(--text-dim); }
.markdown-body ul, .markdown-body ol { margin: 0 0 12px; padding-left: 22px; }
.markdown-body li { margin: 4px 0; }
.markdown-body li > ul, .markdown-body li > ol { margin: 4px 0 0; }
.markdown-body blockquote {
  margin: 0 0 12px; padding: 4px 12px; border-left: 3px solid var(--text-dim);
  color: var(--text-muted);
}
.markdown-body blockquote > *:last-child { margin-bottom: 0; }
.markdown-body code {
  font-family: var(--font-mono); font-size: 11.5px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}
.markdown-body pre {
  margin: 0 0 12px; padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; overflow-x: auto;
}
.markdown-body pre code { background: none; border: none; padding: 0; font-size: 11.5px; white-space: pre; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 12px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; }
.markdown-body th { background: var(--surface-2); color: var(--text); font-weight: 600; }
.markdown-body img { max-width: 100%; border-radius: 6px; }
.artifact-link { display: block; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; color: #a7e6c6; font: 11px var(--font-mono); text-decoration: none; overflow-wrap: anywhere; }
.artifact-link:hover { background: rgba(79,209,165,.1); border-color: rgba(79,209,165,.45); }
.diff-view { padding: 0; overflow: auto; background: #0e1016; white-space: normal; }
.diff-file { border-bottom: 1px solid var(--border); }
.diff-file:last-child { border-bottom: 0; }
.diff-file-name { padding: 8px 10px; color: var(--text-muted); background: #141720; font: 10px var(--font-mono); }
.diff-table { width: 100%; border-collapse: collapse; table-layout: fixed; font: 10px/1.45 var(--font-mono); }
.diff-table td { width: 50%; padding: 0; vertical-align: top; border-right: 1px solid var(--border); }
.diff-table td:last-child { border-right: 0; }
.diff-line { display: grid; grid-template-columns: 38px minmax(0,1fr); min-height: 18px; }
.diff-line-number { padding: 1px 6px; color: var(--text-dim); text-align: right; user-select: none; background: rgba(255,255,255,.02); }
.diff-line-code { padding: 1px 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.diff-line--remove .diff-line-code { color: #ffb2b7; background: rgba(231,89,99,.18); }
.diff-line--add .diff-line-code { color: #a7e6c6; background: rgba(79,209,165,.17); }
.diff-line--empty .diff-line-code { color: transparent; background: rgba(255,255,255,.015); }
.diff-review-modal { position: fixed; inset: 24px; z-index: 45; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 30px 90px rgba(0,0,0,.55); }
.diff-review-modal[hidden] { display: none; }
.diff-review-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 24px 15px; border-bottom: 1px solid var(--border); }
.diff-review-header h2 { margin: 4px 0 0; font-size: 18px; }
.diff-review-header .drawer-close { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 7px; }
.diff-review-legend { display: flex; gap: 16px; padding: 9px 24px; border-bottom: 1px solid var(--border); font: 10px var(--font-mono); }
.diff-legend--remove { color: #ffb2b7; }.diff-legend--add { color: #a7e6c6; }
.diff-review-content { flex: 1; min-height: 0; }
@media (max-width: 700px) { .diff-review-modal { inset: 10px; border-radius: 9px; }.diff-review-header { padding: 16px; }.diff-review-legend { padding: 8px 16px; } }

/* ---------- modal ---------- */

.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 640px;
  max-width: 92vw;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 26px 28px;
  z-index: 35;
}
.modal.show { display: block; }
.modal h3 { margin: 0 0 18px; font-size: 17px; }
.modal label, #drawer-edit-wrap label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.modal input, .modal select, .modal textarea,
#drawer-edit-wrap input, #drawer-edit-wrap select, #drawer-edit-wrap textarea {
  width: 100%;
  margin-top: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--font-ui);
  font-size: 14px;
  resize: vertical;
}
.modal textarea, #drawer-edit-wrap textarea { line-height: 1.5; }
.modal #f-spec, #drawer-edit-wrap #f-edit-spec { min-height: 140px; }
.modal #f-done, #drawer-edit-wrap #f-edit-done { min-height: 70px; }
.task-automation { margin: 18px 0 4px; padding: 13px 14px 3px; border: 1px solid var(--border); border-radius: 8px; }
.task-automation legend { padding: 0 5px; color: var(--text-dim); font: 10px var(--font-mono); letter-spacing: .07em; text-transform: uppercase; }
.modal .task-check, #drawer-edit-wrap .task-check, #drawer-repair-actions .task-check { display: flex; align-items: flex-start; gap: 9px; margin: 0 0 11px; color: var(--text); cursor: pointer; }
.modal .task-check input, #drawer-edit-wrap .task-check input, #drawer-repair-actions .task-check input { width: auto; margin: 2px 0 0; padding: 0; accent-color: var(--doing); }
.task-check strong, .task-check small { display: block; }
.task-check strong { font-size: 12px; font-weight: 600; }
.task-check small { margin-top: 2px; color: var(--text-dim); font-size: 10.5px; line-height: 1.35; }
.modal .task-check input:disabled + span { opacity: .68; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.btn-primary, .btn-secondary {
  border: none; border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.btn-primary { background: var(--doing); color: #1a1200; font-weight: 600; }
.btn-secondary { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.55; cursor: default; }

.task-schedule { margin: 18px 0 4px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 8px; }
.task-schedule legend { padding: 0 5px; color: var(--text-dim); font: 10px var(--font-mono); letter-spacing: .07em; text-transform: uppercase; }
.schedule-row { display: flex; gap: 8px; margin-bottom: 10px; }
.schedule-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.btn-chip { border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-muted); padding: 5px 12px; font-size: 11.5px; cursor: pointer; }
.btn-chip:hover { color: var(--text); border-color: var(--doing); }
.task-schedule input[type="datetime-local"] { min-height: 38px; flex: 1; }
.btn-schedule-cancel { flex: 0 0 auto; width: 38px; min-height: 38px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 14px; }
.btn-schedule-cancel:hover { color: var(--text); border-color: var(--failed); }
.schedule-hint { margin: 0; font-size: 11.5px; color: var(--text-dim); }
.schedule-hint--none { color: var(--text-muted); }

/* ---------- account ---------- */

.modal-account { width: 620px; max-height: min(86vh, 760px); padding: 0; overflow: hidden; }
.modal-account > * { padding-left: 28px; padding-right: 28px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; padding-top: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.modal-heading h3 { margin: 2px 0 0; font-size: 18px; }
.modal-heading .drawer-close { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 6px; }
.modal-heading .drawer-close:hover { color: var(--text); background: var(--surface-2); }
.modal-eyebrow { color: var(--doing); font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .12em; margin: 0; }
.account-identity { display: flex; align-items: center; gap: 12px; padding-top: 16px; padding-bottom: 16px; background: linear-gradient(90deg, rgba(240,166,60,.09), transparent 58%); border-bottom: 1px solid var(--border); }
.account-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: rgba(240,166,60,.16); color: #f6c871; font-family: var(--font-mono); font-weight: 700; }
.account-identity strong, .account-identity span { display: block; }
.account-identity strong { font-size: 13px; }
.account-identity div span { margin-top: 2px; color: var(--text-dim); font-family: var(--font-mono); font-size: 10px; }
.account-section { padding-top: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.account-section h4 { margin: 0 0 14px; color: var(--text); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.account-section label { margin-bottom: 0; }
.account-section input, .account-section select { min-height: 38px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 12px; }
.form-grid--password { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-full { grid-column: 1 / -1; }
.form-error { min-height: 16px; margin: 8px 0 0; color: #ff9398; font-size: 11.5px; }
.account-button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1px; }
.account-button-row .btn-secondary { padding: 8px 11px; }
.user-list { margin-top: 18px; border-top: 1px solid var(--border); }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--border); }
.user-row strong, .user-row span { display: block; }
.user-row strong { font-size: 12px; }
.user-row span, .user-row small { color: var(--text-dim); font-family: var(--font-mono); font-size: 10px; }
.account-actions { justify-content: flex-start; margin: 0; padding-top: 16px; padding-bottom: 16px; background: rgba(0,0,0,.08); }
.account-actions .btn-secondary { border-color: rgba(240,85,90,.35); color: #e9989c; }
.enrollment-token { margin-top: 14px; padding: 12px; border: 1px solid rgba(240,166,60,.42); border-radius: 7px; background: rgba(240,166,60,.07); }
.enrollment-token strong, .enrollment-token small { display: block; }
.enrollment-token strong { font-size: 11px; color: #f6c871; }
.enrollment-token code { display: block; margin: 8px 0 5px; overflow-wrap: anywhere; color: var(--text); font: 10px var(--font-mono); }
.enrollment-token small { color: var(--text-dim); font-size: 10px; }

/* ---------- global administration ---------- */

.admin-page { width: min(1040px, calc(100vw - 48px)); margin: 54px auto; }
.admin-page-heading { margin-bottom: 26px; }
.admin-page-heading h2 { margin: 5px 0 8px; font-size: 28px; letter-spacing: -.03em; }
.admin-page-heading > p:last-child { margin: 0; color: var(--text-muted); font-size: 14px; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.admin-card { padding: 24px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.admin-card h3 { margin: 0 0 18px; font-size: 14px; }
.admin-card-hint { margin: -8px 0 14px; color: var(--text-muted); font-size: 12px; line-height: 1.45; }
.admin-card label { display: block; margin: 14px 0; color: var(--text-muted); font-size: 11.5px; }
.admin-card input:not([type="checkbox"]), .admin-card select { width: 100%; min-height: 38px; margin-top: 6px; border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; color: var(--text); background: #12151d; font: 13px var(--font-ui); outline: none; }
.admin-card input:focus, .admin-card select:focus { border-color: rgba(240,166,60,.75); box-shadow: 0 0 0 3px rgba(240,166,60,.09); }
.admin-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.super-admin-check { display: flex !important; align-items: center; gap: 8px; color: var(--text) !important; }
.super-admin-check input { accent-color: var(--doing); }
.admin-card--wide { margin-top: 18px; }
.project-access-matrix { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.project-access-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.project-access-table th, .project-access-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.project-access-table th { color: var(--text-dim); font: 10px var(--font-mono); text-transform: uppercase; letter-spacing: .05em; background: rgba(0,0,0,.12); }
.project-access-table tr:last-child td { border-bottom: 0; }
.project-access-table small { display: block; margin-top: 3px; color: var(--text-dim); font: 10px var(--font-mono); }
.access-ok { color: var(--done); }
.access-no { color: #e9989c; }
.admin-button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-project-list { margin-top: 18px; border-top: 1px solid var(--border); }
.admin-project-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.admin-project-row strong, .admin-project-row small { display: block; }
.admin-project-row strong { font-size: 12px; }
.admin-project-row small { max-width: 270px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); font: 10px var(--font-mono); }
.admin-project-row .btn-secondary { padding: 6px 9px; }

/* ---------- login ---------- */

.login-page { min-height: 100%; display: grid; place-items: center; overflow: hidden; background: #101219; }
.login-shell { width: min(940px, calc(100vw - 40px)); min-height: 560px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .9fr); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 25px 80px rgba(0,0,0,.35); }
.login-panel { padding: 54px; display: flex; flex-direction: column; justify-content: center; }
.login-brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 13px; font-weight: 700; }
.login-kicker { margin: 46px 0 10px; color: var(--doing); font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .15em; }
.login-panel h1 { margin: 0; color: #f0f1f5; font-size: clamp(28px, 4vw, 40px); letter-spacing: -.04em; line-height: 1.05; }
.login-subtitle { max-width: 390px; margin: 15px 0 28px; color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.login-form { max-width: 370px; }
.login-form label { display: block; margin: 14px 0; color: var(--text-muted); font-size: 11.5px; }
.login-form input { width: 100%; margin-top: 6px; border: 1px solid var(--border); border-radius: 7px; padding: 11px 12px; color: var(--text); background: #12151d; font: 14px var(--font-ui); outline: none; }
.login-form input:focus { border-color: rgba(240,166,60,.75); box-shadow: 0 0 0 3px rgba(240,166,60,.09); }
.login-submit { width: 100%; display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding: 11px 13px; }
.login-submit span { font-size: 18px; font-weight: 400; }
.login-note { margin: 24px 0 0; color: var(--text-dim); font-family: var(--font-mono); font-size: 10px; }
.login-aside { position: relative; overflow: hidden; background: radial-gradient(circle at 65% 34%, rgba(240,166,60,.18), transparent 30%), linear-gradient(150deg, #1c202c, #12141a); }
.login-grid { position: absolute; inset: 0; opacity: .22; background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(to bottom, black, transparent); }
.login-orbit { position: absolute; border: 1px solid rgba(240,166,60,.34); border-radius: 50%; }
.login-orbit--one { width: 440px; height: 440px; top: 72px; left: 55px; }
.login-orbit--two { width: 260px; height: 260px; top: 162px; left: 145px; border-color: rgba(67,198,209,.28); }
.login-status-card { position: absolute; left: 35px; bottom: 38px; display: flex; align-items: center; gap: 8px; padding: 9px 11px; color: var(--text-muted); background: rgba(18,20,26,.78); border: 1px solid var(--border); border-radius: 7px; font: 10px var(--font-mono); }
.login-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--done); box-shadow: 0 0 12px rgba(79,209,165,.85); }

@media (max-width: 900px) {
  .topbar { gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
  .topbar-left { min-width: 0; }
  .topbar-counts { order: 4; flex-basis: 100%; gap: 10px; overflow-x: auto; }
  .topbar-clock { display: none; }
  .organization-switcher { max-width: 130px; }
  .project-filter { max-width: 130px; }
  .account-button-label { display: none; }
  .account-button { padding-right: 5px; }
  .account-button-chevron { display: none; }
  .board { grid-template-columns: 1fr; padding-left: 16px; padding-right: 16px; }
  .drawer { width: 100%; right: -100%; }
  .analytics { grid-template-columns: 1fr; }
  .analytics-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .login-shell { grid-template-columns: 1fr; min-height: 0; }
  .login-aside { display: none; }
  .login-panel { padding: 40px 28px; }
  .login-kicker { margin-top: 38px; }
  .modal-account { width: min(620px, 94vw); }
  .modal-account > * { padding-left: 20px; padding-right: 20px; }
  .form-grid, .form-grid--password { grid-template-columns: 1fr; }
  .form-grid-full { grid-column: auto; }
  .admin-page { width: min(100% - 32px, 1040px); margin: 30px auto; }
  .admin-grid, .admin-form-grid { grid-template-columns: 1fr; }
}
