:root {
  --ink: #162033;
  --muted: #5b667a;
  --line: #d7dce6;
  --paper: #f4f1ea;
  --card: #fffdf8;
  --navy: #12233b;
  --navy-2: #1c3456;
  --accent: #c45c26;
  --accent-soft: rgba(196, 92, 38, 0.16);
  --ok: #1f7a4d;
  --ok-bg: #e6f5ec;
  --warn: #9a5b12;
  --warn-bg: #fff3dd;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --wait: #3157a4;
  --wait-bg: #e8eefc;
  --shadow: 0 12px 28px rgba(18, 35, 59, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Yu Gothic", YuGothic, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  line-height: 1.55;
}

a {
  color: var(--navy-2);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #0f172a;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 26px 8px;
  color: #fff;
}

.header-brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  min-width: 0;
}
.header-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 9px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.04em;
}

.app-header small { color: #cbd5e1; }

.header-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px 16px;
  min-width: 0;
}
.header-subtitle {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #cbd5e1;
}
.last-updated {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: #94a3b8;
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}
.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.env-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.env-badge.is-dev {
  background: #134e4a;
  color: #99f6e4;
  border: 1px solid #5eead4;
}
.env-badge.is-prod {
  background: #9a3412;
  color: #fff7ed;
  border: 1px solid #fb923c;
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.28);
}
.nav-logout { min-width: 0; gap: 6px; padding-left: 8px; padding-right: 10px; color: #e2e8f0; cursor: pointer; }
.nav-logout-icon { width: 13px; height: 13px; flex: 0 0 13px; display: block; }
.nav-logout:hover { background: rgba(148, 163, 184, 0.22); color: #fff; }

.nav-links {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.28);
}
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: #e2e8f0;
  border: 1px solid transparent;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-sales { color: #99f6e4; }
.nav-account { color: #fde68a; }
.nav-admin { color: #c7d2fe; }
.nav-audit { color: #fda4af; }
.nav-sales:hover { background: #0f766e; color: #ecfdf5; text-decoration: none; }
.nav-account:hover { background: #b45309; color: #fffbeb; text-decoration: none; }
.nav-admin:hover { background: #4338ca; color: #eef2ff; text-decoration: none; }
.nav-audit:hover { background: #9d174d; color: #fff1f2; text-decoration: none; }
.nav-btn.is-current {
  pointer-events: none;
  cursor: default;
  color: #0f172a;
}
.nav-sales.is-current { background: #5eead4; }
.nav-account.is-current { background: #fbbf24; }
.nav-admin.is-current { background: #a5b4fc; }
.nav-audit.is-current { background: #fda4af; }

.wrap {
  max-width: 1840px;
  margin: 0 auto;
  padding: 16px 22px 64px;
}

.header-filters {
  padding: 0 26px 10px;
}

.filter-grid {
  display: grid;
  gap: 8px;
  align-items: end;
}
.sales-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr)) auto;
}

.header-filters .filter-grid > label,
.header-filters .filter-grid > .picker-field,
.header-filters label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #cbd5e1;
}

.header-filters label > span { color: #cbd5e1; }
.header-filters .grow { grid-column: span 1; }

.header-filters .filter-grid input,
.header-filters .filter-grid select,
.header-filters .filter-grid .multi {
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border: 1px solid #cfd5dd;
  border-radius: 7px;
  background: #fff;
  color: #12233b;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.filter-actions .btn {
  height: 34px;
  padding: 0 12px;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
}

.presets > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  color: var(--ink);
  cursor: pointer;
}
.presets > button:hover,
.presets > button.is-active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

.month-picker {
  display: inline-flex;
  flex: 0 0 auto;
  width: max-content;
  align-items: center;
  gap: 2px;
  margin: 0;
  height: 28px;
  padding: 0 6px 0 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.month-picker.is-active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

.month-picker select {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  height: 22px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  color-scheme: light;
}

.month-picker.is-active select {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  color-scheme: dark;
}

.month-picker select option {
  background: #fff;
  color: var(--ink);
}

.month-picker button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  min-width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.month-picker button:disabled {
  opacity: 0.35;
  cursor: default;
}

.source,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.detail-note {
  margin: 0 16px 8px;
}

.banner {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
}
.banner-error { background: var(--danger-bg); color: var(--danger); }
.banner-warn { background: var(--warn-bg); color: var(--warn); }

.kpis {
  display: grid;
  grid-template-columns: 1.35fr repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}

.kpi,
.card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.kpi::before,
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
}

.kpi-sales::before { background: linear-gradient(90deg, #1f7a4d, #3cb371); }
.kpi-ticket::before { background: linear-gradient(90deg, #c45c26, #f0a14a); }
.kpi-count::before { background: linear-gradient(90deg, #2457a8, #4f8cff); }
.kpi-vip::before { background: linear-gradient(90deg, #6b3fa0, #b07cff); }
.kpi-fail::before { background: linear-gradient(90deg, #b42318, #f04438); }
.kpi-hotels::before { background: linear-gradient(90deg, #7a4c1f, #d4a017); }
.kpi-areas::before { background: linear-gradient(90deg, #5b4a8a, #8b7cc9); }
.card-areas::before { background: linear-gradient(90deg, #5b4a8a, #8b7cc9); }
.card-vip::before { background: linear-gradient(90deg, #6b3fa0, #b07cff); }
.card-methods::before { background: linear-gradient(90deg, #1f7a4d, #3cb371); }
.card-univapay::before { background: linear-gradient(90deg, #2457a8, #4f8cff); }
.card-univapay-tx::before { background: linear-gradient(90deg, #0f6e6a, #2bb8b0); }
.card-chart::before { background: linear-gradient(90deg, #c45c26, #f0a14a); }
.card-hotels::before { background: linear-gradient(90deg, #0f6e6a, #2bb8b0); }
.card-matrix::before { background: linear-gradient(90deg, #12233b, #3d6ea8); }
.card-detail::before { background: linear-gradient(90deg, #5b4a8a, #8b7cc9); }

.kpi { padding: 20px 18px 16px; }

.kpi h2,
.card-head h2 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.kpi-value {
  margin: 8px 0 0;
  font-size: 28px;
  letter-spacing: 0.02em;
}

.kpi-value small { font-size: 15px; color: var(--muted); }
.kpi-sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.kpi-break {
  margin: 10px 0 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
  display: grid;
  gap: 4px;
}
.kpi-break li {
  display: grid;
  grid-template-columns: 5.5em 1fr auto;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  color: var(--muted);
}
.kpi-break b {
  font-size: 13px;
  color: var(--ink);
  font-weight: 700;
  text-align: right;
}
.kpi-break small { text-align: right; }
.kpi-break li.is-refund b { color: var(--danger); }
.kpi-break-count li { grid-template-columns: 1fr auto; }
.kpi-break-count li.is-sub span { padding-left: 1em; color: #64748b; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.card { padding: 20px 18px 18px; margin-bottom: 14px; }
.card-methods { margin-bottom: 14px; }
.card-methods .total-row th,
.card-methods .total-row td { border-top: 1px solid var(--line); }
.grid-2 > .card { margin-bottom: 0; }
.vip-total {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--muted);
}
.vip-total b {
  margin-left: 6px;
  font-size: 32px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.vip-note { margin: 0; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.chart-panel {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  min-height: 260px;
}

.chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding: 24px 0 46px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
}

.chart-plot {
  position: relative;
  min-width: 0;
}

.chart-grid {
  position: absolute;
  inset: 24px 0 46px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.chart-grid i {
  display: block;
  height: 0;
  border-top: 1px dashed #d9d0c2;
}

.chart-grid i:last-child { border-top: 1px solid #cfc6b8; }

.chart {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 260px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 24px 4px 18px;
}

.chart-col {
  flex: 1 0 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 42px;
}

.chart-bar-wrap {
  position: relative;
  width: 70%;
  max-width: 36px;
  flex: 1;
  display: flex;
  align-items: flex-end;
}

.chart-bar {
  position: relative;
  width: 100%;
  background: #c45c26;
  border-radius: 0;
  min-height: 0;
}

.chart-amount {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -4px);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}

.chart-label {
  height: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #12233b;
}

.chart-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #12233b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 3;
}
.chart-tip strong { font-size: 12px; }
.chart-tip span { font-weight: 600; color: #d7deea; }

.chart-col:hover .chart-tip { opacity: 1; }

.table-wrap { overflow: auto; max-height: 520px; }
.table-wrap-matrix { max-height: 640px; }
.table-wrap-tx { max-height: 528px; }

.group-card { background: #dbe4f0; color: #1e3a5f; font-weight: 700; }
.group-paypay { background: #fde2e4; color: #b42318; font-weight: 700; }
.group-alipay { background: #99f6e4; color: #0f766e; font-weight: 700; }
.group-other { background: #e5e7eb; color: #374151; font-weight: 700; }
.group-price { background: #fef9c3; color: #854d0e; }
.group-method { background: #dbeafe; color: #1d4ed8; }
.card-univapay .total-row th,
.card-univapay .total-row td { border-top: 1px solid var(--line); background: #eef4ff; }
.is-cancel-row td { color: #64748b; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f7f1e6;
  color: var(--muted);
  font-weight: 700;
}

.num { text-align: right; white-space: nowrap; }
.strong { font-weight: 700; }
.sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.has-val { color: var(--ink); }
.matrix .breakdown {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.card-hotels table,
.card-areas table,
.card-detail table {
  font-size: 14px;
  color: #12233b;
}

.card-hotels th,
.card-areas th,
.card-detail th {
  background: #ebe4d6;
  color: #12233b;
  font-size: 13px;
}

.card-hotels td,
.card-areas td,
.card-detail td {
  color: #12233b;
  font-weight: 600;
}

.card-hotels tbody tr:nth-child(even) td,
.card-areas tbody tr:nth-child(even) td,
.card-detail tbody tr:nth-child(even) td {
  background: #f7f3ea;
}

.card-hotels .strong,
.card-areas .strong,
.card-detail .strong {
  color: #12233b;
  font-weight: 800;
}

.card-hotels td.is-neg,
.card-areas td.is-neg,
.card-detail td.is-neg,
.matrix .is-neg {
  color: var(--danger);
}

.card-hotels a,
.card-areas a {
  color: #12233b;
  font-weight: 800;
}

.card-hotels .sub,
.card-areas .sub,
.card-detail .sub {
  color: #3a4658;
  font-weight: 600;
}

.matrix {
  font-size: 14px;
  color: var(--ink);
}

.matrix th {
  z-index: 2;
  background: #ebe4d6;
  color: #12233b;
  font-size: 13px;
  letter-spacing: 0;
}

.matrix thead th {
  background: #1c3456;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  vertical-align: bottom;
  padding: 8px 6px 7px;
  min-width: 52px;
  white-space: nowrap;
  line-height: 1.2;
  box-shadow: 0 2px 0 rgba(15, 29, 48, 0.35);
}

.matrix thead th.day-h .d-md {
  display: block;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.matrix thead th.day-h .d-w {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  color: #c5d3e6;
}

.matrix thead th.day-h.is-weekend {
  background: #3d2a24;
  color: #ffd7b0;
}

.matrix thead th.day-h.is-weekend .d-w { color: #f3c49a; }

.matrix thead th.day-h.is-today {
  background: #c45c26;
  color: #fff;
}

.matrix thead th.day-h.is-today .d-w { color: #ffe7d4; }

.matrix thead .hotel-col {
  z-index: 4;
  background: #12233b;
  color: #fff;
  text-align: left;
  min-width: 220px;
  box-shadow: 2px 2px 0 rgba(15, 29, 48, 0.35);
}

.matrix thead .num:last-child {
  background: #16263d;
}

.matrix td {
  color: #6b7280;
  font-weight: 600;
  vertical-align: middle;
}

.matrix .hotel-col {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 220px;
  background: #fffdf8;
  color: #12233b;
  font-weight: 700;
}

.matrix tbody tr:nth-child(even) td { background: #f7f3ea; }
.matrix tbody tr:nth-child(even) .hotel-col { background: #f3eee3; }
.matrix tbody tr:hover td { background: #efe4cf; }
.matrix tbody tr:hover .hotel-col { background: #ead9b8; }

.matrix .has-val {
  color: #12233b;
  font-weight: 800;
}

.matrix .strong {
  color: #12233b;
  font-weight: 800;
}

.matrix tfoot th {
  top: auto;
  bottom: 0;
  z-index: 2;
  background: #12233b;
  color: #fff;
  font-weight: 800;
}

.matrix tfoot .hotel-col {
  z-index: 3;
  background: #12233b;
  color: #fff;
}

.bar-col { width: 90px; }
.inline-bar {
  display: block;
  height: 8px;
  background: var(--accent);
  border-radius: 99px;
  min-width: 0;
}
.inline-bar.is-neg { background: #c45c4a; }

.num.is-neg,
.chart-col.is-neg .chart-amount { color: var(--danger); }

.chart-bar.is-neg { background: #c45c4a; }

.empty-state {
  margin: 28px 0 8px;
  padding: 36px 24px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--card);
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}
.empty-state p { margin: 0; font-size: 15px; }

.empty {
  margin: 24px 0;
  text-align: center;
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pill-live { background: #1f7a4d; color: #fff; }
.pill-test { background: #9a5b12; color: #fff; }

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.status-successful { background: var(--ok-bg); color: var(--ok); }
.status-refunded { background: var(--warn-bg); color: var(--warn); }
.status-failed,
.status-error,
.status-canceled,
.status-cancelled,
.status-chargeback { background: var(--danger-bg); color: var(--danger); }
.status-awaiting,
.status-pending,
.status-authorized { background: var(--wait-bg); color: var(--wait); }

.loading {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  align-items: center;
  justify-content: center;
  background: rgba(18, 35, 59, 0.42);
}
.loading.is-on { display: flex; }

.loading-card {
  min-width: 280px;
  padding: 28px 32px;
  border-radius: 16px;
  background: #fff;
  text-align: center;
  color: #12233b;
  font-weight: 700;
}

.loading-card p { margin: 14px 0 0; font-size: 15px; }

.loading-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border: 4px solid #e4e0d6;
  border-top-color: #c45c26;
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

.sales-view[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .sales-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .header-bar { flex-direction: column; align-items: flex-start; }
  .sales-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 22px; }
}
