@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&display=swap');

:root {
  --bg: #0F1923; --bg2: #162231; --bg3: #1E3045;
  --accent: #E74C3C; --gold: #F39C12; --green: #27AE60;
  --text: #ECF0F1; --text2: #95A5A6; --border: #2C4A66;
  --card: #1A2C3D; --radius: 12px;
}

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

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* 大文字モード */
.large-font { font-size: 16px; }
.large-font .tab-btn { font-size: 15px; padding: 16px 20px; }
.large-font .app-title { font-size: 20px; }
.large-font .store-table { font-size: 15px; }
.large-font .store-table th { font-size: 14px; padding: 12px 14px; }
.large-font .store-table td { font-size: 14px; padding: 14px 14px; }
.large-font .card-title { font-size: 15px; }
.large-font .btn { font-size: 14px; padding: 10px 18px; }
.large-font .btn-sm { font-size: 13px; padding: 7px 13px; }
.large-font .summary-num { font-size: 44px; }
.large-font .summary-label { font-size: 14px; }
.large-font .form-input { font-size: 16px; padding: 12px 16px; }
.large-font .form-label { font-size: 14px; }
.large-font .limit-coupon { font-size: 14px; }
.large-font .limit-store-name { font-size: 17px; }
.large-font .audit-table td { font-size: 14px; }
.large-font .badge { font-size: 14px; }
.large-font .no-data { font-size: 16px; }

/* ログイン */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px; width: 100%; max-width: 380px; text-align: center;
}
.login-icon { font-size: 48px; margin-bottom: 16px; }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--text2); font-size: 13px; margin-bottom: 28px; }
.login-input {
  width: 100%; padding: 14px 16px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 16px; font-family: inherit; margin-bottom: 12px;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-btn {
  width: 100%; padding: 14px; background: var(--accent); color: white;
  border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.login-btn:hover { background: #c0392b; }
.login-error { color: var(--accent); font-size: 13px; margin-top: 10px; }

/* メインレイアウト */
#main-app { display: none; }

.app-header {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 24px; display: flex; align-items: center;
  justify-content: space-between; height: 60px;
  position: sticky; top: 0; z-index: 100;
}
.app-title { font-size: 16px; font-weight: 700; }
.app-title span { color: var(--accent); }
.header-btns { display: flex; gap: 8px; align-items: center; }
.logout-btn {
  background: none; border: 1px solid var(--border); color: var(--text2);
  padding: 6px 14px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-family: inherit;
}
.font-size-btn {
  background: none; border: 1px solid var(--border); color: var(--text2);
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 700; font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
}
.font-size-btn.active { border-color: var(--gold); color: var(--gold); }

/* タブ */
.tab-nav {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; overflow-x: auto; scrollbar-width: none; padding: 0 16px;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 14px 16px; white-space: nowrap; background: none;
  border: none; border-bottom: 3px solid transparent;
  color: var(--text2); font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: color 0.2s;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-btn:hover { color: var(--text); }

/* コンテンツ */
.tab-content { display: none; padding: 24px; max-width: 1200px; margin: 0 auto; }
.tab-content.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card-title {
  font-size: 13px; font-weight: 700; color: var(--text2);
  letter-spacing: 2px; margin-bottom: 16px; text-transform: uppercase;
}

/* サマリー */
.summary-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.summary-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.summary-num { font-size: 36px; font-weight: 900; color: var(--accent); }
.summary-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* テーブル */
.store-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.store-table th {
  text-align: left; padding: 10px 12px; background: var(--bg3);
  color: var(--text2); font-weight: 600; border-bottom: 1px solid var(--border);
}
.store-table td {
  padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.store-table tr:last-child td { border-bottom: none; }
.store-table tr:hover td { background: rgba(255,255,255,0.02); }
.store-table th.sortable { cursor: pointer; user-select: none; }
.store-table th.sortable:hover { color: var(--gold); }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
}
.badge-today { background: rgba(231,76,60,0.2); color: #E74C3C; }
.badge-total { background: rgba(243,156,18,0.15); color: #F39C12; }
.badge-limit { background: rgba(149,165,166,0.15); color: #95A5A6; }
.badge-assoc { background: rgba(39,174,96,0.15); color: #27AE60; font-size: 11px; }
.badge-superuser { background: rgba(231,76,60,0.25); color: #E74C3C; }
.badge-admin { background: rgba(149,165,166,0.2); color: #95A5A6; }
.superuser-section { display: none; }

/* ボタン */
.btn {
  padding: 8px 16px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: opacity 0.2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: white; }
.btn-gold { background: var(--gold); color: #1A1A1A; }
.btn-green { background: var(--green); color: white; }
.btn-ghost { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-danger { background: rgba(231,76,60,0.15); color: var(--accent); border: 1px solid rgba(231,76,60,0.3); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* フォーム */
.form-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.form-input {
  flex: 1; min-width: 120px; padding: 10px 14px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-size: 14px; font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-label { font-size: 12px; color: var(--text2); margin-bottom: 4px; display: block; }
textarea.form-input { resize: vertical; line-height: 1.6; }

/* 上限 */
.limit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.limit-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.limit-store-name { font-weight: 700; margin-bottom: 12px; font-size: 14px; }
.limit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.limit-coupon { font-size: 12px; color: var(--text2); width: 80px; flex-shrink: 0; }
.limit-input {
  flex: 1; padding: 6px 10px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px; font-family: inherit;
  width: 70px; text-align: center;
}

/* モーダル共通 */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white; color: #1A1A1A; border-radius: 20px;
  padding: 32px; max-width: 400px; width: 90%; text-align: center;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.modal-url { font-size: 11px; color: #888; word-break: break-all; margin: 12px 0; padding: 8px; background: #f5f5f5; border-radius: 8px; }
.modal img { max-width: 240px; margin: 8px auto; display: block; }
.modal-close { margin-top: 16px; padding: 10px 28px; background: #E74C3C; color: white; border: none; border-radius: 10px; cursor: pointer; font-family: inherit; font-weight: 700; }

/* 販売数修正モーダル */
.edit-modal-date {
  width: 100%; padding: 10px; font-size: 15px;
  border: 1px solid #ddd; border-radius: 8px; margin-bottom: 16px; font-family: inherit;
}

/* トースト */
.toast {
  position: fixed; top: 20px; right: 20px;
  background: var(--green); color: white;
  padding: 12px 20px; border-radius: 10px;
  font-weight: 600; font-size: 14px; z-index: 9999;
  transform: translateX(calc(100% + 40px));
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), visibility 0s 0.3s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast.error { background: var(--accent); }
.toast.show { transform: translateX(0); visibility: visible; transition-delay: 0s; }

/* 監査ログ */
.audit-filter { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.audit-table th { font-size: 12px; }
.audit-table td { font-size: 12px; padding: 8px 10px; }

/* ユーティリティ */
.text-center { text-align: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.no-data { text-align: center; padding: 40px; color: var(--text2); }
.hint { font-size: 12px; color: var(--text2); margin-bottom: 10px; }

/* 商店会 */
.assoc-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.assoc-item:last-child { border-bottom: none; }
.assoc-name { font-weight: 600; font-size: 15px; }
.assoc-date { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* 設定タブ グリッドレイアウト */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}
.settings-grid > .card {
  margin-bottom: 0;
  max-width: none;
}
.settings-grid > .card.span-full {
  grid-column: 1 / -1;
}

/* バックアップ日付グループ */
.backup-date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: 6px;
  margin-top: 10px;
}
.backup-date-header:first-child { margin-top: 0; }
.backup-date-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 1px;
}

@media (max-width: 600px) {
  .tab-content { padding: 16px; }
  .store-table { font-size: 12px; }
  .store-table th, .store-table td { padding: 8px 6px; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* ─── 印刷用ヘッダー（画面では非表示） ─── */
#report-print-header {
  display: none;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 2px solid #333;
}
.report-print-title { font-size: 20px; font-weight: 900; margin-bottom: 4px; }
#report-print-period { font-size: 13px; margin-top: 4px; }
#report-print-date { font-size: 11px; margin-top: 2px; }

/* ─── 印刷レイアウト ─── */
@media print {
  @page { size: A4 portrait; margin: 15mm 12mm; }

  /* 管理画面のUI要素を全て非表示 */
  .app-header, .tab-bar, #tab-report > .card { display: none !important; }

  /* 全タブを非表示にしてから、レポートタブだけ表示 */
  .tab-content { display: none !important; }
  #tab-report { display: block !important; }

  /* 本文・タブレイアウトをリセット */
  body { background: #fff !important; color: #000 !important; font-size: 11pt; }
  #tab-report { padding: 0 !important; background: #fff !important; }

  /* 印刷ヘッダーを表示 */
  #report-print-header { display: block !important; color: #000 !important; border-color: #333 !important; }
  .report-print-title { color: #000 !important; }
  #report-print-period, #report-print-date { color: #444 !important; }

  /* カード */
  .card {
    background: #fff !important; color: #000 !important;
    border: 1px solid #bbb !important; border-radius: 4px !important;
    margin-bottom: 12px !important; padding: 12px !important;
    break-inside: auto;
  }
  .card-title { color: #333 !important; letter-spacing: 1px; margin-bottom: 10px !important; }

  /* サマリーカード */
  .summary-card {
    background: #f5f5f5 !important; border: 1px solid #ccc !important;
    border-radius: 4px !important;
  }
  .summary-num { font-size: 26px !important; color: #c0392b !important; }
  .summary-label { color: #555 !important; }

  /* テーブル */
  .store-table { font-size: 10pt !important; border-collapse: collapse !important; }
  .store-table th {
    background: #eeeeee !important; color: #222 !important;
    border: 1px solid #999 !important; padding: 7px 10px !important;
    white-space: nowrap;
  }
  .store-table th.sortable { cursor: default !important; }
  .store-table td {
    color: #000 !important; border: 1px solid #ccc !important;
    padding: 6px 10px !important;
  }
  .store-table tr:hover td { background: none !important; }
  .store-table tbody tr { break-inside: avoid; }

  /* バッジ */
  .badge { background: #e8e8e8 !important; color: #000 !important; border-radius: 3px !important; }
  .badge-today { background: #d5e8d4 !important; color: #1a5e20 !important; }

  /* 印刷ボタン・トースト通知は非表示 */
  #report-print-btn, .toast { display: none !important; }
}
