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

body {
  font-family: 'Segoe UI', sans-serif;
  background: #f4f6f9;
  color: #333;
  min-height: 100vh;
}

/* ─── ヘッダー（共通） ────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: #232f3e; color: #fff;
  height: 54px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { font-size: 0.85rem; color: #ff9900; font-weight: 700; text-decoration: none; letter-spacing: 0.5px; }
.header-sep  { color: #4a5568; font-size: 0.9rem; }
.header-title { font-size: 0.95rem; font-weight: 600; color: #e2e8f0; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* ─── ビュー ─────────────────────────────────────────────────────────────────── */
.view { padding: 24px; max-width: 1200px; margin: 0 auto; }
.view.hidden { display: none; }

/* ─── ツールバー ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.toolbar-left  { display: flex; align-items: center; gap: 12px; }
.toolbar-right { display: flex; gap: 8px; }
.toolbar h1 { font-size: 1.3rem; font-weight: 700; color: #232f3e; }
.count-badge {
  background: #e2e8f0; color: #555;
  padding: 2px 10px; border-radius: 10px;
  font-size: 0.8rem; font-weight: 600;
}

/* ─── ボタン ─────────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px; border-radius: 6px; border: none;
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.btn-primary   { background: #ff9900; color: #fff; }
.btn-primary:hover   { background: #e68a00; }
.btn-secondary { background: #fff; color: #555; border: 1px solid #ccc; }
.btn-secondary:hover { border-color: #888; }
.btn-danger    { background: #e53e3e; color: #fff; }
.btn-danger:hover    { background: #c53030; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-import { background: #2d7d46; color: #fff; }
.btn-import:hover { background: #256339; }
.btn-import:disabled { background: #aaa; cursor: not-allowed; }
.hidden { display: none !important; }

/* ─── インポートバー ──────────────────────────────────────────────────────────── */
.import-bar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px;
  padding: 8px 14px;
  background: #f0faf4; border-radius: 8px;
  border: 1px solid #b7e4c7;
  font-size: 0.8rem;
}
.import-status { font-weight: 700; white-space: nowrap; }
.import-none { color: #888; }
.import-ok   { color: #2d7d46; }
.import-hint { color: #555; }
.import-hint code {
  background: #e2e8f0; padding: 1px 6px;
  border-radius: 4px; font-size: 0.78rem;
}

/* ─── 期間サマリーカード ─────────────────────────────────────────────────────── */
.period-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.period-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-left: 4px solid #ff9900;
}
.period-yesterday { border-left-color: #ff9900; }
.period-week      { border-left-color: #146eb4; }
.period-month30   { border-left-color: #38a169; }
.period-lastmonth { border-left-color: #805ad5; }

.period-label {
  font-size: 0.75rem; font-weight: 700;
  color: #888; letter-spacing: 0.5px;
  text-transform: uppercase; margin-bottom: 4px;
}
.period-date { font-size: 0.72rem; color: #aaa; margin-bottom: 14px; }
.period-metrics { display: flex; flex-direction: column; gap: 9px; }
.metric { display: flex; justify-content: space-between; align-items: baseline; }
.metric-label { font-size: 0.78rem; color: #666; }
.metric-value { font-size: 1rem; font-weight: 700; color: #232f3e; }
.metric-value.no-data { font-size: 0.9rem; color: #ccc; font-weight: 400; }

/* ─── モール別内訳 ────────────────────────────────────────────────────────────── */
.breakdown-section {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
}
.breakdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #f0f0f0;
}
.breakdown-header h2 { font-size: 1rem; font-weight: 700; color: #232f3e; }
.period-tabs { display: flex; gap: 4px; }
.tab-btn {
  padding: 5px 14px; border-radius: 5px;
  border: 1px solid #e2e8f0; background: #fff;
  font-size: 0.8rem; color: #666; cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active { background: #232f3e; color: #fff; border-color: #232f3e; }
.tab-btn:hover:not(.active) { border-color: #aaa; }

/* ─── テーブル ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.list-table-wrap {
  background: #fff; border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  background: #f8f9fa; padding: 10px 14px;
  text-align: left; font-weight: 600; color: #555;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th[data-sort]:hover { background: #eef0f3; }
thead th.num { text-align: right; }
tbody td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; color: #333; }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: none; }
.empty-msg { text-align: center; color: #aaa; padding: 36px !important; }
.total-row td { background: #f8f9fa; border-top: 2px solid #e2e8f0; }

/* ─── フィルターバー ──────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px;
  background: #fff; padding: 14px 16px;
  border-radius: 8px; margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.filter-item { display: flex; flex-direction: column; gap: 4px; }
.filter-item label { font-size: 0.75rem; font-weight: 600; color: #666; }
.filter-item input,
.filter-item select {
  padding: 5px 10px; border: 1px solid #ccc; border-radius: 5px;
  font-size: 0.85rem; min-width: 130px;
}
.filter-reset { justify-content: flex-end; }

/* ─── 操作ボタン（一覧行） ────────────────────────────────────────────────────── */
.action-btn {
  padding: 3px 10px; border-radius: 4px;
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
  border: none; transition: background 0.15s; margin-right: 4px;
}
.action-btn.edit   { background: #ebf4ff; color: #2b6cb0; }
.action-btn.edit:hover   { background: #bee3f8; }
.action-btn.delete { background: #fff5f5; color: #c53030; }
.action-btn.delete:hover { background: #fed7d7; }

/* ─── フォーム ────────────────────────────────────────────────────────────────── */
.form-container { max-width: 700px; }
.form-page-title {
  font-size: 1.3rem; font-weight: 700; color: #232f3e;
  margin-bottom: 20px;
}
.form-section {
  background: #fff; border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 16px; overflow: hidden;
}
.form-section-title {
  background: #f8f9fa; padding: 10px 20px;
  font-size: 0.85rem; font-weight: 700; color: #555;
  border-bottom: 1px solid #e2e8f0;
}
.form-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.8rem; font-weight: 600; color: #555; }
.field.required label::after { content: ' *'; color: #e53e3e; }
.field input,
.field select {
  padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px;
  font-size: 0.9rem; color: #333;
}
.field input:focus,
.field select:focus {
  outline: none; border-color: #ff9900;
  box-shadow: 0 0 0 2px rgba(255,153,0,0.2);
}
.form-actions { display: flex; gap: 10px; align-items: center; padding: 8px 0 20px; }

/* ─── ヘッダーユーザー表示 ────────────────────────────────────────────────────── */
.hdr-user { font-size: 0.8rem; color: #aab7c4; display: flex; align-items: center; gap: 8px; }
.hdr-role {
  padding: 2px 8px; border-radius: 10px;
  font-size: 0.7rem; font-weight: 700;
  background: #ff9900; color: #fff;
}
.hdr-role.editor { background: #146eb4; }
.hdr-role.viewer { background: #555; }
.hdr-logout {
  background: none; border: 1px solid #4a5568; color: #aab7c4;
  padding: 3px 10px; border-radius: 4px; cursor: pointer; font-size: 0.75rem;
}
.hdr-logout:hover { border-color: #ff9900; color: #ff9900; }

/* ─── レスポンシブ ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .period-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .period-grid { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .breakdown-header { flex-direction: column; gap: 10px; align-items: flex-start; }
}
