:root {
  --ink: #1e1526;
  --muted: #6b6172;
  --accent: #a8365c;
  --accent-a: #9e2f55;
  --accent-b: #b33f66;
  --bg: #fbf8f6;
  --card: #ffffff;
  --line: #e8e0dc;
  --ok: #1f6b4a;
  --ok-bg: #e6f3ec;
  --bad: #9b1c1c;
  --bad-bg: #fbeaea;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, .brand, .stat b { font-family: "Archivo", "IBM Plex Sans", system-ui, sans-serif; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 12px; font-weight: 700; overflow-wrap: anywhere; }
h2 { font-size: 16px; margin: 22px 0 10px; font-weight: 600; }
.card > h2:first-child, .card form > h2:first-of-type { margin-top: 0; }
.card form > h2:first-of-type ~ h2 { margin-top: 22px; }
a { color: var(--accent); }
a:hover { color: var(--accent-a); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: #f4eeea; padding: 2px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 24px; padding-bottom: 60px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.late { color: var(--bad); }

.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 24px; min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { text-decoration: none; color: var(--ink); display: flex; align-items: baseline; gap: 7px; }
.brand-a { font-weight: 700; letter-spacing: .06em; font-size: 18px; }
.brand-b { color: var(--accent); font-weight: 600; font-size: 14px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--ink); text-decoration: none; padding: 7px 11px; border-radius: 7px; font-weight: 500; font-size: 14px; }
.nav a:hover { background: #f4eeea; }
.nav a.on { background: #f6e6ec; color: var(--accent-a); }
.who { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 13px; }
.who-mail { color: var(--muted); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin: 0 0 18px; }
.card.narrow { max-width: 420px; margin: 48px auto; }
.card.narrow-left { max-width: 520px; }
.card.empty { color: var(--muted); text-align: center; padding: 40px 20px; }

label { display: block; font-size: 13px; font-weight: 500; margin: 0 0 4px; color: #3b3142; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #cfc5c0; border-radius: 8px; padding: 9px 11px; min-height: 40px; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; margin: 0 8px 0 0; vertical-align: -3px; accent-color: var(--accent); }
input[type=file] { padding: 7px; }
textarea { min-height: 76px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid rgba(168, 54, 92, .35); outline-offset: 1px; }
input.code { font-size: 24px; letter-spacing: .3em; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; }
.check label { font-weight: 400; font-size: 14px; display: flex; align-items: center; }
.btn { display: inline-block; border: 0; border-radius: 8px; padding: 10px 18px; min-height: 40px; font: 600 14px "IBM Plex Sans", system-ui, sans-serif; color: #fff; background: linear-gradient(135deg, var(--accent-a), var(--accent-b)); cursor: pointer; margin-top: 14px; }
.btn:hover { filter: brightness(1.07); }
.btn.small { padding: 7px 13px; min-height: 34px; font-size: 13px; }
.btn.ghost { background: #fff; color: var(--accent-a); border: 1px solid var(--accent); }
.narrow form label { margin-top: 12px; }
.narrow .btn { width: 100%; }

.flash { border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: #b9dcc8; color: var(--ok); }
.flash.err { background: var(--bad-bg); border-color: #efc2c2; color: var(--bad); }
.flash ul { margin: 8px 0 0; padding-left: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 0 0 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.1; font-weight: 700; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.warn { background: var(--warn-bg); border-color: #efd9a0; }
.stat.warn b { color: var(--warn); }
.stat.bad { background: var(--bad-bg); border-color: #efc2c2; }
.stat.bad b { color: var(--bad); }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto auto; gap: 12px; align-items: end; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 0 0 14px; }
.filters .btn { margin-top: 0; }
.filters .check { padding-bottom: 9px; white-space: nowrap; }
.filters .actions { white-space: nowrap; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table.rows { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rows th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.rows td { padding: 11px 14px; border-bottom: 1px solid #f1ebe7; vertical-align: top; overflow-wrap: anywhere; }
table.rows tr:last-child td { border-bottom: 0; }
table.rows tbody tr:hover { background: #fdfaf8; }
table.rows .col-src { min-width: 170px; }
table.rows .col-name { min-width: 150px; overflow-wrap: break-word; }
table.rows.results th, table.rows.results th.num { white-space: normal; vertical-align: bottom; }
table.results th, table.results td { padding-left: 9px; padding-right: 9px; }
table.results .col-src { min-width: 0; }
table.rows .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.plain td { padding: 6px 14px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #efe9e5; color: #4a4050; white-space: nowrap; }
.badge.s-new { background: #e7eefb; color: #1f4a8f; }
.badge.s-contacted { background: #ece8f8; color: #4b3a8c; }
.badge.s-meeting_booked, .badge.s-meeting_attended, .badge.s-proposal_sent { background: var(--warn-bg); color: var(--warn); }
.badge.s-won, .badge.q-qualified, .badge.i-processed { background: var(--ok-bg); color: var(--ok); }
.badge.s-lost, .badge.s-no_show, .badge.q-not_qualified, .badge.i-error { background: var(--bad-bg); color: var(--bad); }
.badge.test { background: #1e1526; color: #fff; }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.head h1 { margin-bottom: 4px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid .wide { grid-column: 1 / -1; }
.sub { border-top: 1px solid var(--line); padding: 12px 0; }
.sub:first-of-type { border-top: 0; padding-top: 0; }
dl { display: grid; grid-template-columns: minmax(90px, 34%) 1fr; gap: 3px 12px; margin: 6px 0 0; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
dl.kv { grid-template-columns: 120px 1fr; gap: 8px 12px; margin-bottom: 12px; }
code.key { display: inline-block; }
.history { list-style: none; margin: 16px 0 0; padding: 0; }
.history li { border-top: 1px solid var(--line); padding: 10px 0; overflow-wrap: anywhere; }
.note { background: #fbf6f1; border-left: 3px solid var(--accent); padding: 8px 10px; border-radius: 0 6px 6px 0; margin-top: 4px; }
.note-form .btn { margin-top: 8px; }
pre.payload { background: #1e1526; color: #f3ecf0; padding: 16px; border-radius: 12px; overflow-x: auto; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pager { display: flex; gap: 16px; justify-content: center; margin-top: 16px; }

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > div:first-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .wrap { padding: 0 14px; }
  h1 { font-size: 22px; }
  .top-in { gap: 10px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { white-space: nowrap; }
  .who { margin-left: auto; }
  .who-mail { display: none; }
  .grid { grid-template-columns: 1fr; }
  .table-wrap { background: none; border: 0; overflow: visible; }
  table.rows:not(.plain) thead { position: absolute; left: -9999px; }
  table.rows:not(.plain), table.rows:not(.plain) tbody, table.rows:not(.plain) tr, table.rows:not(.plain) td { display: block; width: 100%; }
  table.rows:not(.plain) tr { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; padding: 8px 0; }
  table.rows:not(.plain) td { border: 0; padding: 5px 14px 5px 42%; position: relative; min-height: 28px; text-align: left; }
  table.rows:not(.plain) td::before { content: attr(data-label); position: absolute; left: 14px; top: 5px; width: 36%; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
  table.rows:not(.plain) td:empty { display: none; }
  dl.kv { grid-template-columns: 1fr; }
}
