:root {
  --navy: #17325a;
  --navy-2: #1d3d6b;
  --primary: #1f6fe5;
  --primary-soft: #e8f0fe;
  --bg: #f3f6fa;
  --border: #e3e8ef;
  --text: #1f2a37;
  --muted: #6b7684;
  --green: #22a565;
  --blue: #2f7be8;
  --orange: #f29a1f;
  --red: #e5484d;
  --yellow-soft: #fff7db;
  --sidebar-w: 236px;
}

html { font-size: 14px; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { flex-shrink: 0; vertical-align: -0.2em; }

.btn { border-radius: 8px; font-weight: 500; }
.btn .icon { margin-right: 4px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.form-control, .form-select { border-radius: 8px; }
.btn:focus, .btn:active:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(31, 111, 229, .2);
}

/* ===== レイアウト ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-2) 0%, var(--navy) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  padding: 18px 14px;
  transition: transform .2s;
}

.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px 22px; }
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark { color: #fff; display: inline-flex; }
.brand-name { display: block; font-weight: 700; font-size: 1.25rem; letter-spacing: .02em; line-height: 1.2; }
.brand-sub { display: block; font-size: .72rem; opacity: .8; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-bottom { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 12px; display: flex; flex-direction: column; gap: 4px; }

.side-link {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255, 255, 255, .86);
  padding: 10px 14px; border-radius: 8px; font-size: .98rem;
}
.side-link:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.side-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(31, 111, 229, .35); }
.side-badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 7px; }

.sidebar-backdrop { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.demo-banner { background: #fff4d6; color: #7a5a00; font-size: .82rem; padding: 6px 24px; border-bottom: 1px solid #f3e2a9; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 10px 24px; position: sticky; top: 0; z-index: 1020;
}
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px;
  width: 360px; max-width: 100%; color: var(--muted); background: #fafbfd;
}
.topbar-search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: .9rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px; color: var(--muted); background: transparent; border: 0; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.bell-badge { position: absolute; top: 2px; right: 0; background: var(--red); color: #fff; border-radius: 999px; font-size: .68rem; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 4px; }

.user-menu { display: flex; align-items: center; gap: 10px; background: transparent; border: 0; padding: 4px 8px; border-radius: 8px; color: var(--text); }
.user-menu:hover { background: var(--bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; }
.user-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.user-company { font-size: .72rem; color: var(--muted); }
.user-name { font-size: .85rem; font-weight: 600; }

.content { padding: 22px 24px 32px; flex: 1; }
.app-footer { color: var(--muted); font-size: .78rem; padding: 12px 24px; border-top: 1px solid var(--border); background: #fff; }

/* ===== 共通パーツ ===== */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-size: 1.45rem; font-weight: 700; margin: 0; }
.page-sub { color: var(--muted); font-size: .88rem; margin-top: 2px; }

.panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.panel + .panel { margin-top: 18px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.panel-title h2 { font-size: 1.08rem; font-weight: 700; margin: 0; padding-left: 10px; border-left: 4px solid var(--primary); }
.panel-title .more { font-size: .85rem; }

.kpi { display: flex; gap: 16px; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px; height: 100%; }
.kpi-icon { width: 56px; height: 56px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.kpi-icon.green { background: var(--green); }
.kpi-icon.blue { background: var(--blue); }
.kpi-icon.orange { background: var(--orange); }
.kpi-icon.red { background: var(--red); }
.kpi-label { color: var(--muted); font-size: .85rem; }
.kpi-value { font-size: 1.85rem; font-weight: 700; line-height: 1.2; }
.kpi-value small { font-size: .9rem; font-weight: 600; margin-left: 2px; }
.kpi-note { color: var(--muted); font-size: .78rem; }

.table-app { margin: 0; font-size: .9rem; }
.table-app thead th { background: #f6f8fb; color: #4b5563; font-weight: 600; font-size: .82rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-app td, .table-app th { padding: .55rem .65rem; vertical-align: middle; }
.table-app tbody tr:hover { background: #fafcff; }
.table-wrap { overflow-x: auto; }
.ledger-table { font-size: .82rem; }
.ledger-table td, .ledger-table th { padding: .3rem .5rem; }
.ledger-table tbody th { white-space: nowrap; position: sticky; left: 0; background: #fff; }
.ledger-table .ledger-sub th, .ledger-table .ledger-sub td { background: #fafbfd; color: #4b5563; font-size: .78rem; }
.ledger-table tr.group-start > * { border-top: 2px solid #9aa5b5; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.pill-green { background: #e5f6ed; color: #17864f; }
.pill-orange { background: #fff1dc; color: #b46a00; }
.pill-red { background: #fde8e8; color: #c62f34; }
.pill-blue { background: var(--primary-soft); color: #1856b8; }
.pill-gray { background: #eef1f5; color: #586273; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

.tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--border); border-radius: 10px; padding: 14px; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(31, 111, 229, .12); text-decoration: none; color: var(--text); }
.tile-head { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.tile-sub { color: var(--muted); font-size: .8rem; }
.tile .icon.green { color: var(--green); }
.tile .icon.blue { color: var(--blue); }
.tile .icon.purple { color: #7a4fd6; }
.tile .icon.red { color: var(--red); }

.flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flow-box { flex: 1; min-width: 170px; border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; background: #fafcff; }
.flow-box .icon { color: var(--primary); }
.flow-box.master { background: #f2f7ff; }
.flow-box strong { display: block; margin-top: 4px; }
.flow-box span { font-size: .78rem; color: var(--muted); }
.flow-arrow { color: var(--muted); font-size: .78rem; text-align: center; }
.flow-arrow .icon { display: block; margin: 0 auto; color: var(--primary); }

.note-box { display: flex; gap: 10px; align-items: flex-start; background: #f2f7ff; border: 1px solid #d7e5fb; border-radius: 10px; padding: 10px 14px; font-size: .85rem; color: #2a4a7a; }
.note-box .icon { color: var(--primary); margin-top: 2px; }
.note-box.warn { background: #fff8e6; border-color: #f6e1a6; color: #6f5200; }
.note-box.warn .icon { color: var(--orange); }

/* ===== 勤務表 ===== */
.staff-list { max-height: calc(100vh - 260px); overflow-y: auto; margin: 0 -8px; }
.staff-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.staff-item:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.staff-item.active { background: var(--primary-soft); }
.staff-item .name { font-weight: 600; }
.staff-item .meta { font-size: .76rem; color: var(--muted); }

.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-chip { background: #f6f8fb; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; min-width: 92px; }
.stat-chip .label { font-size: .72rem; color: var(--muted); display: block; }
.stat-chip .value { font-weight: 700; font-size: 1.02rem; }

tr.day-sat td:first-child { color: #1856b8; }
tr.day-sun td:first-child { color: #c62f34; }
tr.row-corrected { background: var(--yellow-soft); }
tr.row-corrected:hover { background: #fff2c4 !important; }
tr.row-warning { background: #fff5f5; }
.was { display: block; font-size: .72rem; color: var(--muted); text-decoration: line-through; }

.diff-table td, .diff-table th { padding: 6px 10px; font-size: .88rem; }
.diff-changed { background: var(--yellow-soft); font-weight: 600; }

/* ===== ログイン ===== */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy-2), #2a5ea8); padding: 16px; }
.auth-card { background: #fff; border-radius: 14px; padding: 32px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.auth-brand { display: flex; align-items: center; gap: 10px; color: var(--navy); margin-bottom: 20px; }
.auth-brand .brand-sub { color: var(--muted); opacity: 1; }

/* ===== スマホ表示 ===== */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 1030; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 8px 16px; }
  .topbar-search { width: auto; flex: 1; }
  .user-text { display: none; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .staff-list { max-height: 280px; }
}
