:root {
  --bg: #f4f6f9; --card: #fff; --text: #1c2430; --muted: #6b7686; --line: #e2e7ee;
  --primary: #2563eb; --primary-dark: #1d4ed8; --good: #16a34a; --bad: #dc2626; --warn: #d97706; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.error { color: var(--bad); font-size: 13px; min-height: 1em; margin: 6px 0 0; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.center { text-align: center; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--card); border-radius: var(--radius); padding: 32px 24px; width: 100%; max-width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0 0 8px; font-size: 22px; text-align: center; }

.topbar { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex-wrap: wrap; }
#company-name { font-weight: 700; margin-right: auto; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav input { width: 150px; padding: 6px 8px; }
.tabbar { position: sticky; top: 49px; z-index: 9; background: var(--card); border-bottom: 1px solid var(--line); display: flex; gap: 2px; overflow-x: auto; padding: 4px 8px; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; font: inherit; font-size: 13px; padding: 8px 12px; cursor: pointer; color: var(--muted); border-radius: 8px; white-space: nowrap; }
.tab.active { color: var(--primary); font-weight: 700; background: #eff6ff; }
main { padding: 14px 12px 40px; max-width: 1100px; margin: 0 auto; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.card h2 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card h2 .spacer { flex: 1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.btn { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--text); text-decoration: none; display: inline-block; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.btn.primary:active { background: var(--primary-dark); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border: none; background: none; color: var(--muted); }
.btn.danger { color: var(--bad); }
.btn.link { border: none; background: none; color: var(--primary); padding: 0; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 20px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 14px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafbfc; position: sticky; top: 0; }
th.sticky, td.sticky { position: sticky; left: 0; background: var(--card); z-index: 1; }
th.sticky { z-index: 2; background: #fafbfc; }
tr.total td { font-weight: 700; border-top: 2px solid var(--text); }
tr.current td { background: #eff6ff; }
tr.dim td { color: var(--muted); }
td.inactive { background: #f4f6f9; }
table input.cell { width: 96px; padding: 4px 6px; text-align: right; font-size: 12px; border-radius: 6px; }
table input.cell.actual { background: #f0fdf4; border-color: #bbf7d0; }
table input.cell:placeholder-shown { background: #fff; }
table input.cell.mm { width: 60px; margin-top: 2px; font-size: 11px; color: var(--muted); }
table input.cell.mm.actual { color: var(--text); }
td.input-cell { background: #eff6ff; }
table input.cell.plan { background: #eff6ff; border-color: #bfdbfe; }
tr.section td { background: #f1f5f9; font-weight: 700; font-size: 12px; padding: 5px 8px; border-top: 2px solid var(--line); }
.legend-input { color: #bfdbfe; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
tr.imp-ng td { background: #fef2f2; }
.thumb { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge.A { background: #dcfce7; color: #166534; } .badge.B { background: #fef9c3; color: #854d0e; } .badge.C { background: #fee2e2; color: #991b1b; } .badge.ネタ { background: #e5e7eb; color: #374151; }
.badge.経費 { background: #dbeafe; color: #1e40af; } .badge.私費 { background: #fee2e2; color: #991b1b; }
.badge.完了 { background: #dcfce7; color: #166534; } .badge.進行中 { background: #dbeafe; color: #1e40af; } .badge.未着手 { background: #e5e7eb; color: #374151; } .badge.保留 { background: #fef9c3; color: #854d0e; }
.badge.採用 { background: #dcfce7; color: #166534; } .badge.選考中 { background: #dbeafe; color: #1e40af; } .badge.辞退, .badge.不採用, .badge.研修脱落 { background: #fee2e2; color: #991b1b; }
.bar { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar > div { height: 100%; background: var(--primary); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 20px 12px; overflow-y: auto; }
.modal-card { background: var(--card); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 640px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal-card.wide { max-width: 980px; }
.modal-card h3 { margin: 0 0 14px; font-size: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

@media (min-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }
}
