:root {
  --bg: #f6f7f9;
  --surface: #fff;
  --text: #14181f;
  --muted: #66707d;
  --line: #e6e9ee;
  --accent: #2f6bff;
  --accent-soft: #eef3ff;
  /* --ink is used by code badges; without it they rendered white-on-white. */
  --ink: #17191a;
  --danger: #b42318;
  --ok: #0a7d43;
  --shadow: 0 1px 2px rgba(20,24,31,.04), 0 8px 24px rgba(20,24,31,.05);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }
code { background: #eef1f5; border-radius: 5px; padding: 1px 5px; font-size: 12.5px; }
h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.01em; }
h3 { margin: 22px 0 10px; font-size: 15px; }

.bar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
.logo {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--text); color: #fff; font-size: 12px; font-weight: 700; flex: none;
}
.logo span { color: #7fb0ff; }
.inline { display: inline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: transparent; color: var(--text);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1f59e6; }
.btn-ghost { border-color: var(--line); background: var(--surface); }
.btn-ghost:hover { border-color: #c9d2de; }

.notice {
  margin: 20px 0 0; padding: 12px 16px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid #d6e2ff; color: #1f3f8f; font-size: 13.5px;
}

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; margin: 18px 0; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.panel-sub { color: var(--muted); margin: 0 0 16px; max-width: 720px; font-size: 13.5px; }

.table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 700; padding: 8px 8px; border-bottom: 1px solid var(--line);
}
.table td { padding: 7px 8px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table input[type="text"] {
  width: 100%; height: 38px; padding: 0 11px; font: inherit;
  border: 1px solid var(--line); border-radius: 9px; background: #fdfefe; color: var(--text);
}
.table input[type="text"]:focus,
.form-grid input[type="text"]:focus,
.form-grid input[type="password"]:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.table input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.center { text-align: center; }
.empty-row { color: var(--muted); text-align: center; padding: 22px 0; }
.row-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12.5px; }

.add-form { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 4px; }
.add-grid { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 10px; align-items: end; }
.add-grid label, .form-grid label {
  display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.add-grid input, .form-grid input {
  height: 40px; padding: 0 11px; font: inherit; font-weight: 400; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; background: #fdfefe; width: 100%;
}
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px; align-items: end;
}
.form-grid .wide { grid-column: span 2; }
.form-grid .check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--text);
}
.form-grid .check input { width: 17px; height: 17px; accent-color: var(--accent); }

.build-status { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: 13.5px; }
.build-status strong { color: var(--text); }
.log {
  background: #0f1621; color: #cfe0f5; border-radius: 12px; padding: 14px 16px;
  font: 12.5px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace;
  max-height: 300px; overflow: auto; white-space: pre-wrap; margin: 0;
}

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px; width: min(380px, 92vw); box-shadow: var(--shadow);
  display: grid; gap: 16px;
}
.login-brand { margin-bottom: 4px; }
.login-card label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.login-card input {
  height: 44px; padding: 0 13px; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; background: #fdfefe;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error { color: #b42318; font-size: 13px; margin: 0; }
.login-card .btn { height: 44px; }

/* carts */
.bar-nav { display: flex; gap: 8px; }
.bar-actions { display: flex; align-items: center; gap: 8px; }
.code-form { display: flex; gap: 10px; max-width: 460px; }
.code-form input {
  flex: 1; height: 46px; padding: 0 14px; font: inherit; font-size: 17px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; background: #fdfefe;
}
.code-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.code-link {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  background: var(--ink); color: #fff; font-weight: 700; letter-spacing: .12em; font-size: 12.5px;
}
.code-badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--accent); color: var(--ink); letter-spacing: .12em; font-size: 13px;
}
.cart-summary { display: grid; gap: 2px; text-align: right; }
.cart-summary span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.cart-summary s { color: var(--muted); font-size: 13px; }
.cart-summary strong { font-size: 20px; letter-spacing: -.02em; }
.cart-table td { vertical-align: middle; }
.row-thumb { width: 46px; height: 46px; border-radius: 6px; object-fit: contain; background: #f2f2f0; border: 1px solid var(--line); }
.row-thumb.empty { display: grid; place-items: center; font-size: 8.5px; color: var(--muted); text-align: center; }
.row-name { font-weight: 650; font-size: 13.5px; }
.cart-table input.num {
  width: 100%; height: 36px; padding: 0 8px; font: inherit; font-size: 13.5px; text-align: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fdfefe;
}
.cart-table input.num:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-danger { border-color: #f0c9c4; color: #b42318; background: #fff7f6; }
.btn-danger:hover { background: #b42318; border-color: #b42318; color: #fff; }
.danger-zone { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Row delete: a bin icon instead of a checkbox column. */
.row-remove {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--muted); cursor: pointer;
  transition: border-color .14s, color .14s, background .14s;
}
.row-remove:hover { border-color: #f0c9c4; background: #fff7f6; color: var(--danger); }
.row-remove:focus-visible { outline: none; border-color: var(--danger); box-shadow: 0 0 0 3px #fde8e5; }

.danger-panel { display: flex; align-items: center; gap: 14px; }
.danger-panel form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.notice-warn { background: #fff8e6; border-color: #f3dca6; color: #7a5a12; }
@media (max-width: 720px) {
  .cart-table th:nth-child(3), .cart-table td:nth-child(3) { display: none; }
  .code-form { flex-direction: column; }
}

@media (max-width: 720px) {
  .add-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .table th:nth-child(2), .table td:nth-child(2) { display: none; }
}

/* users */
.role-tag {
  display: inline-block; padding: 3px 9px; border-radius: 6px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .04em;
}
.role-owner { background: var(--accent-soft); color: #1f3f8f; }
.role-select {
  height: 32px; padding: 0 8px; font: inherit; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface); cursor: pointer;
}
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.pill-on { background: #e8f6ee; color: var(--ok); }
.pill-off { background: #f4f4f2; color: var(--muted); }
.row-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn-mini { height: 30px; padding: 0 10px; font-size: 11.5px; border-radius: 7px; }
.form-grid select {
  height: 40px; padding: 0 10px; font: inherit; font-weight: 400; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; background: #fdfefe; width: 100%;
}
.form-grid select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inline { display: inline; }

/* ---------- payments ---------- */
.pay-panel .panel-head { margin-bottom: 14px; }
.pay-state {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fbfbf9; margin-bottom: 14px;
}
.pay-state strong { font-size: 14.5px; }
.pay-state span { color: var(--muted); font-size: 13px; }
.pay-state-ok { background: #f2fbf5; border-color: #bfe6cd; }
.pay-state-ok strong { color: var(--ok); }
.pay-state-wait { background: #fffaf0; border-color: #f3dca6; }
.pay-state-wait strong { color: #7a5a12; }
.invoice-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.invoice-email { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.invoice-email input {
  height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface); min-width: 240px;
}
.invoice-email input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pay-link { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfbf9; margin-bottom: 16px; }
.pay-url {
  flex: 1; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; font-size: 12.5px; color: var(--text); background: var(--surface);
}
.pay-url:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pay-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px;
  font-weight: 700; background: #eef1f5; color: var(--muted);
}
.pay-badge-ok { background: #e7f7ee; color: var(--ok); }
.pay-badge-wait { background: #fff4dd; color: #7a5a12; }
.pay-badge-err { background: #fdecea; color: var(--danger); }
.pay-err { color: var(--danger); margin-top: 4px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.steps { margin: 0 0 14px; padding-left: 20px; color: var(--text); font-size: 13.5px; line-height: 1.7; }
.steps li { margin-bottom: 2px; }

/* ---------- journal ---------- */
.journal-filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; align-items: end; margin: 4px 0 12px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.journal-filters label {
  display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.journal-filters input, .journal-filters select {
  height: 38px; padding: 0 10px; font: inherit; font-weight: 400; font-size: 13px;
  color: var(--text); border: 1px solid var(--line); border-radius: 9px;
  background: #fdfefe; width: 100%;
}
.journal-filters input:focus, .journal-filters select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.journal-actions { display: flex; gap: 8px; }
.journal-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.journal-table td { vertical-align: top; }
.journal-table strong { font-size: 13.5px; }
.nowrap { white-space: nowrap; }
.journal-details {
  margin: 4px 0 0; padding-left: 16px;
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
}
.journal-details li { margin-bottom: 1px; }
.act {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px;
  font-weight: 700; background: #eef1f5; color: var(--muted); white-space: nowrap;
}
.act-login { background: #eef1f5; color: #4a5563; }
.act-cart { background: var(--accent-soft); color: #1f3f8f; }
.act-pay { background: #e7f7ee; color: var(--ok); }
.act-pay[class*="pay.che"] { background: #f4f4f2; color: var(--muted); }
.act-users { background: #f3efff; color: #5b3bb3; }
.act-sources, .act-settings, .act-build, .act-audit { background: #f4f4f2; color: #4a5563; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

/* The header carries four links; on a narrow screen they must wrap instead of
   pushing the page sideways. */
@media (max-width: 860px) {
  .bar-inner { height: auto; flex-wrap: wrap; padding: 10px 0; row-gap: 8px; }
  .bar-nav, .bar-actions { flex-wrap: wrap; }
}

@media (max-width: 720px) {
  .journal-filters { grid-template-columns: 1fr 1fr; }
  .journal-actions { grid-column: span 2; }
  /* Stack each record: a five-column table is unreadable on a phone. */
  .journal-table thead { display: none; }
  .journal-table, .journal-table tbody { display: block; width: 100%; }
  .journal-table tr {
    display: block; padding: 10px 0; border-bottom: 1px solid #f0f2f5;
  }
  .journal-table td { display: block; border: none; padding: 0; }
  /* Date and author share the first line, the rest goes below. */
  .journal-table td:nth-child(1),
  .journal-table td:nth-child(2) { display: inline; }
  .journal-table td:nth-child(2) { margin-left: 8px; }
  .journal-table td:nth-child(2) .hint { display: inline; margin-left: 4px; }
  .journal-table td:nth-child(3) { margin: 4px 0 2px; }
  /* An empty cell would leave a stray dash line on a phone. */
  .journal-table td:empty { display: none; }
}