:root {
  --purple: #5A1E78;
  --grey: #B4B4B4;
  --text: #4A4A4A;
  --bg: #F6F6F8;
  --white: #FFFFFF;
  --danger: #8B1E3F;
  --ok-bg: #E7F4EA;
  --ok-fg: #1B5E2A;
  --review-bg: #F4EDE3;
  --review-fg: #6B4A12;
  --ot-bg: #EFE6F4;
  --ot-fg: #5A1E78;
  --miss-bg: #F8E8ED;
  --miss-fg: #8B1E3F;
  --lock-bg: #EEEEF0;
  --lock-fg: #4A4A4A;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body.app {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--white);
  border-bottom: 1px solid #E4E4EA;
  padding: 14px 28px;
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.brand-logo {
  height: 44px;
  width: auto;
  display: block;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 4px;
  align-items: center;
}
.nav a, .nav .nav-btn {
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.nav a:hover, .nav .nav-btn:hover { background: #F0EAF4; text-decoration: none; }
.nav a.active {
  background: var(--purple);
  color: var(--white);
}
.nav form { display: inline; margin: 0; }

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px 64px;
}

.page h1 {
  color: var(--purple);
  font-weight: 650;
  font-size: 28px;
  margin: 0 0 8px;
}
.lede { color: #6a6a72; margin: 0 0 24px; }

.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.messages li {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.messages li.error, .messages li.warning {
  background: var(--miss-bg);
  color: var(--miss-fg);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--white);
  border: 1px solid #E8E8EE;
  border-radius: 14px;
  padding: 20px 22px;
}
.card .label { color: #6a6a72; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.card .value { font-size: 32px; font-weight: 650; color: var(--purple); margin-top: 6px; }
a.card-link { display: block; text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
a.card-link:hover { border-color: var(--purple); box-shadow: 0 0 0 2px rgba(98, 54, 255, 0.12); }

.toolbar {
  background: var(--white);
  border: 1px solid #E8E8EE;
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
}
.toolbar label { display: block; font-size: 12px; font-weight: 650; color: #6a6a72; margin-bottom: 6px; }
.toolbar .field { min-width: 140px; }

.input, select.input, textarea.input, input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="tel"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--grey);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--white);
}

.btn, button.btn {
  display: inline-block;
  padding: 11px 18px;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--purple); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--grey); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-large { padding: 16px 20px; font-size: 18px; width: 100%; }

.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 0 24px; }

.table-card {
  background: var(--white);
  border: 1px solid #E8E8EE;
  border-radius: 14px;
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
table.data th, table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #EEE;
  white-space: nowrap;
  font-size: 14px;
}
table.data th {
  background: #FAFAFC;
  color: var(--purple);
  font-weight: 650;
}
table.data tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-review { background: var(--review-bg); color: var(--review-fg); }
.badge-ot { background: var(--ot-bg); color: var(--ot-fg); }
.badge-miss { background: var(--miss-bg); color: var(--miss-fg); }
.badge-lock { background: var(--lock-bg); color: var(--lock-fg); }
.badge-neutral { background: #F0F0F3; color: var(--text); }

.empty {
  background: var(--white);
  border: 1px dashed var(--grey);
  border-radius: 14px;
  padding: 36px 28px;
  text-align: center;
}
.empty p { margin-top: 0; }

.form-card {
  background: var(--white);
  border: 1px solid #E8E8EE;
  border-radius: 14px;
  padding: 28px;
  max-width: 640px;
}
.form-card p { margin: 0 0 16px; }
.form-card label { font-weight: 650; display: block; margin-bottom: 6px; }
.help { color: #6a6a72; font-size: 13px; font-weight: 400; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: 6px 0; font-size: 14px; }

.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 28px 32px;
  color: var(--grey);
  font-size: 12px;
}
.footer a { color: var(--grey); }

.public-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.public-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 20px 24px;
  text-align: center;
  background: var(--white);
  border-bottom: 1px solid #E4E4EA;
}
.public-header img { height: 52px; width: auto; }
.public-main { flex: 1; padding: 32px 16px 48px; }
.narrow { max-width: 440px; margin: 0 auto; }

.muted { color: #6a6a72; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; }

.pagination { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.pagination a, .pagination span { padding: 6px 10px; }

.clock-card { background: var(--white); border-radius: 16px; padding: 28px; box-shadow: 0 8px 24px rgba(90,30,120,0.06); }
.clock-in { background: var(--purple); color: #fff; }
.clock-out { background: #6E4C82; color: #fff; }

.poster { width: min(800px, 100%); margin: 0 auto; text-align: center; }
.qr-row { display: flex; justify-content: space-around; gap: 20px; flex-wrap: wrap; margin-top: 30px; }
.qr-box { width: 350px; max-width: 100%; border: 3px solid var(--purple); padding: 20px; border-radius: 15px; background: var(--white); }
.qr-box.out { border-color: var(--grey); }
.qr-box img { width: 260px; height: 260px; }


/* --- Mobile navigation --- */
.topbar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
}
.brand-link { display: inline-flex; align-items: center; }
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #E4E4EA;
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--purple);
  border-radius: 1px;
  position: relative;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }
.nav-open .nav-toggle-bars { background: transparent; }
.nav-open .nav-toggle-bars::before { top: 0; transform: rotate(45deg); }
.nav-open .nav-toggle-bars::after { top: 0; transform: rotate(-45deg); }
.nav-logout { display: inline; margin: 0; }

@media (max-width: 900px) {
  .topbar {
    padding: 10px 14px;
  }
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    flex-wrap: nowrap;
  }
  .topbar-brand-row {
    width: 100%;
  }
  .brand-logo {
    height: 36px;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    padding: 10px 0 4px;
    border-top: 1px solid #E4E4EA;
    margin-top: 10px;
  }
  .nav.is-open {
    display: flex;
  }
  .nav a,
  .nav .nav-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 15px;
  }
  .nav-logout {
    display: block;
    width: 100%;
  }
  .nav-logout .nav-btn {
    width: 100%;
  }
  .page {
    padding: 20px 14px 48px;
  }
  .page h1 {
    font-size: 22px;
  }
  .lede {
    font-size: 14px;
    margin-bottom: 16px;
  }
  .row-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .row-actions .btn,
  .row-actions a.btn {
    width: 100%;
  }
  .toolbar {
    padding: 14px;
  }
  .toolbar .field {
    min-width: 100%;
    flex: 1 1 100%;
  }
  .cards {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .card {
    padding: 14px;
  }
  .card .value {
    font-size: 24px;
  }
  table.data {
    min-width: 560px;
  }
  .footer {
    padding: 16px 14px 28px;
    font-size: 13px;
  }
  .narrow {
    max-width: 100%;
  }
  .clock-card,
  .modal-dialog.fusion-modal {
    margin: 0;
  }
}

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

@media print {
  .topbar, .footer, .no-print { display: none !important; }
  body.app { background: white; }
}

.form-card.wide { max-width: 960px; }
#site-map { height: 360px; border-radius: 12px; margin: 12px 0; border: 1px solid #E8E8EE; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }


/* Payroll export preflight modal */
body.modal-open { overflow: hidden; }
.payroll-live-summary { min-height: 1.25em; margin-top: -8px; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 20, 55, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay[hidden] { display: none !important; }
.modal-dialog.fusion-modal {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(90, 30, 120, 0.28);
  border: 2px solid var(--purple);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 8px;
  border-bottom: 1px solid #E8E4EE;
}
.modal-header h2 {
  margin: 0;
  color: var(--purple);
  font-size: 1.25rem;
}
.modal-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
}
.modal-body { padding: 12px 20px 8px; }
.modal-summary {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--purple);
  margin: 0 0 12px;
}
.modal-section { margin: 14px 0; }
.modal-section h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--text);
}
.modal-list {
  margin: 0 0 8px;
  padding-left: 1.2rem;
  max-height: 160px;
  overflow: auto;
}
.modal-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  margin-top: 8px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 18px;
  border-top: 1px solid #E8E4EE;
}
.alert-danger {
  background: var(--miss-bg);
  color: var(--miss-fg);
  border: 1px solid #E0B4C0;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 12px;
}
