:root {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: #1f2a2f;
  background: #f5f6f2;
  color-scheme: light;
  --ink: #182d37;
  --muted: #506067;
  --line: #dce3de;
  --surface: #fff;
  --accent: #12635a;
  --accent-dark: #0c4c45;
  --danger: #9a282c;
  --warning: #79500a;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, a { touch-action: manipulation; }
a { color: var(--accent-dark); text-underline-offset: .2em; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
:focus-visible { outline: 3px solid #cb7b25; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { color: var(--ink); line-height: 1.16; }
h1 { font-size: clamp(1.9rem, 3vw, 2.7rem); letter-spacing: -.044em; }
h2 { font-size: 1.17rem; letter-spacing: -.018em; }
h3 { font-size: 1rem; }
p { line-height: 1.5; }
pre, code { font-family: "Segoe UI", system-ui, sans-serif; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; line-height: 1.55; }

.skip-link { position: fixed; left: 1rem; top: -4rem; padding: .7rem; z-index: 20; background: white; }
.skip-link:focus { top: .65rem; }
.workspace { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--ink);
  color: #edf6f5;
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 1.55rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 2.4rem;
}
.brand { display: flex; align-items: center; gap: .75rem; font-size: 1.09rem; font-weight: 720; letter-spacing: -.035em; }
.sidebar .brand { padding-inline: .4rem; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 2.05rem;
  aspect-ratio: 1;
  border: 1px solid #84bdad;
  border-radius: .5rem;
  background: #c1dfd4;
  color: #123d39;
  font-size: 1.16rem;
  font-weight: 800;
}
.sidebar nav { display: grid; gap: .34rem; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .7rem .65rem;
  border-radius: .43rem;
  text-decoration: none;
  color: #d4e4e5;
  font-size: .91rem;
  font-weight: 600;
  white-space: nowrap;
}
.sidebar nav a:hover, .sidebar nav a[aria-current] { color: white; background: #2c4954; }
.nav-icon { width: 1.05rem; text-align: center; color: #a7cfc6; }
.account { margin-top: auto; display: flex; align-items: center; gap: .65rem; border-top: 1px solid #3a535a; padding: .95rem .25rem 0; min-width: 0; }
.account-avatar { display: grid; place-items: center; width: 2.1rem; aspect-ratio: 1; flex: none; border-radius: 50%; background: #354f5a; font-size: .77rem; font-weight: 750; }
.account-details { display: grid; min-width: 0; }
.text-button { display: block; border: 0; background: none; padding: .2rem 0; text-align: left; color: inherit; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.text-button:hover { text-decoration: underline; }
.account-logout { color: #c0d3d4; font-size: .78rem; }

.main { min-width: 0; }
.toolbar { min-height: 4.25rem; background: var(--surface); border-bottom: 1px solid var(--line); padding: .7rem clamp(1.15rem, 4vw, 3.85rem); display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.toolbar-label { font-weight: 670; color: var(--ink); }
.toolbar-actions { display: flex; align-items: center; gap: .85rem; }
.connection { color: var(--muted); white-space: nowrap; font-size: .82rem; }
.connection::before { display: inline-block; content: ""; width: .48rem; aspect-ratio: 1; margin-right: .43rem; border-radius: 50%; background: #8c9a94; vertical-align: .06em; }
.connection[data-state="live"]::before { background: #227763; }
.connection[data-state="offline"]::before { background: #b35437; }
.view { width: min(100%, 90rem); padding: clamp(1.4rem, 4.1vw, 3.15rem) clamp(1.15rem, 4vw, 3.85rem); margin-inline: auto; }
.view-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.5rem; }
.view-head p { margin-top: .48rem; }
.back { display: inline-block; margin-bottom: .7rem; font-size: .87rem; }
.muted { color: var(--muted); }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .3rem;
  max-width: 100%;
  border: 1px solid #cad8d0;
  background: var(--surface);
  color: #22413d;
  min-height: 2.5rem;
  border-radius: .42rem;
  font-weight: 670;
  text-align: center;
  text-decoration: none;
  padding: .49rem .83rem;
  line-height: 1.25;
}
.button:hover:not(:disabled) { background: #eef4f0; }
.button.primary { border-color: var(--accent); background: var(--accent); color: white; }
.button.primary:hover:not(:disabled) { background: var(--accent-dark); }
.button.danger { border-color: #e8c7c7; color: var(--danger); }
.button.danger:hover:not(:disabled) { background: #fff2ef; }
.button.small { font-size: .82rem; min-height: 2.1rem; padding: .34rem .61rem; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .57rem; }

.columns { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; }
.stack { display: grid; align-content: start; gap: 1rem; min-width: 0; }
.panel, .metric { border: 1px solid var(--line); background: var(--surface); border-radius: .62rem; min-width: 0; }
.panel { padding: 1.1rem 1.2rem; }
.panel + .panel { margin-top: 1rem; }
.stack > .panel + .panel, .columns > .panel + .panel { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .7rem; margin-bottom: .8rem; }
.panel-head a { font-size: .9rem; font-weight: 650; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.metric { text-decoration: none; display: grid; align-content: start; gap: .28rem; padding: 1rem 1.05rem; }
a.metric:hover { border-color: #a0bfae; }
.metric-label { font-size: .86rem; color: var(--muted); font-weight: 640; }
.metric-value { color: var(--ink); font-size: 2rem; line-height: 1.13; font-variant-numeric: tabular-nums; letter-spacing: -.05em; font-weight: 720; }
.metric-subtitle { font-size: .79rem; color: var(--muted); }
.list { display: grid; list-style: none; padding: 0; margin: 0; }
.list-row { padding: .8rem 0; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-width: 0; }
.list-row:first-child { border-top: none; padding-top: .25rem; }
.list-row:last-child { padding-bottom: .25rem; }
.list-title { font-weight: 670; color: var(--ink); overflow-wrap: anywhere; }
.list-meta { font-size: .83rem; color: var(--muted); overflow-wrap: anywhere; }
.list-main { display: grid; gap: .23rem; min-width: 0; }
.list-side { justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; max-width: 100%; border-radius: 1rem; background: #eef1ef; color: #374a45; padding: .2rem .57rem; line-height: 1.35; font-size: .76rem; font-weight: 690; white-space: nowrap; }
.pill.good { background: #e3f1e9; color: #1f5c47; }
.pill.warn { background: #fbefd9; color: #69400a; }
.pill.bad { background: #f9e9e7; color: #8b3026; }
.empty { color: var(--muted); text-wrap: pretty; font-size: .94rem; padding-block: .15rem .25rem; }
.notice { position: relative; margin: 1rem clamp(1.15rem, 4vw, 3.85rem) 0; padding: .69rem .87rem; border: 1px solid #9fc7b4; border-radius: .45rem; background: #edf6ef; color: #234c39; }
.notice[data-error="true"] { background: #fff0ec; color: var(--danger); border-color: #e0b8af; }

.login-shell { min-height: 100dvh; display: grid; place-items: center; padding: 1.2rem; background: linear-gradient(135deg, #e6efea, #f5f6f2 68%); }
.login-card { width: min(100%, 25rem); background: var(--surface); border: 1px solid var(--line); border-radius: .85rem; padding: clamp(1.25rem, 5vw, 2rem); box-shadow: 0 1.1rem 3rem #19352812; }
.login-card h1 { margin: 1.5rem 0 .45rem; }
.login-card form { margin-top: 1.25rem; }
.form-stack { display: grid; gap: .7rem; align-items: start; }
.form-stack label, .field-label { font-size: .87rem; font-weight: 680; }
.field { display: grid; gap: .33rem; }
.field small, .help { color: var(--muted); line-height: 1.45; font-size: .85rem; }
input, textarea, select { min-width: 0; width: 100%; border: 1px solid #b8c8c0; border-radius: .4rem; padding: .56rem .64rem; background: #fff; color: #233b36; }
textarea { resize: vertical; min-height: 6.2rem; }
.form-error { color: var(--danger); font-size: .86rem; overflow-wrap: anywhere; }
dialog { width: min(34rem, calc(100% - 1.6rem)); max-height: 90dvh; padding: 1.25rem; color: inherit; border: 1px solid var(--line); border-radius: .7rem; box-shadow: 0 1rem 3rem #0a181a3c; }
dialog::backdrop { background: #10232996; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.invite-value { display: block; font-size: .92rem; overflow-wrap: anywhere; line-height: 1.5; padding: .65rem .75rem; background: #eef4f0; border: 1px solid var(--line); border-radius: .35rem; user-select: all; }
.subsection { margin-top: 1rem; }
.description { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font-size: .9rem; }
.queue-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.queue-list li { display: flex; align-items: center; justify-content: space-between; padding: .42rem 0; border-bottom: 1px solid var(--line); }
.queue-list li:last-child { border-bottom: 0; }

.chat-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); align-items: start; gap: 1rem; }
.chat { min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: .65rem; display: grid; grid-template-rows: minmax(14rem, auto) auto; overflow: hidden; }
.older { display: flex; justify-content: center; padding: .65rem 1rem 0; }
.messages { list-style: none; display: flex; flex-direction: column; align-items: stretch; gap: .75rem; margin: 0; padding: 1rem 1.12rem; max-height: 56vh; min-height: 14rem; overflow: auto; overflow-anchor: none; }
.message { align-self: flex-start; max-width: min(95%, 60rem); border: 1px solid var(--line); border-radius: .58rem; padding: .6rem .75rem; background: #f7f8f6; }
.message.mine { align-self: flex-end; background: #e8f3ed; border-color: #c6dbcd; }
.message-meta { color: var(--muted); display: block; margin-bottom: .28rem; font-size: .75rem; font-weight: 650; overflow-wrap: anywhere; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .94rem; }
.composer { border-top: 1px solid var(--line); padding: 1rem 1.12rem; background: #fafbf9; }
.composer textarea { min-height: 4.7rem; }
.composer details > summary { cursor: pointer; color: var(--accent-dark); font-size: .85rem; font-weight: 650; }
.composer details > div { display: grid; gap: .6rem; margin-top: .55rem; }
.job-body { font-size: .83rem; color: var(--muted); overflow-wrap: anywhere; }
.button.job-link { padding: 0; min-height: 1.65rem; border: 0; color: var(--accent-dark); background: transparent; text-decoration: underline; text-underline-offset: .2em; text-align: left; }
.button.job-link:hover { background: transparent; color: var(--ink); }
.result-text { padding: .65rem .75rem; max-height: 20rem; overflow: auto; background: #f7f8f6; border: 1px solid var(--line); border-radius: .35rem; }
.approval-block { display: grid; gap: .75rem; padding-block: .85rem; border-bottom: 1px solid var(--line); }
.approval-block:last-child { padding-bottom: .15rem; border-bottom: none; }
.approval-block pre { background: #f7f8f6; border: 1px solid var(--line); border-radius: .35rem; padding: .6rem .72rem; max-height: 20rem; overflow: auto; }
.fingerprint { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }

@media (max-width: 70rem) {
  .workspace { grid-template-columns: 12.8rem minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 56rem) {
  .columns, .chat-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 43rem) {
  .workspace { display: block; }
  .sidebar { position: relative; height: auto; padding: .85rem 1rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .65rem 1rem; }
  .sidebar .brand { padding: 0; }
  .sidebar nav { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: .2rem; padding-block: .15rem .3rem; }
  .sidebar nav a { padding: .58rem .5rem; }
  .sidebar .account { padding: 0; margin: 0; border: 0; max-width: 11rem; }
  .sidebar .account-avatar, .nav-icon { display: none; }
  .view-head { align-items: flex-start; flex-direction: column; }
  .panel-head { flex-wrap: wrap; }
  .toolbar, .view { padding-inline: 1rem; }
  .messages { max-height: 53vh; }
}
@media (max-width: 25rem) {
  .toolbar-label { display: none; }
  .toolbar-actions { width: 100%; justify-content: space-between; }
  .metric, .panel { padding-inline: .75rem; }
  .list-row { flex-wrap: wrap; }
}
