/* ─────────────────────────── tokens ─────────────────────────── */
:root {
  --bg: #efe9dc;
  --bg-2: #e4dccb;
  --ink: #1f2429;
  --muted: #6b7178;
  --line: #d9d2c2;
  --white: #fffdf8;

  --teal: #5f9c8c;
  --teal-dark: #44776a;
  --teal-darker: #2f564c;
  --teal-light: #83b8a9;

  --cream: #f6eecd;
  --cream-line: #cdbd8c;
  --red: #d43c31;
  --red-ink: #c0392b;
  --blue-ink: #1c3f8a;
  --green: #2e9d5e;
  --amber: #e2a02a;

  --radius: 14px;
  --shadow: 0 10px 30px rgba(40, 30, 10, 0.12);
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-dial: "Oswald", "Arial Narrow", Impact, sans-serif;
  --font-stamp: "Special Elite", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -200px, #fff7e5 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  min-height: 100vh;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
code { background: #00000010; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: #fff; font-size: 0.85em; }
h2, h3 { margin: 0 0 10px; }
.muted { color: var(--muted); font-weight: 400; font-size: 0.9em; }

/* ─────────────────────────── topbar ─────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: #fffdf8cc; backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.02em; }
.brand-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--teal); box-shadow: inset 0 -3px 0 var(--teal-dark); }
.nav { display: flex; gap: 4px; margin-left: 10px; }
.nav-btn {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.nav-btn:hover { background: #00000008; color: var(--ink); }
.nav-btn.is-active { background: var(--teal); color: white; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-btn, .link-btn { white-space: nowrap; }
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand span:last-child { display: none; }
  .nav { margin-left: 0; }
  .nav-btn { padding: 6px 9px; font-size: 13px; }
  .who { display: none; }
}
.who { font-weight: 600; }
.link-btn { border: 0; background: none; color: var(--muted); text-decoration: underline; }
.icon-btn { border: 0; background: none; font-size: 18px; line-height: 1; }

main { padding: 24px 16px 60px; }
.view { max-width: 1100px; margin: 0 auto; }

/* ─────────────────────────── buttons ─────────────────────────── */
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600;
  background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08), inset 0 0 0 1px var(--line);
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--teal); color: white; box-shadow: 0 2px 0 var(--teal-dark); }
.btn-primary:hover { background: var(--teal-light); }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn-danger { background: #fff0ee; color: var(--red-ink); box-shadow: inset 0 0 0 1px #f3c4bf; }
.btn-wide { width: 100%; padding: 14px; font-size: 1.05em; }
.btn-sm { padding: 5px 10px; font-size: 0.85em; border-radius: 8px; }

/* ─────────────────────────── login ─────────────────────────── */
.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 120px); }
.login-card {
  width: min(420px, 100%); padding: 28px 30px 22px;
  background: var(--cream);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 27px, #cdbd8c66 27px 28px);
  border: 1px solid var(--cream-line);
  box-shadow: 0 25px 50px -20px rgba(60, 40, 0, 0.35), 0 2px 0 #e9dfb8;
  transform: rotate(-1.2deg);
  position: relative;
}
.login-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 44px; border-bottom: 2px solid var(--red);
}
.card-head { display: flex; justify-content: space-between; font-family: var(--font-dial); font-size: 12px; letter-spacing: 0.05em; color: #5b5136; }
.login-title { font-family: var(--font-stamp); font-size: 22px; margin: 28px 0 18px; color: #3f3820; font-weight: 400; }
#login-form label { display: block; margin-bottom: 12px; }
#login-form label span { display: block; font-family: var(--font-dial); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: #5b5136; margin-bottom: 4px; }
#login-form input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--cream-line); border-radius: 6px; background: #fffdf4;
  font-family: var(--font-stamp); font-size: 18px; color: var(--blue-ink);
}
#login-form input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.form-error { color: var(--red-ink); font-weight: 600; margin: 0 0 10px; }
.login-hint { font-size: 12px; color: #6d6447; margin: 14px 0 0; }

/* ─────────────────────────── clock scene ─────────────────────────── */
.scene {
  display: grid; grid-template-columns: minmax(300px, 420px) minmax(300px, 1fr);
  gap: 40px; align-items: start;
}
@media (max-width: 820px) {
  .scene { grid-template-columns: 1fr; gap: 24px; }
}

.recorder-wrap { position: relative; padding-top: 215px; }
.shadow {
  position: absolute; left: 10%; right: 10%; bottom: -14px; height: 30px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.28), transparent 70%);
  z-index: 0;
}

.recorder { position: relative; width: min(100%, 400px); margin: 0 auto; z-index: 1; user-select: none; }
.recorder.is-stamping .head { animation: thunk 0.35s ease-out; }
@keyframes thunk {
  0% { transform: translateY(0); }
  30% { transform: translateY(3px) rotate(0.3deg); }
  60% { transform: translateY(-1px) rotate(-0.2deg); }
  100% { transform: translateY(0); }
}

/* card area sits above the head, card sinks behind it */
.card-area { position: absolute; left: 0; right: 0; bottom: 100%; height: 150px; z-index: 0; }
.slot {
  position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%);
  width: 176px; height: 18px;
  background: linear-gradient(180deg, #2b3a36, #1b2623);
  border-radius: 4px 4px 0 0;
  box-shadow: inset 0 3px 4px rgba(0,0,0,0.7);
  z-index: 3;
}
.slot-lip { position: absolute; inset: auto -8px -2px -8px; height: 8px; background: var(--teal-dark); border-radius: 4px 4px 0 0; }

.timecard {
  position: absolute; left: 50%; bottom: -8px;
  width: 160px; height: 212px;
  margin-left: -80px;
  background: var(--cream);
  border: 1px solid #cdbd8c;
  border-radius: 2px;
  box-shadow: 2px 4px 10px rgba(0,0,0,0.25);
  padding: 7px 6px 5px;
  color: #3f3820;
  font-family: var(--font-dial);
  font-size: 7px;
  letter-spacing: 0.03em;
  transform: translateY(0) rotate(0deg);
  transition: transform 0.45s cubic-bezier(.5,0,.5,1);
  z-index: 2;
  cursor: pointer;
  overflow: hidden;
  outline: none;
}
.timecard:hover { transform: translateY(-8px) rotate(-1deg); }
.timecard:focus-visible { box-shadow: 0 0 0 3px var(--teal), 2px 4px 10px rgba(0,0,0,0.25); }
.timecard.is-inserted { transform: translateY(170px) rotate(0deg) !important; transition-duration: 0.5s; }
.timecard.is-ejecting { transform: translateY(-14px) !important; transition-duration: 0.35s; }
.tc-head { display: flex; justify-content: space-between; font-size: 7px; color: #5b5136; }
.tc-no b { font-size: 10px; color: var(--ink); }
.tc-name { border-bottom: 1px solid var(--red); padding: 4px 0 2px; margin-bottom: 3px; font-size: 7px; }
.tc-name b { font-size: 9px; }
.tc-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tc-grid th, .tc-grid td { border: 0.5px solid #c2b283; height: 16px; padding: 0; text-align: center; font-weight: 500; }
.tc-grid th { font-size: 6px; color: #7c7250; background: #efe6c3; }
.tc-grid th.io-in { color: #2c4f8f; }
.tc-grid th.io-out { color: var(--red); }
.tc-grid td.day { font-size: 6.5px; width: 20px; color: #6b6244; text-align: left; padding-left: 2px; }
.tc-grid tr.is-today td.day { color: var(--red-ink); font-weight: 700; }
.tc-grid td.stamp { font-family: var(--font-stamp); font-size: 7.5px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; }
.tc-grid td.stamp.in { color: var(--blue-ink); }
.tc-grid td.stamp.out { color: var(--red-ink); }
.tc-grid td.stamp.fresh { animation: inkin 0.6s ease-out; }
@keyframes inkin {
  0% { opacity: 0; transform: scale(1.6) rotate(-6deg); filter: blur(1px); }
  60% { opacity: 1; transform: scale(0.95) rotate(1deg); }
  100% { transform: scale(1) rotate(0); }
}
.tc-foot { display: flex; justify-content: space-between; margin-top: 4px; font-size: 7px; }
.tc-foot b { font-family: var(--font-stamp); font-size: 9px; color: var(--blue-ink); }

/* body */
.head {
  position: relative; z-index: 2;
  background: linear-gradient(180deg, var(--teal-light) 0%, var(--teal) 18%, var(--teal) 85%, var(--teal-dark) 100%);
  border-radius: 22px 22px 10px 10px;
  padding: 36px 24px 30px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.35),
    inset -6px 0 12px rgba(0,0,0,0.12),
    inset 6px 0 12px rgba(255,255,255,0.08);
}
.head::before {
  /* top lid line */
  content: ""; position: absolute; left: 12px; right: 12px; top: 10px; height: 10px;
  border-radius: 6px; background: linear-gradient(180deg, var(--teal-dark), transparent);
  opacity: 0.5;
}
.face {
  position: relative;
  border-radius: 12px;
  padding: 8px;
  background: linear-gradient(180deg, #3b665b, #2f564c);
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.25);
}
.dial {
  display: block; width: 100%; height: auto; border-radius: 8px;
  box-shadow: inset 0 0 0 2px #b9c1c5, inset 0 6px 12px rgba(0,0,0,0.12);
}
.dial .numbers text {
  font-family: var(--font-dial); font-weight: 700; font-size: 34px; fill: #1b1f22;
  text-anchor: middle; dominant-baseline: central;
}
.dial #hand-hour { stroke: #1b1f22; stroke-width: 7; stroke-linecap: round; }
.dial #hand-min { stroke: #1b1f22; stroke-width: 5; stroke-linecap: round; }
.dial #hand-sec { stroke: var(--red); stroke-width: 2; stroke-linecap: round; }
.dial .hub { fill: #1b1f22; }
.dial .tick { stroke: var(--red); stroke-width: 3; stroke-linecap: round; }
.dial .tick-min { stroke: #4a5257; stroke-width: 1.5; }
.digital {
  position: absolute; right: 18px; bottom: 14px;
  font-family: var(--font-dial); font-size: 13px; letter-spacing: 0.12em;
  color: #2a3a35; background: #d7dde0; padding: 2px 8px; border-radius: 4px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.25);
}

.base {
  position: relative; z-index: 2;
  margin-top: 6px;
  background: linear-gradient(180deg, var(--teal-light) 0%, var(--teal) 10%, var(--teal) 88%, var(--teal-dark) 100%);
  border-radius: 10px 10px 18px 18px;
  padding: 26px 40px 34px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), inset -6px 0 12px rgba(0,0,0,0.12), 0 14px 20px -10px rgba(0,0,0,0.3);
}
.plate {
  height: 58px; border-radius: 6px;
  background: linear-gradient(180deg, #f2f4f5 0%, #c9cfd3 45%, #e6e9eb 50%, #b9c0c5 100%);
  box-shadow: inset 0 0 0 3px #86939a, inset 0 0 0 5px #dfe4e7, 0 2px 4px rgba(0,0,0,0.3);
  display: grid; place-items: center;
  font-family: var(--font-dial); font-size: 14px; letter-spacing: 0.3em; color: #6d7a81;
  text-shadow: 0 1px 0 #fff;
}
.plate.is-busy { color: var(--red-ink); }
.keyhole {
  width: 34px; height: 34px; margin: 22px auto 0; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #e8ecee, #8f9a9f 60%, #5d686e);
  box-shadow: 0 2px 4px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.6);
  display: grid; place-items: center;
}
.keyhole span { width: 7px; height: 14px; background: #1b1f22; border-radius: 3px 3px 1px 1px; }
.feet { height: 10px; margin: 0 24px; background: #2f564c; border-radius: 0 0 8px 8px; }

/* ─────────────────────────── panel ─────────────────────────── */
.panel { padding-top: 10px; }
.greeting { font-size: 34px; letter-spacing: -0.01em; margin-bottom: 8px; }
.status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.status-pill {
  padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase;
  background: #e6e2d7; color: var(--muted);
}
.status-pill[data-state="working"] { background: #daf3e4; color: #1d6f41; }
.status-pill[data-state="break"] { background: #fdeed0; color: #9a5f05; }
.status-pill[data-state="working"]::before, .status-pill[data-state="break"]::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 7px;
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { opacity: 0.3; } }
.status-since { color: var(--muted); font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.stat { background: var(--white); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat-label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { display: block; font-family: var(--font-dial); font-size: 24px; font-weight: 500; margin-top: 2px; }
.progress { height: 8px; border-radius: 999px; background: #00000012; overflow: hidden; margin-bottom: 24px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--green)); transition: width 0.6s ease; }
.progress-bar.is-done { background: linear-gradient(90deg, var(--green), #ffd166); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.punch {
  display: none; flex-direction: column; align-items: flex-start; gap: 2px;
  border: 0; border-radius: 14px; padding: 16px 18px; text-align: left; color: white;
  box-shadow: 0 6px 0 var(--btn-shadow, #333), 0 10px 20px -8px rgba(0,0,0,0.4);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
  position: relative;
}
.punch.is-visible { display: flex; }
.punch.is-primary { grid-column: 1 / -1; padding: 22px 22px; }
.punch:hover { filter: brightness(1.06); }
.punch:active, .punch.is-pressed { transform: translateY(5px); box-shadow: 0 1px 0 var(--btn-shadow, #333), 0 4px 10px -6px rgba(0,0,0,0.4); }
.punch:disabled { opacity: 0.6; cursor: wait; }
.punch-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.85; }
.punch-label { font-family: var(--font-dial); font-size: 26px; font-weight: 700; letter-spacing: 0.06em; line-height: 1; }
.punch.is-primary .punch-label { font-size: 34px; }
.punch-in { background: linear-gradient(180deg, #3db273, #2e9d5e); --btn-shadow: #1f7343; }
.punch-out { background: linear-gradient(180deg, #e65a4d, #d43c31); --btn-shadow: #9b2b22; }
.punch-break { background: linear-gradient(180deg, #f0b142, #e2a02a); --btn-shadow: #a8731a; }
.punch-resume { background: linear-gradient(180deg, #4e8fe0, #3a78c7); --btn-shadow: #27568f; }
.hint { color: var(--muted); font-size: 13px; margin: 14px 0 22px; }

.today-list h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.punch-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.punch-list li { display: flex; align-items: center; gap: 10px; background: var(--white); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); font-size: 14px; }
.punch-list .time { font-family: var(--font-stamp); margin-left: auto; font-size: 15px; }
.punch-list .empty { color: var(--muted); box-shadow: none; background: transparent; padding-left: 0; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; }
.tag.in, .tag.break_end { background: #dce7fb; color: var(--blue-ink); }
.tag.out { background: #fde1dd; color: var(--red-ink); }
.tag.break_start { background: #fdeed0; color: #9a5f05; }

/* toast + confetti */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 12px 18px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 50; animation: toast-in 0.3s ease-out;
}
.toast.is-error { background: var(--red-ink); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

/* ─────────────────────────── pages (time card / admin) ─────────────────────────── */
.page { display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-head h2 { font-size: 28px; }
.date-nav { display: flex; gap: 6px; align-items: center; }
.date-nav input[type="date"] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }
.box { background: var(--white); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.box h3 { font-size: 16px; }
.day-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.day-totals div { background: #f6f2e8; border-radius: 10px; padding: 8px 10px; }
.day-totals span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.day-totals b { font-family: var(--font-dial); font-size: 20px; font-weight: 500; }
@media (max-width: 500px) { .day-totals { grid-template-columns: 1fr 1fr; } }

.timeline { position: relative; height: 26px; border-radius: 8px; background: #efeadf; margin-bottom: 14px; overflow: hidden; }
.timeline .seg { position: absolute; top: 0; bottom: 0; }
.timeline .seg.work { background: var(--teal); }
.timeline .seg.break { background: var(--amber); }
.timeline .seg.running { background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255,255,255,0.25) 6px 12px); }
.timeline .hour { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(0,0,0,0.08); }
.timeline .hour::after { content: attr(data-h); position: absolute; top: 2px; left: 3px; font-size: 9px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.table tfoot th { font-size: 14px; color: var(--ink); border-bottom: 0; }
.table .num { font-family: var(--font-dial); font-size: 15px; }
.table tr.is-today td { background: #f3f8f6; }
.table .empty td { color: var(--muted); text-align: center; padding: 18px; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 90px; margin-top: 14px; }
.bars .bar { background: var(--teal); border-radius: 6px 6px 2px 2px; min-height: 2px; position: relative; }
.bars .bar.is-today { background: var(--green); }
.bars .bar::after { content: attr(data-label); position: absolute; top: 100%; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); margin-top: 3px; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input, .stack-form input:not([type="checkbox"]) { padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.stack-form { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.form-msg { font-size: 13px; color: var(--muted); }
.form-msg.ok { color: #1d6f41; }
.form-msg.err { color: var(--red-ink); }

.state-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: #b9b3a6; }
.state-dot.working { background: var(--green); }
.state-dot.break { background: var(--amber); }
