:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #5e6a82;
  --border: #dde3ee;
  --primary: #1170ee;
  --primary-dark: #0a57bb;
  --secondary: #eff3fb;
  --error: #b42318;
  --ok: #067647;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #ffffff, #edf1fa 55%, #e7ecf7);
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.page.wide {
  display: block;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(20, 44, 92, 0.08);
  width: min(980px, 100%);
  padding: 24px;
}

.card.small {
  width: min(420px, 100%);
}

h1 {
  margin: 0 0 8px;
}

h2 {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  transition: 0.15s ease;
}

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

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

.btn.secondary {
  background: var(--secondary);
  border-color: var(--border);
  color: var(--text);
}

.btn.danger {
  color: var(--error);
  border-color: #fecdca;
  background: #fff7f6;
}

.btn.admin {
  margin-top: 14px;
  background: #151b27;
  color: #fff;
}

.btn.compact {
  padding: 8px 10px;
}

.status {
  margin-top: 8px;
}

.ok {
  color: var(--ok);
}

.error {
  color: var(--error);
}

.flash-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  display: grid;
  gap: 10px;
  z-index: 1200;
}

.flash-toast {
  min-width: 260px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  box-shadow: 0 10px 24px rgba(20, 44, 92, 0.16);
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  transform: translateY(-8px);
  opacity: 0;
  animation: toast-in 0.2s ease forwards;
}

.flash-toast.ok {
  color: #065f46;
  background: #ecfdf3;
  border-color: #abefc6;
}

.flash-toast.error {
  color: #912018;
  background: #fef3f2;
  border-color: #fecdca;
}

.flash-toast.hide {
  animation: toast-out 0.2s ease forwards;
}

@keyframes toast-in {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes toast-out {
  to {
    transform: translateY(-8px);
    opacity: 0;
  }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
}

.admin-grid > aside,
.admin-grid > section {
  min-width: 0;
}

.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.user-list a {
  display: block;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.user-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.user-list a small {
  display: block;
  color: var(--muted);
}

.user-create {
  margin-top: 14px;
}

.user-list a.active {
  background: #eaf2ff;
  border-color: #b7d1ff;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

.week-filter {
  display: grid;
}

.create-punch {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.print-form {
  margin: 8px 0 14px;
}

.week-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 10px;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f9fbff;
}

.print-page {
  padding-top: 12px;
}

.print-card {
  width: min(920px, 100%);
}

.print-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.print-week {
  margin-top: 18px;
  page-break-inside: avoid;
}

td form {
  margin: 0;
}

.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

.pagination .active-page {
  background: #eaf2ff;
  border-color: #b7d1ff;
}

.pagination .disabled {
  opacity: 0.6;
  pointer-events: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

.link {
  color: var(--primary);
  text-decoration: none;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 18px;
  opacity: 0.85;
}

@media (max-width: 860px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
  }
}

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

  .page,
  .page.wide {
    min-height: auto;
    padding: 0;
    display: block;
  }

  .card,
  .print-card {
    width: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .print-actions {
    display: none;
  }
}
