/* 委託料 請求書兼領収書システム — アプリUI（スマホ優先） */
:root {
  --navy: #1f3a5f;
  --navy-dark: #16293f;
  --bg: #f2f4f7;
  --line: #d6dbe3;
  --danger: #b3261e;
  --ok: #1a7f37;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: #1c1c1e;
  font-size: 16px;
  line-height: 1.6;
}

.appbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}
.appbar .brand { color: #fff; text-decoration: none; font-weight: 700; }
.appbar-right { display: flex; gap: 16px; align-items: center; }
.appbar .logout { color: #cfe0f5; font-size: 13px; text-decoration: none; }
.appbar .lang-switch {
  color: #fff; font-size: 12px; text-decoration: none;
  border: 1px solid #4a6b96; border-radius: 999px; padding: 3px 10px;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 16px 14px 96px; }

h1 { font-size: 22px; margin: 8px 0 12px; }
h2, .h2-like { font-size: 17px; margin: 0 0 8px; font-weight: 700; }
h3 { font-size: 15px; margin: 16px 0 6px; }
.muted { color: #667085; font-size: 13px; }
.crumbs { margin: 0; font-size: 14px; }
.crumbs a { color: var(--navy); }
.error { color: var(--danger); font-weight: 700; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
}

/* ---- ボタン・フォーム ---- */
.btn {
  display: inline-block;
  background: #fff;
  border: 1px solid var(--navy);
  color: var(--navy);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:active { background: var(--navy-dark); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; text-align: center; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { border-color: var(--danger); color: var(--danger); }

form.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.stack label { font-size: 14px; font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.row-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

input[type="text"], input[type="password"], input[type="date"],
input[type="month"], select {
  font-size: 16px;               /* iOS のズーム防止 */
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
.row-form input[type="date"] { width: auto; flex: 1; }

/* ---- 月一覧 ---- */
.month-list { list-style: none; margin: 0; padding: 0; }
.month-list li { margin: 10px 0; }
.month-link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}
.month-link .ym { font-size: 18px; font-weight: 700; color: var(--navy); }
.month-link .meta { grid-column: 1; font-size: 12.5px; color: #667085; }
.badge {
  grid-column: 2; grid-row: 1 / span 2;
  font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 4px 12px;
}
.badge.open { background: #fff3cd; color: #7a5b00; }
.badge.final { background: #d9f2e2; color: #14663a; }

/* ---- 月ページ ---- */
.payline { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin: -4px 0 4px; }
.banner {
  border-radius: 10px; padding: 12px 14px; margin: 10px 0; font-size: 14px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.banner.final { background: #d9f2e2; color: #14663a; }

.amount-list { list-style: none; margin: 0; padding: 0; }
.amount-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eceff3;
}
.amount-row:last-child { border-bottom: 0; }
.amount-row label { min-width: 0; }
.amount-row .nm { font-weight: 700; display: block; }
.amount-row .roma { font-size: 11.5px; color: #667085; display: block; overflow-wrap: anywhere; }
.amt-box { display: flex; align-items: center; gap: 6px; position: relative; }
.amt-box .unit { color: #667085; white-space: nowrap; font-size: 12px; }
input.amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  padding: 10px;
}
input.amt:disabled { background: #f2f4f7; color: #98a2b3; }
.state { position: absolute; right: 8px; top: -16px; font-size: 11px; }
.state.ok { color: var(--ok); }
.state.err { color: var(--danger); font-weight: 700; }

/* ---- 作業明細 ---- */
.items {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; gap: 6px;
  padding-left: 12px;
  border-left: 3px solid #eceff3;
}
.items:not(:has(.item)) { border-left-color: transparent; }
.item { display: flex; align-items: center; gap: 6px; position: relative; }
.item .item-name { flex: 1 1 auto; min-width: 0; width: auto; font-size: 14px; padding: 9px 10px; }
.item .item-amt {
  flex: 0 0 auto; width: 110px;
  text-align: right; font-variant-numeric: tabular-nums;
  font-size: 16px; padding: 9px 8px;
}
.item .unit { color: #667085; font-size: 12px; }
.item-del {
  background: #fff; color: var(--danger);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 18px; line-height: 1; padding: 6px 10px; cursor: pointer;
}
.item .state { position: absolute; right: 48px; top: -13px; }
.items-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 20px; }
.items-actions { display: flex; gap: 16px; }
.add-item, .copy-items {
  background: none; border: 0; padding: 4px 0;
  color: var(--navy); font-size: 13px; text-decoration: underline; cursor: pointer;
}
.copy-items { color: #667085; }
.row-total { font-size: 13px; color: #344054; }
.row-total b { font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---- タグ ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13.5px;
  cursor: pointer;
}
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }
.tagchips { display: block; margin-top: 2px; }
.tagchip {
  display: inline-block;
  background: #eef3fa;
  color: #2b5285;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  margin-right: 4px;
  white-space: nowrap;
}
.tag-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tag-checks .check {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 400; flex-direction: row;
}
.tag-checks input[type="checkbox"] { width: 20px; height: 20px; }
.hidden { display: none !important; }
.totalbar .scope { color: #a8c4e8; margin-right: 4px; }

/* ---- 名簿編集 ---- */
details > summary { cursor: pointer; }
.inline-edit { font-size: 13px; }
.inline-edit summary { color: var(--navy); text-decoration: underline; }
.member-list { list-style: none; margin: 0; padding: 0; }
.member-list > li { padding: 10px 0; border-bottom: 1px solid #eceff3; }
.member-line { display: flex; gap: 10px; align-items: center; }
.member-line .nm { font-weight: 700; white-space: nowrap; }
.member-line .addr { flex: 1; font-size: 12px; color: #667085; overflow-wrap: anywhere; }

/* ---- アクション・合計バー ---- */
.actions { display: flex; flex-direction: column; gap: 10px; }
.totalbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--navy-dark); color: #fff;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  font-size: 15px;
}
.totalbar strong { font-size: 19px; font-variant-numeric: tabular-nums; }

/* ---- ログイン ---- */
.login-card { max-width: 420px; margin: 12vh auto 0; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

@media (max-width: 420px) {
  .amount-row { grid-template-columns: minmax(0, 1fr) 150px; }
}
