* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --border: #d2d2d7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-dark: #0058b0;
  --danger: #ff3b30;
  --success: #34c759;
  --header-h: 56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ---- ヘッダー ---- */

#header {
  height: var(--header-h);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.app-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

#corp-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.header-nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  padding: 6px 14px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--accent); color: white; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-right button {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}

#month-label {
  font-size: 14px;
  font-weight: 600;
  min-width: 80px;
  text-align: center;
}

/* ---- メイン ---- */

#main {
  margin-top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 20px;
}

.view { width: 100%; }
.hidden { display: none !important; }

.hint {
  text-align: center;
  padding: 60px;
  color: var(--muted);
}

/* ---- 出退勤テーブル ---- */

#attendance-table-wrap {
  overflow-x: auto;
}

.att-table {
  border-collapse: collapse;
  min-width: 100%;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.att-table th {
  background: #f2f2f7;
  padding: 10px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.att-table th.name-col {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 3;
  background: #f2f2f7;
}

.att-table td {
  border-bottom: 1px solid #f0f0f0;
  border-right: 1px solid #f0f0f0;
  padding: 0;
  vertical-align: middle;
}

.att-table td.name-cell {
  padding: 8px 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface);
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 100px;
}

.att-table td.role-cell {
  font-size: 11px;
  color: var(--muted);
}

.day-cell {
  text-align: center;
  min-width: 72px;
  cursor: pointer;
  padding: 6px 4px;
  transition: background 0.12s;
}

.day-cell:hover { background: #f0f6ff; }
.day-cell.weekend { background: #fafafa; }
.day-cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }

.day-cell .times {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
}

.day-cell .work-h {
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
}

.day-cell.empty-cell { color: var(--muted); font-size: 18px; }

/* ---- スタッフ ---- */

.staff-container {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

#staff-list {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.staff-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  gap: 12px;
}

.staff-row:last-child { border-bottom: none; }

.staff-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.staff-info { flex: 1; }
.staff-name { font-weight: 500; }
.staff-role { font-size: 11px; color: var(--muted); margin-top: 2px; }

.staff-deactivate {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
}

.staff-deactivate:hover { background: #fff0f0; color: var(--danger); }

.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
}

.card label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin: 10px 0 4px;
}

.card input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.card input:focus { border-color: var(--accent); }

button.primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  margin-top: 14px;
  transition: background 0.15s;
}

button.primary:hover { background: var(--accent-dark); }

/* ---- 月次集計 ---- */

.summary-table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.summary-table th {
  background: #f2f2f7;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.summary-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
}

.summary-table tr:last-child td { border-bottom: none; }

.summary-table .num { text-align: right; font-weight: 500; }
.summary-table .highlight { color: var(--accent); font-weight: 700; }

/* ---- モーダル ---- */

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 24px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

#modal h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-row label {
  width: 80px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.modal-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}

.modal-row input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  cursor: pointer;
}

.modal-actions button:not(.primary) {
  background: var(--bg);
  color: var(--text);
}

.modal-actions button.primary {
  background: var(--accent);
  color: white;
  font-weight: 500;
}

/* ---- トースト ---- */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  background: #1c1c1e;
  color: white;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  animation: slideUp 0.2s ease;
}

.toast.error { background: var(--danger); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
