/* OTC売上 月次報告 - 業務用シンプルデザイン（青系） */
:root {
  --blue: #1d4ed8;
  --blue-dark: #1e3a8a;
  --blue-light: #eff6ff;
  --blue-mid: #bfdbfe;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --green: #15803d;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --orange-bg: #fff7ed;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--gray-900);
  background: var(--gray-100);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; font-size: 16px; }

/* ---------- ログイン ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, var(--blue-dark), var(--blue)); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 28px 24px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.login-title { margin: 0 0 4px; font-size: 22px; color: var(--blue-dark); text-align: center; }
.login-lead { margin: 0 0 20px; text-align: center; color: var(--gray-500); }

/* ---------- ヘッダー・タブ ---------- */
.app-header { background: var(--blue); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.header-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 4px; }
.app-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.access-count { color: #dbeafe; font-size: 16px; line-height: 1.3; white-space: nowrap; min-height: 21px; }
.btn-link-light { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 16px; }
.btn-link-light:hover { background: rgba(255,255,255,.12); }
.tab-nav { max-width: 1100px; margin: 0 auto; display: flex; gap: 4px; padding: 6px 12px 0; }
.tab { flex: 1; max-width: 200px; text-align: center; color: #dbeafe; text-decoration: none; padding: 12px 8px; font-weight: 700; border-radius: 10px 10px 0 0; font-size: 17px; }
.tab:hover { background: rgba(255,255,255,.1); color: #fff; }
.tab.active { background: var(--gray-100); color: var(--blue); }

.container { max-width: 1100px; margin: 0 auto; padding: 16px; }
.app-footer { max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; text-align: right; }
.admin-link { color: var(--gray-400); font-size: 16px; text-decoration: none; padding: 8px; }
.admin-link:hover { text-decoration: underline; }

/* ---------- カード ---------- */
.card { background: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(15,23,42,.08); }
.card-title { margin: 0 0 14px; font-size: 18px; color: var(--blue-dark); border-left: 4px solid var(--blue); padding-left: 10px; }
.card-sub { color: var(--gray-500); font-size: 16px; font-weight: normal; }

/* ---------- フォーム ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field-label { display: block; font-weight: 700; margin-bottom: 6px; color: var(--gray-700); }
.field-label .opt { font-weight: normal; color: var(--gray-500); font-size: 16px; margin-left: 4px; }
.input, .select {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: 8px; background: #fff; color: var(--gray-900);
}
.select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus { outline: 3px solid var(--blue-mid); border-color: var(--blue); }
.input.invalid { border-color: var(--red); background: #fffafa; }
.input-amount { font-size: 22px; font-weight: 700; text-align: right; letter-spacing: .02em; }
.ym-row { display: flex; gap: 8px; }
.ym-row .select { flex: 1; }
.amount-wrap { position: relative; }
.amount-wrap .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-500); pointer-events: none; }
.amount-wrap .input-amount { padding-right: 40px; }
.preview { min-height: 24px; margin-top: 6px; color: var(--blue); font-weight: 700; }
.error-text { min-height: 24px; margin: 6px 0 0; color: var(--red); font-weight: 700; }
.hint { color: var(--gray-500); font-size: 16px; margin: 10px 0 0; }
.existing-box { background: var(--orange-bg); border: 1px solid #fed7aa; color: #9a3412; border-radius: 8px; padding: 10px 12px; margin-top: 4px; }
.existing-box strong { font-size: 18px; }

/* ---------- ボタン ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 20px; border-radius: 8px; border: 1px solid transparent; font-weight: 700; cursor: pointer; font-size: 16px; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); }
.btn-danger { background: #fff; color: var(--red); border-color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: var(--red-bg); }
.btn-danger-solid { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-save { width: 100%; min-height: 56px; font-size: 18px; margin-top: 8px; }
.btn-sm { min-height: 44px; padding: 6px 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- 入力状況 ---------- */
.status-summary { margin: 0 0 12px; font-weight: 700; }
.status-summary .done { color: var(--green); }
.status-summary .todo { color: var(--red); }
.status-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.status-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--gray-200); cursor: pointer; }
.status-item.done { background: var(--green-bg); border-color: #86efac; }
.status-item.todo { background: var(--red-bg); border-color: #fca5a5; }
.status-item .name { font-weight: 700; }
.status-item .badge { font-size: 16px; font-weight: 700; white-space: nowrap; }
.status-item.done .badge { color: var(--green); }
.status-item.todo .badge { color: var(--red); }
.status-item .amt { display: block; font-size: 16px; color: var(--gray-700); font-weight: normal; }

/* ---------- 表 ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--gray-200); border-radius: 8px; }
.table { border-collapse: collapse; width: 100%; font-size: 16px; white-space: nowrap; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-200); }
.table thead th { background: var(--blue-light); color: var(--blue-dark); font-weight: 700; text-align: center; position: sticky; top: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.center { text-align: center; }
.table tbody tr:hover td { background: var(--gray-50); }
.table .sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; text-align: left; box-shadow: 1px 0 0 var(--gray-200); }
.table thead .sticky-col { background: var(--blue-light); z-index: 2; }
.table tfoot td { background: var(--blue-light); font-weight: 700; border-top: 2px solid var(--blue-mid); }
.table tfoot .sticky-col { background: var(--blue-light); }
.cell-empty { color: var(--gray-300); text-align: center !important; }
.mark { color: var(--red); font-weight: 700; margin-left: 2px; }
.tag-hidden { display: inline-block; font-size: 16px; color: var(--gray-500); background: var(--gray-100); border-radius: 4px; padding: 0 6px; margin-left: 4px; }
.note { color: var(--gray-500); font-size: 16px; margin: 8px 0 0; }

/* ---------- ランキング ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar .select { width: auto; min-width: 180px; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(15,23,42,.08); border-top: 4px solid var(--blue); }
.kpi-label { color: var(--gray-500); font-weight: 700; font-size: 16px; }
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1.3; margin: 4px 0; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--gray-500); font-size: 16px; }
.up { color: var(--green); }
.down { color: var(--red); }
.ratio-cell { font-weight: 800; }
.rank-cell { font-weight: 800; text-align: center; }
.rank-1 { color: #b45309; }
tr.unranked td { color: var(--gray-500); background: var(--gray-50); }

/* ---------- 管理 ---------- */
.admin-store-list { list-style: none; margin: 0; padding: 0; }
.admin-store { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--gray-200); }
.admin-store .order-btns { display: flex; gap: 4px; }
.admin-store .name-input { flex: 1; min-width: 140px; }
.admin-store.is-hidden .name-input { background: var(--gray-100); color: var(--gray-500); }
.admin-store .meta { color: var(--gray-500); font-size: 16px; min-width: 80px; }
.icon-btn { min-width: 44px; min-height: 44px; border: 1px solid var(--gray-300); background: #fff; border-radius: 8px; cursor: pointer; font-size: 16px; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.add-row { display: flex; gap: 8px; margin-top: 14px; }
.add-row .input { flex: 1; }
.danger-zone { border: 1px solid #fca5a5; }

/* ---------- モーダル・トースト ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal-box { background: #fff; border-radius: 14px; width: 100%; max-width: 440px; padding: 22px; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.modal-title { margin: 0 0 12px; font-size: 19px; color: var(--blue-dark); }
.modal-body { margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
.confirm-table { width: 100%; border-collapse: collapse; }
.confirm-table th { text-align: left; color: var(--gray-500); font-weight: 700; padding: 8px 8px 8px 0; width: 7em; vertical-align: top; }
.confirm-table td { padding: 8px 0; font-weight: 700; font-size: 18px; }
.confirm-table .big { font-size: 22px; color: var(--blue-dark); }
.warn { background: var(--orange-bg); border: 1px solid #fed7aa; color: #9a3412; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--gray-900); color: #fff; padding: 14px 24px; border-radius: 10px; font-weight: 700; z-index: 200; box-shadow: 0 8px 20px rgba(0,0,0,.25); max-width: calc(100% - 32px); text-align: center; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.loading { color: var(--gray-500); padding: 20px; text-align: center; }
.chart-box { position: relative; height: 340px; }
.legend-note { display: flex; flex-wrap: wrap; gap: 16px; color: var(--gray-500); font-size: 16px; margin-top: 8px; }

/* ---------- スマホ ---------- */
@media (max-width: 720px) {
  .container { padding: 12px; }
  .card { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 26px; }
  .app-title { font-size: 17px; }
  .tab { max-width: none; font-size: 17px; }
  .chart-box { height: 280px; }
  .toolbar .select { flex: 1; }
  .admin-store .name-input { flex-basis: 100%; order: -1; }
}
