:root {
  --bg:        #f8f5f0;
  --panel:     #ffffff;
  --line:      #e2d5c3;
  --gold:      #bf8127;
  --gold-dk:   #8b5a16;
  --text:      #1d160d;
  --muted:     #6f604e;
  --ok:        #1f7a3a;
  --danger:    #b3261e;
  --focus:     #1c64f2;
  --topbar-h:  60px;
  --tabbar-h:  42px;
  --statusbar-h: 32px;
  --alertbanner-h: 0px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}

.topbar-left { display: flex; align-items: baseline; gap: 10px; }

h1 { font-size: 18px; font-weight: 800; color: var(--gold-dk); white-space: nowrap; }

.version { font-size: 11px; color: var(--muted); white-space: nowrap; }

.store-select-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.store-select {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.store-select:focus { outline: 2px solid var(--focus); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ais-username { font-size: 13px; color: var(--muted); }

.btn-logout {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.btn-logout:hover { color: var(--text); border-color: var(--text); }

/* ── Login overlay ──────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 99999;
}
.login-overlay.hidden { display: none; }
.login-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 40px 32px;
  width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  display: flex; flex-direction: column; gap: 14px;
}
.login-logo { font-size: 32px; font-weight: 900; color: var(--gold-dk); text-align: center; }
.login-subtitle { font-size: 12px; color: var(--muted); text-align: center; margin-top: -6px; }
.login-error { color: #e53e3e; font-size: 13px; min-height: 16px; text-align: center; }
.login-setup-note { font-size: 12px; color: #f6ad55; margin: 0; }
.login-field { display: flex; flex-direction: column; gap: 4px; }
.login-field label { font-size: 12px; color: var(--muted); }
.login-field input {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
.btn-login {
  padding: 10px;
  background: var(--gold-dk);
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-login:hover { filter: brightness(1.1); }
.hidden { display: none !important; }

.range-presets { display: flex; gap: 4px; }

.preset-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.preset-btn[data-active] {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}
.preset-btn:hover:not([data-active]) { background: #f1e8d8; }

.range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-inputs input[type="date"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
.range-inputs input[type="date"]:focus { outline: 2px solid var(--focus); }

.range-inputs span { color: var(--muted); font-weight: 700; }

.btn-primary {
  border: none;
  border-radius: 7px;
  background: var(--gold);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 14px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--gold-dk); }
.btn-primary.active { background: var(--gold-dk); box-shadow: inset 0 0 0 2px rgba(0,0,0,.25); }

.btn-ghost {
  border: 1px solid var(--gold);
  border-radius: 7px;
  background: #fff;
  color: var(--gold-dk);
  font-weight: 800;
  font-size: 13px;
  padding: 5px 13px;
  cursor: pointer;
}
.btn-ghost:hover { background: #f1e8d8; }
.btn-ghost.active { background: var(--gold); color: #fff; }

/* ── Tab bar ─────────────────────────────────────────────────────────────── */

.tabbar {
  display: flex;
  gap: 0;
  height: var(--tabbar-h);
  background: #f3eadb;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  position: sticky;
  top: var(--topbar-h);
  z-index: 90;
}

.tab-btn {
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 0 18px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab-btn.active {
  color: var(--gold-dk);
  border-bottom-color: var(--gold);
}
.tab-btn:hover:not(.active) { color: var(--text); }

/* ── Tab content ─────────────────────────────────────────────────────────── */

.tab-content { display: none; padding: 14px 16px; }
.tab-content.active { display: block; }

/* 清算レポートタブ: 上部に見出しが2段(清算レポート操作行＋月次エクスポート行)あり、
   固定pxで.table-wrapの残り高さを見積もる方式(calc(100vh - ... - 90px))だと、
   件数が多い時にわずかに数値が合わず、表がビューポートより少しだけ高くなって
   ページ全体が縦スクロールしてしまい、表自体の横スクロールバーが画面外に隠れる
   不具合があった(1ヶ月では起きないが3ヶ月だと発生)。このタブだけflexboxにして、
   上の見出し類の実際の高さを差し引いた「残り全部」を表の領域に割り当てることで、
   表が必ずビューポート内に収まり、横スクロールバーも常に見える位置に来るようにする。 */
/* 画面下部に position:fixed の .status-bar が常時重なっているため、その高さ分も
   差し引かないと、表の横スクロールバーがちょうど.status-barの下に隠れて
   (うっすら透けて見えるが操作できない状態になる)。 */
#tab-daily.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - var(--statusbar-h) - var(--alertbanner-h));
}
#tab-daily.active #dailyTableWrap {
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-height: none;
}

.tab-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tab-title { font-size: 15px; font-weight: 800; color: var(--gold-dk); }
.tab-desc  { font-size: 12px; color: var(--muted); }

.tab-range {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.btn-csv {
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: #fff;
  color: var(--gold-dk);
  font-weight: 800;
  font-size: 12px;
  padding: 5px 11px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-csv:hover { background: var(--gold); color: #fff; }

.filter-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.filter-label input { width: 16px; height: 16px; accent-color: var(--gold); }

.group-btns { display: flex; gap: 3px; }
.group-btn {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  cursor: pointer;
}
.group-btn.active { background: var(--gold); color: #fff; border-color: var(--gold); }

/* ── Table ───────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - 90px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(60,44,20,.06);
}

table {
  /* width:100%だけだと、列数が多く中身がnowrapで縮められないテーブル(清算レポート等)で
     ブラウザ・環境によっては横方向にはみ出さず文字が潰れるだけになり、.table-wrapの
     overflow-xが効かないことがあった。min-width:100%にして、必要な時だけ実際の内容幅
     (max-content)まで広がれるようにし、確実に横スクロールできるようにする。 */
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table .small { font-size: 11px; color: var(--muted); }

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f0e6d6;
  border-bottom: 2px solid var(--line);
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-dk);
}
thead th:first-child { text-align: left; }

tbody tr:nth-child(even) { background: #faf6f0; }
tbody tr:hover { background: #f5eddf; }

td {
  border-bottom: 1px solid #ede4d5;
  padding: 7px 10px;
  text-align: right;
  white-space: nowrap;
}
td:first-child { text-align: left; }

.col-date { min-width: 100px; text-align: left !important; }
.col-yen  { min-width: 90px; }
.col-n    { min-width: 60px; }

tfoot td {
  font-weight: 800;
  background: #f0e6d6;
  border-top: 2px solid var(--line);
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
  position: sticky;
  bottom: 0;
}
tfoot td:first-child { text-align: left; }

.total-row td { background: #f0e6d6; font-weight: 800; }
.total-cell   { font-weight: 800; }

/* category separator row */
.cat-row td {
  background: #f7f0e6;
  padding: 6px 10px;
  color: var(--gold-dk);
  font-size: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.cat-row td.col-yen { text-align: right; }

.sponsor-cell { font-size: 11px; color: var(--muted); }

.badge.sponsor {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  background: #ffe0b2;
  color: #7a4500;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
}

.empty {
  text-align: center !important;
  color: var(--muted);
  padding: 32px 16px;
  font-size: 13px;
}

/* ── Status bar ──────────────────────────────────────────────────────────── */

.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255,255,255,.9);
  border-top: 1px solid var(--line);
  min-height: 28px;
}
.status-bar.ok    { color: var(--ok); }
.status-bar.error { color: var(--danger); }

/* ── Realtime dashboard ──────────────────────────────────────────────────── */

.rt-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 4px 2px 60px;
}

.rt-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 13px;
}

.rt-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(60,44,20,.06);
}

.rt-card-main {
  background: linear-gradient(135deg, var(--gold-dk) 0%, var(--gold) 100%);
  border-color: var(--gold);
  color: #fff;
}
.rt-card-main .rt-label { color: rgba(255,255,255,.75); }
.rt-card-main .rt-big   { color: #fff; }
.rt-card-main .rt-sub   { color: rgba(255,255,255,.8); }

.rt-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.rt-big {
  font-size: 30px;
  font-weight: 800;
  color: var(--gold-dk);
  line-height: 1.1;
  margin-bottom: 4px;
}

.rt-unit {
  font-size: 16px;
  font-weight: 600;
  margin-left: 3px;
}

.rt-sub {
  font-size: 12px;
  color: var(--muted);
}

.rt-gender {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.rt-card-tax { grid-column: span 2; }

.rt-tax-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.rt-tax-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  min-width: 42px;
}

.rt-bar-track {
  flex: 1;
  height: 10px;
  background: #f0e6d6;
  border-radius: 5px;
  overflow: hidden;
}

.rt-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 5px;
  transition: width .4s ease;
}

.rt-tax-amt {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  min-width: 90px;
  text-align: right;
}

/* ── Analysis tab ────────────────────────────────────────────────────────── */

.analysis-chart-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 20px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(60,44,20,.06);
}

.analysis-chart-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold-dk);
  margin-bottom: 12px;
}

/* トレンドグラフ等、期間を長くすると点数が増えるグラフは横に伸ばして
   スクロール表示する(押し縮めて読めなくなるのを防ぐ)。#chartInner がJS側で
   必要幅を計算してpxで指定し、#chartBoxがそれより狭ければ横スクロールになる。 */
#chartBox { position: relative; max-height: 420px; overflow-x: auto; overflow-y: hidden; }
#chartInner { height: 400px; }
#chartBox canvas { max-height: 400px; }

.analysis-tbl-outer { padding-bottom: 60px; }
.analysis-tbl .table-wrap { max-height: 340px; margin-bottom: 0; }

.analysis-print-header { display: none; }

/* ── Print ───────────────────────────────────────────────────────────────── */

@media print {
  body.printing-analysis .topbar,
  body.printing-analysis .tabbar,
  body.printing-analysis .status-bar,
  body.printing-analysis .tab-content:not(#tab-analysis),
  body.printing-analysis #tab-analysis .tab-head { display: none !important; }

  body.printing-analysis .analysis-print-header {
    display: flex !important;
    align-items: baseline;
    gap: 12px;
    padding: 0 0 10px;
    border-bottom: 2px solid var(--gold);
    margin-bottom: 16px;
    font-size: 14px;
  }

  body.printing-analysis #tab-analysis {
    display: block !important;
    padding: 16px;
  }

  body.printing-analysis .analysis-chart-wrap {
    border: none;
    box-shadow: none;
    page-break-inside: avoid;
  }

  body.printing-analysis .analysis-tbl-outer { padding-bottom: 0; }
  body.printing-analysis .table-wrap { max-height: none !important; overflow: visible !important; }

  @page { margin: 15mm; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* ── Shopify tab ──────────────────────────────────────────────────────────── */

.shopify-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px 4px;
}

.shopify-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 160px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shopify-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.shopify-card-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

.shopify-card.accent .shopify-card-value { color: var(--ok); }
.shopify-card.danger .shopify-card-value { color: var(--danger); }

/* ── Shopify 購入者リスト ─────────────────────────────────────────────────── */

.shopify-section {
  margin-top: 28px;
  border-top: 2px solid var(--border);
  padding-top: 16px;
  padding-bottom: 8px;
}

#shopifyCustomerTable { table-layout: fixed; width: 100%; }
#shopifyCustomerTable th:nth-child(1),
#shopifyCustomerTable td:nth-child(1) { width: 90px; }
#shopifyCustomerTable th:nth-child(2),
#shopifyCustomerTable td:nth-child(2) { width: 100px; }
#shopifyCustomerTable th:nth-child(3),
#shopifyCustomerTable td:nth-child(3) { width: 120px; }
#shopifyCustomerTable th:nth-child(4),
#shopifyCustomerTable td:nth-child(4) { width: auto; }
#shopifyCustomerTable td { white-space: normal; word-break: break-all; vertical-align: top; }

/* ── 購入者検索 チェックボックスパネル ──────────────────────────────────── */

.variant-group {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  min-width: 200px;
  max-width: 320px;
}
.variant-group-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.variant-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: .82rem;
  cursor: pointer;
  padding: 2px 0;
}
.variant-label { flex: 1; color: var(--text); }
.variant-count { font-size: .75rem; color: var(--muted); white-space: nowrap; }

#purchaseListTable { table-layout: fixed; width: 100%; }
#purchaseListTable th:nth-child(1),
#purchaseListTable td:nth-child(1) { width: 90px; }
#purchaseListTable th:nth-child(2),
#purchaseListTable td:nth-child(2) { width: 130px; }
#purchaseListTable th:nth-child(3),
#purchaseListTable td:nth-child(3) { width: 110px; }
#purchaseListTable th:nth-child(4),
#purchaseListTable td:nth-child(4) { width: auto; }
#purchaseListTable td { white-space: normal; word-break: break-word; vertical-align: top; }

/* ── PayPal section ───────────────────────────────────────────────────────── */

.paypal-section {
  margin-top: 28px;
  border-top: 2px solid #009cde33;
  padding-top: 16px;
  padding-bottom: 2.5rem;
}
.paypal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.paypal-logo {
  background: #003087;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.paypal-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.pp-card {
  background: var(--panel);
  border: 1px solid #009cde44;
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pp-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.pp-card-val {
  font-size: 18px;
  font-weight: 800;
  color: #003087;
}
.col-mono { font-family: monospace; font-size: 11px; }
.col-ref  { font-size: 11px; color: var(--muted); max-width: 120px; word-break: break-all; }
.muted-small { font-size: 11px; color: var(--muted); }
.pp-row-usd td { background: #fffbe6; color: #7a5500; }
.pp-foreign-note {
  font-size: 11px; color: #b35c00; align-self: center;
  background: #fff3cd; border: 1px solid #f5c07a;
  border-radius: 4px; padding: 3px 8px;
}

/* ── Journal overlay ──────────────────────────────────────────────────────── */

.daily-row { cursor: pointer; }
.daily-row:hover td { background: #fdf8ef; }

.wd-sat td { background: #eef4fb; }
.wd-sat:hover td { background: #e3edf9; }
.wd-sat .col-date { color: #2b6cb0; font-weight: 700; }
.wd-sun td { background: #fdeeee; }
.wd-sun:hover td { background: #fbe1e1; }
.wd-sun .col-date { color: #c0392b; font-weight: 700; }

.journal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex; align-items: stretch; justify-content: flex-end;
}
.journal-overlay.hidden { display: none; }

.journal-panel {
  background: #fff;
  width: min(720px, 100vw);
  height: 100vh;
  display: flex; flex-direction: column;
  box-shadow: -4px 0 32px rgba(0,0,0,.18);
  overflow: hidden;
}

.journal-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 2px solid var(--gold);
  font-size: 15px; font-weight: 800; color: var(--gold-dk);
}
.journal-close-btn {
  border: none; background: none; font-size: 18px; cursor: pointer;
  color: var(--muted); padding: 0 4px; line-height: 1;
}
.journal-close-btn:hover { color: var(--text); }

.journal-body {
  flex: 1;
  min-height: 0;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}
.journal-body > * + * { margin-top: 14px; }

.j-loading, .j-empty, .j-error { color: var(--muted); text-align: center; padding: 32px; }
.j-error { color: var(--danger); }

.j-payment {
  border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden;
}
.j-payment.voided {
  border: 2px solid var(--danger);
}
.j-payment.voided .j-pay-hd {
  background: #fee2e2;
}
.j-payment.voided .j-total {
  color: var(--danger);
  text-decoration: line-through;
}

.j-pay-hd {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.j-time    { font-weight: 700; font-size: 13px; color: var(--muted); }
.j-table   { font-weight: 700; font-size: 13px; }
.j-receipt { font-size: 12px; color: var(--gold-dk); font-weight: 700; }
.j-guests  { font-size: 13px; }
.j-method  { font-size: 12px; color: var(--muted); flex: 1; }
.j-total   { font-weight: 800; color: var(--gold-dk); }
.j-pay-sub { padding: 4px 12px; font-size: 12px; color: var(--muted); }

.j-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 12px;
}
.j-badge.void { background: #fee2e2; color: #dc2626; }
.j-badge.corr { background: #fef9c3; color: #854d0e; }
.j-badge.entry { background: #dbeafe; color: #1d4ed8; }

.j-jump-hl {
  outline: 3px solid #f59e0b;
  box-shadow: 0 0 0 4px rgba(245,158,11,.25);
  transition: outline-color .2s, box-shadow .2s;
}

.j-lines {
  width: 100%; border-collapse: collapse; font-size: 13px;
  margin: 0;
}
.j-lines th, .j-lines td {
  padding: 5px 10px; border-bottom: 1px solid var(--line);
  text-align: left;
}
.j-lines thead th { background: #fafafa; font-size: 11px; color: var(--muted); }
.j-lines tbody tr:last-child td { border-bottom: none; }

.j-corr-history {
  border-top: 1px solid var(--line);
  background: #fafaf5;
  padding: 8px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.j-corr-item {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.j-corr-item.void .j-corr-type { color: var(--danger); }
.j-corr-type { font-weight: 700; font-size: 11px; color: var(--ok); }
.j-corr-note { font-style: italic; }
.j-corr-item ul { margin: 2px 0 0 12px; padding: 0; list-style: disc; width: 100%; }
.j-corr-item li { margin: 1px 0; }

.j-actions {
  display: flex; gap: 8px; padding: 8px 12px;
  border-top: 1px solid var(--line); background: #fff;
}
.btn-j-void {
  border: 1px solid var(--danger); border-radius: 6px;
  background: #fff; color: var(--danger);
  padding: 5px 14px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.btn-j-void:hover { background: #fee2e2; }
.btn-j-corr {
  border: 1px solid var(--gold); border-radius: 6px;
  background: #fff; color: var(--gold-dk);
  padding: 5px 14px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.btn-j-corr:hover { background: var(--bg); }
.btn-secondary {
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--muted);
  padding: 5px 14px; font-size: 13px; cursor: pointer;
}

/* ── 決済突合せ: 清算レポート中心の統合カード表示 ── */
.rc-unified {
  max-height: 560px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 6px;
  margin-top: 8px;
}
.rc-tl-day {
  font-size: 11px;
  font-weight: 800;
  color: var(--gold-dk);
  background: #f7f1e4;
  padding: 4px 8px;
  margin: 6px 0 4px;
  border-radius: 4px;
  position: sticky;
  top: 0;
}
.rc-card {
  border-radius: 6px;
  margin: 4px 0;
  padding: 6px 8px;
  background: #fbfaf7;
  border: 1px solid var(--line);
}
.rc-card-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
.rc-card-main .rc-tl-time { color: var(--muted); white-space: nowrap; }
.rc-card-main .rc-tl-method { color: var(--muted); font-size: 11px; }
.rc-card-main .rc-tl-amt { font-weight: 700; white-space: nowrap; }
.rc-card-attach {
  margin: 6px 0 0 18px;
  padding: 5px 8px;
  border-left: 3px solid var(--gold);
  background: #f4efe3;
  border-radius: 0 4px 4px 0;
  font-size: 11.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.rc-card.mismatch { border: 1px solid var(--danger); background: #fdecea; }
.rc-card.mismatch .rc-card-attach { border-left-color: var(--danger); background: #fbe0dc; }
.rc-card.missing { border: 1px solid var(--danger); background: #fdecea; }

/* ── 決済突合せ: 3列表示・ドラッグ紐づけ ── */
.rc-timeline {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.rc-tl-col {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 260px);
}
.rc-tl-head {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-dk);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #f0e6d6;
  border-radius: 8px 8px 0 0;
  position: sticky;
  top: 0;
  z-index: 1;
}
.rc-tl-warn {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 5px 10px; background: #fdf6ec; border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.rc-warn-count { font-weight: 800; color: var(--danger); }
.rc-warn-count.rc-warn-count-zero { color: var(--muted); font-weight: 600; }
.rc-warn-jump-btn {
  border: 1px solid var(--danger); border-radius: 6px; background: #fff; color: var(--danger);
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; cursor: pointer;
}
.rc-warn-jump-btn:hover { background: var(--danger); color: #fff; }
.rc-jump-hl { outline: 3px solid #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,.25); }
.rc-tl-body { overflow-y: auto; padding: 4px 6px; }
.rc-card[draggable="true"] { cursor: grab; }
.rc-card.dragging { opacity: .4; }
.rc-tl-body.drag-over { background: #fff7e0; outline: 2px dashed var(--gold); }
.rc-card.drop-target { outline: 2px dashed var(--gold); }

/* 色分けルール: 自動照合=緑／手動紐づけ=赤／現金(未紐づけ)=無色／照合先なし=黄色点滅 */
.rc-card.rc-auto { background: #eafaf0; border-left: 4px solid #16a34a; }
.rc-card.rc-manual { background: #fdecea; border-left: 4px solid #b3261e; }
.rc-card.rc-blink {
  border: 2px solid #d4a017;
  animation: rcBlink 1.2s ease-in-out infinite;
}
@keyframes rcBlink {
  0%, 100% { background: #fffaf0; }
  50% { background: #ffe58a; }
}

/* 現金記録の疑い(MISMATCH): 何もされていない未確定の提案であることが一目で分かるよう、
   赤文字の注意書き＋点滅するオレンジの「修正」ボタンをカード内に表示する。 */
.rc-card.rc-suspect { background: #fff5f5; border-left: 4px solid var(--danger); }
.rc-suspect-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 4px; padding-top: 4px; border-top: 1px dashed #f3b4ac;
}
.rc-suspect-label { color: var(--danger); font-size: 11.5px; font-weight: 700; }
.rc-fix-btn-blink {
  border: none; border-radius: 6px; padding: 3px 10px; font-size: 11px; font-weight: 700;
  color: #7c2d12; cursor: pointer;
  animation: rcFixBlink 1s ease-in-out infinite;
}
@keyframes rcFixBlink {
  0%, 100% { background: #fdba74; }
  50% { background: #f97316; color: #fff; }
}
.rc-fixed-row { margin-top: 4px; font-size: 11px; font-weight: 700; color: #16a34a; }

/* CSV側MISSING(POSのどの記録にも一致しない): 清算レポート側の「相手なし」(黄点滅)とは
   意味が違う最重要ケース(売上計上漏れの可能性)なので、赤系の点滅で色相自体を分ける。 */
.rc-card.rc-blink-danger {
  border: 2px solid var(--danger);
  animation: rcBlinkDanger 1.2s ease-in-out infinite;
}
@keyframes rcBlinkDanger {
  0%, 100% { background: #fff0ef; }
  50% { background: #ffb4ac; }
}
.rc-note-row { margin-top: 4px; font-size: 11px; font-weight: 700; color: var(--danger); }

/* 一致(OK)等のサマリーカードは他タブの.rt-dashboardと共用だが、突合せ画面では
   カード下の余白(padding-bottom:60px)が無駄に広く見えるため個別に詰める。 */
#rcSummary.rt-dashboard { padding-bottom: 4px; }

/* 突合せ画面の色の意味を常設で示す凡例。 */
.rc-import-history { font-size: 11.5px; color: var(--muted); margin: 0 0 8px; }
.rc-import-item { display: inline-block; margin-right: 12px; }

.rc-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  padding: 6px 10px; margin: 4px 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  font-size: 11.5px; color: var(--muted);
}
.rc-legend-item { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.rc-legend-swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
}
.rc-legend-swatch.rc-auto { background: #eafaf0; border-left: 4px solid #16a34a; }
.rc-legend-swatch.rc-manual { background: #fdecea; border-left: 4px solid #b3261e; }
.rc-legend-swatch.rc-blink { background: #ffe58a; border: 2px solid #d4a017; }
.rc-legend-swatch.rc-suspect { background: #fff5f5; border-left: 4px solid var(--danger); }
.rc-legend-swatch.rc-blink-danger { background: #ffb4ac; border: 2px solid var(--danger); }

/* ── システム使用量・アラートバナー ── */
.system-alert-banner {
  background: #fdecea;
  border-bottom: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
}
.system-alert-banner .sab-item { display: flex; align-items: center; gap: 6px; }
.system-alert-banner .sab-item::before { content: "⚠"; }

.ss-cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.ss-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
  min-width: 220px;
}
.ss-card-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ss-card-value { font-size: 24px; font-weight: 700; color: var(--text); }
.ss-card-value.warn { color: var(--danger); }
.ss-card-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

.j-corr-form {
  border-top: 2px solid var(--gold); background: #fffdf5; padding: 12px;
}
.j-corr-form-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.j-corr-form-note { display: flex; gap: 8px; margin: 8px 0; }

.j-new-entry { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.btn-j-entry {
  background: var(--gold-dk); color: #fff;
  border: none; border-radius: 6px;
  padding: 6px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-j-entry:hover { background: var(--gold); }

.j-entry-form {
  border: 2px solid var(--gold-dk); border-radius: 8px;
  background: #fdf8ef; padding: 14px; margin-bottom: 14px;
}
.j-entry-total {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 0; font-size: 14px; padding: 8px 12px;
  background: var(--bg); border-radius: 6px;
}
.j-entry-total strong { font-size: 18px; color: var(--gold-dk); }

.sku-dropdown {
  position: absolute; top: 100%; left: 0; z-index: 2000;
  background: #fff; border: 1px solid var(--line);
  border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.15);
  min-width: 280px; max-height: 220px; overflow-y: auto;
}
.sku-drop-item {
  display: flex; gap: 8px; padding: 6px 10px;
  cursor: pointer; align-items: baseline; font-size: 13px;
}
.sku-drop-item:hover { background: var(--bg); }
.sku-drop-code { color: var(--muted); font-size: 11px; min-width: 36px; font-weight: 700; }
.sku-drop-name { flex: 1; }
.sku-drop-price { color: var(--gold-dk); font-weight: 700; white-space: nowrap; }

@media (max-width: 800px) {
  .topbar { flex-direction: column; height: auto; padding: 8px 12px; gap: 8px; }
  .topbar-right { justify-content: flex-start; }
  .tab-btn { padding: 0 10px; font-size: 13px; }
  .table-wrap { max-height: calc(100vh - 180px); }
  .shopify-card { min-width: 140px; }
}

/* ── New entry tab ────────────────────────────────────────────────────────── */

.ne-form {
  padding: 16px;
  max-width: 920px;
}

.ne-form.hidden { display: none; }

.ne-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.ne-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-dk);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── New entry calendar ──────────────────────────────────────────────────── */

.ne-cal-outer {
  padding: 14px 16px 4px;
}

.ne-cal-wrap {
  display: inline-block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 260px;
}

.ne-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-dk);
}

.ne-cal-nav {
  background: none;
  border: 1px solid var(--line);
  border-radius: 5px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ne-cal-nav:hover { background: var(--bg); color: var(--gold-dk); }

.ne-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 34px);
  gap: 2px;
}

.ne-cal-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  padding: 3px 0 5px;
}

.ne-cal-day {
  text-align: center;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-radius: 50%;
  color: var(--line);
}

.ne-cal-day.has-close {
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  border-radius: 50%;
}
.ne-cal-day.has-close:hover { background: var(--bg); }

.ne-cal-day.today.has-close  { color: var(--focus); }
.ne-cal-day.today.no-close   { color: var(--focus); opacity: .4; }

.ne-cal-day.selected {
  background: var(--gold-dk) !important;
  color: #fff !important;
}

/* ── 担当者PIN管理 ─────────────────────────────────────────── */
.staff-pin-panel { margin: 8px 0 20px; padding: 12px; border: 1px solid #ddd; border-radius: 10px; background: #fafafa; }
.staff-pin-form { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.staff-pin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.staff-pin-table th, .staff-pin-table td { padding: 6px 10px; border-bottom: 1px solid #e5e5e5; text-align: left; }
.staff-pin-table tr.inactive { opacity: .5; }
