:root {
  color-scheme: light;
  --bg: #f7f3f3;
  --surface: #ffffff;
  --ink: #211819;
  --muted: #706163;
  --line: #e0d7d8;
  --primary: #b4232f;
  --primary-dark: #8f1722;
  --accent: #7d3550;
  --danger: #b4232f;
  --shadow: 0 18px 40px rgba(33, 24, 25, 0.1);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  padding: 0;
  accent-color: var(--primary);
}

a {
  color: inherit;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1.2rem;
  line-height: 1.2;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.week-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff0f1;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  max-width: 420px;
  padding: 4px;
  margin: 10px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tab {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.tab.active {
  background: var(--primary);
  color: #fff;
}

.subtabs {
  display: flex;
  gap: 8px;
  margin: -4px 0 18px;
}

.subtab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 850;
  cursor: pointer;
}

.subtab.active {
  border-color: var(--primary);
  background: #fff0f1;
  color: var(--primary-dark);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

.panel {
  width: min(720px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.panel-heading p {
  color: var(--muted);
}

.split {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.stack {
  display: grid;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(180, 35, 47, 0.16);
}

.button,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

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

.button.secondary {
  border-color: var(--line);
  background: #fff0f1;
  color: var(--ink);
}

.button.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.button.compact {
  min-height: 48px;
  white-space: nowrap;
}

.button.punch {
  width: 100%;
  min-height: 82px;
  margin-top: 18px;
  background: var(--primary);
  color: #fff;
  font-size: 1.5rem;
}

.button.punch.clocked-in {
  background: var(--danger);
}

.icon-button {
  width: 44px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.2rem;
}

.status-block {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 18px;
}

.status-block strong {
  font-size: 2rem;
  line-height: 1.05;
}

.status-block span,
.notice {
  color: var(--muted);
}

.notice {
  margin-top: 12px;
  font-size: 0.9rem;
}

.clock-fields {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.clock-fields label {
  display: grid;
  gap: 6px;
}

.location-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.report-controls {
  display: grid;
  grid-template-columns: 44px minmax(150px, 1fr) 44px auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.date-field {
  display: grid;
  gap: 6px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 460px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.punch-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.punch-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.punch-item strong {
  display: block;
  margin-bottom: 6px;
}

.punch-item p {
  color: var(--muted);
  line-height: 1.45;
}

.check-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #fff0f1;
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 850;
}

.check-badge.bad {
  background: #fff1f1;
  color: var(--danger);
}

.check-badge.warn {
  background: #fff7df;
  color: #87520c;
}

.employee-create {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(110px, 150px) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.employee-create label,
.employee-field {
  display: grid;
  gap: 6px;
}

.employee-list {
  display: grid;
  gap: 10px;
}

.employee-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(110px, 150px) auto auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.employee-active {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  white-space: nowrap;
}

.employee-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
  color: var(--muted);
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.settings-form label {
  display: grid;
  gap: 6px;
}

.settings-form .button {
  grid-column: span 2;
}

.backup-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.backup-panel p {
  color: var(--muted);
  margin-top: 4px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

@media (max-width: 700px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    display: grid;
  }

  .week-pill {
    justify-self: start;
  }

  .panel {
    padding: 16px;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .report-controls {
    grid-template-columns: 44px 1fr 44px;
  }

  .report-controls .button {
    grid-column: span 3;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .employee-create,
  .employee-row {
    grid-template-columns: 1fr;
  }

  .employee-active {
    min-height: 32px;
  }

  .location-field {
    grid-template-columns: 1fr;
  }

  .settings-form {
    grid-template-columns: 1fr;
  }

  .settings-form .button {
    grid-column: auto;
  }

  .backup-panel {
    display: grid;
  }
}
