:root {
  --bg: #f4f6f8;
  --card: #fff;
  --primary: #2563eb;
  --success: #16a34a;
  --danger: #dc2626;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: #0f172a;
  color: #fff;
}
.topbar a {
  color: #cbd5e1;
  text-decoration: none;
  margin-left: 16px;
}
.topbar a.active, .topbar a:hover { color: #fff; }
.topnav { display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: 75%; justify-content: flex-end; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; text-decoration: underline; padding: 0; font-size: inherit; }
.btn-link.danger { color: var(--danger); }
.status-paid_leave { background: #e0e7ff; color: #3730a3; }
.status-registered_absence { background: #fecaca; color: #7f1d1d; }
.status-special_leave { background: #f3e8ff; color: #6b21a8; }
.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-value { font-size: 2rem; font-weight: 700; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { border: 1px solid var(--border); padding: 10px; text-align: left; }
th { background: #f8fafc; }
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
}
.btn-secondary { background: #475569; }
.btn-danger { background: var(--danger); }
.form-group { margin-bottom: 12px; }
label { display: block; margin-bottom: 4px; font-weight: 600; }
input, select {
  width: 100%;
  max-width: 400px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.alert { padding: 12px; border-radius: 6px; margin-bottom: 12px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.footer { text-align: center; color: var(--muted); padding: 24px; font-size: 13px; }
.badge-in { color: var(--success); font-weight: 700; }
.badge-out { color: var(--primary); font-weight: 700; }

.stat-label { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.chart-wide { grid-column: 1 / -1; }
.chart-card h2 { margin: 0 0 12px; font-size: 1rem; }
@media (max-width: 768px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-wide { grid-column: auto; }
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-row .form-group { margin-bottom: 0; }
.filter-row input, .filter-row select { max-width: 200px; }
.filter-row input[type="search"] { max-width: 160px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 8px; }
.view-tabs {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  margin-bottom: 4px;
}
.view-tab {
  padding: 8px 16px;
  border-radius: 6px;
  background: #e2e8f0;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.view-tab:hover { background: #cbd5e1; }
.view-tab.active {
  background: var(--primary);
  color: #fff;
}
.card-filter { padding: 14px 16px; }
.filter-compact { display: flex; flex-direction: column; gap: 10px; }
.filter-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.period-line {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.period-mode {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.period-mode input { width: auto; max-width: none; margin: 0; }
.filter-line input[type="date"],
.filter-select,
.input-month-select {
  width: auto;
  max-width: none;
  padding: 6px 8px;
  font-size: 14px;
}
.input-month-select { min-width: 110px; }
.filter-select { min-width: 140px; max-width: 200px; }
.filter-inline-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
.filter-sep { color: var(--border); user-select: none; }
.range-tilde { color: var(--muted); font-size: 13px; }
.period-applied-inline { font-size: 12px; color: var(--muted); white-space: nowrap; }
.period-quick-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.period-quick-link:hover { text-decoration: underline; }
.hint-compact { margin: 6px 0 0; font-size: 12px; }
.view-tabs { margin-top: 10px; margin-bottom: 0; }
tr.row-total td {
  background: #f1f5f9;
  border-top: 2px solid #cbd5e1;
  font-weight: 600;
}
tfoot tr.row-total td { background: #e2e8f0; }
.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-header-row h2 { margin: 0; }
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.status-normal { background: #dcfce7; color: #166534; }
.status-late { background: #fef3c7; color: #92400e; }
.status-early_leave { background: #ffedd5; color: #9a3412; }
.status-working { background: #dbeafe; color: #1e40af; }
.status-incomplete { background: #fee2e2; color: #991b1b; }
.status-absent { background: #f1f5f9; color: #475569; }
.status-paid_leave { background: #e0e7ff; color: #3730a3; }
.status-registered_absence { background: #fce7f3; color: #9d174d; }

.btn-sm { padding: 4px 10px; font-size: 13px; }
.cell-note {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-break { font-size: 13px; }
.badge-count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  font-size: 11px;
  background: var(--border);
  border-radius: 3px;
  color: var(--muted);
}
.summary-mini { width: 100%; border-collapse: collapse; margin-top: 8px; }
.summary-mini th, .summary-mini td { padding: 6px 12px; text-align: left; }
.summary-mini th { color: var(--muted); font-weight: 500; width: 72px; }
.break-form .filter-row { margin-bottom: 12px; }
