*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #65727f;
  --line: #d8dee4;
  --panel: #ffffff;
  --surface: #f4f7f6;
  --field: #ffffff;
  --topbar: #ffffff;
  --ghost-bg: #e1f3f1;
  --tile-hover: #e6f6f4;
  --message-bg: #ecfdf5;
  --message-border: #b8ddd8;
  --message-ink: #064e3b;
  --error-bg: #fff1f0;
  --error-border: #f4b8b2;
  --admin-create-bg: #2563eb;
  --admin-create-hover: #1d4ed8;
  --submit-bg: #334155;
  --submit-hover: #1f2937;
  --pill-bg: #d1fae5;
  --pill-ink: #065f46;
  --warn-bg: #fef3c7;
  --danger-bg: #fee4e2;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #9a6700;
  --danger: #b42318;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5edf2;
  --muted: #a8b5bf;
  --line: #33424c;
  --panel: #162028;
  --surface: #0f171d;
  --field: #101a21;
  --topbar: #121c23;
  --ghost-bg: #153b3a;
  --tile-hover: #123d3b;
  --message-bg: #0f3029;
  --message-border: #247064;
  --message-ink: #a7f3d0;
  --error-bg: #3a1514;
  --error-border: #8f332d;
  --admin-create-bg: #3b82f6;
  --admin-create-hover: #60a5fa;
  --submit-bg: #3f4d5c;
  --submit-hover: #526173;
  --pill-bg: #113f32;
  --pill-ink: #86efac;
  --warn-bg: #3b300f;
  --danger-bg: #461918;
  --accent: #0f766e;
  --accent-dark: #5eead4;
  --warn: #facc15;
  --danger: #fca5a5;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
}

button, input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

button:hover { background: var(--accent-dark); }
button.ghost {
  color: var(--accent-dark);
  background: var(--ghost-bg);
}

button.admin-create {
  background: var(--admin-create-bg);
}

button.admin-create:hover {
  background: var(--admin-create-hover);
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-switch {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.theme-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.switch-track {
  position: relative;
  width: 48px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.18s ease;
}

.theme-switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.theme-switch input:focus-visible + .switch-track {
  outline: 3px solid var(--accent-dark);
  outline-offset: 2px;
}

.topbar h1,
.workspace h2,
.panel h2,
.panel h3 {
  margin: 0;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.layout {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px);
}

.app-version {
  position: fixed;
  left: 12px;
  bottom: 10px;
  z-index: 10;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.panel,
.workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  padding: clamp(18px, 4vw, 28px);
}

.compact {
  padding: 18px;
}

.workspace {
  padding: clamp(14px, 3vw, 24px);
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--field);
}

.message {
  margin-bottom: 16px;
  border: 1px solid var(--message-border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--message-ink);
  background: var(--message-bg);
}

.message.error {
  border-color: var(--error-border);
  color: var(--danger);
  background: var(--error-bg);
}

.month-head,
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.total {
  display: grid;
  justify-items: end;
  color: var(--muted);
}

.total span {
  color: var(--ink);
  font-size: 1.8rem;
  font-weight: 800;
}

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

.weekday {
  min-height: 28px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.day-tile {
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: space-between;
  justify-items: start;
  border: 1px solid var(--line);
  padding: 8px;
  color: var(--ink);
  background: var(--field);
}

.day-tile:hover,
.day-tile.active {
  border-color: var(--accent);
  background: var(--tile-hover);
}

.day-tile span {
  font-weight: 800;
}

.day-tile strong {
  font-size: clamp(0.8rem, 2.5vw, 1rem);
}

.entry-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 160px) auto;
  align-items: end;
  gap: 12px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.selected-date {
  margin: 0;
  font-weight: 800;
}

.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.submit {
  width: 100%;
  margin-top: 16px;
  background: var(--submit-bg);
}

.submit:hover {
  background: var(--submit-hover);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.status-list,
.employee-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(160px, 1fr) minmax(120px, auto) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.list-row span,
.list-row small {
  color: var(--muted);
}

.status-pill {
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--pill-ink);
  background: var(--pill-bg);
  font-size: 0.8rem;
  font-weight: 800;
}

.status-pill.warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.status-pill.danger {
  color: var(--danger);
  background: var(--danger-bg);
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-grid {
    gap: 4px;
  }

  .day-tile {
    padding: 6px;
  }

  .entry-form,
  .admin-grid,
  .list-row {
    grid-template-columns: 1fr;
  }

  .entry-form button {
    width: 100%;
  }

  .app-version {
    left: 8px;
    bottom: 8px;
    font-size: 0.72rem;
  }
}
