:root {
  --ink: #0a2540;
  --muted: #425466;
  --paper: #ffffff;
  --band: #f6f9fc;
  --card: #ffffff;
  --line: #e6ebf1;
  --brand: #0a5cff;
  --brand-dark: #0847c7;
  --green: #0d7a4f;
  --warn: #b54708;
  --bad: #c2413b;
  --hold: #5b4b8a;
  --info: #0b63ce;
  --shadow: 0 8px 24px rgba(10, 37, 64, 0.06);
  color: var(--ink);
  background: var(--band);
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 {
  font-family: inherit;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.4rem;
}
h1 { font-size: 1.7rem; }
p { margin: 0.4rem 0; }

.boot { padding: 2rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: white; padding: 0.5rem; z-index: 5; }

.app-banner {
  background: var(--ink);
  color: white;
  text-align: center;
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
}
.app-banner.impersonate { background: #7a4b00; }
.app-banner .linkish { color: white; text-decoration: underline; }
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  background: white;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.brand {
  color: inherit;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  gap: 0.55rem;
  align-items: center;
}
.brand-mark { width: 36px; height: 36px; border-radius: 0; display: block; object-fit: contain; }
.brand-name span { color: var(--brand); }
.clock { margin: 0; color: var(--muted); font-size: 0.88rem; }
.who { margin-left: auto; display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.header-switch { display: flex; gap: 0.4rem; }
.header-switch .button { padding: 0.35rem 0.75rem; font-size: 0.9rem; }
.linkish, .menu {
  background: transparent;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}
.menu { display: none; border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.7rem; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 84px); }
.nav {
  background: var(--band);
  border-right: 1px solid var(--line);
  padding: 1rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-weight: 550;
}
.nav a[aria-current="page"], .nav a:hover {
  background: #e8f0fe;
  color: var(--brand-dark);
}
main { padding: 1.5rem; max-width: 1180px; }
.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.lede { color: var(--muted); max-width: 70ch; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.8rem; margin: 1rem 0; }
.stat, .card, .callout, .empty {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.stat { padding: 0.9rem 1rem; }
.stat span, .stat small, .muted, .hint, .eyebrow { color: var(--muted); }
.stat strong, .amount { display: block; font-variant-numeric: tabular-nums; font-size: 1.4rem; margin: 0.25rem 0; }
.payment-split .stat strong { font-size: 1.55rem; }
.card { padding: 1rem 1.1rem; margin: 0.8rem 0; }
.feature { border-color: #c9d7f5; }
.callout { padding: 0.9rem 1rem; margin: 0.8rem 0; }
.callout.warn { background: #fff7ed; border-color: #f3d3b0; }
.action-row, .filters, .row-between, .page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.action-row .button { white-space: normal; text-align: center; height: auto; }
.filters { margin-bottom: 1rem; }
a.button, .button, button.button {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  font-weight: 650;
}
.button.secondary { background: white; color: var(--ink); border-color: var(--line); }
.button.danger { background: var(--bad); border-color: var(--bad); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.form { display: grid; gap: 0.7rem; }
.form.narrow { max-width: 520px; }
.main-link p { max-width: 42rem; }
.link-field {
  display: flex;
  align-items: stretch;
  margin-top: 0.85rem;
  max-width: 52rem;
}
.link-field input {
  flex: 1;
  min-width: 0;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 500;
}
.link-field .button {
  border-radius: 0 8px 8px 0;
  white-space: nowrap;
}
.link-working .link-status,
.form .link-status {
  font-weight: 650;
  color: var(--ink);
}
.link-progress {
  height: 4px;
  background: #e8f0fe;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 1rem;
}
.link-progress span {
  display: block;
  height: 100%;
  width: 36%;
  background: var(--brand);
  border-radius: inherit;
  animation: link-slide 1.05s ease-in-out infinite;
}
.link-result { animation: link-in 0.28s ease-out; }
@keyframes link-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
@keyframes link-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
label { display: grid; gap: 0.25rem; font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
textarea { min-height: 90px; resize: vertical; }
.form-error { color: var(--bad); min-height: 1.2rem; font-weight: 700; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.account-grid, .stack { display: grid; gap: 0.7rem; }
.fee-edit {
  display: inline-block;
  min-width: 3.5rem;
  font-weight: 700;
  border-bottom: 1px dashed var(--line);
  cursor: text;
}
.fee-inline {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
}
.fee-inline input {
  width: 4.6rem;
  padding: 0.3rem 0.4rem;
}
.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.badge { display: inline-block; border-radius: 6px; padding: 0.12rem 0.5rem; font-size: 0.75rem; font-weight: 700; background: var(--band); white-space: nowrap; }
.badge-pending, .badge-requested, .badge-approved { background: #fff4e5; color: var(--warn); }
.badge-available, .badge-paid, .badge-active { background: #e6f6ee; color: var(--green); }
.badge-held, .badge-partial { background: #efeaf8; color: var(--hold); }
.badge-failed, .badge-rejected, .badge-suspended, .badge-blocked, .badge-deleted, .badge-removed { background: #fdecec; color: var(--bad); }
.badge-paused { background: #fff4e5; color: var(--warn); }
.badge-processing { background: #e8f1fe; color: var(--info); }
.badge-general, .badge-archived, .badge-cancelled, .badge-international, .badge-test { background: #eef2f6; color: var(--muted); }
.badge-test { background: #fff4e5; color: var(--warn); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.8rem; }
.detail-grid span { display: block; color: var(--muted); font-size: 0.82rem; }
.note.unread { border-color: #c9d7f5; }
.instructions, .email-body { white-space: pre-wrap; background: var(--band); padding: 0.8rem; border-radius: 8px; }
.empty { padding: 1rem; }
.toast { position: fixed; bottom: 1rem; right: 1rem; background: var(--ink); color: white; padding: 0.8rem 1rem; border-radius: 10px; max-width: 320px; }
.toast[data-kind="bad"] { background: var(--bad); }
.checkout { max-width: 640px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1rem 0; }
.plan-card h2 small { font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.plan-card.current { border: 2px solid var(--brand); }
.plan-card-otc { border: 2px solid #ffd23f; background: #fffdf3; }
.plan-card ul { margin: 0.6rem 0 1rem; padding-left: 1.1rem; }
.plan-otc-note {
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: #fff8d6;
  border: 1px solid #ffd23f;
  color: #5c4300;
  font-size: 0.86rem;
  line-height: 1.4;
}
.plan-otc-note a { color: #7a4b00; font-weight: 700; }
.plan-otc-block { margin: 0.4rem 0 1.2rem; }
.badge-none, .badge-canceled { background: #eef2f6; color: var(--muted); }
.badge-past_due { background: #fdecec; color: var(--bad); }
.badge-trialing { background: #e6f6ee; color: var(--green); }

@media (max-width: 860px) {
  .menu { display: inline; }
  .layout { grid-template-columns: 1fr; }
  .nav { display: none; }
  body.nav-open .nav { display: flex; }
  .clock { display: none; }
  .split, .page-head { grid-template-columns: 1fr; display: grid; }
  .topbar { flex-wrap: wrap; }
  table thead { display: none; }
  table tr { display: block; border-bottom: 1px solid var(--line); padding: 0.4rem; background: white; }
  table td { display: flex; justify-content: space-between; gap: 1rem; border: 0; }
  table td::before { content: attr(data-label); color: var(--muted); font-weight: 700; }
}
