/* RMS の見た目（画面デザインのとおり）：白い面と細い線、色は深い緑と注意の橙だけ。文字は Noto Sans JP、数字は Inter */
:root {
  --ink: #16201E; --ink2: #33403D; --muted: #5B6663;
  --bg: #F5F6F4; --panel: #FFFFFF; --line: #E2E5E3; --line2: #EEF0EE; --field: #CFD5D2;
  --green: #0B6E69; --green-dark: #08524E; --green-bg: #E6F1F0;
  --orange: #A8480A; --orange-bg: #FBEDE3; --grey-bg: #ECEFEC;
  --red: #B42318; --red-bg: #FDECEA;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Inter, 'Noto Sans JP', sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.6; }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }
h1 { margin: 4px 0 0; font-size: 26px; font-weight: 700; line-height: 1.3; }
h2 { margin: 0; font-size: 15px; font-weight: 700; }
p { margin: 0; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 8px 12px 0; border-bottom: 1px solid var(--line2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.r { text-align: right; }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--orange); }
.ok { color: var(--green); }
.right { align-self: flex-end; }
.center { align-self: center; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- ボタンと入力（高さ44px以上） ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; background: none; color: var(--ink); white-space: nowrap; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); color: #fff; }
.btn.outline { border-color: var(--field); background: #fff; font-weight: 500; }
.btn.outline:hover { background: var(--grey-bg); }
.btn.ghost { color: var(--green); font-weight: 500; }
.btn.ghost:hover { background: var(--green-bg); }
.btn.big { min-height: 50px; font-size: 15px; width: 100%; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .soon, .soon { font-size: 11px; font-weight: 500; color: var(--muted); background: var(--grey-bg); border-radius: 8px; padding: 0 6px; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.field input, .select select { min-height: 48px; border: 1px solid var(--field); border-radius: 10px; padding: 0 14px; font: inherit; font-size: 16px; color: var(--ink); background: #fff; }
.field.narrow { max-width: 360px; margin-bottom: 12px; }
.select { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.select select { min-height: 44px; font-size: 14px; padding: 0 10px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 10px; padding: 1px 8px; white-space: nowrap; vertical-align: middle; }
.badge.ok { background: var(--green-bg); color: var(--green-dark); }
.badge.warn { background: var(--orange-bg); color: var(--orange); }
.badge.none { background: var(--grey-bg); color: var(--ink2); }
h1 .badge { font-size: 13px; margin-left: 6px; }

/* ---- 枠：PC は左のメニュー、スマホは下のタブ ---- */
.app { display: flex; min-height: 100vh; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 10; background: #fff; padding: 8px; }
.side { flex: 0 0 232px; padding: 24px 16px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 8px; color: var(--ink2); font-size: 14px; }
.side a:hover { background: var(--grey-bg); color: var(--ink); }
.side a[aria-current="page"] { background: var(--green-bg); color: var(--green-dark); font-weight: 600; }
.side .count { margin-left: auto; font-size: 12px; background: var(--orange-bg); color: var(--orange); border-radius: 10px; padding: 1px 8px; }
.side .sep { height: 1px; background: var(--line); margin: 10px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 20px; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.logo.big { width: 40px; height: 40px; border-radius: 10px; font-size: 16px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.who { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 32px 1fr; gap: 4px 10px; align-items: center; }
.who .who-text { min-width: 0; overflow-wrap: anywhere; line-height: 1.4; }
.who .btn { grid-column: 1 / -1; justify-self: start; padding: 0; }
.avatar { width: 32px; height: 32px; border-radius: 16px; background: #DCE3E1; display: flex; align-items: center; justify-content: center; font-weight: 600; }
main { flex: 1 1 auto; min-width: 0; padding: 28px 40px 48px; outline: none; }
.wrap { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.tabs { display: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head .sub { font-size: 13px; color: var(--muted); }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 10px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: -12px; }
.lead { color: var(--ink2); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel.flush { padding: 0; gap: 0; }
.panel.flush table th:first-child, .panel.flush table td:first-child { padding-left: 20px; }
.panel.flush table th:last-child, .panel.flush table td:last-child { padding-right: 20px; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 10px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.empty { background: #fff; border: 1px dashed var(--field); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; color: var(--ink2); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.loading span { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { border-radius: 10px; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.notice.warn { background: var(--orange-bg); color: #7A3407; }
.notice.ok { background: var(--green-bg); color: var(--green-dark); }
.notice.error { background: var(--red-bg); color: var(--red); }
.notice ul { margin: 0; padding-left: 20px; }

/* ホーム */
.todo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.todo { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.todo:hover { border-color: var(--field); color: var(--ink); }
.todo .label { font-size: 13px; color: var(--muted); }
.todo .num { font-size: 30px; font-weight: 700; line-height: 1.2; }
.todo .num.warn { color: var(--orange); }
.todo .num small { font-size: 14px; font-weight: 500; margin-left: 4px; }
.todo .cta { font-size: 12px; color: var(--green); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.kpis .k { font-size: 12px; color: var(--muted); }
.kpis .v { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpis .v small { font-size: 12px; font-weight: 400; }
.bar { height: 10px; border-radius: 5px; background: #E8ECEA; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--green); border-radius: 5px; }
.row-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line2); color: var(--ink); align-items: center; }
.row-item:last-child { border-bottom: 0; }
a.row-item:hover { color: var(--ink); background: #FAFBFA; }

/* 請求 */
.month-nav { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.month-nav .btn { min-height: 32px; padding: 0 10px; font-size: 18px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--field); background: #fff; font: inherit; font-size: 13px; color: var(--ink2); cursor: pointer; }
.chip b { font-weight: 600; margin-left: 4px; }
.chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(22,32,30,.12); z-index: 5; min-width: 220px; padding: 6px; }
.menu button { display: block; width: 100%; text-align: left; min-height: 44px; padding: 0 12px; border: 0; background: none; font: inherit; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--grey-bg); }

table.bills th:last-child, table.bills td:last-child { padding-left: 16px; }

/* 入金と消込 */
.review { display: grid; grid-template-columns: 220px 1fr; gap: 8px 24px; }
.review-head { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.review .amount { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.review .candidate { display: flex; flex-direction: column; gap: 2px; }
.review .reason { margin-top: 6px; color: var(--orange); font-size: 13px; }
.review .actions, .review .pick { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.review .pick select { max-width: 100%; }

/* 契約の詳細 */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-variant-numeric: tabular-nums; }
.more a { display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 0 20px; border-bottom: 1px solid var(--line2); color: var(--ink); font-size: 15px; }
.more a:last-child { border-bottom: 0; }

/* ログイン */
.login { min-height: 100vh; display: flex; justify-content: center; background: #fff; }
.login-card { width: 100%; max-width: 420px; padding: 72px 28px 32px; display: flex; flex-direction: column; gap: 0; min-height: 100vh; }
.login .brand { padding: 0; }
.login .brand-name { font-size: 17px; }
.login h1 { margin: 36px 0 6px; font-size: 24px; }
.login .lead { margin-bottom: 28px; color: var(--muted); }
.login .msg { margin-top: 20px; border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.login .msg.error { background: var(--red-bg); color: var(--red); }
.login .msg.ok { background: var(--green-bg); color: var(--green-dark); }
.login .stack { gap: 16px; }
.login .stack.tight { gap: 10px; }
.or { display: flex; align-items: center; gap: 12px; margin: 24px 0; font-size: 12px; color: var(--muted); }
.or span { flex: 1; height: 1px; background: var(--line); }
.hint { font-size: 12px; color: var(--muted); }
.foot { margin-top: auto; padding-top: 32px; font-size: 12px; color: var(--muted); text-align: center; }
.steps { margin: 0 0 20px; padding-left: 20px; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 15px; background: var(--grey-bg); border-radius: 8px; padding: 8px 12px; letter-spacing: .04em; overflow-wrap: anywhere; user-select: all; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 20; max-width: calc(100% - 32px); font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.error { background: var(--red); }

/* ---- スマホ ---- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .side { display: none; }
  main { padding: 20px 16px calc(88px + env(safe-area-inset-bottom)); }
  .wrap { gap: 18px; }
  h1 { font-size: 22px; }
  .todo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .todo { padding: 14px; }
  .todo .num { font-size: 26px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis > div:first-child { grid-column: 1 / -1; }
  .kpis .v { font-size: 20px; }
  .two { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .review { grid-template-columns: 1fr; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn, .page-head .actions .menu-wrap { flex: 1 1 auto; }
  .page-head .actions .menu-wrap .btn { width: 100%; }
  .filters { flex-direction: column; align-items: stretch; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .chip { flex: 0 0 auto; }
  .tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
  .tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; color: var(--muted); font-size: 11px; position: relative; }
  .tabs a[aria-current="page"] { color: var(--green); font-weight: 600; }
  .tabs i { position: absolute; top: 6px; left: calc(50% + 6px); font-style: normal; font-size: 10px; line-height: 16px; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--orange); color: #fff; text-align: center; }
  .login-card { padding-top: 56px; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
