:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f172a;
  --primary-hover: #1e293b;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warning: #92400e;
  --warning-bg: #fffbeb;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.small { font-size: 0.86rem; }
.muted { color: var(--muted); }
.align-right { text-align: right; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.65rem, 5vw, 2.4rem); line-height: 1.12; letter-spacing: -0.035em; }
h2 { margin-bottom: 6px; font-size: 1.2rem; letter-spacing: -0.02em; }
p { line-height: 1.55; }

.eyebrow {
  margin-bottom: 7px;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 14px;
  color: #fff;
  background: var(--primary);
  font-size: 1.3rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
}

.brand-block { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.brand-block p:last-child { margin-bottom: 0; }

.employee-page {
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 30rem),
    var(--bg);
}

.employee-shell {
  width: min(100% - 30px, 600px);
  margin: 0 auto;
  padding: max(34px, env(safe-area-inset-top)) 0 max(30px, env(safe-area-inset-bottom));
}

.attendance-card { padding: clamp(22px, 5vw, 34px); }
.section-heading, .panel-heading, .dashboard-header, .modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.section-heading { margin-bottom: 24px; }
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.12); margin-top: 8px; }

.field-label { display: block; margin-bottom: 8px; color: #334155; font-size: 0.84rem; font-weight: 700; }
input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { border-color: #64748b; box-shadow: 0 0 0 4px rgba(100,116,139,.12); }
input:disabled { opacity: .65; background: #f1f5f9; }

.code-input {
  min-height: 58px;
  padding: 12px 16px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.code-input-small { min-height: 48px; font-size: 1rem; }

#attendanceForm { display: grid; gap: 12px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 750;
  transition: transform .12s ease, background .12s ease, border-color .12s ease, opacity .12s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .58; }
.button-large { min-height: 52px; }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover:not(:disabled) { background: var(--primary-hover); }
.button-secondary { color: #1e293b; background: #fff; border-color: #cbd5e1; }
.button-secondary:hover:not(:disabled) { background: #f8fafc; }
.button-ghost { color: #475569; background: transparent; border-color: var(--line); }
.button-danger-soft { color: #991b1b; background: #fff; border-color: #fecaca; }
.button-small { min-height: 34px; padding: 6px 10px; font-size: .82rem; border-radius: 9px; }

.progress-box {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  color: #334155;
  background: #f8fafc;
  border: 1px solid var(--line);
}
.progress-box p { margin: 3px 0 0; color: var(--muted); font-size: .88rem; }
.spinner { width: 22px; height: 22px; flex: 0 0 auto; border: 3px solid #dbe3ee; border-top-color: #334155; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert { margin-top: 14px; padding: 12px 14px; border-radius: 11px; border: 1px solid; line-height: 1.45; font-size: .9rem; }
.alert-error { color: var(--danger); background: var(--danger-bg); border-color: #fecaca; }
.alert-warning { color: var(--warning); background: var(--warning-bg); border-color: #fde68a; }

.camera-box {
  position: relative;
  overflow: hidden;
  margin-top: 16px;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  background: #0f172a;
}
.camera-box video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-label { position: absolute; left: 12px; bottom: 12px; padding: 5px 8px; border-radius: 999px; color: #fff; background: rgba(15,23,42,.72); font-size: .75rem; }

.privacy-note { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); color: #475569; font-size: .84rem; }
.privacy-note p { margin: 5px 0 0; }
.footer-note { margin: 16px 10px 0; text-align: center; color: var(--muted); font-size: .78rem; }

.success-pane { text-align: center; padding: 8px 0 0; }
.success-icon { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 999px; color: var(--success); background: var(--success-bg); border: 1px solid #bbf7d0; font-size: 1.7rem; font-weight: 900; }
.receipt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0; text-align: left; }
.receipt-grid > div { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.receipt-grid dt { color: var(--muted); font-size: .76rem; }
.receipt-grid dd { margin: 4px 0 0; font-weight: 800; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 430px); padding: 32px; }
.login-card .brand-mark { margin-bottom: 20px; }
.stack { display: grid; gap: 16px; margin-top: 24px; }

.dashboard { width: min(100% - 36px, 1240px); margin: 0 auto; padding: 34px 0 60px; }
.dashboard-header { align-items: center; margin-bottom: 22px; }
.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 16px; box-shadow: none; }
.toolbar label { width: 185px; }
.toolbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 16px 0; }
.summary-card { padding: 18px; box-shadow: none; }
.summary-card span { display: block; margin-bottom: 8px; color: var(--muted); font-size: .82rem; }
.summary-card strong { font-size: 1.8rem; letter-spacing: -.04em; }

.panel { margin-top: 16px; overflow: hidden; box-shadow: none; }
.panel-heading { align-items: center; padding: 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .panel-heading p { margin-bottom: 0; }
.search-input { width: min(280px, 42vw); min-height: 40px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 18px; border-bottom: 1px solid #edf2f7; text-align: left; vertical-align: middle; }
th { color: #64748b; background: #fbfdff; font-size: .74rem; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
td { color: #334155; font-size: .87rem; }
tbody tr:last-child td { border-bottom: 0; }
.employee-name { color: var(--text); font-weight: 800; }
.row-muted { opacity: .58; }
.actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 8px; border-radius: 999px; font-size: .76rem; font-weight: 750; white-space: nowrap; }
.badge-success { color: #166534; background: #dcfce7; }
.badge-neutral { color: #475569; background: #f1f5f9; }
.badge-warning { color: #92400e; background: #fef3c7; }
.code-badge { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; }
.empty-state { padding: 32px; color: var(--muted); text-align: center; }
.photo-thumb { width: 54px; height: 54px; display: block; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: #f1f5f9; }
.location-link { color: #1d4ed8; font-weight: 700; text-decoration: none; }
.location-link:hover { text-decoration: underline; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: min(420px, calc(100vw - 40px)); padding: 13px 16px; color: #fff; background: #991b1b; border-radius: 12px; box-shadow: 0 16px 40px rgba(15,23,42,.22); }

.modal { width: min(92vw, 520px); padding: 0; border: 0; border-radius: 18px; background: transparent; }
.modal::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); }
.modal-wide { width: min(94vw, 760px); }
.modal-card { display: grid; gap: 17px; padding: 24px; background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(15,23,42,.28); }
.modal-heading { align-items: flex-start; }
.modal-heading h2, .modal-heading p { margin-bottom: 0; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: #64748b; background: #fff; font-size: 1.3rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.generated-table-wrap { max-height: 50vh; border: 1px solid var(--line); border-radius: 12px; }
.generated-table-wrap table { min-width: 580px; }
.generated-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #0f172a; font-weight: 900; letter-spacing: .08em; }

@media (max-width: 760px) {
  .dashboard { width: min(100% - 22px, 1240px); padding-top: 22px; }
  .dashboard-header { align-items: flex-start; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar label { width: 100%; }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions .button { flex: 1 1 auto; }
  .summary-grid { grid-template-columns: 1fr; gap: 8px; }
  .summary-card { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
  .summary-card span { margin: 0; }
  .summary-card strong { font-size: 1.4rem; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .search-input { width: 100%; }
}

@media (max-width: 520px) {
  .employee-shell { width: min(100% - 20px, 600px); padding-top: 24px; }
  .brand-block { gap: 12px; }
  .brand-mark { width: 44px; height: 44px; }
  .attendance-card { padding: 20px; }
  .receipt-grid { grid-template-columns: 1fr; }
  .login-shell { padding: 12px; }
  .login-card { padding: 24px 20px; }
  .dashboard-header h1 { font-size: 1.7rem; }
  .modal-card { padding: 20px; }
}
