:root {
  --ink: #17212b;
  --muted: #63707d;
  --line: #dce3e8;
  --paper: #ffffff;
  --canvas: #f3f6f7;
  --brand: #0c6b5c;
  --brand-dark: #084c42;
  --brand-soft: #dff3ee;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning: #9a6700;
  --shadow: 0 10px 32px rgba(24, 39, 50, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
a { color: var(--brand-dark); }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: .75rem 1rem; background: var(--ink); color: #fff; }
.skip-link:focus { top: 1rem; }
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 68px; display: flex; align-items: center;
  gap: 1.5rem; padding: 0 2rem; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); font-weight: 750; text-decoration: none; white-space: nowrap; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: var(--ink); color: #fff; }
.nav { display: flex; align-self: stretch; align-items: center; gap: .25rem; }
.nav-link { display: flex; align-items: center; height: 100%; padding: 0 .9rem; border-bottom: 3px solid transparent; color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 650; }
.nav-link:hover, .nav-link:focus-visible, .nav-link.active { color: var(--ink); border-bottom-color: var(--brand); }
.top-actions { margin-left: auto; }
.menu-button { display: none; }
.page { width: min(1500px, calc(100% - 3rem)); margin: 0 auto; padding: 2.5rem 0 5rem; }
.page-heading { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-start; margin-bottom: 1.5rem; }
.page-heading h1 { margin: .15rem 0 .35rem; font-size: clamp(1.8rem, 3vw, 2.6rem); letter-spacing: -.035em; }
.page-heading p { margin: .2rem 0; color: var(--muted); max-width: 72ch; }
.eyebrow { color: var(--brand) !important; text-transform: uppercase; letter-spacing: .13em; font-size: .72rem; font-weight: 800; }
.panel { margin-bottom: 1.25rem; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 2px 8px rgba(24,39,50,.035); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.metric { padding: 1.15rem 1.3rem; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.metric span { display: block; color: var(--muted); font-size: .82rem; font-weight: 650; }
.metric strong { display: block; margin-top: .3rem; font-size: 2rem; letter-spacing: -.04em; }
.metric small { display: block; margin-top: .2rem; color: var(--muted); }
.filters { display: grid; grid-template-columns: minmax(240px, 1fr) 220px auto; gap: 1rem; align-items: end; padding: 1.1rem; border-bottom: 1px solid var(--line); }
label { display: grid; gap: .4rem; color: var(--ink); font-size: .86rem; font-weight: 650; }
label small { color: var(--muted); font-weight: 400; }
input, select, textarea { min-height: 44px; width: 100%; padding: .68rem .75rem; border: 1px solid #c9d2d9; border-radius: 9px; background: #fff; color: var(--ink); }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(12,107,92,.22); outline-offset: 2px; border-color: var(--brand); }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: .62rem 1rem; border: 1px solid #c6d0d7; border-radius: 9px; background: #fff; color: var(--ink); font-weight: 700; text-decoration: none; cursor: pointer; }
.button:hover { background: #f7f9fa; }
.button.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-dark); }
.button.ghost { min-height: 38px; border-color: transparent; }
.button.danger { border-color: #edb4ae; background: var(--danger-soft); color: var(--danger); }
.button.compact { min-height: 36px; padding: .35rem .7rem; font-size: .83rem; }
.button.wide { width: 100%; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { padding: .8rem 1rem; color: var(--muted); background: #fafbfb; text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
td { padding: .95rem 1rem; border-top: 1px solid var(--line); vertical-align: middle; }
.task-name { display: block; color: var(--ink); font-weight: 750; text-decoration: none; }
.subtle { display: block; margin-top: .18rem; color: var(--muted); font-size: .78rem; font-weight: 400; }
.status { display: inline-flex; align-items: center; min-height: 26px; padding: .2rem .55rem; border-radius: 999px; background: #eef1f3; color: #46515b; font-size: .75rem; font-weight: 750; }
.status.active, .status.succeeded, .status.ready { background: var(--brand-soft); color: var(--brand-dark); }
.status.running, .status.queued { background: #e8f1ff; color: #175cd3; }
.status.failed, .status.blocked, .status.cancelled { background: var(--danger-soft); color: var(--danger); }
.status.paused, .status.skipped, .status.unknown { background: #fff4d8; color: var(--warning); }
.readiness { color: var(--brand-dark); font-weight: 700; }
.readiness.bad { color: var(--danger); }
.empty { padding: 4rem 2rem; text-align: center; }
.empty h2 { margin-bottom: .4rem; }
.empty p { color: var(--muted); }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-section { padding: 1.35rem; margin: 0; }
.form-section h2, .section-heading h2, .panel > h2 { margin: 0 0 1rem; font-size: 1.05rem; }
.wide-section, .form-actions { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions, .action-row { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }
.code-editor, .output { font-family: "SFMono-Regular", Consolas, monospace; font-size: .84rem; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.summary-card { display: grid; gap: .4rem; padding: 1.2rem; margin: 0; }
.summary-card > span { color: var(--muted); font-size: .78rem; font-weight: 650; }
.summary-card > strong { overflow-wrap: anywhere; font-size: 1rem; }
.summary-card > small { color: var(--muted); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; padding: 1.25rem 1.35rem; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin-bottom: .25rem; }
.section-heading p { margin: 0; color: var(--muted); }
.dependency-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; padding: 1.1rem; }
.dependency { padding: 1rem; border: 1px solid var(--line); border-radius: 12px; }
.dependency strong, .dependency small { display: block; margin-top: .45rem; }
.dependency small, .dependency p { color: var(--muted); }
.memory-panel { padding-bottom: 1.25rem; }
.memory-panel form, .memory-panel details { margin: 1.1rem 1.25rem 0; }
.memory-panel form { display: grid; gap: .8rem; }
.revision-list { color: var(--muted); line-height: 1.8; }
.danger-zone { padding: 1.25rem; border-color: #f0c2bd; }
.danger-zone p { color: var(--muted); }
.output { max-height: 64vh; margin: 0; padding: 1.25rem; overflow: auto; border-top: 1px solid var(--line); background: #101820; color: #e8f0f2; white-space: pre-wrap; overflow-wrap: anywhere; }
.alert { margin: 1rem 0; padding: .85rem 1rem; border-radius: 10px; background: #eef4f7; }
.alert.error { border: 1px solid #f0c2bd; background: var(--danger-soft); color: var(--danger); }
.hidden { display: none; }
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 1.5rem; background: radial-gradient(circle at 10% 10%, #dff3ee, transparent 32%), var(--canvas); }
.auth-card { width: min(100%, 470px); padding: clamp(1.5rem, 5vw, 2.5rem); border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.auth-brand { margin-bottom: 2rem; }
.auth-card h1 { margin: .25rem 0 .7rem; font-size: 2rem; letter-spacing: -.035em; }
.lede { color: var(--muted); line-height: 1.6; }
.fineprint { margin: 1rem 0 0; color: var(--muted); text-align: center; font-size: .75rem; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.project-card { display: flex; gap: 1rem; align-items: flex-start; margin: 0; padding: 1.2rem; color: var(--ink); text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.project-card strong, .project-card small, .project-meta { display: block; }
.project-card small { max-width: 46ch; margin-top: .25rem; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.project-meta { margin-top: .7rem; color: var(--brand-dark); font-size: .78rem; font-weight: 700; }
.project-avatar { display: grid; flex: 0 0 44px; width: 44px; height: 44px; place-items: center; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 850; }
.check { display: flex; min-height: 44px; flex-direction: row; align-items: center; gap: .7rem; }
.check input { width: 20px; min-height: 20px; }
.chat-new { display: grid; max-width: 900px; gap: 1rem; padding: 1.4rem; }
.chat-layout { display: grid; grid-template-columns: minmax(240px, 310px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.chat-sidebar { position: sticky; top: 86px; display: grid; gap: 1rem; padding: 1.2rem; }
.chat-sidebar h2 { margin: .25rem 0 0; overflow-wrap: anywhere; }
.chat-sidebar form { display: grid; gap: .6rem; }
.chat-main { overflow: hidden; }
.chat-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.3rem; border-bottom: 1px solid var(--line); }
.chat-header h1 { margin: .15rem 0 0; font-size: 1.4rem; }
.chat-messages { display: grid; gap: 1rem; min-height: 360px; max-height: 66vh; padding: 1.25rem; overflow-y: auto; background: #f8fafb; }
.chat-message { max-width: min(82%, 900px); padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.chat-message.user { justify-self: end; border-color: #b8ddd4; background: var(--brand-soft); }
.chat-message.event { max-width: 100%; border-style: dashed; background: #f1f4f5; }
.chat-role { margin-bottom: .35rem; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.chat-message pre { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font: inherit; line-height: 1.55; }
.chat-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .8rem; align-items: end; padding: 1.1rem; border-top: 1px solid var(--line); }
.chat-composer .button { min-width: 110px; }
.status-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1000px) {
  .topbar { padding: 0 1rem; flex-wrap: wrap; gap: .75rem; }
  .menu-button { display: inline-flex; margin-left: auto; min-height: 44px; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
  .nav { display: none; order: 4; width: 100%; height: auto; padding-bottom: .75rem; flex-direction: column; align-items: stretch; }
  .nav.open { display: flex; }
  .nav-link { min-height: 44px; padding: .65rem .8rem; border: 0; border-radius: 8px; }
  .nav-link.active { background: var(--brand-soft); }
  .top-actions { margin-left: 0; }
  .metrics, .detail-grid { grid-template-columns: 1fr 1fr; }
  .editor-grid { grid-template-columns: 1fr; }
  .wide-section, .form-actions { grid-column: auto; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { position: static; }
  .status-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .page { width: min(100% - 1.25rem, 1500px); padding-top: 1.4rem; }
  .page-heading { flex-direction: column; gap: 1rem; }
  .page-heading > .button, .page-heading .action-row { width: 100%; }
  .action-row form, .action-row .button, .action-row form .button { width: 100%; }
  .metrics, .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .top-actions { display: none; }
  .project-grid, .status-metrics { grid-template-columns: 1fr; }
  .chat-composer { grid-template-columns: 1fr; }
  .chat-message { max-width: 94%; }
}
