/* ===== 通知バー ===== */
.notice-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: #451a03;
  border-bottom: 1px solid #92400e;
  padding: 0.55rem 1rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #fef3c7;
}
.notice-bar .notice-icon { flex-shrink: 0; font-size: 0.9rem; margin-top: 0.1rem; }
.notice-bar strong { color: #fde68a; }

/* ===== 免責モーダル ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.82);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }

.modal-box {
  background: #0f1929;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.8rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0;
  color: #f1f5f9;
  letter-spacing: 0.04em;
}
.modal-body { display: flex; flex-direction: column; gap: 1rem; }

.modal-section {
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 10px;
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.75;
  color: rgba(255,255,255,.82);
}
.modal-section p { margin: 0.4rem 0 0; }
.modal-section p:first-child { margin-top: 0.3rem; }

.modal-warn { border-color: rgba(251,191,36,.35); background: rgba(120,53,15,.25); }
.modal-must { border-color: rgba(99,102,241,.45); background: rgba(30,27,75,.35); }

.modal-sec-head {
  font-weight: 800;
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
  color: #e2e8f0;
}
.modal-list {
  margin: 0.4rem 0 0.4rem 1.2rem;
  padding: 0;
  font-size: 0.82rem;
  color: rgba(255,255,255,.75);
}
.modal-list li { margin-bottom: 0.2rem; }

.modal-btn {
  width: 100%;
  padding: 0.85rem;
  background: #2563eb;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.02em;
}
.modal-btn:hover { background: #1d4ed8; }

/* ===== リセット・ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #059669;
  --accent-hover: #047857;
  --danger: #dc2626;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 2px 12px rgba(0,0,0,0.05);
}

html { font-size: 16px; }
body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== 画面切り替え ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== ヘッダー ===== */
.app-header {
  background: var(--primary);
  color: #fff;
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}
.app-title { font-size: 2rem; font-weight: 800; letter-spacing: 0.05em; }
.app-subtitle { font-size: 0.9rem; opacity: 0.85; margin-top: 0.3rem; }

.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.page-header h2 { font-size: 1.1rem; font-weight: 700; }

/* ===== ホームメニュー ===== */
.home-menu {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1.5rem 1rem;
  max-width: 480px;
  margin: 0 auto;
}
.menu-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.2rem;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s;
}
.menu-card:hover { transform: translateY(-2px); box-shadow: 0 4px 18px rgba(0,0,0,0.1); }
.menu-card:active { transform: translateY(0); }
.menu-icon { font-size: 2rem; }
.menu-label { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.menu-desc { font-size: 0.82rem; color: var(--text-muted); }

/* ===== 2カラムレイアウト ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
}

.form-section {
  padding: 1.4rem 1.2rem;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.preview-section {
  padding: 1.4rem 1.2rem;
  background: #f1f5f9;
  overflow-y: auto;
}

/* ===== フォーム ===== */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.optional { font-weight: 400; text-transform: none; color: #94a3b8; }

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.section-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 1.2rem 0 0.6rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* ===== 品目行 ===== */
.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  align-items: center;
}
.item-row input {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  width: 100%;
}
.item-row input:focus {
  outline: none;
  border-color: var(--primary);
}
.btn-remove-item {
  background: none;
  border: 1px solid #fca5a5;
  color: var(--danger);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}
.btn-remove-item:hover { background: #fef2f2; }

.btn-add-item {
  width: 100%;
  padding: 0.5rem;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--primary);
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 1rem;
}
.btn-add-item:hover { background: #eff6ff; }

/* ===== ボタン ===== */
.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.btn-primary, .btn-secondary, .btn-accent, .btn-back, .btn-danger {
  padding: 0.6rem 1.1rem;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-word { background: #185ABD; color: #fff; }
.btn-word:hover { background: #144FA6; }
.btn-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  font-size: 0.88rem;
}
.btn-back:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; font-size: 0.8rem; padding: 0.4rem 0.8rem; }
.btn-danger:hover { background: #b91c1c; }

/* ===== プレビュータイトル ===== */
.preview-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
}

/* ===== 領収書プレビュー ===== */
.receipt-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.8rem;
  box-shadow: var(--shadow);
  max-width: 380px;
  margin: 0 auto;
}
.doc-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  border-bottom: 3px double #334155;
  padding-bottom: 0.8rem;
  margin-bottom: 1.2rem;
}
.receipt-to {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.receipt-amount-row {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin: 1rem 0;
  padding: 0.8rem;
  background: #f8fafc;
  border-radius: 6px;
}
.amount-label { font-size: 0.9rem; color: var(--text-muted); }
.amount-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.02em;
}
.receipt-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.receipt-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-end;
}
.receipt-invoice-no { font-size: 0.78rem; color: var(--text-muted); }

/* ===== 請求書プレビュー ===== */
.invoice-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem 1.6rem;
  box-shadow: var(--shadow);
  max-width: 420px;
  margin: 0 auto;
}
.invoice-client-row {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.invoice-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 0.8rem;
}
.invoice-table th {
  background: #f1f5f9;
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.78rem;
}
.invoice-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #f1f5f9;
}
.invoice-table td:not(:first-child) { text-align: right; }
.invoice-totals {
  border-top: 2px solid var(--border);
  padding-top: 0.6rem;
}
.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.2rem 0;
  color: var(--text-muted);
}
.total-final {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  margin-top: 0.3rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}

/* ===== 履歴一覧 ===== */
.history-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
}
.tab-btn {
  flex: 1;
  padding: 0.8rem;
  border: none;
  background: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.history-panel { display: none; }
.history-panel.active { display: block; }

.history-list { padding: 1rem; max-width: 700px; margin: 0 auto; }

.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 0.8rem;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.history-card-info { flex: 1; }
.history-card-title { font-weight: 700; font-size: 0.95rem; }
.history-card-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.2rem; }
.history-card-amount { font-size: 1.1rem; font-weight: 800; color: var(--primary); white-space: nowrap; }
.history-card-actions { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== トースト ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: #fff;
  padding: 0.7rem 1.4rem;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 999;
  transition: transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
  .two-col {
    grid-template-columns: 1fr;
  }
  .form-section {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .preview-section {
    background: var(--surface);
  }
  .item-row {
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 0.3rem;
  }
  .app-title { font-size: 1.6rem; }
  .amount-value { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  .item-row { grid-template-columns: 1fr 0.6fr 0.8fr auto; }
  .btn-row { flex-direction: column; }
  .btn-row button { width: 100%; }
  .history-card { flex-direction: column; align-items: flex-start; }
  .history-card-actions { width: 100%; justify-content: flex-end; }
}
