/* =========================================================
   koneko-office  stylesheet
   ========================================================= */
:root {
  --navy: #1f3f66;
  --navy-2: #2c5d8f;
  --line: #d8dee7;
  --bg: #f4f6f9;
  --text: #24303f;
  --muted: #6b7a8c;
  --work: #4f80bd;
  --paid: #4d9e6a;
  --special: #d9a400;
  --sick: #d9534f;
  --training: #7c6bb0;
  --absent: #8a94a6;
  --holiday: #e8b4b4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo",
               -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 56px;
  background: #1f3f66;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-logo { height: 28px; width: auto; display: block; }
.brand-sub {
  font-size: 11px; font-weight: 400; color: #a9c0d8;
  padding-left: 10px; border-left: 1px solid rgba(255,255,255,.28);
  letter-spacing: .12em; white-space: nowrap;
}
.nav { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.nav a {
  color: #cfdcea;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13.5px;
}
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav a.on { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 12px; }
.uname { font-size: 13px; color: #dfe8f2; }
.userbox .btn-outline { border-color: rgba(255,255,255,.4); color: #fff; padding: 5px 12px; }
.userbox .btn-outline:hover { background: rgba(255,255,255,.12); text-decoration: none; }

/* ---------- layout ---------- */
.wrap { max-width: 1400px; margin: 0 auto; padding: 24px 20px 60px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0 40px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 21px; margin: 0; letter-spacing: .02em; }
.head-actions { display: flex; gap: 8px; align-items: center; }

h2.sec { font-size: 16px; margin: 32px 0 12px; color: var(--navy); }

.monthpick { display: flex; align-items: center; gap: 8px; }
.monthpick input[type=month], .monthpick select {
  font-size: 14px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff;
}

/* ---------- buttons ---------- */
.btn-primary, .btn-outline, .btn-mini {
  display: inline-block;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: .12s ease;
  white-space: nowrap;
}
.btn-primary {
  background: #2c5d8f; background: var(--navy-2);
  color: #fff; border: 1px solid #2c5d8f;
  border-color: var(--navy-2);
  padding: 9px 20px; font-size: 14px; font-weight: 600;
}
.btn-primary:hover { background: #1f3f66; background: var(--navy); text-decoration: none; }
.btn-outline {
  background: #fff; color: var(--navy-2); border: 1px solid var(--line);
  padding: 8px 16px; font-size: 13.5px;
}
.btn-outline:hover { border-color: var(--navy-2); text-decoration: none; }
.btn-outline.on { background: #eaf1f9; border-color: var(--navy-2); }
.btn-mini {
  background: #fff; border: 1px solid var(--line); color: var(--navy-2);
  padding: 3px 10px; font-size: 12px;
}
.btn-mini:hover { border-color: var(--navy-2); text-decoration: none; }
.btn-mini.danger { color: #c0392b; }
.btn-mini.danger:hover { border-color: #c0392b; background: #fdf0ee; }
.btn-block { display: block; width: 100%; }

/* ---------- flash ---------- */
.flash {
  padding: 11px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 13.5px;
}
.flash-ok { background: #e8f5ec; border: 1px solid #b7ddc5; color: #22603c; }
.flash-error { background: #fdecea; border: 1px solid #f3b8b3; color: #8e2b22; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px;
}
.card-k { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.card-v { font-size: 24px; font-weight: 700; color: var(--navy); letter-spacing: .01em; }
.card-v small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 3px; }

/* ---------- tables ---------- */
.table-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  overflow: auto;
}
.table-wrap.scroll-x { overflow-x: auto; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #eef1f5;
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}
table.grid thead th {
  background: #eef2f7; color: var(--navy); font-weight: 600;
  font-size: 12.5px; position: sticky; top: 0; z-index: 2;
}
table.grid tbody tr:hover { background: #fafbfd; }
table.grid .empty { text-align: center; color: var(--muted); padding: 28px; }

.c-name { min-width: 150px; }
.c-num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid th.c-num, table.grid th.c-cent { text-align: center; }
.c-cent { text-align: center; }
.strong { font-weight: 700; color: var(--navy); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.nowrap { white-space: nowrap; }
.sub { font-size: 11px; color: var(--muted); }
.code {
  display: inline-block; font-size: 10.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 0 5px; margin-right: 6px; vertical-align: 1px;
}
.tag {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px;
  background: #eef2f7; color: var(--navy-2); border: 1px solid #d5e0ee;
}
.tag-company { background: #fdf0ee; color: #a8453c; border-color: #f0cdc8; }
.row-inactive td { color: #9aa5b3; background: #fbfbfc; }
.badge-on { color: #22734a; background: #e8f5ec; border-radius: 4px; padding: 1px 7px; font-size: 11.5px; }
.badge-off { color: #7c8794; background: #f0f2f5; border-radius: 4px; padding: 1px 7px; font-size: 11.5px; }
.sat { color: #2c6fb5; }
.sun { color: #c0392b; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 14px; }

.actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- attendance grid ---------- */
table.attendance th.c-day, table.attendance td.c-day {
  width: 30px; min-width: 30px; padding: 4px 2px; text-align: center;
  font-size: 11px; border-right: 1px solid #eef1f5;
}
table.attendance thead th.c-day { font-weight: 500; line-height: 1.15; padding: 5px 2px; }
table.attendance thead th.c-day .dnum { display: block; font-size: 11.5px; font-weight: 700; }
table.attendance thead th.c-day .dwd { display: block; font-size: 10px; color: var(--muted); }
th.wk-end, td.wk-end { background: #f3f5f8; }
th.wk-hol { background: #fbeeee; }
th.wk-end .dwd { color: #8a94a6; }
th.wk-hol .dwd { color: #b3685f; }

td.clickable { cursor: pointer; user-select: none; position: relative; }
td.clickable:hover { outline: 2px solid #9db8d6; outline-offset: -2px; }
td.clickable .mark { font-size: 11px; font-weight: 700; color: #fff; }
td.cell-off { background: #f7f8fa; }
td.cell-na { background: #fbfbfc; }
td.cell-na::after { content: ""; }
.sticky-l { position: sticky; left: 0; background: #fff; z-index: 1; }
tbody tr:hover .sticky-l { background: #fafbfd; }
.sum-col { background: #f7f9fc !important; min-width: 52px; }

/* status colors */
td.st-work     { background: var(--work); }
td.st-paid     { background: var(--paid); }
td.st-special  { background: var(--special); }
td.st-sick     { background: var(--sick); }
td.st-training { background: var(--training); }
td.st-absent   { background: var(--absent); }

/* legend */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 12px; font-size: 12.5px; }
.lg { display: inline-flex; align-items: center; gap: 5px; color: var(--text); }
.lg i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.lg.st-work i { background: var(--work); }
.lg.st-paid i { background: var(--paid); }
.lg.st-special i { background: var(--special); }
.lg.st-sick i { background: var(--sick); }
.lg.st-training i { background: var(--training); }
.lg.st-absent i { background: var(--absent); }
.lg-holiday i { background: var(--holiday); }
.lg-off i { background: #f3f5f8; border: 1px solid var(--line); }
.lg-hint { color: var(--muted); font-size: 12px; margin-left: auto; }

.sticky-actions {
  position: sticky; bottom: 0; background: rgba(244,246,249,.96);
  padding: 12px 0; margin-top: 14px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}

/* ---------- forms ---------- */
.form-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 22px 24px;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 20px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
label.req::after { content: " *"; color: #c0392b; }
input[type=text], input[type=date], input[type=number],
input[type=month], input[type=password], select, textarea {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--navy-2);
  box-shadow: 0 0 0 3px rgba(44,93,143,.12);
}
label.full { margin-top: 18px; }
fieldset.checks {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 18px; margin: 20px 0 0;
}
fieldset.checks legend { font-size: 12.5px; color: var(--muted); padding: 0 6px; }
fieldset.checks label {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text); font-size: 13.5px; margin: 4px 20px 4px 0;
}
fieldset.checks input[type=checkbox] { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; align-items: center; flex-wrap: wrap; }
.inline-form { padding: 16px 20px; margin-bottom: 18px; }
.form-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 150px; margin-bottom: 0; }
.form-row button { height: 38px; }
form.inline { display: inline; }

/* ---------- login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(160deg, #1f3f66, #35597f 60%, #4a739b);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 14px;
  padding: 34px 30px 26px; box-shadow: 0 18px 50px rgba(10,25,45,.28);
}
.login-brand { text-align: center; line-height: 1; margin-bottom: 16px; }
.login-brand img { width: 262px; max-width: 82%; height: auto; }
.login-card h1 { font-size: 16px; text-align: center; margin: 0 0 22px; color: var(--navy); font-weight: 600; }
.login-card label { margin-bottom: 14px; font-size: 12.5px; }
.login-card input { margin-top: 4px; }
.login-card .btn-primary { margin-top: 8px; }
.login-note { font-size: 11.5px; color: var(--muted); text-align: center; margin: 18px 0 0; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .wrap { padding: 16px 12px 50px; }
  .page-head h1 { font-size: 18px; }
  .lg-hint { margin-left: 0; width: 100%; }
  table.grid { font-size: 12px; }
}

/* =========================================================
   第3期：給与計算
   ========================================================= */
table.payroll th { font-size: 11.5px; line-height: 1.25; padding: 7px 6px; white-space: nowrap; }
table.payroll td { padding: 4px 6px; }
table.payroll .in-grp { background: #fbfcfe; }
table.payroll .in-ded { background: #fdfbf7; }
table.payroll .calc { background: #eef3f9 !important; font-weight: 600; color: var(--navy); }
table.payroll .net { background: #e6eefa !important; }
table.payroll thead th.in-grp { background: #e7eef7; }
table.payroll thead th.in-ded { background: #f7f0e4; }
table.payroll thead th.calc { background: #dde7f3; }
table.payroll tfoot .total-row th {
  background: #dfe8f3; color: var(--navy); font-weight: 700;
  border-top: 2px solid var(--navy-2);
}
input.cell-num {
  width: 82px; text-align: right; font-size: 13px;
  padding: 5px 7px; border: 1px solid #dde3ea; border-radius: 5px;
  font-variant-numeric: tabular-nums; background: #fff;
}
input.cell-num.mini { width: 52px; }
input.cell-num:focus { border-color: var(--navy-2); box-shadow: 0 0 0 2px rgba(44,93,143,.15); outline: none; }
input.cell-num::-webkit-outer-spin-button,
input.cell-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.cell-num[type=number] { -moz-appearance: textfield; }

.tag-saved { background: #e8f5ec; color: #22734a; border-color: #b7ddc5; font-size: 10px; }
.tag-draft { background: #fff4e0; color: #8a6410; border-color: #f0dcae; font-size: 10px; }
.chk-inline {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text); margin: 0;
}
.chk-inline input { width: auto; }

/* =========================================================
   ユーザーメニュー / 年次集計
   ========================================================= */
.userbox { position: relative; }

.userbtn {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid rgba(255,255,255,.25);
  border-radius: 22px; padding: 5px 14px 5px 5px; cursor: pointer;
  color: #fff; font-family: inherit; font-size: 13px; transition: .15s;
}
.userbtn:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.45); }
.userbox.open .userbtn { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.5); }

.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #4a739b; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700;
}
.caret { font-size: 9px; opacity: .8; margin-left: 2px; }

.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 236px;
  background: #fff; border: 1px solid #dbe2ec; border-radius: 10px;
  box-shadow: 0 12px 32px rgba(18,36,60,.18);
  padding: 6px; opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: .16s ease; z-index: 200;
}
.userbox.open .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }

.dd-head { padding: 10px 12px 12px; border-bottom: 1px solid #eef1f5; margin-bottom: 4px; }
.dd-name { font-size: 14px; font-weight: 700; color: #1f3f66; }
.dd-sub { font-size: 11.5px; color: #6b7a8c; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.dd-role {
  background: #e8f0f9; color: #2c5d8f; border-radius: 9px;
  padding: 0 7px; font-size: 10px; line-height: 16px;
}
.dd-role.viewer { background: #f0f2f5; color: #6b7a8c; }

.dropdown a {
  display: block; padding: 9px 12px; border-radius: 7px;
  color: #33455c; font-size: 13.5px; text-decoration: none; transition: .12s;
}
.dropdown a:hover { background: #f2f6fb; color: #1f3f66; text-decoration: none; }
.dd-sep { height: 1px; background: #eef1f5; margin: 5px 8px; }
.dropdown a.dd-logout { color: #b0483f; }
.dropdown a.dd-logout:hover { background: #fdf0ee; }

.who-line {
  display: flex; align-items: center; gap: 14px;
  padding: 0 0 20px; margin-bottom: 20px; border-bottom: 1px solid #eef1f5;
}
.avatar-lg {
  width: 46px; height: 46px; border-radius: 50%;
  background: #e8eef6; color: #2c5d8f;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700;
}
.who-name { font-size: 16px; font-weight: 700; color: #1f3f66; }
.who-sub { font-size: 12px; color: #6b7a8c; margin-top: 2px; }

.pill {
  display: inline-block; min-width: 22px; text-align: center;
  border-radius: 11px; padding: 1px 7px; font-size: 11.5px; font-weight: 600;
}
.pill-paid { background: #e6f4ea; color: #22734a; border: 1px solid #bfe3cb; }

@media (max-width: 760px) {
  .userbtn .uname { display: none; }
  .dropdown { right: 0; min-width: 210px; }
}

/* =========================================================
   印刷用（ブラウザの印刷 / PDF保存）
   ========================================================= */
@media print {
  @page { size: A4 landscape; margin: 10mm; }

  .topbar, .foot, .flash, .hint,
  .page-head .monthpick, .page-head .head-actions,
  .btn-primary, .btn-outline, .btn-mini,
  .actions, .sticky-actions, .cards { display: none !important; }

  body { background: #fff !important; color: #000; font-size: 11px; }
  .wrap { max-width: none; padding: 0; margin: 0; }

  .page-head { margin-bottom: 8px; }
  .page-head h1 { font-size: 15px; }

  h2.sec { font-size: 12px; margin: 14px 0 6px; page-break-after: avoid; }

  .table-wrap {
    border: none; border-radius: 0; overflow: visible; background: #fff;
  }
  table.grid { font-size: 10px; width: 100%; }
  table.grid th, table.grid td { padding: 3px 5px; }
  table.grid thead th { position: static !important; background: #eef2f7 !important; }
  .sticky-l { position: static !important; }

  tr, thead, tfoot { page-break-inside: avoid; }
  thead { display: table-header-group; }

  /* 入力欄は枠線だけ残して印刷 */
  input.cell-num {
    border: none !important; box-shadow: none !important;
    background: transparent !important; width: auto; text-align: right;
    font-size: 10px;
  }
  .tag, .pill, .badge-on, .badge-off { border: 1px solid #999; }
}

/* 画面表示でも印刷プレビュー時に崩れないよう */
@media print and (max-width: 1px) {
  .no-print { display: none; }
}

/* 社員一覧の操作列 */
td.ops { padding: 6px 8px; }
td.ops .btn-mini { margin: 1px 1px; font-size: 11px; padding: 2px 7px; }

@media (max-width: 760px) {
  .brand-logo { height: 24px; }
  .brand-sub { display: none; }
  .login-brand img { width: 200px; }
}

/* hidden フィールドは絶対に表示しない（印刷/PDF変換時の保険） */
input[type="hidden"] { display: none !important; }

/* input[type=submit] をボタンと同じ見た目に */
input.btn-primary, input.btn-outline {
  width: auto; cursor: pointer; font-family: inherit;
  -webkit-appearance: none; appearance: none;
}
input.btn-block { display: block; width: 100%; }
