:root {
  --bg: #eef1f3;
  --surface: #ffffff;
  --ink: #1a2b24;
  --muted: #6a7a72;
  --line: rgba(26, 43, 36, 0.08);
  --soft: #f3f5f4;
  --soft-2: #e8eeea;
  --accent: #1f6b4a;
  --accent-hover: #185a3d;
  --accent-2: #8a6f2f;
  --ok: #1f6b4a;
  --warn: #9a7b2f;
  --fail: #9a3f3f;
  --danger: #9a3f3f;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(26, 43, 36, 0.04), 0 8px 28px rgba(26, 43, 36, 0.05);
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --display: "Manrope", "Source Sans 3", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 8% -8%, rgba(31, 107, 74, 0.07), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(154, 123, 47, 0.05), transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.bg-orb { display: none; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 22px 14px 18px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  padding: 4px 8px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
}
.brand-text {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.2rem;
}

.nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2px;
  font-weight: 550;
  font-size: 0.92rem;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--soft); color: var(--ink); }
.nav-item.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 650;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 8px;
}
.workspace-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  width: fit-content;
}
.workspace-badge.vendor {
  color: var(--accent-2);
  background: rgba(138, 111, 47, 0.1);
}
.workspace-badge.company {
  color: var(--accent);
  background: rgba(31, 107, 74, 0.1);
}
.user-chip strong { display: block; color: var(--ink); font-size: 0.9rem; }
.user-chip .muted { font-size: 0.75rem; }
.linkish {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-weight: 600;
  text-align: left;
}

.main { padding: 28px 32px 48px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 550;
}
h1 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: clamp(1.45rem, 2vw, 1.85rem);
  letter-spacing: -0.03em;
  font-weight: 700;
  color: var(--ink);
}
h2 {
  margin: 0 0 14px;
  font-size: 1rem;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-grid.compact { grid-template-columns: repeat(3, 1fr); }
.kpi {
  background: var(--soft);
  border-radius: 14px;
  padding: 14px 16px;
  min-height: 84px;
}
.kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 550;
}
.kpi strong {
  display: block;
  font-size: 1.55rem;
  margin-top: 6px;
  font-family: var(--display);
  letter-spacing: -0.03em;
  font-weight: 700;
  color: var(--ink);
}
.kpi em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.75rem;
  display: block;
  margin-top: 2px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}
.panel-head h2 { margin: 0; }
.panel-head a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 650;
}

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  background: var(--soft);
}
.table th:first-child { border-radius: 10px 0 0 10px; }
.table th:last-child { border-radius: 0 10px 10px 0; }
.table tbody tr:hover td { background: rgba(243, 245, 244, 0.55); }
.table a { color: var(--accent); text-decoration: none; font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.84rem; }
.break { word-break: break-all; }
.muted { color: var(--muted); }
.danger { color: var(--danger); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  background: var(--soft);
  color: var(--muted);
}
.pill.xl { font-size: 0.85rem; padding: 6px 14px; }
.status-active, .status-completed, .status-signed, .status-sent {
  background: rgba(31, 107, 74, 0.12);
  color: var(--ok);
}
.status-in_progress, .status-pending, .status-waiting, .status-paused, .status-merging, .status-bank_pending {
  color: var(--warn);
  background: rgba(154, 123, 47, 0.14);
}
.status-failed, .status-rejected, .status-expired, .status-cancelled, .status-archived {
  color: var(--fail);
  background: rgba(154, 63, 63, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  font-size: 0.88rem;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover { background: var(--soft); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.btn.ghost:hover { color: var(--ink); background: var(--soft); }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.bars {
  display: flex;
  align-items: end;
  gap: 10px;
  min-height: 140px;
  padding-top: 12px;
}
.bar-col { flex: 1; display: grid; justify-items: center; gap: 8px; }
.bar {
  width: 100%;
  max-width: 26px;
  height: var(--h, 8px);
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--accent), rgba(31, 107, 74, 0.25));
}
.bar-col span { font-size: 0.68rem; color: var(--muted); }

.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.filters label,
.stack label,
fieldset label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 550;
}
input, select, textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--soft);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: rgba(31, 107, 74, 0.35);
  box-shadow: 0 0 0 3px rgba(31, 107, 74, 0.1);
}
.form-grid { display: grid; gap: 16px; }
fieldset {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 12px;
  background: var(--surface);
}
legend {
  padding: 0 8px;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
}
.hint { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.check { display: flex !important; align-items: center; gap: 8px; color: var(--ink); }
.check input { width: auto; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.signer-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--soft);
}
.signer-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 12px 0 12px 14px;
  border-left: 2px solid rgba(31, 107, 74, 0.35);
  margin-left: 6px;
}
.t-kind {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 650;
  margin-bottom: 2px;
}
.plain { margin: 0; padding-left: 18px; }
.cardish h2 { margin-bottom: 8px; }
.cardish p { color: var(--muted); margin: 0; line-height: 1.45; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-brand { margin-bottom: 18px; }
.alert {
  background: rgba(154, 63, 63, 0.1);
  border: 1px solid rgba(154, 63, 63, 0.22);
  color: var(--fail);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
}
.alert.soft {
  background: rgba(154, 123, 47, 0.1);
  border-color: rgba(154, 123, 47, 0.25);
  color: var(--warn);
}
.stack { display: grid; gap: 12px; }
.tpl-toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.tpl-toolbar .grow { flex: 1; min-width: 220px; }
.tpl-preview {
  background: var(--soft);
  border-radius: 12px;
  padding: 12px 14px;
}
.tpl-preview pre {
  white-space: pre-wrap;
  margin: 8px 0;
  font-family: inherit;
  color: var(--ink);
  line-height: 1.45;
}
.tpl-params { display: grid; gap: 10px; }
.tpl-params label {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  align-items: center;
}
.tpl-params label span {
  font-family: ui-monospace, monospace;
  color: var(--accent);
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .grid-2, .kpi-grid, .kpi-grid.compact { grid-template-columns: 1fr 1fr; }
  .main { padding: 18px; }
  .kv { grid-template-columns: 1fr; }
}
