/*
 * common.css — 全画面共通のスタイル
 *
 * GAS 版 各 html の見た目（配色・角丸・影・フォント）をそのまま引き継いでいる。
 *   背景 #f0f2f5 ／ 文字 #1a1a2e ／ 見出し帯 #1a1a2e→#16213e のグラデーション
 *   アクセント #e94560 ／ カードは白・角丸 10px・薄い影
 *
 * 画面固有のスタイルは各 html の <style> に置き、ここには共通部分だけを書く。
 */

/* ===== 基本 ===== */

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

:root {
  --bg: #f0f2f5;
  --fg: #1a1a2e;
  --navy: #16213e;
  --navy-dark: #1a1a2e;
  --accent: #e94560;
  --accent-dark: #c23152;
  --ok: #28a745;
  --ng: #dc3545;
  --info: #007bff;
  --muted: #666;
  --line: #eee;
  --card: #fff;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--fg);
  padding: 12px;
  /* iPhone のホーム画面 PWA で下端のバーに隠れないようにする */
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  font-size: 14px;
  line-height: 1.5;
}

[hidden] { display: none !important; }

/* ===== ヘッダー ===== */

.app-header {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: #fff;
  padding: 13px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  position: relative;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.app-header .sub {
  margin-top: 5px;
  font-size: 0.78rem;
  opacity: 0.75;
  text-align: center;
}

/* ヘッダー左の「戻る」 */
.app-header .home-link {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
}
.app-header .home-link:active { background: rgba(255, 255, 255, 0.28); }

/* ===== バッジ ===== */

.ui-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}
.ui-badge.online { background: #d4edda; color: #155724; }
.ui-badge.offline { background: #e2e3e5; color: #41464b; }

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #eef2ff;
  color: var(--navy);
}
.chip.warn { background: #fff3cd; color: #664d03; }
.chip.err { background: #f8d7da; color: #721c24; }
.chip.ok { background: #d4edda; color: #155724; }

/* ===== ボタン ===== */

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: 10px;
  margin-top: 12px;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 50px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { background: #aaa; cursor: default; transform: none; }

.btn-flat { background: var(--accent); }
.btn-green { background: linear-gradient(135deg, var(--ok), #218838); }
.btn-navy { background: linear-gradient(135deg, var(--navy-dark), var(--navy)); }
.btn-gray { background: #6c757d; }
.btn-outline {
  background: #fff;
  color: var(--navy);
  border: 2px solid #d9dde5;
}
.btn-outline:active { background: #f1f5f9; }
.btn-sm {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  font-size: 0.85rem;
  min-height: 40px;
  margin-top: 0;
}

.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row .btn { margin-top: 0; }

/* ===== カード・セクション ===== */

.card {
  background: var(--card);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.card h2,
.section-title {
  font-size: 1rem;
  margin: 0 0 10px;
  padding: 8px 12px;
  background: var(--navy);
  color: #fff;
  border-radius: 8px;
}

.section { margin-bottom: 18px; }

.note {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
}

.note.strong { color: var(--fg); }

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 0.85rem; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv .k { color: var(--muted); flex-shrink: 0; }
.kv .v { text-align: right; font-weight: 600; word-break: break-all; }

/* ===== メッセージ ===== */

.msg {
  text-align: center;
  padding: 10px;
  font-size: 0.88rem;
  border-radius: 8px;
  margin-top: 10px;
  display: none;
  line-height: 1.6;
}
.msg.ok { display: block; background: #d4edda; color: #155724; }
.msg.err { display: block; background: #f8d7da; color: #721c24; }
.msg.info { display: block; background: #d1ecf1; color: #0c5460; }
.msg.warn { display: block; background: #fff3cd; color: #664d03; }

.banner {
  background: var(--ng);
  color: #fff;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 0.9rem;
}
.banner.accent { background: var(--accent); }
.banner.warn { background: #fff3cd; color: #664d03; }

/* ===== 表 ===== */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.82rem;
}

th, td {
  padding: 7px 5px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
th {
  background: #f8f9fa;
  color: #555;
  font-size: 0.72rem;
  white-space: nowrap;
}
td.name, th.name { text-align: left; }
td.name { font-weight: 600; }

/* 横に広い表は表自身の中でスクロールさせ、ページ全体が横に揺れないようにする */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 14px;
}
.table-scroll table { box-shadow: none; margin-bottom: 0; }

/* ===== メニュー（ホーム） ===== */

.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.menu a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 84px;
  padding: 12px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  text-decoration: none;
  color: var(--fg);
}
.menu a:active { background: #f1f5f9; }
.menu a .title { font-weight: 700; font-size: 0.98rem; }
.menu a .desc { font-size: 0.74rem; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.menu a.wide { grid-column: 1 / -1; min-height: 0; }

/* ===== トースト ===== */

.ui-toast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--ok);
  color: #fff;
  text-align: center;
  padding: 14px;
  font-size: 0.98rem;
  font-weight: 700;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform 0.3s;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.ui-toast.show { transform: translateY(0); }
.ui-toast.err { background: var(--ng); }
.ui-toast.warn { background: #f0ad4e; }

/* ===== モーダル ===== */

.ui-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ui-modal-overlay.active { display: flex; }

.ui-modal {
  background: #fff;
  border-radius: 18px;
  padding: 24px 22px;
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.ui-modal h3 { font-size: 1.05rem; margin-bottom: 16px; }
.ui-modal-body { font-size: 0.92rem; line-height: 1.7; color: #333; }
.ui-modal-actions { display: flex; gap: 10px; margin-top: 22px; }

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 13px 16px;
  cursor: pointer;
  touch-action: manipulation;
  flex: 1;
  min-height: 50px;
}
.ui-btn:active { transform: scale(0.97); }
.ui-btn-cancel { background: #f1f5f9; color: #64748b; border: 2px solid #e2e8f0; }
.ui-btn-ok { background: #2563eb; color: #fff; }
.ui-btn-danger { background: var(--ng); color: #fff; }

/* ===== ローディング ===== */

.ui-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(240, 242, 245, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  z-index: 9998;
}

/* ===== 入力 ===== */

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 700;
}
.field input[type="text"],
.field input[type="number"],
.field select {
  width: 100%;
  padding: 11px;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: var(--fg);
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }

.big-input {
  display: block;
  margin: 0 auto;
  padding: 14px;
  font-size: 1.8rem;
  border: 2px solid #ddd;
  border-radius: 10px;
  text-align: center;
  width: 170px;
  letter-spacing: 0.28em;
  background: #fff;
  color: var(--fg);
}
.big-input:focus { border-color: var(--accent); outline: none; }

/* ===== 印刷 ===== */

@media print {
  body { background: #fff; padding: 0; font-size: 11px; }
  .app-header { background: none; color: #000; border-radius: 0; padding: 0 0 8px; }
  .app-header .home-link, .no-print { display: none !important; }
  .card, .table-scroll { box-shadow: none; }
  table { font-size: 10px; }
  th { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr { page-break-inside: avoid; }
  .section-title, .card h2 {
    background: none !important;
    color: #000 !important;
    border-bottom: 2px solid #000;
    border-radius: 0;
    padding: 0 0 4px;
  }
}

/* ===== 広い画面 ===== */

@media (min-width: 720px) {
  body { max-width: 980px; margin: 0 auto; padding: 18px; }
  .menu { grid-template-columns: repeat(3, 1fr); }
}
