*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cp: hsl(181, 60%, 32%);
  --cpd: hsl(201, 65%, 22%);
  --ca: hsl(181, 55%, 52%);
  --cl: hsl(181, 55%, 94%);
  --danger: hsl(0, 70%, 48%);
  --danger-bg: hsl(0, 70%, 96%);
  --success: hsl(140, 55%, 35%);
  --success-bg: hsl(140, 55%, 94%);
  --border: rgba(0, 0, 0, 0.1);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  color: #1a1a2e;
  background: #f4f6fb;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--cpd) 0%, var(--cp) 60%, var(--ca) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}

.hdr {
  max-width: 960px;
  margin: 0 auto;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  border: 2px solid rgba(255,255,255,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  font-weight: 700;
  flex-shrink: 0;
}

.site-name { font-size: 1.1rem; font-weight: 600; flex: 1; }

.nav-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .85rem;
}

.nav-user span { opacity: .85; }

.btn-logout {
  background: rgba(255,255,255,.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  padding: .3rem .85rem;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  text-decoration: none;
}

.btn-logout:hover { background: rgba(255,255,255,.28); }

/* ── Layout ──────────────────────────────────── */
main {
  flex: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  width: 100%;
}

footer {
  background: #1a1a2e;
  color: rgba(255,255,255,.5);
  text-align: center;
  padding: 1rem;
  font-size: .78rem;
  letter-spacing: .04em;
}

footer strong { color: rgba(255,255,255,.85); }

/* ── Page headings ───────────────────────────── */
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: .25rem;
}

.page-sub {
  font-size: .88rem;
  color: #666;
  margin-bottom: 1.5rem;
}

/* ── Alerts ──────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 1.25rem;
  border-left: 4px solid;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}

/* ── Forms ───────────────────────────────────── */
.form-card {
  background: #fff;
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 2px 14px rgba(0,0,0,.07);
  border: 1px solid var(--border);
  max-width: 420px;
  margin: 0 auto;
}

.form-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--cpd);
}

.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: #555;
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-control {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid #d0d5dd;
  border-radius: 8px;
  font-size: .95rem;
  color: #1a1a2e;
  background: #fff;
  transition: border-color .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--ca);
  box-shadow: 0 0 0 3px rgba(80, 194, 188, .15);
}

textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .6rem 1.4rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--cp);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.btn-primary:hover { opacity: .9; }

.btn-secondary {
  background: #f0f0f5;
  color: #444;
}

.btn-secondary:hover { background: #e4e4ec; }

.btn-block { width: 100%; text-align: center; }

/* ── Action button grid (attendance) ─────────── */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
  margin-bottom: 1.75rem;
}

@media (min-width: 600px) {
  .action-grid { grid-template-columns: repeat(4, 1fr); }
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: 1.1rem .75rem;
  border-radius: 12px;
  background: #fff;
  border: 1.5px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  color: var(--cpd);
  transition: box-shadow .15s, transform .1s;
  width: 100%;
}

.action-btn:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  transform: translateY(-1px);
}

.action-btn:active { transform: scale(.97); }

.action-btn .icon { font-size: 1.5rem; }

/* ── Tables ──────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-top: 1rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

th {
  background: var(--cl);
  color: var(--cpd);
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .6rem .9rem;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: .6rem .9rem;
  border-bottom: 1px solid #f0f0f5;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: #fafbff; }

.table-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 14px rgba(0,0,0,.07);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-card .table-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f0f0f5;
}

.table-card .table-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cpd);
}

/* ── Badges ──────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .18rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.badge-entry { background: #e7f9f1; color: #1d7a4d; }
.badge-exit { background: #fde8e8; color: #b91c1c; }
.badge-break_start { background: #fef3c7; color: #92400e; }
.badge-break_end { background: #e0f2fe; color: #075985; }
.badge-insert { background: var(--cl); color: var(--cpd); }

/* ── Filter bar ──────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  background: #fff;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  border: 1px solid var(--border);
}

.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ── Section links ───────────────────────────── */
.section-links {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

/* ── Login centered card ─────────────────────── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 65vh;
}

/* ── Detail readonly field ───────────────────── */
.readonly-field {
  background: #f4f6fb;
  border: 1.5px solid #e0e4ef;
  border-radius: 8px;
  padding: .55rem .85rem;
  font-size: .95rem;
  color: #444;
}

/* ── Audit detail JSON ───────────────────────── */
.audit-detail {
  font-family: monospace;
  font-size: .78rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: #555;
  max-width: 280px;
}

/* ── Empty state ─────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #aaa;
  font-size: .9rem;
}

/* ── Hero (index) ────────────────────────────── */
.hero { text-align: center; padding: 3rem 1rem 2rem; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 700; line-height: 1.2; color: #1a1a2e; margin-bottom: .75rem; }
.hero h1 span { color: var(--ca); display: block; }
.tagline { font-size: 1.05rem; color: #666; margin-bottom: .5rem; }
.desc { font-size: .92rem; color: #777; max-width: 520px; margin: .4rem auto 0; }
.cta { margin-top: 2rem; text-align: center; }
