:root {
  --bg: #eef1f6;
  --paper: #ffffff;
  --ink: #1b2230;
  --muted: #667085;
  --line: #e4e8f0;
  --sidebar: #141922;
  --sidebar-2: #10141b;
  --accent: #ff6a1a;
  --accent-2: #2f6fed;
  --ok: #1f9d57;
  --warn: #e7a30a;
  --danger: #e23b32;
  --shadow: 0 12px 40px rgba(20, 25, 34, .08);
  --radius: 14px;
  --mono: "IBM Plex Mono", Consolas, "Courier New", monospace;
  --sans: "Manrope", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body, #app {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  background: #10141b;
  color: #fff;
}
.login-art {
  padding: 48px 56px;
  background:
    radial-gradient(800px 400px at 20% 20%, rgba(255, 106, 26, .18), transparent),
    linear-gradient(#10141b, #0c1016);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-art .brand {
  font-weight: 800;
  letter-spacing: 0.1em;
  font-size: 15px;
  text-transform: uppercase;
  color: #fff;
  margin: 0 0 8px;
}
.login-art h2 {
  font-size: 42px;
  line-height: 1.1;
  margin: 28px 0 16px;
  font-weight: 800;
}
.login-art p { color: #9aa5b8; max-width: 460px; font-size: 16px; margin: 0; }
.login-card {
  background: #fff;
  color: var(--ink);
  margin: 24px;
  border-radius: 20px;
  padding: 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow);
}
.login-card .brand {
  font-weight: 800;
  letter-spacing: 0.1em;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}
.login-card h1 { margin: 0 0 18px; font-size: 26px; font-weight: 800; }
.login-card label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 4px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
}
.login-card button {
  margin-top: 22px;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 11px 12px;
  font-weight: 700;
}
.hint { margin-top: 14px; color: var(--muted); font-size: 12px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

.shell {
  display: block;
  height: 100%;
  overflow: hidden;
}
.side {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 248px;
  z-index: 30;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #d7dde8;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.brand-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 0;
  color: #fff;
  padding: 0;
  text-align: center;
}
.brand-home.static { cursor: default; }
.brand-home img {
  width: 100%;
  max-width: 132px;
  height: auto;
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  display: block;
}
.brand-home .brand-title {
  font-weight: 800;
  letter-spacing: 0.1em;
  font-size: 15px;
  text-transform: uppercase;
  color: #fff;
}
.brand-home small {
  display: block;
  color: #8b95a7;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.brand-home:hover .brand-title { color: var(--accent); }
.login-art .brand-home { align-items: flex-start; max-width: 240px; }
.login-art .brand-home img { max-width: 220px; }
.side .brand {
  padding: 16px 14px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  margin: 0;
}
.side h2 { display: none; }
.side button.nav {
  background: transparent;
  color: #c5cedc;
  border: 0;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  margin: 0 10px;
}
.side button.nav:first-of-type { margin-top: 12px; }
.side button.nav:hover { background: #ffffff0d; }
.side button.nav.active { background: #ff6a1a29; color: #fff; }
.side .who {
  margin-top: auto;
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  font-size: 13px;
  color: #9aa5b8;
}
.side .who b { color: #fff; display: block; }
.side .who button {
  margin-top: 10px;
  background: transparent;
  color: #c5cedc;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 8px;
  padding: 6px 10px;
  width: 100%;
}

.main {
  margin-left: 248px;
  height: 100%;
  overflow: auto;
  padding: 22px 28px 40px;
  background: var(--bg);
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
h1.page { margin: 0 0 16px; font-size: 24px; font-weight: 800; }
h3 { margin: 20px 0 8px; font-size: 15px; font-weight: 700; }

.btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 13px;
}
.btn.ghost { background: #f3f5f9; color: var(--ink); border: 0; }
.btn.small { padding: 4px 8px; font-size: 12px; border-radius: 8px; }
.btn.ord { min-width: 28px; padding: 4px 6px; font-size: 12px; line-height: 1; }
.btn:disabled { opacity: 0.45; cursor: default; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.field span { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700; }
.param-box { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; text-align: left; }
.param-line { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.param-line span { font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; min-width: 72px; }
.param-line input, .param-line select { min-width: 64px; }

.field input, .field select {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 10px;
  padding: 8px 10px;
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0 0; overflow-x: auto; }
.tabs button {
  background: transparent;
  border: 0;
  border-radius: 8px 8px 0 0;
  padding: 8px 12px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 700;
  font-size: 13px;
}
.tabs button:hover { background: #f3f5f9; color: var(--ink); }
.tabs button.active { color: var(--ink); background: #fff1e8; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 14px;
  overflow: hidden;
}
.card header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card header .grow { font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; }
.card .body { padding: 12px 16px; overflow: auto; }

.stack { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.stack > .field { width: 100%; min-width: 0; }
.stack .field input { width: 100%; box-sizing: border-box; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid.grid-fit { width: max-content; min-width: 100%; }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.grid.grid-fit th,
table.grid.grid-fit td { overflow: hidden; }
table.grid td.wrap {
  white-space: normal;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.35;
}
table.grid td.wrap .wrap-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
  white-space: normal;
}
table.grid textarea.cell {
  display: block;
  width: 100%;
  min-height: calc(1.35em * 2);
  max-height: calc(1.35em * 2);
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  line-height: 1.35;
}
table.grid td:has(.actions),
table.grid td:has(.btn) {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
table.grid th.col-head { position: relative; user-select: none; }
.col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}
.col-resizer:hover,
.col-resizing .col-resizer { background: #ff6a1a55; }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing iframe { pointer-events: none; }
table.grid th { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 0.03em; }
table.grid .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid tr.rate td { font-weight: 700; background: #f7f8fb; }
table.grid tr.mat-main td { background: #e4f7ec; }
table.grid tr.mat-cons td { background: #e8f0ff; }
table.grid tr.clickable { cursor: pointer; }
table.grid td.clickable { cursor: pointer; }
table.grid tr.clickable:hover td,
table.grid td.clickable:hover { background: #fff1e8; }
table.grid tr.mat-main:hover td { background: #d4eedd; }
table.grid tr.mat-cons:hover td { background: #d9e4fb; }
.code, .id-badge { font-variant-numeric: tabular-nums; font-family: var(--mono); }
.id-badge {
  display: inline-block;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: #fff1e8;
  border-radius: 999px;
  padding: 4px 10px;
  letter-spacing: 0.04em;
  font-weight: 700;
  font-size: 12px;
}

table.grid input.cell {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: inherit;
  padding: 0;
}
table.grid a { word-break: break-all; }

.pill { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; }
.pill.draft { background: #e4f7ec; color: #157a42; }
.pill.issued { background: #fff4cc; color: #8a6400; }

.list { display: grid; gap: 8px; }
.list button.item {
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.list button.item:hover,
.list button.item.active { border-color: var(--accent); box-shadow: 0 0 0 3px #ff6a1a1f; }
.list button.item b { display: block; }
.muted { color: var(--muted); }
.money { font-variant-numeric: tabular-nums; font-family: var(--mono); }

.modal-back {
  position: fixed; inset: 0; background: #10141b75;
  display: grid; place-items: center; z-index: 20;
}
.modal {
  width: min(720px, 92vw); max-height: 80vh; overflow: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 18px;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line); border-radius: 3px; }
.swatch.main { background: #e4f7ec; }
.swatch.cons { background: #e8f0ff; }
.dup-cluster { border-top: 1px solid var(--line); padding: 12px 0; }
.dup-cluster:first-child { border-top: 0; }
.search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0 12px;
  background: var(--paper);
}

.log { font-size: 12px; max-height: 240px; overflow: auto; white-space: pre-wrap; color: var(--muted); font-family: var(--mono); }

@media (max-width: 860px) {
  html, body, #app { height: auto; min-height: 100%; overflow: auto; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .shell { height: auto; overflow: visible; }
  .side {
    position: static;
    width: auto;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .side .brand { border-bottom: 0; border-right: 1px solid rgba(255,255,255,.06); }
  .side .who { margin-top: 0; margin-left: auto; border-top: 0; }
  .main { margin-left: 0; height: auto; overflow: visible; }
}

@media print {
  .side, .tabs, .btn, .no-print { display: none !important; }
  html, body, #app, .shell, .main { height: auto; overflow: visible; }
  .shell { display: block; }
  .main { margin-left: 0; padding: 0; background: #fff; }
}
