/* ============================================================
   ZIOBIT WEBシステムツール - スタイル
   （StaffBoardのデザイン言語を踏襲・テーマ色は設定で変更可能）
============================================================ */
:root {
  --theme: #0f766e;
  --theme-dark: #0d5f59;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* ============ ログイン ============ */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--theme) 0%, var(--theme-dark) 60%, #083f3b 100%);
}
.login-box {
  width: 100%; max-width: 400px; background: var(--card);
  border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,.25); overflow: hidden;
}
.login-head { text-align: center; padding: 28px 24px 8px; }
.login-head .sys-logo { width: 64px; height: 64px; border-radius: 14px; }
.login-head h1 { font-size: 19px; margin: 12px 0 2px; }
.login-head .sub { color: var(--muted); font-size: 13px; }
.login-body { padding: 20px 28px 30px; }
.login-error {
  display: none; background: #fef2f2; color: var(--danger);
  border: 1px solid #fecaca; border-radius: 8px;
  padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}

/* ============ ヘッダー・ナビ ============ */
.header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--theme); color: #fff; padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; min-width: 0; }
.brand img { width: 28px; height: 28px; border-radius: 6px; background: #fff; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.user-chip {
  background: rgba(255,255,255,.16); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; max-width: 180px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-mark { color: #fbbf24; margin-right: 4px; }
.icon-btn {
  background: none; border: none; color: #fff; font-size: 17px;
  padding: 8px 10px; cursor: pointer; border-radius: 8px;
}
.icon-btn:hover { background: rgba(255,255,255,.15); }

.nav {
  display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 0 8px; position: sticky; top: 48px; z-index: 40;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav button {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; border-bottom: 3px solid transparent;
  color: var(--muted); padding: 12px 13px 9px; font-size: 13.5px;
  cursor: pointer; white-space: nowrap;
}
.nav button.active { color: var(--theme); border-bottom-color: var(--theme); font-weight: 700; }
.nav button:hover { color: var(--theme); }
body:not(.admin-mode) .admin-only { display: none !important; }

.main { max-width: 1180px; margin: 0 auto; padding: 18px 20px 60px; }
/* スタッフ管理画面のみ全幅レイアウト（一覧を広く使うため） */
body.wide-view .main { max-width: 100%; }

/* ============ 共通部品 ============ */
h2.page-title { font-size: 18px; margin: 4px 0 14px; display: flex; align-items: center; gap: 9px; }
h2.page-title i { color: var(--theme); }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card h3 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h3 i { color: var(--theme); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--theme); color: #fff; border: none;
  border-radius: 9px; padding: 9px 16px; font-size: 14px;
  cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--theme-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f8fafc; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }

.form-row { margin-bottom: 13px; }
.form-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 5px; }
.form-control {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 9px;
  padding: 9px 12px; background: #fff;
}
.form-control:focus { outline: 2px solid var(--theme); outline-offset: 0; border-color: var(--theme); }
.form-hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .form-control { width: auto; flex: 1; min-width: 140px; }

/* テーブル（PC）→ カード（スマホ） */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th {
  text-align: left; background: #f8fafc; color: var(--muted);
  font-size: 12px; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:hover td { background: #f8fafc; }

/* スタッフ一覧: 枠（フレーム）を固定し、一覧はその中で縦横スクロールする
   縦: 画面の約6割で固定 ／ 横: 枠内でスクロール（ページ全体は広がらない） */
#viewStaff .card { overflow: hidden; }             /* カードからはみ出させない */
#viewStaff .table-wrap {
  max-height: 62vh; overflow: auto;              /* 縦横ともに枠内スクロール */
  width: 100%; max-width: 100%;
  border: 1px solid var(--line); border-radius: 9px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#viewStaff table.list {
  width: max-content;                             /* 内容ぶんの幅・枠を超えたら枠内で横スクロール */
  min-width: 100%;                                /* 内容が少ないときは枠いっぱい */
}
#viewStaff table.list thead th {
  position: sticky; top: 0; z-index: 2;           /* 見出し行は縦スクロールしても上部に固定 */
  background: #f8fafc; box-shadow: 0 1px 0 var(--line);
}
@media (max-width: 640px) {
  #viewStaff .table-wrap { max-height: 70vh; }
}

.badge {
  display: inline-block; border-radius: 999px; font-size: 11.5px;
  padding: 2px 10px; font-weight: 700; white-space: nowrap;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-staff2 { background: #e0f2fe; color: #075985; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-suspended { background: #fee2e2; color: #991b1b; }
.badge-deleted { background: #f1f5f9; color: #64748b; }
.badge-on { background: #dcfce7; color: #166534; }
.badge-off { background: #f1f5f9; color: #64748b; }

/* ============ ホーム: システムタイル（業務イラスト・統一カード） ============ */
.tiles {
  --tile-gap: 22px; --ill-size: 108px; --ill-svg: 70px; --card-h: 214px;
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: var(--tile-gap); justify-content: center;
  max-width: 1200px; margin: 0 auto;
}
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  height: var(--card-h);
  text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid #edf0f4; border-radius: 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 22px rgba(16,24,40,.055);
  padding: 24px 12px 18px; text-align: center;
  transition: transform .16s ease, box-shadow .16s ease;
}
/* カード上部の機能別アクセントライン（色は --accent = 各システムの色） */
.tile::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--accent, var(--theme)); border-radius: 16px 16px 0 0;
}
.tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(16,24,40,.08), 0 18px 34px rgba(16,24,40,.11);
}
/* イラスト表示領域（背景円・SVGサイズを全カードで統一） */
.tile .t-ill {
  width: var(--ill-size); height: var(--ill-size); border-radius: 50%;
  background: #f1f4f8; display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.tile .t-ill-svg { width: var(--ill-svg); height: var(--ill-svg); display: block; }
.tile .t-name { margin-top: 15px; font-weight: 700; font-size: 15px; line-height: 1.34; letter-spacing: .01em; color: var(--text); }
.tile .t-note { margin-top: 5px; font-size: 11px; color: var(--muted); line-height: 1.35; font-weight: 500; max-width: 96%; }
.empty-note { color: var(--muted); text-align: center; padding: 30px 10px; }
@media (max-width: 1160px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 900px)  { .tiles { grid-template-columns: repeat(3, 1fr); } }

/* ============ モーダル ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100;
  display: none; align-items: flex-start; justify-content: center;
  padding: 4vh 14px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 9px;
  background: var(--theme); color: #fff; padding: 13px 18px; font-weight: 700;
}
.modal-body { padding: 18px; max-height: 68vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 13px 18px; border-top: 1px solid var(--line); background: #f8fafc;
}
.confirm-text { font-size: 14.5px; }
.confirm-target {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 14px; margin: 12px 0; font-size: 14px;
}

/* チェックボックス群 */
.check-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 14px; }
.check-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--theme); }

/* トグルスイッチ */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: none; }
.switch-label { font-size: 14.5px; font-weight: 700; }
.switch-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px;
  cursor: pointer; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============ QRコード ============ */
.qr-area { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 0; }
.qr-box { background: #fff; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.qr-box img, .qr-box canvas { display: block; width: 220px !important; height: 220px !important; image-rendering: pixelated; }
.qr-url { font-size: 13px; color: var(--muted); word-break: break-all; text-align: center; }

/* ============ 操作履歴 ============ */
.audit-item { border-bottom: 1px solid var(--line); padding: 9px 2px; font-size: 13px; }
.audit-item .a-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audit-item .a-action { font-weight: 700; color: var(--theme); }
.audit-item .a-date { color: var(--muted); font-size: 12px; }
.audit-item .a-detail { color: var(--text); margin-top: 2px; word-break: break-all; }
.audit-item .a-meta { color: var(--muted); font-size: 11.5px; }

/* ============ トースト ============ */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff; border-radius: 10px;
  padding: 11px 20px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: .25s; z-index: 200; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ============ スマホ調整 ============ */
@media (max-width: 640px) {
  .main { padding: 14px 10px 70px; }
  .card { padding: 14px; }
  .nav { top: 47px; }
  .nav button span { font-size: 12.5px; }
  table.list { font-size: 12.5px; }
  table.list th, table.list td { padding: 7px 6px; }
  .hide-sp { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 12px; --ill-size: 92px; --ill-svg: 60px; --card-h: 198px; }
}
@media print {
  .header, .nav, .toolbar, .btn { display: none !important; }
}
