:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e2e8f0;
  --brand: #1f6feb;
  --brand-dark: #1657c0;
  --danger: #d64545;
  --ok: #2f9e44;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.hidden { display: none !important; }

#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand { font-weight: 700; color: var(--brand-dark); }

#nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }

#nav button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}
#nav button:hover { background: var(--bg); color: var(--ink); }
#nav button.active { background: var(--brand); color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
#current-user { font-size: 13px; color: var(--muted); }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b83232; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.field { margin-bottom: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; background: #fafbfc; }
td input, td select { padding: 6px 8px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.row-actions { display: flex; gap: 6px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { text-align: center; font-size: 20px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 100;
  font-size: 14px;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

.muted { color: var(--muted); font-size: 13px; }
.right { text-align: right; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--bg); color: var(--muted); }
.total-line { font-size: 16px; font-weight: 700; }
.section-sub { font-size: 13px; color: var(--muted); margin: -6px 0 10px; }

@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  #topbar { gap: 8px; }
  main { padding: 16px 10px 50px; }
  table { font-size: 13px; }
  th, td { padding: 6px 6px; }
}



.num-input { width: 90px; text-align: right; }
.expense-input-table td { padding: 6px 8px; }
.expense-input-table td:first-child { font-weight: 500; white-space: nowrap; }

.tab-bar { display: flex; gap: 4px; margin-bottom: 16px; }
.tab-bar .tab {
  border: 1px solid var(--line);
  background: transparent;
  padding: 8px 20px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}
.tab-bar .tab:hover { background: var(--bg); color: var(--ink); }
.tab-bar .tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.balance-full-table { font-size: 14px; overflow-x: auto; }
.balance-full-table th, .balance-full-table td { padding: 6px 8px; white-space: nowrap; }
.balance-full-table th { position: sticky; top: 0; z-index: 2; }
.balance-full-table .total-line { font-weight: 700; background: #f0f6ff; border-top: 2px solid var(--brand); }
.balance-full-table .expense-row { color: var(--danger); font-size: 13px; }
.balance-full-table .balance-foot { font-weight: 700; font-size: 15px; background: #f0fdf4; border-top: 2px solid var(--ok); }
.balance-full-table .balance-foot td { color: var(--ok); }
.summary-row { display: flex; gap: 16px; flex-wrap: wrap; }
.summary-box {
  flex: 1; min-width: 120px;
  text-align: center; padding: 12px 8px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fafbfc;
}
.summary-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.summary-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-value.income { color: var(--ok); }
.summary-value.expense { color: var(--danger); }
.summary-value.balance-plus { color: var(--brand); }
.summary-value.balance-minus { color: var(--danger); }
.agg-table { max-width: 640px; }
.agg-table td { padding: 6px 10px; }


/* ===== 乗船日チェック（チップ式） ===== */
.day-check-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 4px; }
.day-check {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--panel); cursor: pointer; font-weight: 600; font-size: 15px;
  user-select: none; transition: border-color .15s, background .15s, color .15s;
}
.day-check:hover { border-color: var(--brand); }
.day-check input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); margin: 0; }
.day-check.is-checked { border-color: var(--brand); background: #eaf2ff; color: var(--brand-dark); }

/* ===== 「往路と同じ」コピートグル ===== */
.copy-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border: 2px solid var(--brand); border-radius: 8px;
  background: #eaf2ff; cursor: pointer; font-weight: 600; color: var(--brand-dark);
  user-select: none; margin-bottom: 12px;
}
.copy-toggle:hover { background: #dcebff; }
.copy-toggle input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); margin: 0; }

/* ===== 申込一覧のメモ行 ===== */
.memo-row td { background: #fff8e1; color: #5c4400; font-size: 13px; border-top: none; }
.memo-badge {
  display: inline-block; background: #f59f00; color: #fff; font-size: 11px;
  font-weight: 700; padding: 1px 8px; border-radius: 10px; margin-right: 6px;
}
