:root {
  --pine: #404a3d;
  --pine-dark: #283027;
  --pine-soft: #e8ece6;
  --gold: #eec78c;
  --gold-dark: #a9752c;
  --cream: #f8f5ef;
  --paper: #fffdf9;
  --ink: #1e251f;
  --muted: #6b736b;
  --line: #dfe3dc;
  --danger: #9a3535;
  --success: #266844;
  --shadow: 0 18px 50px rgba(31, 43, 33, .09);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 85% 5%, rgba(238,199,140,.2), transparent 30rem), var(--cream); }
button, input, select { font: inherit; }
a { color: var(--pine); text-decoration-color: rgba(64,74,61,.35); text-underline-offset: 3px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .7rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4vw, 3.35rem); font-weight: 500; line-height: 1.05; letter-spacing: -.025em; }
h2 { margin-bottom: .75rem; font-size: 1.1rem; }
code { padding: .1rem .35rem; border-radius: .35rem; background: var(--pine-soft); }

.app-shell { min-height: 100vh; }
.page-area { min-width: 0; }
.landing, .auth-shell, .clock-shell { width: min(100% - 2rem, 620px); margin: 0 auto; }
.landing { min-height: 100vh; display: grid; align-content: center; justify-items: start; padding: 4rem 1rem; }
.landing > p:not(.eyebrow) { max-width: 38rem; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 0; }
.clock-shell { padding: max(1.25rem, env(safe-area-inset-top)) 0 max(2rem, env(safe-area-inset-bottom)); }

.brand-mark { width: 76px; height: 76px; display: grid; place-items: center; margin-bottom: 1.4rem; border: 1px solid rgba(238,199,140,.65); border-radius: 50%; color: var(--gold); background: var(--pine); font: 500 2rem Georgia, serif; box-shadow: 0 10px 30px rgba(40,48,39,.18); }
.brand-mark.small { width: 46px; height: 46px; flex: 0 0 46px; margin: 0; font-size: 1.25rem; }
.eyebrow { margin-bottom: .6rem; color: var(--gold-dark); font-size: .73rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.privacy-note { margin: 1.25rem 0 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }

.panel { padding: clamp(1.25rem, 3vw, 2rem); border: 1px solid rgba(64,74,61,.11); border-radius: var(--radius); background: rgba(255,253,249,.94); box-shadow: var(--shadow); }
.auth-card { width: 100%; }
.stack { display: grid; gap: 1rem; }
label { display: grid; gap: .45rem; color: var(--pine-dark); font-size: .86rem; font-weight: 700; }
label small { color: var(--muted); font-weight: 400; line-height: 1.5; }
input, select { width: 100%; min-height: 48px; padding: .72rem .85rem; border: 1px solid #cbd1c8; border-radius: 11px; outline: none; color: var(--ink); background: white; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { border-color: var(--gold-dark); box-shadow: 0 0 0 4px rgba(238,199,140,.25); }
input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--pine); }

.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; padding: .78rem 1.15rem; border: 1px solid var(--pine); border-radius: 12px; color: white; background: var(--pine); font-weight: 800; text-decoration: none; cursor: pointer; transition: transform .15s, background .15s, opacity .15s; }
.button:hover { background: var(--pine-dark); transform: translateY(-1px); }
.button:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.button-secondary { color: var(--pine); background: transparent; }
.button-secondary:hover { color: white; }
.button-out { border-color: #78403b; background: #78403b; }
.button-small { min-height: 40px; padding: .55rem .85rem; font-size: .85rem; }
.link-button { padding: 0; border: 0; color: var(--pine); background: transparent; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-button.danger { color: var(--danger); }

.mobile-header { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; margin-bottom: 1.4rem; padding: .7rem .2rem; }
.mobile-header h1 { margin: 0; font-size: clamp(1.55rem, 6vw, 2.25rem); }
.mobile-header .eyebrow { margin-bottom: .25rem; }
.live-clock { color: var(--pine); font-variant-numeric: tabular-nums; font-weight: 800; }
.shift-card { display: grid; gap: .3rem; margin-bottom: 1rem; padding: 1.35rem; border-radius: 18px; color: white; background: linear-gradient(135deg, var(--pine), var(--pine-dark)); box-shadow: 0 14px 35px rgba(40,48,39,.2); }
.shift-card span, .shift-card small { color: rgba(255,255,255,.7); }
.shift-card strong { font-size: 1.2rem; }
.action-panel { text-align: center; }
.state-message { margin-bottom: .65rem; font-weight: 800; }
.window { color: var(--muted); font-size: .82rem; }
.punch-button { width: min(100%, 310px); min-height: 94px; margin-top: 1rem; border-radius: 22px; font-size: 1.25rem; }
.location-status { min-height: 1.25em; margin: .7rem 0 0; color: var(--muted); font-size: .82rem; }
.subtle-form { margin-top: 1.4rem; text-align: center; }
.status-icon { width: 60px; height: 60px; display: grid; place-items: center; margin-bottom: 1rem; border-radius: 50%; font-size: 1.5rem; font-weight: 900; }
.status-error { color: var(--danger); background: #fae7e5; }

.flash { position: relative; z-index: 5; width: min(calc(100% - 2rem), 980px); margin: 1rem auto; padding: 1rem 1.2rem; border: 1px solid transparent; border-radius: 13px; box-shadow: 0 10px 30px rgba(31,43,33,.08); font-weight: 700; }
.flash-success { border-color: #b9d8c5; color: #1e603d; background: #e9f5ed; }
.flash-error { border-color: #edc1be; color: #862e2e; background: #fae9e7; }
.flash-warning { border-color: #e9d198; color: #72561a; background: #fff7df; }
.flash-code { border: 2px dashed var(--gold-dark); color: var(--pine-dark); background: #fff5df; font-size: 1.1rem; }

.admin-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.4rem; color: white; background: var(--pine-dark); }
.sidebar-brand { display: flex; gap: .8rem; align-items: center; margin-bottom: 2rem; color: white; font-weight: 800; text-decoration: none; line-height: 1.15; }
.sidebar-brand small { color: rgba(255,255,255,.58); font-weight: 500; }
.sidebar nav { display: grid; gap: .35rem; }
.sidebar nav a { padding: .72rem .8rem; border-radius: 10px; color: rgba(255,255,255,.78); text-decoration: none; font-weight: 650; }
.sidebar nav a:hover { color: white; background: rgba(255,255,255,.08); }
.sidebar form { margin-top: auto; }
.sidebar-logout { width: 100%; padding: .7rem; border: 1px solid rgba(255,255,255,.2); border-radius: 10px; color: rgba(255,255,255,.75); background: transparent; cursor: pointer; }
.admin-content { width: min(100% - 3rem, 1180px); margin: 0 auto; padding: 3rem 0 5rem; }
.page-heading { display: flex; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.5rem; }
.page-heading h1 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stats article { display: grid; gap: .6rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.7); }
.stats span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.stats strong { color: var(--pine); font: 500 2rem Georgia, serif; }
.panel + .panel { margin-top: 1rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .85rem .7rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; }
.empty { padding: 2rem; color: var(--muted); text-align: center; }
.badge { display: inline-flex; padding: .28rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.muted-badge { color: #626960; background: #eceeea; }
.open-badge { color: #765316; background: #fff0ca; }
.success-badge { color: var(--success); background: #e1f1e7; }
.employee-list { display: grid; gap: 1rem; }
.employee-card { display: grid; gap: 1.2rem; }
.employee-summary { display: flex; gap: .9rem; align-items: center; }
.employee-summary h2, .employee-summary p { margin: 0; }
.employee-summary p { margin-top: .3rem; color: var(--muted); font-size: .85rem; }
.avatar { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; color: var(--gold); background: var(--pine); font: 500 1.2rem Georgia, serif; }
.inline-grid { display: grid; grid-template-columns: 2fr 1fr auto; gap: .8rem; align-items: end; }
.card-actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.card-actions form { margin: 0; }
.upload-panel { max-width: 780px; margin-bottom: 1rem; }
.file-drop { padding: 1rem; border: 1px dashed #aeb7ab; border-radius: 14px; background: #f7f8f5; }
.export-count { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.export-count strong { color: var(--pine); font: 500 2.5rem Georgia, serif; }
.export-count span { color: var(--muted); }
.attendance-edit { display: grid; grid-template-columns: minmax(160px, .7fr) 2fr; gap: 1rem; align-items: end; }
.attendance-edit h2, .attendance-edit p { margin: 0; }
.attendance-edit p { margin-top: .3rem; color: var(--muted); }
.date-filter { display: flex; gap: .6rem; align-items: end; }
.settings-grid { display: grid; gap: 1rem; }
.settings-grid > .panel { margin: 0; }
.two-cols { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; }
.check-row { display: flex; flex-direction: row; align-items: center; gap: .7rem; }

.qr-sheet { width: min(100%, 650px); min-height: 830px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 1rem; padding: 3rem; border: 1px solid var(--line); background: white; text-align: center; box-shadow: var(--shadow); }
.qr-sheet h1 { font-size: 2.5rem; }
.qr-code { width: 340px; min-height: 340px; display: grid; place-items: center; margin: 1.5rem auto; padding: 10px; border: 1px solid var(--line); background: white; }
.qr-code img, .qr-code canvas { max-width: 100%; height: auto !important; }
.qr-url { max-width: 100%; overflow-wrap: anywhere; color: var(--muted); font-size: .72rem; }

@media (max-width: 900px) {
  .admin-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; display: block; padding: 1rem; }
  .sidebar-brand { margin-bottom: 1rem; }
  .sidebar nav { display: flex; overflow-x: auto; padding-bottom: .4rem; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar form { position: absolute; top: 1rem; right: 1rem; }
  .sidebar-logout { width: auto; }
  .admin-content { width: min(100% - 2rem, 760px); padding: 2rem 0 4rem; }
  .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .attendance-edit { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .landing, .auth-shell, .clock-shell { width: min(100% - 1.2rem, 620px); }
  .panel { border-radius: 17px; }
  .mobile-header { grid-template-columns: auto 1fr; }
  .live-clock { grid-column: 2; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .stats { gap: .65rem; }
  .stats article { padding: 1rem; }
  .inline-grid, .two-cols { grid-template-columns: 1fr; }
  .date-filter { align-items: stretch; }
  .qr-sheet { min-height: 0; padding: 2rem 1rem; }
  .qr-code { width: 290px; min-height: 290px; }
}

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: white; }
  .sidebar, .flash, .no-print { display: none !important; }
  .admin-shell { display: block; }
  .admin-content { width: 100%; padding: 0; }
  .qr-sheet { width: 100%; min-height: 270mm; margin: 0; border: 0; box-shadow: none; }
}

