:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161b22;
  --panel-soft: #1b222c;
  --border: #303943;
  --text: #e6edf3;
  --muted: #8b98a7;
  --accent: #66b3ff;
  --accent-strong: #2f81f7;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --shadow: 0 16px 40px rgba(0, 0, 0, .2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  background: #11161d;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #37658f;
  border-radius: 10px;
  color: var(--accent);
  font-size: 23px;
  font-weight: 700;
}
h1, h2, p { margin: 0; }
h1 { font-size: 19px; letter-spacing: 0; }
h2 { font-size: 18px; letter-spacing: 0; }
.brand p { margin-top: 2px; color: var(--muted); font-size: 12px; }
.top-actions, .panel-heading, .form-footer, .job-summary, .subheading, .action-bar { display: flex; align-items: center; }
.top-actions { gap: 12px; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr);
  gap: 18px;
  width: min(1420px, calc(100% - 36px));
  margin: 24px auto 50px;
}
.panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel-form { grid-row: span 2; }
.panel-heading { justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.eyebrow { margin-bottom: 4px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.field-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.field em { color: #728297; font-size: 11px; font-style: normal; font-weight: 400; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: 0;
  color: var(--text);
  background: #0f141a;
  padding: 10px 11px;
  font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; min-height: 92px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(47, 129, 247, .18); }
input:disabled, textarea:disabled, select:disabled { color: #687584; background: #12171d; }
.fieldset { margin: 18px 0 4px; padding: 16px; border: 1px solid var(--border); border-radius: 7px; }
.fieldset legend { padding: 0 7px; color: var(--text); font-size: 12px; font-weight: 700; }
.fieldset legend span { color: var(--muted); font-weight: 400; }
.form-footer { justify-content: space-between; gap: 18px; margin-top: 20px; }
.privacy-note { max-width: 560px; color: var(--muted); font-size: 11px; }
.button {
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.button-primary { border-color: #367bd6; background: var(--accent-strong); color: white; }
.button-secondary { border-color: #826121; background: #4b3815; color: #f5d28b; }
.button-danger { border-color: #8d3734; background: #421f20; color: #ffaaa5; }
.button-ghost { border-color: var(--border); background: transparent; color: #b9c5d2; }
.button:hover { filter: brightness(1.12); }
.badge, .status-chip { display: inline-flex; align-items: center; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1; white-space: nowrap; }
.badge { padding: 7px 10px; }
.badge-muted { color: var(--muted); background: #242c35; }
.badge-ok { color: #a6e3ad; background: #17351f; }
.badge-error { color: #ffaaa5; background: #472020; }
.status-chip { padding: 7px 9px; text-transform: lowercase; }
.status-queued { color: #b9c5d2; background: #29313b; }
.status-running { color: #a8d3ff; background: #173a61; }
.status-requires_action { color: #f5d28b; background: #493817; }
.status-succeeded { color: #a6e3ad; background: #17351f; }
.status-declined, .status-failed { color: #ffaaa5; background: #472020; }
.status-canceled { color: #c5ccd4; background: #30353b; }
.message { min-height: 20px; margin-top: 13px; color: var(--muted); font-size: 12px; }
.message-success { color: #a6e3ad; }
.message-error { color: #ffaaa5; }
.empty-state { display: grid; place-items: center; min-height: 178px; padding: 20px; border: 1px dashed #36414e; border-radius: 7px; color: var(--muted); font-size: 12px; text-align: center; }
.empty-state.compact { min-height: 70px; }
.job-summary { justify-content: space-between; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.muted-label, .small-label { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
code { color: #b9d9ff; font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; overflow-wrap: anywhere; }
.job-facts { display: grid; gap: 10px; margin: 16px 0; }
.job-facts div { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 12px; }
.job-facts dt { color: var(--muted); font-size: 11px; }
.job-facts dd { margin: 0; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.action-bar { flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.result-block, .event-block { margin-top: 19px; }
.subheading { justify-content: space-between; margin-bottom: 8px; color: var(--text); font-size: 12px; font-weight: 700; }
.result-box { min-height: 64px; max-height: 170px; overflow: auto; margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 6px; color: #b9c5d2; background: #0c1015; font: 11px/1.6 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.event-log { display: grid; gap: 1px; max-height: 230px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: #0c1015; }
.event-row { display: grid; grid-template-columns: 70px 118px minmax(0, 1fr); gap: 9px; padding: 8px 10px; border-bottom: 1px solid #232b34; font-size: 11px; }
.event-row:last-child { border-bottom: 0; }
.event-row time { color: var(--muted); }
.event-row strong { color: #b9d9ff; overflow-wrap: anywhere; }
.event-row span { color: #aab5c0; overflow-wrap: anywhere; }
.event-empty { padding: 18px; color: var(--muted); font-size: 11px; text-align: center; }
.history-list { display: grid; gap: 7px; }
.history-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); background: var(--panel-soft); text-align: left; }
.history-item:hover { border-color: #4b6a89; background: #202b38; }
.history-main { display: grid; gap: 3px; min-width: 0; }
.history-main span { color: var(--muted); font-size: 11px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .panel-form { grid-row: auto; }
}
@media (max-width: 620px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: space-between; }
  .layout { width: min(100% - 22px, 620px); margin-top: 12px; }
  .panel { padding: 17px; }
  .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .form-footer .button { width: 100%; }
  .event-row { grid-template-columns: 60px 1fr; }
  .event-row span { grid-column: 1 / -1; }
}

/* Compatibility layout for the current Protocol Desk markup. */
.app-shell { min-height: 100vh; }
.brand { color: var(--text); text-decoration: none; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 18px; }
.brand-copy small { color: var(--muted); font-size: 11px; }
.connection-state { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #596574; }
.status-dot.connected, .status-dot.green { background: var(--success); box-shadow: 0 0 0 4px rgba(63, 185, 80, .12); }
.status-dot.error { background: var(--danger); }
.icon-button { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 6px; color: #b9c5d2; background: transparent; }
.icon-button:hover { border-color: #4b6a89; background: #202b38; }
.main-layout { display: grid; grid-template-columns: 258px minmax(0, 1fr); width: min(1420px, 100%); min-height: calc(100vh - 83px); margin: 0 auto; }
.sidebar { display: flex; flex-direction: column; gap: 24px; padding: 24px 18px; border-right: 1px solid var(--border); background: #11161d; }
.side-section { display: grid; gap: 10px; }
.section-kicker { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-heading h2 { margin-top: 3px; font-size: 14px; }
.field-label, .field-label-row { color: var(--muted); font-size: 11px; font-weight: 600; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-meta, .field-hint { color: #728297; font-size: 10px; }
.text-input { width: 100%; }
.mono, .code-input { font-family: "SFMono-Regular", Consolas, monospace; }
.code-input { min-height: 86px; }
.button-quiet { border-color: var(--border); background: transparent; color: #b9c5d2; }
.full-width { width: 100%; }
.sidebar-footer { display: grid; gap: 12px; margin-top: auto; color: var(--muted); font-size: 11px; }
.sidebar-footer a { color: #9fc8ef; text-decoration: none; }
.live-chip { display: inline-flex; align-items: center; gap: 8px; }
.workspace { min-width: 0; padding: 34px clamp(20px, 4vw, 54px) 50px; }
.workspace-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.workspace-heading h1 { margin-top: 7px; font-size: clamp(24px, 3vw, 34px); }
.workspace-heading p { max-width: 640px; margin-top: 9px; color: var(--muted); font-size: 13px; }
.heading-mark { display: flex; align-items: flex-end; gap: 4px; height: 36px; opacity: .7; }
.heading-mark span { display: block; width: 5px; height: 16px; border-radius: 2px; background: var(--accent); }
.heading-mark span:nth-child(2) { height: 25px; opacity: .7; }
.heading-mark span:nth-child(3) { height: 34px; opacity: .5; }
.heading-mark span:nth-child(4) { height: 23px; opacity: .7; }
.heading-mark span:nth-child(5) { height: 12px; opacity: .45; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, .9fr); gap: 18px; align-items: start; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.panel-index { color: var(--muted); font: 11px "SFMono-Regular", Consolas, monospace; }
.form-row { display: grid; gap: 13px; margin-bottom: 14px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.job-form .field { margin-bottom: 14px; }
.form-divider { display: flex; align-items: center; gap: 10px; margin: 22px 0 16px; color: var(--muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.form-divider::before, .form-divider::after { content: ""; height: 1px; background: var(--border); }
.form-divider::before { width: 18px; }
.form-divider::after { flex: 1; }
.toggle-field { display: flex; align-items: center; gap: 9px; align-self: end; min-height: 40px; color: var(--muted); font-size: 11px; cursor: pointer; }
.toggle-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-box { width: 30px; height: 17px; border: 1px solid var(--border); border-radius: 999px; background: #10151b; }
.toggle-field input:checked + .toggle-box { border-color: #3476c8; background: var(--accent-strong); }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.form-message { min-height: 18px; color: var(--muted); font-size: 11px; }
.activity-panel { min-height: 420px; }
.status-badge { display: inline-flex; align-items: center; padding: 7px 10px; border-radius: 999px; color: var(--muted); background: #29313b; font-size: 11px; font-weight: 700; }
.status-badge.status-success { color: #a6e3ad; background: #17351f; }
.status-badge.status-action { color: #f5d28b; background: #493817; }
.status-badge.status-error { color: #ffaaa5; background: #472020; }
.status-badge.status-running { color: #a8d3ff; background: #173a61; }
.job-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 6px 0 22px; padding: 13px 0; border-block: 1px solid var(--border); }
.summary-cell { display: grid; gap: 5px; min-width: 0; }
.summary-cell span, .result-label { color: var(--muted); font-size: 9px; letter-spacing: .1em; }
.summary-cell strong { color: #b9d9ff; font: 11px "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; }
.trace-wrap { position: relative; max-height: 290px; overflow: auto; }
.trace-line { position: absolute; top: 8px; bottom: 8px; left: 6px; width: 1px; background: #34404d; }
.timeline { display: grid; gap: 0; margin: 0; padding: 0 0 0 24px; list-style: none; }
.timeline li { position: relative; padding: 0 0 15px; }
.timeline li::before { content: ""; position: absolute; top: 4px; left: -21px; width: 7px; height: 7px; border: 2px solid #4a5a6a; border-radius: 50%; background: var(--panel); }
.timeline li.event-current::before { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px rgba(102, 179, 255, .12); }
.timeline li.event-success::before { border-color: var(--success); background: var(--success); }
.timeline li.event-error::before { border-color: var(--danger); background: var(--danger); }
.timeline-step { color: #b9d9ff; font-size: 11px; font-weight: 700; }
.timeline-detail { margin-top: 3px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.timeline-time { margin-top: 3px; color: #657487; font-size: 10px; }
.timeline-empty { color: var(--muted); font-size: 11px; }
.action-box { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; padding: 13px; border: 1px solid #725b2d; border-radius: 6px; background: #2a2112; }
.action-title { color: #f5d28b; font-size: 12px; font-weight: 700; }
.action-box p { margin-top: 4px; color: #c4ad7d; font-size: 11px; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 7px; }
.small-button { min-height: 32px; padding: 6px 9px; font-size: 11px; }
.result-box { margin-top: 17px; }
.result-label { margin-bottom: 6px; }
.result-box pre { margin: 0; color: #b9c5d2; font: 11px/1.6 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.hidden { display: none !important; }

@media (max-width: 1050px) {
  .main-layout { grid-template-columns: 210px minmax(0, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .main-layout { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .workspace { padding: 24px 14px 40px; }
  .workspace-heading { align-items: flex-start; }
  .heading-mark { display: none; }
  .two-columns, .three-columns { grid-template-columns: 1fr; }
  .action-box { align-items: flex-start; flex-direction: column; }
}
