:root {
  --bg: #0b1020;
  --surface: #131a2e;
  --surface-2: #1b2440;
  --surface-3: #232f52;
  --border: #263154;
  --border-soft: #1e2946;
  --text: #eef1f8;
  --muted: #9aa6c4;
  --dim: #6b7794;
  --purple: #7b68ae;
  --gold: #d4af37;
  --green: #35c48d;
  --red: #e56b6b;
  --cyan: #4cc9f0;
  --radius: .75rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 20% -10%, #1a1330 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, .8); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 1.25rem; font-weight: 800; letter-spacing: .02em; }
.brand .logo { color: var(--gold); margin-right: .35rem; }
.brand .sub { color: var(--muted); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: .5rem; }

.pill {
  font-size: .75rem; padding: .3rem .6rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); background: var(--surface);
}
.pill.ok { color: var(--green); border-color: rgba(53, 196, 141, .4); }
.pill.bad { color: var(--red); border-color: rgba(229, 107, 107, .4); }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .75rem; padding: 1.25rem 1.5rem 0;
}
.stat {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem;
}
.stat .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.stat .value { font-size: 1.4rem; font-weight: 800; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.stat .value.gold { color: var(--gold); }
.stat .value.green { color: var(--green); }
.stat .value.cyan { color: var(--cyan); }

.tabs { display: flex; gap: .25rem; padding: 1rem 1.5rem 0; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--muted); font: inherit; font-weight: 600;
  padding: .6rem .9rem; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--gold); }

main { padding: 1.25rem 1.5rem; max-width: 1400px; margin: 0 auto; }
.panel { display: block; }
.hidden { display: none; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.controls { display: flex; gap: .5rem; flex-wrap: wrap; }
.controls .input { flex: 1; min-width: 18rem; }
.controls select.input { flex: 0 0 auto; min-width: 11rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.card h3 { margin: 0 0 .6rem; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.input {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: .55rem; padding: .55rem .7rem; font: inherit; font-size: .9rem; min-width: 0;
}
.input:focus { outline: 2px solid rgba(123, 104, 174, .6); border-color: var(--purple); }
select.input { cursor: pointer; }

.btn {
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text);
  border-radius: .55rem; padding: .5rem .8rem; font: inherit; font-size: .85rem;
  font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--purple); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--purple); border-color: var(--purple); }
.btn.accent { background: var(--gold); border-color: var(--gold); color: #241d05; }
.btn.block { display: block; width: 100%; margin-top: .6rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th, .table td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.table th { background: var(--surface-2); color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.table tbody tr:hover { background: rgba(123, 104, 174, .08); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); font-size: .8rem; }

.test-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: .9rem; align-items: start; }
.results { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; max-height: 22rem; overflow-y: auto; }
.result {
  display: flex; justify-content: space-between; gap: .6rem; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: .5rem;
  padding: .45rem .6rem; cursor: pointer; font-size: .85rem;
}
.result:hover { border-color: var(--purple); }
.result .price { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }

.cart { display: flex; flex-direction: column; gap: .3rem; min-height: 2rem; }
.cart-line {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .4rem .5rem; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: .5rem;
  font-size: .85rem;
}
.cart-line .qty { color: var(--muted); }
.cart-line .rm { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 1rem; }
.cart-line .rm:hover { color: var(--red); }
.totals { margin-top: .6rem; font-size: .85rem; display: flex; flex-direction: column; gap: .2rem; }
.totals .row { display: flex; justify-content: space-between; }
.totals .grand { font-weight: 800; font-size: 1rem; border-top: 1px solid var(--border); padding-top: .35rem; margin-top: .2rem; }
.totals .grand span:last-child { color: var(--gold); }

.field { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .5rem; }
.field .input { display: block; width: 100%; margin-top: .25rem; }

.json {
  background: #0a0e1c; border: 1px solid var(--border); border-radius: .55rem;
  padding: .6rem; font-size: .72rem; line-height: 1.45; overflow-x: auto; margin-top: .6rem;
  max-height: 22rem; overflow-y: auto; color: #c8d3ee;
}
.json:empty { display: none; }

.invoice {
  border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .75rem;
  background: var(--surface);
}
.invoice .head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.invoice .head strong { font-size: 1rem; }
.invoice .meta { color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.invoice .lines { margin-top: .6rem; font-size: .82rem; }
.invoice .lines table { width: 100%; border-collapse: collapse; }
.invoice .lines th, .invoice .lines td { padding: .3rem .4rem; border-bottom: 1px solid var(--border-soft); text-align: left; }
.invoice .lines .num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { font-size: .72rem; padding: .15rem .45rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge.ok { color: var(--green); border-color: rgba(53, 196, 141, .4); }
.badge.warn { color: var(--gold); border-color: rgba(212, 175, 55, .4); }
.badge.err { color: var(--red); border-color: rgba(229, 107, 107, .4); }

.foot {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.5rem 1.5rem; color: var(--dim); font-size: .78rem;
}
