:root {
  --navy: #10233f;
  --navy-dark: #0a1729;
  --blue: #2f6fed;
  --blue-dark: #1f52c0;
  --green: #1f9d55;
  --red: #d64545;
  --gray-50: #f7f8fa;
  --gray-100: #eef1f5;
  --gray-200: #dde2ea;
  --gray-400: #98a2b3;
  --gray-600: #4b5565;
  --gray-800: #1f2733;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(16, 35, 63, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--gray-50);
  color: var(--gray-800);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); }

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  gap: 12px;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar img.logo {
  height: 34px;
  width: auto;
  background: #fff;
  border-radius: 6px;
  padding: 3px 6px;
}

.topbar .company {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.topbar .user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.topbar button.link {
  background: none;
  border: none;
  color: #cdd7ee;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}
.topbar button.link:hover { color: #fff; }

main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* PIN pad */
.pin-screen { text-align: center; max-width: 340px; width: 100%; }
.pin-screen .logo-lg { max-width: 220px; height: auto; margin-bottom: 8px; }
.pin-screen h1 { font-size: 18px; color: var(--gray-600); font-weight: 500; margin: 0 0 20px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin-bottom: 22px; }
.pin-dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--gray-400); display: inline-block;
}
.pin-dots span.filled { background: var(--blue); border-color: var(--blue); }
.pin-error { color: var(--red); font-size: 14px; min-height: 20px; margin-bottom: 10px; }
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pin-keypad button {
  font-size: 24px;
  padding: 18px 0;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: #fff;
  cursor: pointer;
  color: var(--gray-800);
}
.pin-keypad button:active { background: var(--gray-100); }
.pin-keypad button.ghost { border: none; background: none; color: var(--gray-600); font-size: 15px; }

/* Clock button */
.clock-status { text-align: center; }
.clock-status .state { font-size: 15px; color: var(--gray-600); margin-bottom: 14px; }
.clock-btn {
  width: 100%;
  max-width: 320px;
  padding: 28px 0;
  font-size: 22px;
  font-weight: 600;
  border: none;
  border-radius: 20px;
  color: #fff;
  cursor: pointer;
  background: var(--green);
  box-shadow: var(--shadow);
}
.clock-btn.out { background: var(--red); }
.clock-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Tables */
table.report { width: 100%; border-collapse: collapse; font-size: 14px; }
table.report th, table.report td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}
table.report th { color: var(--gray-600); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
table.report tr.total-row td { font-weight: 700; border-top: 2px solid var(--gray-200); border-bottom: none; }
table.report td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.report td.edit-cell { text-align: right; }
table.report button.edit-link {
  background: none; border: none; color: var(--blue); cursor: pointer; font-size: 13px; padding: 4px 6px;
}
.table-scroll { overflow-x: auto; }

.week-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.week-nav .range { font-weight: 600; font-size: 14px; }
.week-nav button {
  border: 1px solid var(--gray-200); background: #fff; border-radius: 10px; padding: 8px 12px; cursor: pointer;
}

h2.section-title { font-size: 15px; color: var(--gray-600); margin: 0 0 14px; font-weight: 600; }

/* Modal */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 23, 41, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal { background: #fff; border-radius: var(--radius); padding: 22px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-top: 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--gray-600); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: 10px; font-size: 15px;
}
.field textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
button.btn {
  border: none; border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
button.btn.primary { background: var(--blue); color: #fff; }
button.btn.primary:hover { background: var(--blue-dark); }
button.btn.ghost { background: var(--gray-100); color: var(--gray-800); }
button.btn.danger { background: var(--red); color: #fff; }
.form-error { color: var(--red); font-size: 13px; margin-top: 6px; min-height: 18px; }
.hint { color: var(--gray-600); font-size: 12px; margin-top: 6px; }

.history-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.history-list li { padding: 8px 0; border-bottom: 1px solid var(--gray-100); }
.history-list .meta { color: var(--gray-600); font-size: 12px; }

.admin-nav { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-nav button {
  border: 1px solid var(--gray-200); background: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 13px; cursor: pointer; font-weight: 600; color: var(--gray-600);
}
.admin-nav button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.employee-select { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.admin { background: #e6edff; color: var(--blue-dark); }
.badge.inactive { background: #f2d9d9; color: var(--red); }

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

@media (min-width: 640px) {
  main { padding: 30px 24px 70px; }
  .topbar { padding: 14px 28px; }
}
