:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #5d6b82;
  --line: #dfe4ee;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-soft: #eef0ff;
  --ok: #0f8a5f;
  --ok-soft: #e6f6ef;
  --warn: #a15c00;
  --warn-soft: #fff4e0;
  --bad: #c0362c;
  --bad-soft: #fdecea;
  --info: #1f6fb2;
  --info-soft: #e8f2fc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --card: #171e2d;
    --text: #e7ebf3;
    --muted: #97a3b8;
    --line: #29324a;
    --brand: #7c74ff;
    --brand-ink: #0f1420;
    --brand-soft: #232a4a;
    --ok: #45c28f;
    --ok-soft: #13291f;
    --warn: #f0b252;
    --warn-soft: #2d2412;
    --bad: #ff7b70;
    --bad-soft: #351a19;
    --info: #6cb3f0;
    --info-soft: #14263a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0.4rem 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }

.mono, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { background: var(--brand-soft); padding: 0.1em 0.35em; border-radius: 6px; font-size: 0.92em; }
.wrap-any { word-break: break-all; }
.muted { color: var(--muted); }
.small, small { font-size: 0.85rem; }
.center { text-align: center; }
.hidden { display: none; }

/* Header */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 1120px; margin: 0 auto; padding: 0.65rem 1rem; display: flex; align-items: center; gap: 1rem; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 0.55rem; color: var(--text); font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--brand); }
.mark {
  width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #9b5cf6); color: #fff; font-weight: 800;
}
.who { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.who .email { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.pill { background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 0.2rem 0.7rem; font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.pill.owner { background: var(--ok-soft); color: var(--ok); }
.tabs { max-width: 1120px; margin: 0 auto; padding: 0 0.6rem; display: flex; gap: 0.15rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 0.6rem 0.8rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }

/* Layout */
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 1.25rem 1rem 2rem; flex: 1; }
.wrap.narrow { max-width: 620px; }
.foot { color: var(--muted); font-size: 0.82rem; border-top: 1px solid var(--line); }
.foot .wrap { padding: 1rem; }
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.two.tight { gap: 0 1rem; margin: 0; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid > .card { margin-bottom: 0; }
.card.auth { margin-top: 1.5rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.stat { display: flex; flex-direction: column; gap: 0.2rem; }
.stat .label { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 1.9rem; font-weight: 700; line-height: 1.15; }
.stat .value.small { font-size: 1.05rem; padding: 0.35rem 0; }

.plan { display: flex; flex-direction: column; gap: 0.3rem; }
.plan .price { font-size: 1.5rem; font-weight: 700; margin: 0; }
.plan.off { opacity: 0.75; }
.plan .btn { align-self: flex-start; margin-top: auto; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 0.85rem; margin: 0 0 0.5rem; }
.form.row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form.row .field { min-width: 160px; }
.form.inline, form.inline { display: inline; margin: 0; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field.grow { flex: 1; }
.field > span { font-weight: 600; font-size: 0.9rem; }
.field small { color: var(--muted); }
.field small.err { color: var(--bad); }
.filters { margin-bottom: 1rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.75rem; min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.check { display: flex; gap: 0.5rem; align-items: center; }
.check input { width: 18px; height: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 600; border-radius: 10px; padding: 0.6rem 1rem; min-height: 44px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0.3rem 0.7rem; font-size: 0.88rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Messages and badges */
.alert { border-radius: 10px; padding: 0.7rem 0.9rem; margin: 0 0 1rem; border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert a { color: inherit; text-decoration: underline; }
.badge { display: inline-block; border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--line); color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -0.2rem; }
table.list { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.list th, table.list td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.late td { background: var(--bad-soft); }
table.list tr.hl td { background: var(--brand-soft); }
table.list tr.dim td { opacity: 0.6; }
td.plus { color: var(--ok); font-weight: 600; }
td.minus { color: var(--bad); font-weight: 600; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 0.75rem; }

dl.facts { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 0.45rem 1rem; margin: 0 0 1rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.key { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 0.6rem 0.75rem; margin: 0.4rem 0 0.8rem; }
.key code { background: none; padding: 0; font-size: 1rem; letter-spacing: 0.03em; flex: 1; min-width: 0; }
ol.steps { padding-left: 1.25rem; margin: 0; }
ol.steps > li { margin-bottom: 1rem; }
ul.ticks, ul.plain { padding-left: 1.1rem; margin: 0; }
ul.ticks li, ul.plain li { margin-bottom: 0.4rem; }
.total { font-size: 1.15rem; margin: 0.6rem 0 1rem; }
.paypal { min-height: 50px; }

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .who .email { display: none; }
  .wrap { padding: 1rem 0.75rem 1.5rem; }
  .card { padding: 1rem; }
  .form.row { flex-direction: column; align-items: stretch; }
  .stat .value { font-size: 1.55rem; }
  .grid.stats { gap: 0.6rem; }
  .brand > span:last-child { font-size: 0.95rem; }
  .btn.wide, .form:not(.row) > .btn { white-space: normal; }
  dl.facts { grid-template-columns: 1fr; gap: 0.1rem; }
  dl.facts dd { margin-bottom: 0.5rem; }
}
