/* かんたん勤怠 — 共通スタイル
   レイアウト: 左ナビ＋作業領域（スマホでは上部の横スクロールナビ）。帳票は A4 印刷用の独立レイアウト。 */
:root {
  --bg: #f2f5f4; --surface: #ffffff; --surface2: #f7f9f8; --ink: #15201d; --muted: #5a6964; --line: #d6dedb;
  --accent: #0a6b5c; --accent-soft: #dcefe9; --on-accent: #ffffff;
  --good: #1d7a3a; --good-soft: #e1f3e6; --warn: #a76a06; --warn-soft: #fbefd6; --bad: #b42318; --bad-soft: #fbe4e1;
  --brk: #2b5ca6; --brk-soft: #e2ebf8;
  --font: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "BIZ UDGothic", ui-monospace, Menlo, Consolas, monospace;
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1514; --surface: #172020; --surface2: #1c2726; --ink: #e5ecea; --muted: #97a7a2; --line: #2c3936;
    --accent: #3db39c; --accent-soft: #173b35; --on-accent: #06201b;
    --good: #5cc27a; --good-soft: #17301f; --warn: #e0a640; --warn-soft: #3a2c10; --bad: #f07a6c; --bad-soft: #3d1a16;
    --brk: #7ea8ec; --brk-soft: #1b2a44; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1514; --surface: #172020; --surface2: #1c2726; --ink: #e5ecea; --muted: #97a7a2; --line: #2c3936;
  --accent: #3db39c; --accent-soft: #173b35; --on-accent: #06201b;
  --good: #5cc27a; --good-soft: #17301f; --warn: #e0a640; --warn-soft: #3a2c10; --bad: #f07a6c; --bad-soft: #3d1a16;
  --brk: #7ea8ec; --brk-soft: #1b2a44; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.6; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { line-height: 1.3; text-wrap: balance; margin: 0; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--accent); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden, [hidden] { display: none !important; }

/* ボタン・入力 */
button, .btn { font: inherit; cursor: pointer; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .5rem 1rem; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none; }
button:hover, .btn:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.primary, .btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
button.sm { min-height: 32px; padding: .2rem .7rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; min-height: 40px; max-width: 100%; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
textarea { width: 100%; min-height: 120px; }
label.f { display: grid; gap: .25rem; font-size: .9rem; }
label.f > span { color: var(--muted); font-size: .85rem; }
.help { font-size: .82rem; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 1rem; }
.stack { display: grid; gap: 1rem; }
.check { display: flex; gap: .5rem; align-items: center; cursor: pointer; }

/* 管理画面レイアウト */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.nav { background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .7rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 1.1rem; padding: .2rem .6rem 1rem; display: flex; align-items: center; gap: .5rem; }
.brand .mark { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent); position: relative; flex: none; }
.brand .mark::before { content: ""; position: absolute; left: 50%; top: 4px; width: 2px; height: 8px; background: var(--accent); transform: translateX(-50%); }
.brand .mark::after { content: ""; position: absolute; left: 50%; top: 50%; width: 7px; height: 2px; background: var(--accent); }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.nav a { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .95rem; }
.nav a:hover { background: var(--surface2); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav .badge { margin-left: auto; }
.nav .sep { height: 1px; background: var(--line); margin: .7rem .4rem; }
.main { padding-block: 1.4rem 4rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); min-width: 0; }
.main-inner { max-width: 1200px; margin: 0 auto; display: grid; gap: 1.2rem; }
.page-head { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; }
.page-head p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.2rem; min-width: 0; }
.panel > h2 { margin-bottom: .8rem; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; white-space: nowrap; padding: .5rem .9rem; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 700; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: sticky; top: env(safe-area-inset-top, 0px); height: auto; z-index: 20; display: flex; gap: .2rem; overflow-x: auto; padding: .4rem max(16px, env(safe-area-inset-left, 0px)); border-right: 0; border-bottom: 1px solid var(--line); }
  .nav .brand, .nav .sep { display: none; }
  .nav a { white-space: nowrap; padding: .45rem .7rem; }
}

/* 指標 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem; }
.stat .k { font-size: .8rem; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .v small { font-size: .9rem; color: var(--muted); font-family: var(--font); }

/* 表 */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.tbl { border-collapse: collapse; width: 100%; font-size: .88rem; }
.tbl th, .tbl td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { background: var(--surface2); font-weight: 700; font-size: .8rem; color: var(--muted); position: sticky; top: 0; }
.tbl td.n, .tbl th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface2); }
.tbl tr.sun td:first-child, .tbl tr.sun td:nth-child(2) { color: var(--bad); }
.tbl tr.sat td:first-child, .tbl tr.sat td:nth-child(2) { color: var(--brk); }
.tbl tr.off td { background: var(--surface2); }
.tbl tr.total td { font-weight: 700; background: var(--accent-soft); }
.tbl tr.err td { background: var(--bad-soft); }

/* 状態ピル */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.pill.working { background: var(--good-soft); color: var(--good); }
.pill.break { background: var(--brk-soft); color: var(--brk); }
.pill.left { background: var(--surface2); color: var(--muted); }
.pill.none { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.ok { background: var(--good-soft); color: var(--good); }
.pill.plain::before { display: none; }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .45rem; font-weight: 700; }
.note { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: .7rem .9rem; border-radius: 0 6px 6px 0; font-size: .9rem; }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note.bad { border-color: var(--bad); background: var(--bad-soft); }

/* モーダル */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: min(680px, 100%); padding: 1.3rem; display: grid; gap: 1rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
#toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .6rem 1.2rem; border-radius: 999px; z-index: 99; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }

/* ウィザード */
.wizard { max-width: 720px; margin: 0 auto; padding-block: 2rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 1.2rem; }
.steps { display: flex; gap: .3rem; flex-wrap: wrap; }
.steps span { flex: 1; min-width: 70px; height: 6px; border-radius: 3px; background: var(--line); }
.steps span.done { background: var(--accent); }
.choice { display: grid; gap: .5rem; }
.choice label { display: flex; gap: .7rem; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r); padding: .7rem .9rem; cursor: pointer; background: var(--surface); }
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.wd-pick { display: flex; gap: .35rem; flex-wrap: wrap; }
.wd-pick label { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; font-weight: 700; background: var(--surface); }
.wd-pick input { position: absolute; opacity: 0; pointer-events: none; }
.wd-pick label:has(input:checked) { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.login { min-height: 100vh; display: grid; place-items: center; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login .panel { width: min(400px, 100%); display: grid; gap: 1rem; }
.qr { width: 110px; height: 110px; background: #fff; padding: 6px; border-radius: 6px; }
.qr img, .qr canvas { width: 100% !important; height: auto !important; }
.urlbox { display: grid; gap: .5rem; grid-template-columns: auto 1fr; align-items: center; }

/* ===== 帳票（印刷） ===== */
.report-area { background: #e9ecea; padding: 1rem; border-radius: var(--r); overflow-x: auto; }
.sheet { background: #fff; color: #000; width: 210mm; min-height: 297mm; margin: 0 auto 1rem; padding: 12mm 11mm; font-size: 9pt; line-height: 1.4; box-shadow: 0 2px 10px rgba(0,0,0,.15); font-family: var(--font); }
.sheet.land { width: 297mm; min-height: 210mm; }
.sheet h1 { font-size: 15pt; text-align: center; letter-spacing: .3em; margin-bottom: 3mm; }
.sheet .meta { display: flex; justify-content: space-between; gap: 4mm; margin-bottom: 3mm; font-size: 9pt; flex-wrap: wrap; }
.sheet table { border-collapse: collapse; width: 100%; }
.sheet th, .sheet td { border: .3mm solid #333; padding: .6mm 1.2mm; font-size: 8pt; text-align: center; white-space: nowrap; }
.sheet th { background: #eee; font-weight: 700; }
.sheet td.l { text-align: left; }
.sheet td.r { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sheet tr.sun td { color: #c00; } .sheet tr.sat td { color: #0050b0; }
.sheet tr.tot td { font-weight: 700; background: #f3f3f3; }
.sheet .stamps { display: flex; justify-content: flex-end; margin-top: 4mm; }
.sheet .stamps div { width: 20mm; height: 22mm; border: .3mm solid #333; margin-left: -.3mm; display: grid; grid-template-rows: 5mm 1fr; text-align: center; font-size: 7.5pt; }
.sheet .stamps div span { border-bottom: .3mm solid #333; background: #eee; }
.sheet .sumgrid { display: grid; grid-template-columns: repeat(6, 1fr); border-top: .3mm solid #333; border-left: .3mm solid #333; margin-top: 3mm; }
.sheet .sumgrid div { border-right: .3mm solid #333; border-bottom: .3mm solid #333; padding: 1mm 1.5mm; font-size: 8pt; display: flex; justify-content: space-between; gap: 2mm; }
.sheet .sumgrid b { font-family: var(--mono); }
.sheet .foot { margin-top: 3mm; font-size: 7.5pt; color: #444; }
.sheet .over { color: #c00; font-weight: 700; }

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff !important; }
  .no-print, .nav, .page-head, .panel:not(.print-keep), #toast, .modal-bg { display: none !important; }
  .shell { display: block; }
  .main { padding: 0 !important; }
  .main-inner { display: block; max-width: none; }
  .report-area { background: none; padding: 0; overflow: visible; }
  .sheet { box-shadow: none; margin: 0; page-break-after: always; break-after: page; width: auto; min-height: 0; }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
  body.print-land .sheet { width: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
