/* ラクキン — 共通スタイル
   レイアウト：管理画面はサイドナビ＋作業面、従業員画面はスマホ1カラム、打刻はiPad全面
   質感：紙のタイムカードの「印字」をドット文字で引用し、それ以外は静かな業務UI */
:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --sunk: #eaeeec;
  --line: #d9e0dd;
  --ink: #17212b;
  --muted: #5f6d73;
  --brand: #0d6b61;
  --brand-soft: #dcefeb;
  --brand-ink: #ffffff;
  --stamp: #c4412d;          /* タイムレコーダーの赤インク */
  --ok: #1d7f49; --ok-soft: #dff1e6;
  --warn: #a8670f; --warn-soft: #fbefd8;
  --crit: #b8332a; --crit-soft: #f9e1de;
  --info: #2c5f9e; --info-soft: #e1ebf7;
  --shadow: 0 1px 2px rgba(23, 33, 43, .06), 0 6px 20px rgba(23, 33, 43, .06);
  --font: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  --font-print: "DotGothic16", "Osaka-Mono", "MS Gothic", monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1518; --surface: #161e22; --sunk: #1c262b; --line: #29363c; --ink: #e5ecee; --muted: #93a2a8;
    --brand: #3dbaa8; --brand-soft: #173a36; --brand-ink: #062521; --stamp: #f07560;
    --ok: #4cc382; --ok-soft: #173826; --warn: #e4a447; --warn-soft: #3a2c14; --crit: #f07a6f; --crit-soft: #3d1d1a; --info: #7fb0ee; --info-soft: #1b2b40;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1518; --surface: #161e22; --sunk: #1c262b; --line: #29363c; --ink: #e5ecee; --muted: #93a2a8;
  --brand: #3dbaa8; --brand-soft: #173a36; --brand-ink: #062521; --stamp: #f07560;
  --ok: #4cc382; --ok-soft: #173826; --warn: #e4a447; --warn-soft: #3a2c14; --crit: #f07a6f; --crit-soft: #3d1d1a; --info: #7fb0ee; --info-soft: #1b2b40;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { text-wrap: balance; line-height: 1.3; margin: 0; }
p { margin: 0; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.print { font-family: var(--font-print); letter-spacing: .04em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- ボタン ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, var(--ink)); }
.btn-danger { color: var(--crit); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--sunk); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 15px; border-radius: 10px; }

/* ---------- ピル（状態表示） ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; white-space: nowrap; background: var(--sunk); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-plain::before { display: none; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-crit { background: var(--crit-soft); color: var(--crit); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- 入力 ---------- */
.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 11px; min-height: 40px; }
.textarea { min-height: 72px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.seg { display: inline-flex; background: var(--sunk); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-weight: 700; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- 表 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.t th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); background: var(--sunk); padding: 9px 12px; white-space: nowrap; letter-spacing: .02em; }
.t td { padding: 10px 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.t .r { text-align: right; }
.t .c { text-align: center; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.t tfoot td { font-weight: 700; background: var(--sunk); border-top: 2px solid var(--line); }
.t tr.weekend-0 td:first-child { color: var(--crit); }
.t tr.weekend-6 td:first-child { color: var(--info); }

/* ---------- モーダル／ドロワー ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 20, .45); z-index: 50; display: flex; justify-content: flex-end; animation: fade .15s ease; }
.scrim.center { justify-content: center; align-items: center; padding: 16px; }
.drawer { width: min(520px, 100%); height: 100%; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .2s ease; padding-bottom: env(safe-area-inset-bottom, 0px); }
.dialog { width: min(760px, 100%); max-height: 100%; overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); animation: pop .18s ease; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 20px; overflow: auto; flex: 1; display: grid; gap: 16px; align-content: start; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

/* ---------- トースト ---------- */
.toast-box { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); animation: pop .2s ease; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-crit { background: var(--crit); color: #fff; }
.toast.out { opacity: 0; transition: opacity .3s; }

/* ---------- アバター ---------- */
.av { --c: var(--brand); width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 900; color: #fff; background: var(--c); flex: none; font-size: 14px; }

/* ---------- 給与明細（紙の明細書の様式） ---------- */
.slip { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: grid; gap: 16px; }
.slip-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 10px; }
.slip-title { font-size: 20px; font-weight: 900; letter-spacing: .3em; }
.slip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.slip-box { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.slip-box h4 { margin: 0; font-size: 12px; letter-spacing: .4em; padding: 6px 10px; background: var(--sunk); color: var(--muted); }
.slip-box dl { margin: 0; display: grid; grid-template-columns: 1fr auto; font-variant-numeric: tabular-nums; }
.slip-box dt, .slip-box dd { margin: 0; padding: 6px 10px; border-top: 1px solid var(--line); font-size: 13px; }
.slip-box dd { text-align: right; }
.slip-box .sum { font-weight: 900; background: color-mix(in srgb, var(--sunk) 60%, transparent); }
.slip-net { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: 10px; background: var(--brand-soft); }
.slip-net strong { font-size: 28px; font-weight: 900; color: var(--brand); font-variant-numeric: tabular-nums; }

@media print {
  body { background: #fff; color: #000; }
  .no-print, .scrim > :not(.print-target) { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.confirm-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: 8px; background: var(--crit-soft); font-size: 13px; }
