:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1f27;
  --muted: #6b7280;
  --border: #e2e4e9;
  --accent: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --card: #1e2129;
    --text: #f2f3f5;
    --muted: #9aa0ab;
    --border: #2c303a;
    --accent: #3b82f6;
    --green: #22c55e;
    --red: #ef4444;
    --amber: #f59e0b;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: 24px;
  min-height: 100vh;
}

.tabs {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.tab {
  flex: 1;
  padding: 14px 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

main { padding: 16px; max-width: 480px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; }

.today-date {
  font-size: 15px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 4px;
}

.status {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.punch-btn {
  padding: 28px 8px;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  color: white;
  user-select: none;
}

.punch-btn:disabled,
.punch-btn.btn-disabled {
  opacity: 0.35;
}

.punch-in { background: var(--green); }
.punch-out { background: var(--red); }
.punch-break { background: var(--amber); }

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

.edit-today-btn {
  width: 100%;
  margin-top: 12px;
}

.today-summary {
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.7;
}

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

.week-label {
  font-weight: 700;
  font-size: 16px;
  text-align: center;
}

.icon-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 16px;
}

.week-days { display: flex; flex-direction: column; gap: 8px; }

.week-day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.week-day .wd-name { font-weight: 600; width: 44px; }
.week-day .wd-times { color: var(--muted); font-size: 13px; flex: 1; padding: 0 8px; }
.week-day .wd-hours { font-weight: 700; }
.week-day.today { border-color: var(--accent); }

.week-total {
  text-align: right;
  font-weight: 700;
  font-size: 16px;
  margin: 14px 4px;
}

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

.action-btn {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.action-btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.action-btn.danger { background: none; color: var(--red); border-color: var(--red); }

.status-line { text-align: center; color: var(--muted); font-size: 13px; min-height: 18px; }

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.field input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.checkbox-field span {
  display: inline;
  margin-bottom: 0;
  color: var(--text);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--card);
  width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 { margin-top: 0; font-size: 18px; }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.modal-actions .action-btn { flex: 1; padding: 12px; }
