:root {
  --navy: #0f2c4d;
  --navy-2: #16406f;
  --gold: #c8a85a;
  --gold-2: #e0c178;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #6b7785;
  --ok: #1f9d57;
  --warn: #d98324;
  --err: #c0392b;
  --line: #e3e8ef;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(15, 44, 77, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  -webkit-text-size-adjust: 100%;
  line-height: 1.6;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  min-height: 100vh;
}

header.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 4px;
}
header.bar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--navy);
  font-size: 1.05rem;
}
header.bar .moon {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 14px 0;
}

h1, h2 { color: var(--navy); margin: 0 0 12px; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

label {
  display: block;
  font-size: 0.9rem;
  color: var(--navy);
  font-weight: 600;
  margin: 12px 0 0;
}
input, select {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 1.05rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--navy-2);
  box-shadow: 0 0 0 3px rgba(22, 64, 111, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 14px 18px;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.gold { background: var(--gold); color: #2a2206; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--navy);
}

.notice {
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 0.95rem;
}
.notice.error { background: #fdecea; color: var(--err); border: 1px solid #f5c6c0; }
.notice.ok { background: #e8f7ee; color: var(--ok); border: 1px solid #b8e6c8; }
.notice.warn { background: #fdf2e2; color: var(--warn); border: 1px solid #f3d9af; }

/* クーポン表示 */
.coupon {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff;
  border: none;
  position: relative;
  overflow: hidden;
}
.coupon::before, .coupon::after {
  content: "";
  position: absolute;
  width: 26px; height: 26px;
  background: var(--bg);
  border-radius: 50%;
  top: 50%; transform: translateY(-50%);
}
.coupon::before { left: -13px; }
.coupon::after { right: -13px; }
.coupon .guest {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(224, 193, 120, 0.35);
}
.coupon .face {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--gold-2);
  letter-spacing: 1px;
}
.coupon .face small { font-size: 1rem; color: #fff; font-weight: 600; }
.coupon .plan { font-size: 1.1rem; font-weight: 700; margin-top: 4px; }
.coupon .meta { color: #cdd8e6; font-size: 0.9rem; margin-top: 8px; }
.coupon .qrwrap {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  margin: 16px auto 4px;
  width: fit-content;
}
.coupon canvas, .coupon img { display: block; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.badge.issued { background: var(--gold); color: #2a2206; }
.badge.redeemed { background: #d6dbe2; color: #515b66; }
.badge.expired { background: #f5c6c0; color: var(--err); }
.badge.void { background: #d6dbe2; color: #515b66; }

/* スキャナ */
#reader { width: 100%; border-radius: 12px; overflow: hidden; }

/* 結果の内訳 */
.breakdown { margin-top: 10px; }
.breakdown .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.breakdown .row:last-child { border-bottom: none; }
.breakdown .row .v { font-weight: 700; }
.breakdown .row.big .v { font-size: 1.3rem; color: var(--navy); }
.breakdown .row.over .v { color: var(--warn); }

/* テーブル（集計） */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--navy); color: #fff; position: sticky; top: 0; }
tbody tr:nth-child(even) { background: #f8fafc; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.kpi .label { color: var(--muted); font-size: 0.82rem; }
.kpi .value { font-size: 1.5rem; font-weight: 800; color: var(--navy); }
.kpi .value small { font-size: 0.9rem; font-weight: 600; color: var(--muted); }

a.linkcard {
  display: block;
  text-decoration: none;
  color: inherit;
}
a.linkcard:hover { box-shadow: 0 8px 28px rgba(15, 44, 77, 0.14); }
a.linkcard .arrow { color: var(--gold); font-weight: 700; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 8px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
