* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: #f5f6f8; color: #1a1a1a; }
.hidden { display: none !important; }
.muted { color: #777; font-weight: normal; }
.err { color: #c62828; min-height: 1.2em; }
code { background: #eef0f3; padding: 2px 6px; border-radius: 4px; font-size: 12px; word-break: break-all; }

input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #cfd3d9; border-radius: 8px; background: #fff; min-width: 0;
}
button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 8px;
  padding: 8px 14px; background: #2563eb; color: #fff;
}
button:hover { filter: brightness(1.07); }
button.ghost { background: #eef0f3; color: #1a1a1a; }
button.danger { background: #dc2626; }
button.small { padding: 4px 10px; font-size: 13px; }

.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.card { background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 4px 24px rgba(0,0,0,.06); }
.login .card { display: flex; flex-direction: column; gap: 12px; width: 300px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }

header {
  display: flex; align-items: center; gap: 20px; padding: 12px 24px; background: #fff;
  border-bottom: 1px solid #e3e5e8; position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
header nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
header nav a { padding: 6px 12px; border-radius: 8px; color: #444; text-decoration: none; }
header nav a.active { background: #eaf0ff; color: #2563eb; font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }
h2 { font-size: 20px; margin: 8px 0 16px; }
.row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row input { flex: 1; min-width: 200px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.stat { background: #fff; border-radius: 12px; padding: 16px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .l { color: #666; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef0f3; white-space: nowrap; }
th { background: #fafbfc; font-weight: 600; color: #555; font-size: 13px; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f7f9ff; }
td.wrap { white-space: normal; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.b-free { background: #eef0f3; color: #444; }
.b-paid { background: #dcfce7; color: #166534; }
.b-unlimited { background: #ede9fe; color: #5b21b6; }
.b-expired { background: #fef3c7; color: #92400e; }
.b-blocked { background: #fee2e2; color: #991b1b; }
.b-success { background: #dcfce7; color: #166534; }
.b-failure, .b-error, .b-amount_mismatch, .b-reversed { background: #fee2e2; color: #991b1b; }
.b-created, .b-creating, .b-processing, .b-hold { background: #e0f2fe; color: #075985; }
.b-expired-pay { background: #eef0f3; color: #555; }

.pager { display: flex; gap: 6px; margin-top: 12px; }

form.grid { display: grid; gap: 16px; max-width: 640px; }
fieldset { border: 0; background: #fff; border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 700; padding: 0; float: left; margin-bottom: 4px; }
fieldset label { display: flex; flex-direction: column; gap: 4px; color: #444; }
fieldset label.check { flex-direction: row; align-items: center; gap: 8px; }
.hint { color: #777; font-size: 13px; margin: 0; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 20; }
.modal-box { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 760px; position: relative; }
.modal-box h3 { margin: 0 0 12px; }
.modal-box h4 { margin: 20px 0 8px; }
.close { position: absolute; right: 12px; top: 10px; background: none; color: #666; font-size: 24px; padding: 4px 10px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; }
.kv div:nth-child(odd) { color: #666; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.formcol { display: flex; flex-direction: column; gap: 10px; }
.formcol label { display: flex; flex-direction: column; gap: 4px; }
fieldset > button { align-self: flex-start; }
fieldset .row { margin-bottom: 0; }
.err:empty { display: none; }
