@charset "UTF-8";

/* =========================================================
   給料計算ツール — 白ベース / 差し色 #403999
   スマートフォンの縦画面での操作を最優先に設計
   ========================================================= */

:root {
  --accent: #403999;
  --accent-dark: #322c7a;
  --accent-soft: #efeefa;
  --accent-line: #d9d6f0;

  --bg: #f5f5f9;
  --surface: #ffffff;
  --text: #1b1b22;
  --muted: #6e6e7c;
  --line: #e6e6ee;
  --danger: #d92d20;

  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(27, 27, 34, .05);
  --shadow: 0 2px 12px rgba(27, 27, 34, .08);
  --shadow-lg: 0 10px 30px rgba(64, 57, 153, .25);

  /* タッチ操作の基準寸法 */
  --tap: 52px;
  --tabbar-h: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性を常に効かせる（.login や .btn の display 指定に負けないように） */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
               "Yu Gothic UI", "Noto Sans JP", Meiryo, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overscroll-behavior-y: none;
}

h1, h2 { margin: 0; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 13px; }

.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; margin: 0; }
.hint { margin: 2px 2px 0; font-size: 13px; color: var(--muted); line-height: 1.55; }

/* ---------- 入力 ---------- */
input, select, button, textarea { font: inherit; color: inherit; }
button, label, .tab, .rec { touch-action: manipulation; }

input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="month"], select {
  width: 100%;
  min-width: 0;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 17px;                 /* iOS のズーム防止（16px 以上） */
  appearance: none;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--accent); }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 53%, calc(100% - 13px) 53%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 38px;
}

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface); color: var(--text);
  font-size: 16px; font-weight: 600; cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:active { background: var(--accent-dark); }
.btn.block { width: 100%; }
.btn.tiny { min-height: 44px; padding: 0 16px; font-size: 14px; border-radius: 12px; }
.btn.dashed { border-style: dashed; color: var(--accent); background: transparent; }
.btn.danger-outline { color: var(--danger); border-color: #f3c9c5; background: #fff; }
.btn:disabled { opacity: .55; }

.icon-btn {
  width: 48px; height: 48px; flex: 0 0 48px;
  border: none; border-radius: 14px; background: transparent;
  color: var(--accent); font-size: 30px; line-height: 1; cursor: pointer;
  user-select: none;
}
.icon-btn:active { background: var(--accent-soft); }

.link {
  background: none; border: none; color: var(--accent);
  font-size: 16px; min-height: 48px; padding: 0 8px; cursor: pointer; user-select: none;
}
.link.strong { font-weight: 700; }

/* =========================================================
   ログイン
   ========================================================= */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px calc(24px + var(--safe-b)); background: var(--bg); }
.login-card {
  width: min(420px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  padding: 32px 22px; display: grid; gap: 15px; text-align: left;
}
.login-logo {
  width: 62px; height: 62px; margin: 0 auto 4px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 19px; font-size: 33px; font-weight: 700;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { text-align: center; }
.login-card .sub { margin: -8px 0 6px; text-align: center; color: var(--muted); font-size: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login-card .btn { margin-top: 8px; }

/* =========================================================
   アプリ枠
   ========================================================= */
/* 上部に固定するバー群（タブ + 月の切り替え） */
.topbars {
  position: sticky; top: 0; z-index: 20;
  padding-top: var(--safe-t);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.appbar {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px 8px;
  border-top: 1px solid var(--line);
}
.appbar-center { flex: 1; min-width: 0; text-align: center; }
.month-field input[type="month"] {
  border: none; background: transparent; text-align: center; min-height: 44px;
  font-size: 19px; font-weight: 700; padding: 0; color: var(--text);
}
.month-field input:focus { outline: none; }
/* 月の切り替えは左右のボタンと、この文字のタップで行う */
.month-field input::-webkit-calendar-picker-indicator { display: none; }
.appbar-center small { display: block; font-size: 12px; color: var(--muted); margin-top: -2px; }

/* 下端は登録ボタンの分だけ空けて、一覧の最後が隠れないようにする */
main { padding: 14px 14px calc(104px + var(--safe-b)); max-width: 640px; margin: 0 auto; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 22px 4px 8px; }
.section-head h2 { color: var(--muted); font-size: 13px; letter-spacing: .04em; }
.head-actions { display: flex; gap: 8px; }
.badge { display: inline-block; min-width: 22px; padding: 1px 8px; margin-left: 4px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; text-align: center; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 14px; display: grid; gap: 14px; }

/* =========================================================
   ヒーロー（総支給額）
   ========================================================= */
.hero {
  background: linear-gradient(140deg, var(--accent) 0%, #5b52c9 55%, #6f5bd6 100%);
  color: #fff; border-radius: 20px; padding: 20px 20px 17px;
  box-shadow: var(--shadow-lg);
}
.hero-label { font-size: 13px; opacity: .85; letter-spacing: .05em; }
.hero-amount { font-size: 42px; font-weight: 800; line-height: 1.12; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero.small .hero-amount { font-size: 34px; }
.hero-net { font-size: 13px; opacity: .9; min-height: 1.2em; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.chip { background: rgba(255, 255, 255, .18); border-radius: 99px; padding: 5px 13px; font-size: 13px; }
.chip b { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- 内訳 ---------- */
.breakdown { list-style: none; margin: 14px 0 0; padding: 4px 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.breakdown li { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 16px; }
.breakdown li + li { border-top: 1px solid var(--line); }
.bd-name { font-size: 15px; color: #3a3a46; }
.bd-name small { display: block; font-size: 12px; color: var(--muted); }
.breakdown b { font-size: 18px; font-variant-numeric: tabular-nums; }
.bd-total { background: var(--accent-soft); border-radius: 0 0 15px 15px; }
.bd-total .bd-name { font-weight: 700; color: var(--accent); }
.bd-total b { color: var(--accent); font-size: 20px; }

/* =========================================================
   勤務カード（1行まるごとがタップ領域）
   ========================================================= */
.record-list { display: grid; gap: 10px; }
.rec {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center;
  min-height: 68px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow-sm); cursor: pointer; text-align: left; width: 100%;
  font: inherit; color: inherit;
}
.rec:active { background: #fafaff; transform: scale(.994); }
.rec-date { text-align: center; line-height: 1.05; }
.rec-day { display: block; font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-wd { font-size: 11px; color: var(--muted); }
.rec.sat .rec-wd { color: #1a6fd4; }
.rec.sun .rec-wd { color: var(--danger); }
.rec-main { min-width: 0; }
.rec-time { font-size: 14px; color: #3a3a46; }
.rec-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.tag { font-size: 12px; border-radius: 7px; padding: 2px 8px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tag.gray { background: #f1f1f5; color: var(--muted); }
.tag.note { background: transparent; color: var(--muted); font-weight: 400; padding-left: 0; }
.rec-amount { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 34px 12px; margin: 0;
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* 読み込み中のプレースホルダー */
.skeleton { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  height: 68px; box-shadow: var(--shadow-sm); animation: pulse 1.1s ease-in-out infinite; }
.skeleton:nth-child(2) { animation-delay: .12s; }
.skeleton:nth-child(3) { animation-delay: .24s; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* =========================================================
   年間
   ========================================================= */
.year-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 14px; font-size: 19px; font-weight: 700; }

.months { list-style: none; margin: 0; padding: 4px 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.months li + li { border-top: 1px solid var(--line); }
.months button { display: grid; grid-template-columns: 66px 1fr auto; gap: 12px; align-items: center;
  width: 100%; min-height: 56px; background: none; border: none; padding: 10px 16px;
  cursor: pointer; text-align: left; font: inherit; }
.months button:active { background: #fafaff; }
.mo-name { font-weight: 700; font-size: 15px; }
.mo-name small { font-size: 12px; }
.mo-meter { height: 7px; border-radius: 99px; background: #ededf3; overflow: hidden; }
.mo-meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.mo-amount { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.months li.current { background: var(--accent-soft); }

/* =========================================================
   設定フォーム
   ========================================================= */
.field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 7px 10px;
  font-size: 15px; font-weight: 600; }
.field > input, .field > select { grid-column: 1 / -1; font-weight: 400; }
.field .unit { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-height: var(--tap); font-size: 15px; font-weight: 600; cursor: pointer; }
.switch span { flex: 1; }
.switch small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.switch input { width: 56px; height: 32px; border-radius: 99px; background: #d6d6e0; position: relative;
  appearance: none; transition: background .18s; flex: 0 0 56px; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .18s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(24px); }

/* アカウント表示行 */
.acct { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.acct-label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.acct-id { display: block; font-size: 21px; font-weight: 700; word-break: break-all; line-height: 1.3; }

.version { text-align: center; font-size: 12px; color: var(--muted); margin: 24px 0 0; }
#settingsForm { display: grid; gap: 0; }
#settingsForm .btn { margin-top: 18px; }

/* =========================================================
   タブ（画面上部）と登録ボタン
   ========================================================= */
.tabbar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: var(--tabbar-h);
}
.tab {
  position: relative; display: grid; place-items: center; border: none; background: none;
  font-size: 16px; color: var(--muted); cursor: pointer; font-weight: 600; letter-spacing: .04em;
  user-select: none;
}
.tab::after {
  content: ""; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 46px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; transition: background .15s;
}
.tab:active { background: rgba(64, 57, 153, .06); }
.tab.is-active { color: var(--accent); }
.tab.is-active::after { background: var(--accent); }

.fab {
  position: fixed; right: 18px; z-index: 25;
  bottom: calc(20px + var(--safe-b));
  width: 64px; height: 64px; border-radius: 22px; border: none;
  background: var(--accent); color: #fff; font-size: 34px; line-height: 1;
  box-shadow: var(--shadow-lg); cursor: pointer; user-select: none;
  transition: transform .22s ease, opacity .22s ease;
}
.fab:active { background: var(--accent-dark); transform: scale(.95); }
/* 下方向へスクロール中は一覧の金額を隠さないように引っ込める */
.fab.is-away { transform: translateY(130px); opacity: 0; pointer-events: none; }

/* =========================================================
   シート（入力・アカウント）
   ========================================================= */
.sheet { border: none; padding: 0; margin: 0 auto auto; max-width: 640px; width: 100%; background: transparent; }
.sheet::backdrop { background: rgba(20, 18, 40, .5); }
.sheet[open] { position: fixed; inset: 0; display: flex; align-items: flex-end; }
.sheet form {
  width: 100%; max-height: 94dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 24px 24px 0 0; overflow: hidden;
  animation: slideUp .24s cubic-bezier(.22, .9, .3, 1);
}
@keyframes slideUp { from { transform: translateY(28px); opacity: .4; } }

/* 上端のつまみ（下から出てきたことが分かるように） */
.sheet-grip { height: 16px; background: var(--surface); display: grid; place-items: center; padding-top: 7px; }
.sheet-grip::before { content: ""; width: 40px; height: 4px; border-radius: 99px; background: #d5d5df; }

.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 2px 8px 8px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.sheet-head strong { font-size: 17px; text-align: center; }
.sheet-head .link { justify-self: start; }
.sheet-head-pad { display: block; }

.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px 0; flex: 1;
  overscroll-behavior: contain; }
.sheet-spacer { height: 12px; }

.sheet-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px calc(12px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(27, 27, 34, .06);
}
.foot-total { display: grid; line-height: 1.25; }
.foot-total small { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.foot-total b { font-size: 25px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.sheet-foot .btn { flex: 1; min-height: 54px; font-size: 17px; }

/* ---------- シート内のカード ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 14px; display: grid; gap: 11px; margin-bottom: 12px;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.lbl { font-size: 15px; font-weight: 600; }
.lbl-sm { display: grid; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }

.chips-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn {
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 99px; font-size: 14.5px; cursor: pointer; user-select: none; color: var(--text);
}
.chip-btn:active { background: var(--accent-soft); }
.chip-btn.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 700; }

.time-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.time-sep { padding-bottom: 14px; color: var(--muted); }
.time-row input { font-size: 19px; font-weight: 600; text-align: center; }

.sub-field { display: flex; align-items: center; gap: 8px; }
.sub-field input { flex: 1; }
.sub-field .unit { font-size: 13px; color: var(--muted); font-weight: 600; }

/* 計算結果の行 */
.result {
  background: var(--accent-soft); border-radius: 11px; padding: 11px 14px;
  font-size: 14.5px; color: var(--accent); text-align: center;
}
.result b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.result .muted { color: var(--muted); font-size: 13px; }

.stepper { display: grid; grid-template-columns: 1fr 52px 60px 52px 72px; align-items: center; gap: 7px; }
.st-name { font-size: 15px; font-weight: 600; }
.st-name small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.st-btn {
  height: var(--tap); border: 1px solid var(--line); background: var(--surface); border-radius: 13px;
  font-size: 24px; color: var(--accent); cursor: pointer; user-select: none;
}
.st-btn:active { background: var(--accent-soft); }
.stepper input { text-align: center; padding: 12px 2px; font-size: 20px; font-weight: 700; }
.st-amount { text-align: right; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.st-amount.zero { color: var(--muted); font-weight: 400; }

.special-row { display: grid; grid-template-columns: 1fr 112px 44px; gap: 8px; align-items: center; }
.special-row .rm { height: var(--tap); border: none; background: none; color: var(--danger);
  font-size: 22px; cursor: pointer; border-radius: 12px; }
.special-row .rm:active { background: #fdeceb; }

/* =========================================================
   トースト / インストール案内
   ========================================================= */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(96px + var(--safe-b));
  background: #26243a; color: #fff; padding: 11px 20px; border-radius: 99px;
  font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; text-align: center;
  animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } }

.install-hint {
  position: fixed; left: 12px; right: 12px; z-index: 40;
  bottom: calc(16px + var(--safe-b));
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--accent-line); border-radius: 15px;
  padding: 10px 10px 10px 15px; box-shadow: var(--shadow); font-size: 13.5px;
}
.install-hint span { flex: 1; }

/* =========================================================
   横向き・タブレット・PC
   ========================================================= */
@media (min-width: 760px) {
  main { max-width: 720px; }
  .topbars { max-width: 720px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .fab { bottom: 28px; right: calc(50% - 360px + 12px); }
  .sheet[open] { align-items: center; }
  .sheet form { border-radius: 20px; max-height: 88dvh; }
  .install-hint { display: none; }
}

/* 縦画面向けに作っているため、低い横画面ではシートを全画面に */
@media (max-height: 500px) and (orientation: landscape) {
  .sheet form { max-height: 100dvh; border-radius: 0; }
  .sheet[open] { align-items: stretch; }
}

/* 動きを抑える設定にしている端末では、アニメーションを止める */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; }
}

/* =========================================================
   印刷（給与明細）
   ========================================================= */
@media print {
  :root { --shadow: none; --shadow-sm: none; --shadow-lg: none; }
  body { background: #fff; font-size: 11px; }
  .topbars, .fab, .toast, .install-hint,
  .head-actions, #viewYear, #viewMore { display: none !important; }
  main { max-width: none; padding: 0; }
  .hero { background: none; color: #000; border: 1px solid #999; border-radius: 8px; }
  .hero-label, .hero-net { color: #333; }
  .chip { background: #f0f0f0; color: #000; border: 1px solid #ddd; }
  .breakdown, .record-list .rec { border: 1px solid #bbb; break-inside: avoid; }
  .record-list { gap: 3px; }
  .rec { padding: 5px 8px; min-height: 0; }
  .bd-total { background: #eee; }
}
