:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18201e;
  background: #f7f9f8;
  font-size: 15px;
  --line: #dce2df;
  --muted: #65716c;
  --blue: #175cd3;
  --blue-soft: #eaf2ff;
  --green: #16875b;
  --amber: #c47700;
  --red: #c83d43;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f7f9f8; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 30px; line-height: 1.2; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 17px; letter-spacing: 0; }
h3 { margin-bottom: 14px; font-size: 16px; letter-spacing: 0; }

.topbar { height: 64px; display: grid; grid-template-columns: 260px 1fr auto; align-items: center; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 5; }
.brand { height: 100%; padding: 0 24px; display: flex; align-items: center; gap: 10px; border-right: 1px solid var(--line); font-size: 22px; font-weight: 720; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; background: #137a55; color: #fff; border-radius: 6px; font-size: 18px; }
.mode-nav { height: 100%; display: flex; align-items: stretch; gap: 12px; padding-left: 24px; }
.mode-link { position: relative; display: flex; align-items: center; padding: 0 14px; border: 0; background: transparent; color: #46504c; cursor: pointer; white-space: nowrap; }
.mode-link.active { color: var(--blue); font-weight: 650; }
.mode-link.active::after { content: ""; position: absolute; height: 3px; background: var(--blue); left: 8px; right: 8px; bottom: 0; }
.account { display: flex; align-items: center; gap: 18px; padding: 0 20px; white-space: nowrap; }
.account form { margin: 0; }
.health { display: flex; align-items: center; gap: 7px; color: #3e4944; font-size: 13px; }
.health i { width: 9px; height: 9px; border-radius: 50%; background: #159447; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 0; background: transparent; color: #33403b; cursor: pointer; font-size: 22px; border-radius: 5px; }
.icon-button:hover { background: #edf1ef; }

.app-shell { min-height: calc(100vh - 64px); display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { padding: 26px 12px; background: #fbfcfb; border-right: 1px solid var(--line); }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 16px 12px; }
.project-search { width: calc(100% - 16px); margin: 0 8px 12px; padding: 9px 10px; border: 1px solid #bfc9c4; border-radius: 5px; background: #fff; }
.project-list { display: grid; gap: 4px; }
.project-item { min-height: 52px; width: 100%; display: flex; align-items: center; gap: 11px; padding: 8px 12px; border: 0; border-left: 3px solid transparent; border-radius: 5px; background: transparent; color: #303a36; text-align: left; cursor: pointer; overflow: hidden; }
.project-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item:hover { background: #f0f3f2; }
.project-item.active { color: #124fb3; background: var(--blue-soft); border-left-color: #1f68df; }
.project-icon { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 4px; font-size: 13px; }
.sidebar-actions { display: grid; gap: 8px; margin: 24px 8px 0; }
.sidebar-actions .button { width: 100%; justify-content: flex-start; }

.workspace { min-width: 0; padding: 34px 40px 120px; background: #fff; }
.workspace-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.workspace-actions { display: flex; align-items: center; gap: 8px; }
.project-menu { position: relative; }
.project-menu summary { list-style: none; }
.project-menu summary::-webkit-details-marker { display: none; }
.project-menu-items { position: absolute; z-index: 8; top: 42px; right: 0; width: 168px; padding: 5px; border: 1px solid #c7d0cb; border-radius: 5px; background: #fff; box-shadow: 0 10px 28px #16221c26; }
.project-menu-items button { width: 100%; min-height: 38px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; text-align: left; cursor: pointer; }
.project-menu-items button:hover { background: #eef2f0; }
.project-menu-items .danger-command { color: #b52e37; }
.eyebrow { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--blue); font-size: 13px; }
.status::before { content: ""; width: 8px; height: 8px; background: var(--blue); border-radius: 50%; }
.phase-track { display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); margin: 30px 0 36px; }
.phase { position: relative; padding: 31px 2px 0; border: 0; border-top: 2px solid #cbd2cf; background: transparent; text-align: center; color: #6d7773; cursor: pointer; }
.phase::before { content: attr(data-step); position: absolute; top: -18px; left: calc(50% - 17px); width: 32px; height: 32px; display: grid; place-items: center; border: 2px solid #aab4af; border-radius: 50%; background: #fff; color: #5e6964; }
.phase.complete { border-color: var(--green); color: #277257; }
.phase.complete::before { content: "✓"; border-color: var(--green); color: var(--green); }
.phase.in_progress { border-color: var(--blue); color: var(--blue); font-weight: 650; }
.phase.in_progress::before { border-color: var(--blue); color: var(--blue); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr); gap: 38px; }
.main-column { padding-right: 38px; border-right: 1px solid var(--line); }
.section { padding: 0 0 28px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.command-list { display: grid; }
.command { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 14px; min-height: 62px; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--line); background: #fff; text-align: left; cursor: pointer; }
.command:hover { color: var(--blue); }
.command-icon { width: 30px; height: 30px; display: grid; place-items: center; color: var(--blue); border: 1px solid #9dbdf1; border-radius: 5px; }
.definition-grid { display: grid; grid-template-columns: 120px 1fr; }
.definition-grid dt, .definition-grid dd { margin: 0; padding: 13px 4px; border-bottom: 1px solid var(--line); }
.definition-grid dt { color: var(--muted); }
.definition-grid dd.empty { color: #8c9691; font-style: italic; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 9px 8px; border-bottom: 1px solid #aeb8b3; color: var(--muted); text-align: left; font-weight: 500; }
.table td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td:first-child { width: 32px; }
.checkbox { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }
.priority { display: inline-flex; align-items: center; gap: 6px; text-transform: capitalize; }
.priority::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.priority.high::before { background: var(--red); }
.priority.low::before { background: var(--green); }
.analysis-list { display: grid; }
.analysis-row { width: 100%; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 46px; padding: 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; }
button.analysis-row { cursor: pointer; }
button.analysis-row:hover { color: var(--blue); background: #f7f9f8; }
.analysis-icon { color: var(--blue); font-size: 18px; }
.analysis-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analysis-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty-state { padding: 18px 0; color: var(--muted); }
.loading { color: var(--muted); }
.assistant-bar { position: fixed; left: 282px; right: 22px; bottom: 18px; min-height: 58px; display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 8px; padding: 0 14px; border: 1px solid #aeb9b3; border-radius: 6px; background: #fff; color: #5e6964; box-shadow: 0 7px 24px #1b2d2418; cursor: text; z-index: 4; }
.assistant-bar:hover { border-color: var(--blue); }
.assistant-clip, .assistant-send { display: grid; place-items: center; font-size: 24px; color: #47534d; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-weight: 620; }
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover { background: #124da9; }
.button.secondary { background: #fff; border-color: #cbd3cf; color: #25302b; }
.button.secondary:hover { background: #f2f5f3; }
.button.full { width: 100%; }
.muted { color: var(--muted); }

dialog { width: min(520px, calc(100vw - 28px)); border: 1px solid #bcc6c1; border-radius: 7px; padding: 0; box-shadow: 0 18px 60px #17231d33; }
dialog::backdrop { background: #1a241f66; }
dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.analysis-dialog { width: min(860px, calc(100vw - 28px)); max-height: min(820px, calc(100vh - 28px)); }
.analysis-dialog-panel { padding: 22px; }
.analysis-detail { max-height: calc(100vh - 150px); overflow: auto; padding-right: 4px; }
.analysis-detail section { padding: 0 0 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.analysis-detail section:last-child { border-bottom: 0; }
.analysis-detail h3 { margin-bottom: 10px; }
.run-detail-grid { display: grid; grid-template-columns: minmax(160px, 0.4fr) minmax(0, 1fr); margin: 0; }
.run-detail-grid dt, .run-detail-grid dd { margin: 0; padding: 9px 6px; border-bottom: 1px solid #edf0ee; overflow-wrap: anywhere; }
.run-detail-grid dt { color: var(--muted); }
.run-detail-grid dd { color: #25302b; }
.run-detail-grid pre { margin: 0; white-space: pre-wrap; font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.run-warnings { margin: 8px 0 0; padding-left: 20px; }
.provenance { margin-top: 4px; }
.provenance summary { cursor: pointer; color: var(--blue); font-weight: 620; }
label { display: grid; gap: 7px; margin-bottom: 16px; color: #35413c; font-size: 13px; font-weight: 620; }
input, textarea, select { width: 100%; padding: 10px 11px; border: 1px solid #b9c3be; border-radius: 5px; background: #fff; color: #18201e; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid #a9c7f7; border-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-error { padding: 10px; margin-bottom: 16px; color: #922a31; background: #ffeff0; border: 1px solid #f0b5b9; border-radius: 5px; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 360px; padding: 12px 16px; background: #26332d; color: #fff; border-radius: 5px; z-index: 20; box-shadow: 0 8px 24px #17231d33; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: #f2f5f3; }
.login-shell { width: min(410px, calc(100vw - 32px)); }
.brand-large { height: auto; justify-content: center; border: 0; margin-bottom: 26px; }
.login-form { padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 10px 35px #23312912; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 210px 1fr auto; }
  .brand { padding: 0 16px; }
  .health { display: none; }
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .main-column { padding-right: 0; border-right: 0; }
  .assistant-bar { left: 232px; }
}

@media (max-width: 720px) {
  .topbar { height: auto; grid-template-columns: 1fr auto; }
  .brand { height: 58px; border-right: 0; }
  .mode-nav { grid-row: 2; grid-column: 1 / -1; height: 48px; padding-left: 8px; border-top: 1px solid var(--line); overflow-x: auto; }
  .account { padding-right: 10px; }
  #user-name { display: none; }
  .app-shell { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 10px; }
  .sidebar-heading { padding-bottom: 8px; }
  .project-list { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .project-item { min-width: 180px; }
  .sidebar-actions { display: flex; margin-top: 10px; overflow-x: auto; }
  .sidebar-actions .button { width: auto; flex: none; }
  .workspace { padding: 24px 18px 80px; }
  .workspace-header { align-items: flex-start; }
  .workspace-actions .button { width: 130px; min-height: 52px; }
  .assistant-bar { left: 14px; right: 14px; bottom: 12px; }
  .phase-track { grid-template-columns: repeat(5, minmax(64px, 1fr)); padding: 18px 0 0; font-size: 12px; }
  .content-grid { gap: 12px; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .run-detail-grid { grid-template-columns: 1fr; }
  .run-detail-grid dt { padding-bottom: 2px; border-bottom: 0; }
  .run-detail-grid dd { padding-top: 2px; }
}
