:root {
  --bg: #eef2f6;
  --card: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #d0d5dd;
  --accent: #1b4ddb;
  --accent-soft: #e8eeff;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #067647;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }

.shell { min-height: 100vh; padding-bottom: 28px; }

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: -0.04em;
  flex: none;
}
h1 { margin: 0; font-size: 18px; font-weight: 700; }
.who { margin: 2px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seg {
  display: flex;
  background: #f2f4f7;
  padding: 4px;
  border-radius: 12px;
  flex: none;
}
.tab {
  border: 0;
  background: transparent;
  color: #475467;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.tab.is-on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16,24,40,.12); }

.banner {
  margin: 12px 20px 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.stage { width: min(1080px, calc(100% - 32px)); margin: 16px auto 0; }
.page-h { margin: 0; font-size: 18px; }

.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 8px;
  margin-bottom: 14px;
}
.block-h { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.block-h h2 { margin: 0; font-size: 16px; }
.block-h p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.step {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; flex: none;
}

.id-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.id-card {
  background: #f8fafc;
  border: 1px dashed #cfd6e4;
  border-radius: 12px;
  padding: 12px 14px;
}
.id-card span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.id-card strong { font-size: 15px; }

.two { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.field > span, legend { font-weight: 650; font-size: 13px; }
.field i { color: var(--danger); font-style: normal; }
small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.err { color: var(--danger); font-size: 12px; }

input, textarea, select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid #c7d7ff;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 72px; }

.prio { border: 0; padding: 0; margin: 0 0 14px; }
.prio-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prio-card {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  background: #fff;
}
.prio-card input { position: absolute; opacity: 0; pointer-events: none; }
.prio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.prio-card.crit:has(input:checked) {
  border-color: var(--danger);
  background: #fff4f3;
  box-shadow: inset 0 0 0 1px var(--danger);
}
.prio-title { font-weight: 700; font-size: 14px; }
.prio-sub { color: var(--muted); font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  color: #344054;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }

.opt-list { display: grid; gap: 12px; margin-bottom: 10px; }
.option {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fafbff;
}
.option-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.option-top strong { font-size: 13px; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.opt-grid textarea, .option .o-title { min-height: 0; }
.linkish {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px;
}
.linkish:hover { color: var(--danger); }

.drop {
  display: flex; flex-direction: column; gap: 4px;
  border: 1px dashed #98a2b3;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}
.drop input { display: none; }
.drop strong { color: var(--accent); font-size: 14px; }
.file-list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; color: #344054; }
.file-list li { padding: 4px 0; border-bottom: 1px solid #eef2f6; }

.dock {
  position: sticky; bottom: 0;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  margin: 8px 0 20px;
}
.dock-hint { margin: 0; color: var(--muted); font-size: 12px; }

.btn {
  border: 0; border-radius: 10px;
  padding: 10px 16px; cursor: pointer; font-weight: 650;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.block-h h2 i { color: var(--danger); font-style: normal; }

.btn.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner.lg {
  width: 36px; height: 36px;
  border-width: 3px;
  border-color: #d0d5dd;
  border-top-color: var(--accent);
}
@keyframes spin { to { transform: rotate(360deg); } }

.busy {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16, 24, 40, .45);
  display: grid; place-items: center;
  padding: 20px;
}
.busy-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.busy-card p { margin: 14px 0 6px; font-weight: 700; }
.busy-card small { color: var(--muted); }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: #344054; }
.back { margin-bottom: 12px; }

.status {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.status.ok { border-color: #abefc6; background: #f6fef9; color: var(--ok); }
.status.bad { border-color: #fecdca; background: #fff5f4; color: var(--danger); }
.status.wait { color: var(--muted); }

.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { min-width: 140px; }

.cards { display: grid; gap: 8px; }
.item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-left: 4px solid #98a2b3;
  box-shadow: var(--shadow);
}
.item:hover { border-color: #b2c4ff; }
.item.crit { border-left-color: var(--danger); }
.item.overdue { background: #fffaf0; }
.item-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.item-id { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.item-title { font-size: 14px; line-height: 1.4; }
.muted { color: var(--muted); font-size: 12px; margin-top: 6px; }
.empty {
  background: #fff; border: 1px dashed var(--line); border-radius: 12px;
  padding: 40px 16px; text-align: center; color: var(--muted);
}

.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: #eef2f6; color: #344054;
}
.badge.crit { background: #fee4e2; color: var(--danger); }
.badge.over { background: #feefc7; color: var(--warn); }
.badge.ok { background: #d1fadf; color: var(--ok); }
.badge.wait { background: var(--accent-soft); color: var(--accent); }

.detail {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.detail h2 { margin: 0 0 8px; font-size: 20px; font-family: ui-monospace, Consolas, monospace; }
.detail h3 { margin: 18px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.detail p { margin: 0; white-space: pre-wrap; line-height: 1.5; }
.reply-box {
  background: #f6fef9;
  border: 1px solid #abefc6;
  border-radius: 12px;
  padding: 12px 14px;
}
.reply-box.empty-reply { background: #f8fafc; border-style: dashed; border-color: var(--line); color: var(--muted); }
.history { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .bar { flex-wrap: wrap; }
  .two, .id-grid, .prio-row, .opt-grid { grid-template-columns: 1fr; }
  .stage { width: calc(100% - 20px); }
  .dock { flex-direction: column; align-items: stretch; }
}
