:root {
  --bg: #070707;
  --bg-2: #101114;
  --card: #121316;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --faint: #6f6f78;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #e23a4a;
  --accent-2: #ff5d6c;
  --ok: #7dcea0;
  --font: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}
button, input, select, textarea { font-family: inherit; font-size: 15px; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; display: block; }

.shell { display: flex; min-height: 100vh; }
.side {
  width: 240px;
  flex: 0 0 240px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand img { width: 188px; height: auto; }
.side-kicker {
  margin: 16px 8px 8px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a {
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--muted);
}
.side nav a.on,
.side nav a:hover { background: rgba(226, 58, 74, 0.12); color: var(--text); }
.side-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.side-foot button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
}

.main { flex: 1; padding: 28px 36px 72px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
h1 { font-size: 32px; line-height: 1.1; font-weight: 640; letter-spacing: -0.03em; margin: 0; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
.lead { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }
.kicker { color: var(--accent); letter-spacing: 0.16em; text-transform: uppercase; font-size: 11px; margin: 0 0 6px; }

.btn, button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  border: 0;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 560;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-2); }
.btn.ghost, button.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.ghost:hover { border-color: rgba(255,255,255,0.32); background: transparent; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 22px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat b { display: block; font-size: 26px; letter-spacing: -0.03em; font-weight: 640; }
.stat span { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
}
.grid-2, .grid-3 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  background: #0c0c0e;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(226, 58, 74, 0.45); border-color: var(--accent); }
.span-2 { grid-column: span 2; }
.secret { display: flex; gap: 8px; width: 100%; }
.secret input { flex: 1 1 auto; width: 0; min-width: 0; }
.secret button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
}

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 560;
  padding: 0 10px 8px;
}
td { padding: 12px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: rgba(255,255,255,0.03); }
.muted { color: var(--muted); }
.right { text-align: right; }
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 10px; }
.row-actions form { margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge-active, .badge-sent { color: #ffd0d4; border-color: rgba(226,58,74,0.45); background: rgba(226,58,74,0.12); }
.badge-unpaid { color: #fff; background: #e23a4a; border-color: #e23a4a; }
.badge-paid, .badge-accepted, .badge-finished { color: var(--ok); border-color: rgba(125,206,160,0.4); background: rgba(125,206,160,0.1); }
.badge-paused, .badge-declined { color: #f0c674; border-color: rgba(240,198,116,0.35); }

.banner { border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }
.banner.ok { background: rgba(125,206,160,0.12); color: var(--ok); }
.banner.err, .banner.warn { background: rgba(226,58,74,0.12); color: #ffc1c7; }
.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input { max-width: 420px; }
.empty { padding: 28px 8px 12px; }
.empty p { color: var(--muted); }
.cred-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 12px 4px;
  margin-bottom: 10px;
}
.cred-card .field { margin-bottom: 10px; }
.icon-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 0 10px;
}
.items td { vertical-align: top; }
.items input { min-width: 0; }
.totals { margin-left: auto; width: min(320px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); }
.totals .grand { color: var(--text); font-size: 18px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px 22px;
}
.gate-card img { width: 240px; margin: 0 auto 8px; }
.gate-card h1 { font-size: 22px; text-align: center; margin-bottom: 16px; }
.gate-card .btn { width: 100%; }

body.paper { background: #dedee2; color: #171717; }
body.paper .btn.ghost { color: #171717; background: white; border-color: #c8c8c8; }
body.paper .btn.ghost:hover { background: #f6f6f6; }
body.paper .badge { color: #333; background: #f3f3f4; border-color: #ddd; }
body.paper .badge-paid, body.paper .badge-accepted, body.paper .badge-finished { color: #0d6b3a; background: #e7f6ee; border-color: #b7e4c7; }
body.paper .badge-sent, body.paper .badge-active { color: #a11d2b; background: #fdecee; border-color: #f3c2c8; }
.unpaid-stamp {
  display: inline-block;
  margin-top: 8px;
  color: #e23a4a;
  border: 3px solid #e23a4a;
  font-weight: 760;
  letter-spacing: 0.18em;
  font-size: 22px;
  line-height: 1;
  padding: 8px 12px;
  transform: rotate(-8deg);
}
.toolbar {
  width: min(820px, calc(100% - 24px));
  margin: 18px auto 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.sheet {
  width: min(820px, calc(100% - 24px));
  margin: 14px auto 32px;
  background: white;
  color: #171717;
  padding: 46px 50px 40px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
}
.sheet-top { display: flex; justify-content: space-between; gap: 24px; }
.wordmark { font-size: 40px; font-weight: 760; letter-spacing: -0.045em; line-height: 0.95; }
.wordmark span:first-child { color: #111; }
.lanka { color: #e23a4a; }
.tag { margin-top: 6px; letter-spacing: 0.2em; font-size: 11px; color: #6a6a6a; }
.doc-kind { text-align: right; }
.doc-kind h1 { font-size: 28px; letter-spacing: 0.08em; margin: 0; }
.doc-meta { color: #444; font-size: 14px; margin-top: 8px; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 28px 0 18px; }
.parties h2 { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: #888; }
.parties p { margin: 0; }
.sheet table th { color: #777; border-bottom: 1px solid #e4e4e4; }
.sheet td { border-top: 1px solid #ececec; }
.sheet .totals { color: #222; }
.sheet .totals div { color: #333; }
.sheet a { color: #1a56c4; text-decoration: underline; }
.pack-block { margin-top: 22px; }
.pack-block h2 { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: #888; margin: 0 0 8px; }
.fact { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid #ececec; }
.fact span { color: #777; }
.fact b { font-weight: 560; overflow-wrap: anywhere; }
.sign-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-top: 28px; min-height: 118px; }
.pad-seal { width: 148px; height: 148px; flex: 0 0 148px; transform: rotate(-8deg); overflow: visible; }
.pad-seal svg { width: 100%; height: 100%; display: block; }
.sheet-foot { margin-top: 28px; padding-top: 12px; border-top: 1px solid #ececec; color: #777; font-size: 12px; display: flex; justify-content: space-between; gap: 12px; }

@media (max-width: 980px) {
  .stats, .grid-3 { grid-template-columns: 1fr 1fr; }
  .cred-card { padding: 10px; }
  .side { width: 100%; height: auto; position: relative; flex-basis: auto; }
  .shell { display: block; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 12px; }
  .main { padding: 20px 16px 48px; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 640px) {
  .stats, .grid-2, .grid-3, .parties, .sheet-top { grid-template-columns: 1fr; display: grid; }
  .head { align-items: flex-start; flex-direction: column; }
  .doc-kind { text-align: left; }
  .sheet { padding: 24px 16px; }
}
@media print {
  body.paper { background: white; }
  .toolbar { display: none; }
  .pad-seal, .unpaid-stamp { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .sheet { box-shadow: none; margin: 0; width: auto; }
}
