/* 管理画面・販売者画面・販売者画面・ログイン: design A "titanium"
   (light silver background, white cards, graphite ink, USDT green as the accent).
   Fonts are served from /vendor (see scripts/copy-vendor.mjs). */
:root {
  color-scheme: light;
  --bg: #eceef2;
  --bg-2: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1f27;
  --muted: #626a78;
  --line: #dde1e7;
  --line-2: #c9ced7;
  --accent: #1b1f27;
  --accent-ink: #ffffff;
  --brand: #1f9a75;
  --warn: #a15c00;
  --danger: #c4321f;
  --ok: #157a5c;
  --info: #2f5fc4;
  --font: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
  --display: 'Unbounded', var(--font);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(0, 0, 0, .03), 0 14px 32px -24px rgba(25, 30, 45, .45);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(160deg, #f7f8fa 0%, #e9ecf1 45%, #f1f2f5 100%) fixed var(--bg);
  color: var(--ink);
}

/* header */
header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: rgba(255, 255, 255, .78); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
header .brand { display: flex; align-items: baseline; gap: 10px; }
header .brand b { font: 800 17px/1 var(--display); letter-spacing: -.03em; }
header .brand b::after {
  content: ''; display: inline-block; width: 8px; height: 8px; margin-left: 4px; border-radius: 2px;
  background: var(--brand); transform: translateY(-2px) rotate(45deg);
}
header .brand em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--muted); padding: 2px 8px; border-radius: 6px; background: var(--bg); }
header .who { margin-left: auto; color: var(--muted); font-size: 13px; }
header button { white-space: nowrap; }

/* side navigation */
.layout { display: grid; grid-template-columns: 216px 1fr; min-height: calc(100vh - 56px); }
nav { padding: 18px 12px; border-right: 1px solid var(--line); }
nav a {
  display: block; padding: 9px 14px; border-radius: 10px; color: var(--muted); text-decoration: none; margin-bottom: 2px; font-weight: 500;
}
nav a:hover { background: rgba(255, 255, 255, .7); color: var(--ink); }
nav a.active { background: var(--ink); color: #fff; font-weight: 700; }
main { padding: 26px 28px; max-width: 1200px; width: 100%; min-width: 0; }

/* type */
h1 { font: 700 22px/1.3 var(--font); margin: 0 0 18px; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; }
a { color: var(--ink); text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; white-space: normal; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

/* cards and stats */
.card { background: var(--panel); border: 1px solid transparent; border-radius: 18px; padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font: 600 22px/1.3 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* tables */
.table-wrap { overflow-x: auto; }
/* Columns keep their natural width (no squeezed cells with stacked buttons); narrow screens scroll sideways. */
.table-wrap table { width: max-content; min-width: 100%; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; border-bottom-color: var(--line-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg-2); }
td.num { text-align: right; }

/* forms. Fields line up by their TOP edge, so a hint under one field never shifts the others.
   Buttons / links in the row sit level with the input boxes (label 18px + gap 4px). */
.inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.inline > button, .inline > a { margin-top: 22px; }
.inline > a > button { margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.field span { font-size: 12px; line-height: 18px; color: var(--muted); }
.field small { font-size: 12px; line-height: 1.5; }
input, select, textarea {
  font: inherit; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(27, 31, 39, .08); }
textarea { min-height: 120px; font-family: var(--mono); font-size: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: 0 0 18px; }
.check span { display: flex; flex-direction: column; gap: 2px; }
.check small { font-size: 12px; }

/* buttons */
button {
  font: 700 13px/1.4 var(--font); padding: 9px 16px; border-radius: 10px; border: 1.5px solid var(--accent); background: var(--accent);
  color: var(--accent-ink); cursor: pointer;
}
button:hover { background: #2c323e; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button.secondary { background: var(--panel); color: var(--ink); border-color: var(--line-2); }
button.secondary:hover { border-color: var(--ink); }
button.danger { background: var(--panel); border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* status badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bg); color: var(--muted); margin-left: 6px; }
td > .badge:first-child, .badge:first-child { margin-left: 0; }
.s-paid, .s-settled, .s-confirmed, .s-approved, .s-distributed, .s-refunded { color: var(--ok); background: #e3f4ec; }
.s-review_required, .s-held, .s-pending, .s-open, .s-unapproved, .s-refund_pending { color: var(--warn); background: #fdf0d9; }
.s-failed, .s-suspended, .s-rejected, .s-failed_onchain { color: var(--danger); background: #fbe5e1; }
.s-signed, .s-broadcast, .s-awaiting_payment { color: var(--info); background: #e5ecfa; }
.sev-critical { box-shadow: inset 4px 0 0 var(--danger), var(--shadow); }
.sev-warning { box-shadow: inset 4px 0 0 var(--warn), var(--shadow); }
.sev-info { box-shadow: inset 4px 0 0 var(--info), var(--shadow); }

.kv { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

#toast {
  position: fixed; right: 20px; bottom: 20px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700;
  opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; max-width: 420px; box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .5);
}
#toast.show { opacity: 1; transform: none; }
#toast.error { background: var(--danger); }

/* login / account */
.login { max-width: 400px; margin: 12vh auto; padding: 30px 28px; }
.login .wordmark { font: 800 26px/1 var(--display); letter-spacing: -.04em; margin-bottom: 6px; }
.login .wordmark::after {
  content: ''; display: inline-block; width: 10px; height: 10px; margin-left: 5px; border-radius: 2px;
  background: var(--brand); transform: translateY(-3px) rotate(45deg);
}
.login .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login button[type='submit'] { padding: 12px; font-size: 14px; margin-top: 4px; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 12px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  nav { display: flex; align-items: center; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; gap: 4px; }
  nav a { white-space: nowrap; margin: 0; }
  main { padding: 18px 16px; }
  .kv { grid-template-columns: 1fr; }
  /* Header: brand on the first line; signed-in user and buttons on the second. */
  header { flex-wrap: wrap; gap: 6px 10px; padding: 10px 16px; }
  header .brand { flex-basis: 100%; }
  header .who { flex: 1; min-width: 0; margin-left: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  header button { padding: 6px 10px; font-size: 12px; }
}

dialog.dlg { border: 0; border-radius: 18px; background: var(--panel); color: var(--ink); padding: 22px; width: min(460px, calc(100vw - 32px)); box-shadow: 0 30px 80px -30px rgba(20, 24, 40, .55); }
dialog.dlg::backdrop { background: rgba(27, 31, 39, .35); backdrop-filter: blur(2px); }
dialog.dlg form { display: flex; flex-direction: column; gap: 14px; }
dialog.dlg .dlg-msg { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
dialog.dlg .actions { justify-content: flex-end; }
dialog.dlg .field { min-width: 0; }
dialog.dlg .dlg-input { width: 100%; }
dialog.dlg textarea.dlg-input { min-height: 72px; font-family: inherit; font-size: inherit; }

/* 販売者画面: 支払いページのテーマ選択 */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 14px 0; }
.theme-option { border: 1.5px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--panel); }
.theme-option.selected { border-color: var(--ink); }
.theme-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; }
.swatch { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.swatch-price { font: 600 26px/1 var(--display); letter-spacing: -.04em; }
.swatch-price small { font: 700 12px var(--font); opacity: .7; letter-spacing: 0; }
.swatch-card { border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.swatch-net { font-size: 11px; opacity: .8; }
.swatch-addr { display: flex; gap: 4px; font: 11px var(--mono); }
.swatch-addr span { padding: 3px 5px; border-radius: 4px; }
.swatch-btn { border-radius: 10px; padding: 8px; text-align: center; font-size: 12px; font-weight: 700; }

/* 一覧のページ送り */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }

/* 月別の縦棒グラフ */
.chart { margin: 0; }
.chart-plot { position: relative; height: 180px; display: flex; align-items: flex-end; gap: 6px; padding-top: 22px; border-bottom: 1px solid var(--line-2); }
.chart-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: default; outline: none; }
.chart-bar { width: 100%; max-width: 28px; background: var(--brand); border-radius: 6px 6px 0 0; opacity: .8; transition: opacity .15s; }
.chart-col:hover .chart-bar, .chart-col:focus .chart-bar { opacity: 1; }
.chart-val { font-size: 11px; color: var(--ink); margin-bottom: 4px; white-space: nowrap; }
.chart-axis { display: flex; gap: 6px; margin-top: 6px; }
.chart-axis > div { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.chart-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 8px; padding: 4px 9px; font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .1s; }
.chart-tip.on { opacity: 1; }

@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* 二段階認証の設定: QRコード */
.qr-box { display: flex; gap: 16px; align-items: center; margin: 14px 0; }
.qr-box svg { flex: 0 0 auto; border-radius: 12px; box-shadow: var(--shadow); }
.qr-box p { margin: 0; }
@media (max-width: 480px) { .qr-box { flex-direction: column; align-items: flex-start; } }
