:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #1f2330;
  --muted: #6b7280;
  --border: #e2e4ea;
  --danger: #dc2626;
  --success: #16a34a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

header.top {
  padding: 16px 4px 8px;
}

header.top h1 {
  font-size: 20px;
  margin: 0 0 2px;
}

header.top p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

details.card summary {
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  list-style: none;
}

details.card summary::-webkit-details-marker {
  display: none;
}

details.card summary::before {
  content: '▸ ';
  color: var(--muted);
}

details.card[open] summary::before {
  content: '▾ ';
}

.employee-add-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.employee-add-form .field {
  margin-bottom: 10px;
}

.employee-add-form button {
  width: 100%;
  padding: 10px;
  margin-top: 4px;
}

.hint-text {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0;
}

#backupBtn {
  width: 100%;
  padding: 10px;
}

.restore-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.restore-row input[type="file"] {
  font-size: 13px;
}

.restore-row button {
  width: 100%;
  padding: 10px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 64px;
  font-family: inherit;
}

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.employee-name {
  margin-top: 6px;
  font-size: 13px;
  min-height: 18px;
}

.employee-name.ok {
  color: var(--success);
  font-weight: 600;
}

.id-name-row {
  display: flex;
  gap: 8px;
}

.id-name-row input {
  flex: 0 0 80px;
  min-width: 0;
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}

.employee-name-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7f7fa;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-name-box.ok {
  color: var(--text);
  font-weight: 700;
  background: #fff;
  border-color: var(--border);
}

.employee-name-box.error {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fecaca;
}

.employee-name.error {
  color: var(--danger);
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.month-nav button {
  border: none;
  background: var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
}

.month-nav .label {
  font-weight: 700;
  font-size: 15px;
}

.deadline-note {
  text-align: center;
  font-size: 12px;
  color: var(--danger);
  margin-bottom: 10px;
}

.deadline-note.passed {
  color: var(--danger);
  font-weight: 700;
}

.calendar.disabled,
.selected-list.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #2563eb;
  font-weight: 600;
  background: #f7f7fa;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

button.primary:disabled {
  background: #b7b9c4;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar .dow {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding-bottom: 4px;
}

.calendar .day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  background: #f7f7fa;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}

.calendar .day.empty {
  visibility: hidden;
  cursor: default;
}

.calendar .day.sun {
  color: #e0455a;
}

.calendar .day.sat {
  color: #2563eb;
}

.calendar .day.selected {
  background: var(--primary);
  color: #fff !important;
  font-weight: 700;
}

.selected-summary {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.selected-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f7f7fa;
  border-radius: 10px;
  padding: 8px;
}

.selected-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.selected-item .date-pill {
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.selected-item select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.selected-item .inline-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.selected-item input[type="text"],
.selected-item input[type="time"] {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 8px;
}

.selected-item .remove-btn {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 15px;
  padding: 4px 6px;
  flex-shrink: 0;
}

button.primary {
  width: 100%;
  padding: 13px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  margin-top: 16px;
}

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

button.secondary {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}

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

.link-row {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
}

.link-row a {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.pill {
  display: inline-block;
  background: #eef0fb;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 2px 8px;
  margin: 2px 3px 0 0;
  font-size: 12px;
}

.pill-alert {
  background: #fff1e6;
  color: #b45309;
}

.pill-muted {
  background: #eceef2;
  color: var(--muted);
}

.del-btn {
  border: none;
  background: none;
  color: var(--danger);
  font-size: 12px;
  padding: 4px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.overlay .card {
  width: 100%;
  max-width: 340px;
  margin: 0;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 24px 0;
  font-size: 13px;
}
