:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --text: #1e2420;
  --muted: #667067;
  --line: #d9ded8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warn-bg: #fff7d6;
  --ok-bg: #e9f7ef;
  --idle-bg: #eef2f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

a {
  color: var(--accent-dark);
}

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

.topbar strong {
  display: block;
}

.muted,
.since,
.date {
  color: var(--muted);
}

.logout,
.button,
button,
.google,
.subtabs a {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .7;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tabs a {
  flex: 0 0 auto;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--muted);
  text-decoration: none;
}

.tabs a.active {
  background: #d9f2ee;
  color: #093d38;
  font-weight: 700;
}

.container {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.flash {
  margin-bottom: 12px;
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.flash.success {
  background: var(--ok-bg);
}

.flash.error {
  background: #ffe8e5;
}

.status-panel,
.auth-panel,
.settings,
.admin-editor {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.status-panel {
  text-align: center;
}

.status-panel.working {
  background: var(--ok-bg);
}

.status-panel.idle {
  background: var(--idle-bg);
}

h1,
h2 {
  margin: 0 0 12px;
  letter-spacing: 0;
}

.status-panel h1 {
  font-size: 30px;
}

.punch {
  width: 100%;
  max-width: 430px;
  min-height: 76px;
  margin-top: 10px;
  color: white;
  border: 0;
  font-size: 22px;
  font-weight: 800;
}

.punch.start,
.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.punch.stop,
.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

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

.metrics article {
  min-height: 82px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.notice,
.summary,
.identity {
  margin: 14px 0;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--warn-bg);
  border: 1px solid #eadf9c;
}

.summary,
.identity {
  background: var(--surface);
  border-color: var(--line);
}

.identity span {
  display: block;
  color: var(--muted);
}

.section-head,
.month-nav,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.month-nav h1 {
  text-align: center;
  font-size: 22px;
}

.day-list {
  display: grid;
  gap: 8px;
}

.day-row {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

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

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

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

th {
  background: #eef2ef;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

fieldset {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  font-weight: 700;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-form {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
  margin: 10px 0 14px;
}

.edit-item {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.edit-item summary {
  cursor: pointer;
  font-weight: 700;
}

.auth-panel {
  max-width: 430px;
  margin: 50px auto;
}

.google {
  display: block;
  margin-top: 12px;
  text-align: center;
}

.or {
  margin: 16px 0;
  color: var(--muted);
  text-align: center;
}

.auth-panel h2 {
  margin: 0;
  font-size: 17px;
}

.passkey-login {
  width: 100%;
}

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.subtabs a {
  color: var(--muted);
  text-decoration: none;
}

.subtabs a.active {
  background: #d9f2ee;
  color: #093d38;
  font-weight: 700;
}

.security-grid {
  display: grid;
  gap: 14px;
}

.security-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.passkey-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.passkey-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.passkey-item span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.revoke-all {
  margin-top: 12px;
}

.qr-panel {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: center;
}

.qr-canvas {
  display: grid;
  place-items: center;
  width: 220px;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.qr-canvas img {
  display: block;
  width: 196px;
  height: 196px;
  image-rendering: pixelated;
}

.qr-details span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.qr-actions form {
  display: block;
}

.checkbox {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  width: 18px;
  min-height: 18px;
}

@media (max-width: 720px) {
  .container {
    padding: 12px;
  }

  .metrics,
  .day-row,
  .grid-form,
  .passkey-item,
  .qr-panel {
    grid-template-columns: 1fr;
  }

  .qr-canvas {
    width: 100%;
  }

  .metrics strong {
    font-size: 22px;
  }

  .section-head,
  .month-nav,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .month-nav h1 {
    order: -1;
  }

  .inline-form {
    width: 100%;
  }

  .inline-form input,
  .inline-form button,
  .actions .button {
    flex: 1;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .tabs,
  .flash,
  .qr-actions,
  .notice {
    display: none;
  }

  .container,
  .settings {
    width: 100%;
    border: 0;
    padding: 0;
  }

  .subtabs,
  .qr-details .muted {
    display: none;
  }

  .qr-panel {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}
