/* Layout: 店舗タブ → 状況サマリー → 一覧/月別表/履歴/設定。スタッフ詳細は右から出るパネル。 */
:root {
  --bg: #eef2f0;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --ink: #1c2a2c;
  --muted: #5b6b6c;
  --line: #d9e1de;
  --accent: #1f6e5c;
  --accent-ink: #ffffff;
  --accent-soft: #dcede6;
  --seg-empty: #e3e9e6;
  --warn: #9a6512;
  --warn-soft: #f8ecd3;
  --bad: #ac3a37;
  --bad-soft: #f6e0df;
  --good: #2b7349;
  --good-soft: #def0e3;
  --shadow: 0 1px 2px rgba(20, 40, 36, .06), 0 8px 24px rgba(20, 40, 36, .08);
  --f-display: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  --f-body: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111718; --surface: #192123; --surface-2: #1e282a; --ink: #e4ecea; --muted: #97a8a6; --line: #2a3638;
    --accent: #5fbfa3; --accent-ink: #0d1c18; --accent-soft: #1b3630; --seg-empty: #2a3537;
    --warn: #e2ad55; --warn-soft: #382c16; --bad: #ea8580; --bad-soft: #3c2322; --good: #76c995; --good-soft: #1b3424;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111718; --surface: #192123; --surface-2: #1e282a; --ink: #e4ecea; --muted: #97a8a6; --line: #2a3638;
  --accent: #5fbfa3; --accent-ink: #0d1c18; --accent-soft: #1b3630; --seg-empty: #2a3537;
  --warn: #e2ad55; --warn-soft: #382c16; --bad: #ea8580; --bad-soft: #3c2322; --good: #76c995; --good-soft: #1b3424;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.6; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 96px; display: grid; gap: 18px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--f-display); font-variant-numeric: tabular-nums; }

/* header */
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.brand h1 { margin: 0; font-family: var(--f-display); font-size: 26px; font-weight: 700; letter-spacing: .04em; line-height: 1.2; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.btn { white-space: nowrap; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.danger.armed { background: var(--bad); color: var(--surface); border-color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { border-color: var(--line); }
.btn:disabled { opacity: .5; cursor: default; }

/* store tabs */
.stores { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.store-tab { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 16px; font-weight: 500; display: inline-flex; gap: 8px; align-items: baseline; }
.store-tab .cnt { color: var(--muted); font-size: 12px; }
.store-tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.store-tab[aria-selected="true"] .cnt { color: inherit; opacity: .7; }

/* summary */
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.stat .k { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.stat .v { font-family: var(--f-display); font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat.warn .v { color: var(--warn); }
.stat.bad .v { color: var(--bad); }
@media (max-width: 720px) { .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* view tabs */
.views { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.view-tab { flex: none; border: 0; background: none; padding: 8px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
@media (max-width: 520px) { .view-tab { padding: 8px 10px; font-size: 14px; } }
.view-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.group-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-family: var(--f-display); font-weight: 700; }
.group-h span { font-family: var(--f-body); font-weight: 400; font-size: 13px; color: var(--muted); }

/* staff rows */
.row { display: grid; grid-template-columns: minmax(150px, 1.4fr) minmax(200px, 1.6fr) minmax(120px, 1fr) minmax(130px, 1fr) 70px 92px; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.head { padding-block: 8px; font-size: 12px; color: var(--muted); letter-spacing: .04em; background: var(--surface); }
.row.body { cursor: pointer; }
.row.body:hover { background: var(--surface-2); }
.who { min-width: 0; display: grid; gap: 2px; }
.who .name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.who .sub { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 1px 8px; font-size: 11.5px; font-weight: 700; line-height: 1.6; white-space: nowrap; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip.acc { background: var(--accent-soft); color: var(--accent); }
.bal { display: grid; gap: 4px; min-width: 0; }
.bal-top { display: flex; align-items: baseline; gap: 4px; }
.bal-top .big { font-family: var(--f-display); font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.bal-top .unit { font-size: 12px; color: var(--muted); }
.bal-top .cap { margin-left: auto; font-size: 11px; color: var(--muted); }
.bal.neg .big { color: var(--bad); }
.meter { display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; max-width: 260px; }
.meter i { height: 8px; border-radius: 2px; background: var(--seg-empty); }
.meter i.f { background: var(--accent); }
.meter i.h { background: linear-gradient(90deg, var(--accent) 50%, var(--seg-empty) 50%); }
.meter i:nth-child(5n) { margin-right: 2px; }
.cell { font-size: 13px; min-width: 0; }
.cell .l1 { font-weight: 700; font-size: 14px; }
.cell .l2 { color: var(--muted); font-size: 12px; }
.five { display: grid; gap: 4px; }
.five-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; max-width: 110px; }
.five-bar i { height: 6px; border-radius: 2px; background: var(--seg-empty); }
.five-bar i.f { background: var(--good); }
.five-bar.warn i.f { background: var(--warn); }
.five-bar.bad i.f { background: var(--bad); }
.five-bar i.h { background: linear-gradient(90deg, var(--good) 50%, var(--seg-empty) 50%); }
.empty-note { padding: 28px 16px; text-align: center; color: var(--muted); }
.unset { color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  .row.head { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who act" "bal bal" "nx five"; row-gap: 10px; }
  .row > .who { grid-area: who; }
  .row > .bal { grid-area: bal; }
  .row > .c-next { grid-area: nx; }
  .row > .c-five { grid-area: five; }
  .row > .c-fy { display: none; }
  .row > .c-act { grid-area: act; }
  .meter { max-width: none; }
}

/* month table */
.tbl-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 13.5px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.grid thead th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--surface-2); position: sticky; top: 0; }
table.grid th.nm, table.grid td.nm { text-align: left; padding-left: 16px; position: sticky; left: 0; background: var(--surface); font-weight: 700; min-width: 120px; }
table.grid thead th.nm { background: var(--surface-2); }
table.grid td.has { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
table.grid td.tot { font-weight: 700; border-left: 1px solid var(--line); }
table.grid td.fut { color: var(--muted); }
table.grid tr.gh td { background: var(--surface-2); text-align: left; padding-left: 16px; font-family: var(--f-display); font-weight: 700; }
.fy-nav { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.fy-nav .t { font-family: var(--f-display); font-weight: 700; font-size: 17px; }
.fy-nav .note { color: var(--muted); font-size: 12px; margin-left: auto; }

/* log */
.log-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 70px auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.log-row:last-child { border-bottom: 0; }
.log-row .d { font-variant-numeric: tabular-nums; font-weight: 500; }
.log-row .n { min-width: 0; }
.log-row .n b { font-weight: 700; }
.log-row .n span { color: var(--muted); font-size: 12px; margin-left: 6px; }
.log-row .amt { font-family: var(--f-display); font-weight: 700; text-align: right; }
@media (max-width: 560px) { .log-row { grid-template-columns: 82px minmax(0, 1fr) 52px; } .log-row .x { grid-column: 1 / -1; justify-self: end; } }

/* settings */
.set-body { padding: 16px; display: grid; gap: 22px; }
.set-sec h3 { margin: 0 0 8px; font-family: var(--f-display); font-size: 16px; }
.set-sec p { margin: 0 0 10px; color: var(--muted); font-size: 13px; max-width: 65ch; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.law { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.law th, .law td { border: 1px solid var(--line); padding: 5px 9px; text-align: center; }
.law th { background: var(--surface-2); font-weight: 500; color: var(--muted); }

/* form controls */
.field { display: grid; gap: 4px; min-width: 0; align-content: start; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fgrid .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .fgrid { grid-template-columns: minmax(0, 1fr); } }
.seg { display: inline-flex; justify-self: start; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { padding: 7px 16px; cursor: pointer; font-weight: 500; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

/* overlay & sheet */
.overlay { position: fixed; inset: 0; background: rgba(10, 20, 18, .42); display: flex; justify-content: flex-end; z-index: 20; }
.overlay.center { justify-content: center; align-items: flex-start; padding: 6vh 16px 16px; overflow-y: auto; }
.sheet { background: var(--bg); width: min(560px, 100%); height: 100%; overflow-y: auto; box-shadow: var(--shadow); display: grid; align-content: start; }
.dialog { background: var(--surface); width: min(520px, 100%); border-radius: 16px; box-shadow: var(--shadow); }
.sh-head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top, 0px)); display: flex; align-items: center; gap: 10px; }
.dialog .sh-head { position: static; border-radius: 16px 16px 0 0; padding-top: 14px; }
.sh-head h2 { margin: 0; font-family: var(--f-display); font-size: 19px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sh-body { padding: 16px; display: grid; gap: 16px; }
.sh-foot { padding: 12px 16px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }
.hero-bal { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-bal .big { font-family: var(--f-display); font-size: 48px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-bal .big small { font-size: 16px; color: var(--muted); margin-left: 4px; font-weight: 500; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.facts dd small { font-weight: 400; color: var(--muted); display: block; font-size: 12px; }
.legacy { font-size: 12.5px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 12px; }
.hist { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.hist td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.hist td.d { white-space: nowrap; color: var(--muted); width: 1%; padding-right: 10px; }
.hist td.a { text-align: right; font-weight: 700; white-space: nowrap; width: 1%; padding-left: 10px; }
.hist td.b { text-align: right; white-space: nowrap; width: 1%; color: var(--muted); padding-left: 10px; }
.hist td.x { width: 1%; padding-left: 6px; }
.hist tr.fut td { opacity: .6; }
.hist .plus { color: var(--good); }
.hist .minus { color: var(--ink); }
.hist .lost { color: var(--bad); }
.msg { font-size: 13px; border-radius: 10px; padding: 8px 12px; }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.bad { background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: var(--accent-soft); color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 500; z-index: 40; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.fab { position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 15; box-shadow: var(--shadow); padding: 12px 20px; border-radius: 999px; font-size: 15px; }
@media (min-width: 861px) { .fab { display: none; } }
@media (max-width: 860px) { .top .btn.primary { display: none; } }
.state { padding: 40px 16px; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.state b { color: var(--ink); font-family: var(--f-display); font-size: 17px; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: slide .18s ease-out; }
  .dialog { animation: pop .16s ease-out; }
  @keyframes slide { from { transform: translateX(24px); opacity: .6; } }
  @keyframes pop { from { transform: translateY(8px); opacity: .6; } }
}

:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
[hidden] { display: none !important; }
body[data-mode="auth"] .wrap, body[data-mode="loading"] .wrap { display: none; }
body:not([data-mode="auth"]) #auth-root { display: none; }
body:not([data-mode="loading"]) #loading-root { display: none; }
body:not([data-mode="company"]) .fab, body:not([data-mode="company"]) #btn-record { display: none !important; }
body[data-mode="operator"] #stores, body[data-mode="operator"] #summary, body[data-mode="operator"] #views,
body[data-mode="operator"] #main, body[data-mode="operator"] #billing-banner { display: none !important; }
/* 事務所の画面（顧問先の一覧）：上の集計とお支払いの案内は出し、台帳の部分は隠す。一覧は運営画面と同じ場所（#operator-root）に出す */
body[data-mode="office"] #stores, body[data-mode="office"] #views, body[data-mode="office"] #main { display: none !important; }
body:not([data-mode="operator"]):not([data-mode="office"]) #operator-root { display: none; }
.of-invite { margin-top: 4px; }
.of-row .op-act { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
#office-list .group-h { flex-wrap: wrap; }
@media (max-width: 720px) { .of-row .op-act { justify-content: flex-start; } }
#operator-root { display: grid; gap: 16px; }
.acct { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.acct select { width: auto; max-width: 220px; padding: 5px 8px; font-size: 13px; }
a.btn { text-decoration: none; }
a.btn:not(.primary) { color: inherit; }
.top .inline { gap: 10px; }
#auth-root, #loading-root { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 28px 24px; display: grid; gap: 14px; }
.auth-card h1 { margin: 0; font-family: var(--f-display); font-size: 22px; }
.auth-card p { margin: 0; color: var(--muted); font-size: 14px; }
.auth-card a { color: var(--accent); }
#signup-price { display: grid; gap: 6px; }
.signup-price-list { margin: 0; padding-left: 20px; font-size: 14px; display: grid; gap: 2px; }
.auth-brand { font-family: var(--f-display); font-weight: 700; color: var(--accent); letter-spacing: .06em; font-size: 13px; }
.legal { font-size: 12px !important; color: var(--muted); }
.legal a { color: inherit; }
.banner { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; border-radius: 12px; padding: 12px 16px; font-size: 14px; }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner-text { min-width: 0; flex: 1 1 280px; }
.price { display: inline-block; font-weight: 700; margin-left: 4px; }
.op-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.op-row:last-child { border-bottom: 0; }
.op-main { min-width: 0; display: grid; gap: 4px; }
.op-name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.op-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.op-act { display: grid; gap: 8px; justify-items: end; }
@media (max-width: 720px) { .op-row { grid-template-columns: minmax(0, 1fr); } .op-act { justify-items: start; } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* 年次有給休暇管理簿（1.9.0） */
.sheet.wide { width: min(1180px, 100%); }
table.book { border-collapse: collapse; width: 100%; min-width: 980px; font-size: 13px; }
table.book th, table.book td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; font-variant-numeric: tabular-nums; }
table.book thead th { background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
table.book td.nm { font-weight: 700; white-space: nowrap; }
table.book td.tk { min-width: 280px; }
table.book td .nt { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
table.book td.bad { color: var(--bad); font-weight: 700; }
table.book td.muted, table.book tr.none td { color: var(--muted); }
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; color: #000; }
  #print-root .pb-head { display: flex; gap: 16px; align-items: baseline; margin-bottom: 6px; font-size: 12px; }
  #print-root .pb-head b { font-size: 16px; }
  #print-root table.book { min-width: 0; font-size: 10.5px; }
  #print-root table.book th, #print-root table.book td { border: 1px solid #888; padding: 3px 5px; color: #000; background: #fff; }
  #print-root table.book tr { break-inside: avoid; }
  #print-root .pb-note { font-size: 10px; margin-top: 6px; }
}
