@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --indigo:   #6366f1;
  --indigo-d: #4f46e5;
  --s-color:  #6366f1;
  --k-color:  #f59e0b;
  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --text:     #0f172a;
  --muted:    #64748b;
  --border:   #e2e8f0;
  --radius:   16px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}

/* ===== ヘッダー ===== */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: #0f172a;
  padding: 14px 20px;
  padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid rgba(255,255,255,.06);
  backdrop-filter: blur(12px);
}

.header-inner { max-width: 640px; margin: 0 auto; }

.header-left {
  display: flex; align-items: center; gap: 12px;
}

.header-icon-wrap {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--indigo), #818cf8);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}

.header-title {
  font-size: 1.05rem; font-weight: 700; color: #f8fafc;
  letter-spacing: -.02em;
}

.header-sub {
  font-size: 0.7rem; color: #64748b; margin-top: 1px;
}

/* ===== ヒーロー（サマリー） ===== */
.hero {
  background: linear-gradient(160deg, #0f172a 0%, #1e1b4b 60%, #1e293b 100%);
  padding: 24px 20px 28px;
  padding-bottom: 28px;
}

.hero-cards {
  max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; gap: 0;
  margin-bottom: 20px;
}

.hero-card {
  flex: 1; text-align: center; padding: 18px 12px;
  border-radius: var(--radius);
}

.hero-s { background: rgba(99,102,241,.18); border: 1px solid rgba(99,102,241,.3); }
.hero-k { background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.3); }

.hero-card-label {
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: #94a3b8; margin-bottom: 6px;
}

.hero-s .hero-card-label { color: #a5b4fc; }
.hero-k .hero-card-label { color: #fcd34d; }

.hero-card-amount {
  font-size: 1.5rem; font-weight: 800;
  letter-spacing: -.04em; color: #f8fafc;
}

.hero-divider {
  width: 44px; text-align: center; flex-shrink: 0;
}

.hero-vs {
  font-size: 0.65rem; font-weight: 800;
  color: #475569; letter-spacing: .1em;
}

.hero-settlement {
  max-width: 640px; margin: 0 auto;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
}

.hero-settlement-label {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: #64748b; white-space: nowrap;
}

.hero-settlement-amount {
  font-size: 1.6rem; font-weight: 800;
  color: #f8fafc; letter-spacing: -.04em;
  margin-top: 2px;
}

.hero-settlement-msg {
  font-size: 0.78rem; color: #94a3b8; margin-top: 3px;
}

/* ===== メインコンテンツ ===== */
.main {
  max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

/* ===== カード ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
}

.card-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.card-icon { font-size: 1rem; }

.card-title {
  font-size: 0.88rem; font-weight: 700;
  color: var(--text); flex: 1;
  letter-spacing: -.01em;
}

.card-badge {
  font-size: 0.72rem; font-weight: 700;
  background: #f1f5f9; color: var(--muted);
  padding: 2px 8px; border-radius: 999px;
}

/* ===== フォーム ===== */
.pay-form {
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
}

.payer-row {
  display: flex; gap: 8px;
}

.payer-option input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}

.payer-chip {
  display: block;
  padding: 10px 0; width: 100%;
  text-align: center; border-radius: 10px;
  border: 1.5px solid var(--border);
  font-size: 0.9rem; font-weight: 600;
  color: var(--muted); cursor: pointer;
  transition: all .15s;
  user-select: none;
}

.payer-option { flex: 1; }

.payer-option input[type="radio"]:checked + .payer-chip {
  border-color: var(--indigo);
  background: #eef2ff;
  color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.fields-row { display: flex; gap: 10px; }

.field { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 0.72rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
}

.field-input-wrap { position: relative; display: flex; align-items: center; }

.field-prefix {
  position: absolute; left: 12px;
  color: #94a3b8; font-weight: 600; font-size: 0.9rem; pointer-events: none;
}

.field-input {
  width: 100%; padding: 11px 12px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 0.95rem; font-family: inherit; color: var(--text);
  background: #f8fafc;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
}

.field-input-wrap .field-input { padding-left: 26px; }

.field-input:focus {
  outline: none; border-color: var(--indigo);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.btn-submit {
  width: 100%; padding: 13px;
  background: var(--indigo);
  background: linear-gradient(135deg, var(--indigo), #818cf8);
  color: #fff; border: none; border-radius: 12px;
  font-size: 0.97rem; font-weight: 700; font-family: inherit;
  cursor: pointer; letter-spacing: -.01em;
  box-shadow: 0 2px 12px rgba(99,102,241,.35);
  transition: transform .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
}

.btn-submit:active { transform: scale(.98); box-shadow: none; }

/* ===== 支払いリスト ===== */
.pay-list { list-style: none; }

.pay-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid #f8fafc;
  transition: background .1s;
}

.pay-item:last-child { border-bottom: none; }
.pay-item:active { background: #f8fafc; }

.pay-badge {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800;
  flex-shrink: 0;
}

.pay-badge-s { background: #ede9fe; color: #5b21b6; }
.pay-badge-k { background: #fef3c7; color: #92400e; }

.pay-info { flex: 1; min-width: 0; }

.pay-memo {
  font-size: 0.9rem; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pay-date { font-size: 0.72rem; color: #94a3b8; margin-top: 2px; }

.pay-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
  flex-shrink: 0;
}

.pay-amount {
  font-size: 0.97rem; font-weight: 700; color: var(--text);
  letter-spacing: -.02em;
}

.btn-del {
  font-size: 0.7rem; font-weight: 600; font-family: inherit;
  padding: 3px 10px; border-radius: 6px;
  border: 1px solid #fee2e2; background: #fff5f5; color: #ef4444;
  cursor: pointer; white-space: nowrap;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-del:active { background: #fee2e2; }

/* ===== ページネーション ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.pg-btn {
  padding: 8px 20px; border-radius: 8px;
  background: var(--indigo); color: #fff;
  text-decoration: none; font-size: 0.85rem; font-weight: 600;
  transition: background .15s;
}

.pg-btn:active { background: var(--indigo-d); }

.pg-disabled {
  background: #e2e8f0; color: #94a3b8; pointer-events: none;
}

.pg-info { font-size: 0.82rem; color: var(--muted); font-weight: 500; }

/* ===== 空状態 ===== */
.empty-state {
  padding: 40px 20px; text-align: center;
  color: #94a3b8; font-size: 0.88rem;
}
.empty-icon { font-size: 2.2rem; margin-bottom: 10px; }

/* ===== レスポンシブ (タブレット〜PC) ===== */
@media (min-width: 600px) {
  .hero { padding: 32px 24px 36px; }
  .hero-card-amount { font-size: 1.9rem; }
  .hero-settlement-amount { font-size: 2rem; }
  .main { padding: 24px 24px 40px; }
  .fields-row { gap: 14px; }
}


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

body {
  font-family: 'Inter', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== ヘッダー ===== */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #312e81 100%);
  color: #fff;
  padding: 20px 24px 24px;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-icon { font-size: 2rem; line-height: 1; }

.app-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.02em;
}

.subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* ===== コンテナ ===== */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== セクション共通 ===== */
.section {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: linear-gradient(180deg, #6366f1, #818cf8);
  border-radius: 2px;
}

/* ===== サマリー ===== */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  border-radius: 12px;
  padding: 16px 20px;
  overflow: hidden;
  position: relative;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -24px; right: -24px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
}

.stat-s { background: linear-gradient(135deg, #6366f1, #818cf8); color: #fff; }
.stat-k { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #fff; }

.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: .85;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -.03em;
}

.settlement-card {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border: 1.5px solid #bbf7d0;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.settlement-icon { font-size: 2rem; flex-shrink: 0; }

.settlement-body { display: flex; flex-direction: column; }

.settlement-amount {
  font-size: 1.55rem;
  font-weight: 700;
  color: #166534;
  letter-spacing: -.03em;
}

.settlement-message {
  font-size: 0.85rem;
  color: #166534;
  font-weight: 500;
  margin-top: 2px;
}

/* ===== フォーム ===== */
.pay-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 8px; }

.form-group > label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.payer-toggle { display: flex; gap: 8px; }

.toggle-label input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}

.toggle-btn {
  display: inline-block;
  padding: 9px 28px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}

.toggle-label input[type="radio"]:checked + .toggle-btn {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
  box-shadow: 0 2px 10px rgba(99,102,241,.35);
}

.input-wrap { position: relative; display: flex; align-items: center; }

.input-prefix {
  position: absolute; left: 13px;
  color: #94a3b8; font-weight: 600; font-size: 0.95rem; pointer-events: none;
}

.form-group input[type="number"],
.form-group input[type="text"] {
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  color: #1e293b;
  background: #f8fafc;
  transition: border-color .15s, box-shadow .15s, background .15s;
  width: 100%;
  font-family: inherit;
}

.input-wrap input[type="number"] { padding-left: 30px; }

.form-group input:focus {
  outline: none;
  border-color: #6366f1;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.btn-add {
  align-self: flex-start;
  padding: 11px 32px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 2px 10px rgba(99,102,241,.35);
  font-family: inherit;
}

.btn-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(99,102,241,.45);
}

.btn-add:active { transform: translateY(0); }

/* ===== テーブル ===== */
.table-wrapper { overflow-x: auto; margin: 0 -4px; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

thead th {
  padding: 10px 14px;
  background: #f8fafc;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .07em;
  text-align: left;
  border-bottom: 1.5px solid #f1f5f9;
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid #f8fafc;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; transition: background .1s; }

.date-cell { color: #94a3b8; font-size: 0.82rem; white-space: nowrap; }
.amount-cell { font-weight: 700; color: #0f172a; white-space: nowrap; }
.memo-cell {
  color: #64748b;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.badge-s { background: #ede9fe; color: #5b21b6; }
.badge-k { background: #fef3c7; color: #92400e; }

/* 削除ボタン */
.btn-delete {
  width: 28px; height: 28px;
  border: none; border-radius: 8px;
  background: #fee2e2; color: #ef4444;
  font-size: 0.75rem; font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .12s;
  display: inline-flex; align-items: center; justify-content: center;
}

.btn-delete:hover { background: #ef4444; color: #fff; transform: scale(1.1); }

/* ===== ページネーション ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-top: 20px; padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}

.page-btn {
  padding: 7px 18px;
  background: #6366f1; color: #fff;
  border-radius: 8px; text-decoration: none;
  font-size: 0.85rem; font-weight: 600;
  transition: background .15s, transform .12s;
}

.page-btn:hover { background: #4f46e5; transform: translateY(-1px); }

.page-btn.disabled {
  background: #e2e8f0; color: #94a3b8;
  cursor: default; pointer-events: none;
}

.page-info { font-size: 0.82rem; color: #94a3b8; font-weight: 500; }

.page-info-simple {
  margin-top: 12px; font-size: 0.82rem; color: #cbd5e1; text-align: right;
}

/* ===== 空状態 ===== */
.empty-state { text-align: center; padding: 40px 20px; color: #94a3b8; }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ===== レスポンシブ ===== */
@media (max-width: 560px) {
  .form-row-2 { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.2rem; }
  .settlement-amount { font-size: 1.3rem; }
  .app-header h1 { font-size: 1.2rem; }
  .memo-cell, thead th:nth-child(4) { display: none; }
}
