/* punchclock: a time clock for a bar's back room.
   One typeface (Archivo) used across its width axis: condensed and heavy for
   the stamped clock and times, normal width for the interface.
   Colour carries meaning: green = clock in, red = clock out, brass = pause. */

:root {
  --ink: #1c2a23;
  --paper: #edf0ea;
  --surface: #f7f9f5;
  --rule: #c5cfc6;
  --muted: #56655b;
  --in: #2d7a4b;
  --out: #a8382b;
  --pause: #8a6a12;
  --brass: #a9781f;
  --focus: #1f5fbf;
  --on-color: #ffffff;
  --radius-control: 10px;
  --space: 1rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e2e8e1;
    --paper: #121a16;
    --surface: #1a241f;
    --rule: #33443a;
    --muted: #9aaa9f;
    --in: #4caf74;
    --out: #e06a5b;
    --pause: #d5a73e;
    --brass: #d5a73e;
    --focus: #7fb0ff;
    --on-color: #0e1511;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
}

h1, h2 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; margin-top: 2rem; }
p { margin: 0 0 0.75em; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.label { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.loading { padding: 2rem; }

/* ---------------------------------------------------------------- frame */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.demo-banner {
  margin: 0;
  padding: 0.5rem var(--space);
  background: var(--brass);
  color: var(--on-color);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  padding: 0.75rem var(--space);
  border-bottom: 2px solid var(--ink);
}

.brand {
  font-stretch: 75%;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.company { color: var(--muted); }
.who { margin-left: auto; font-weight: 600; }

.content, .login {
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.5rem var(--space) 3rem;
  flex: 1;
}

.footer {
  padding: 1rem var(--space) 2rem;
  border-top: 1px solid var(--rule);
  text-align: center;
}

/* ---------------------------------------------------------------- controls */

button { cursor: pointer; }

.primary, .secondary, .danger {
  min-height: 3rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-control);
  border: 2px solid transparent;
  font-weight: 700;
}
.primary { background: var(--ink); color: var(--paper); }
.secondary { background: transparent; border-color: var(--ink); }
.danger { background: var(--out); color: var(--on-color); }

.link {
  background: none;
  border: none;
  padding: 0.25rem;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--surface);
  font-size: 1.5rem;
  line-height: 1;
}

.row-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 0.75rem; }
.row-actions.stacked { flex-direction: column; align-items: stretch; max-width: 26rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 1rem; }
.field span:first-child { font-weight: 600; }
.field[hidden] { display: none; }

input, select, textarea {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--muted);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.kinds { border: none; padding: 0; margin: 0 0 1rem; }
.kinds legend { font-weight: 600; margin-bottom: 0.4rem; }
.kinds label { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0; }
.kinds input { width: 1.25rem; min-height: 1.25rem; accent-color: var(--ink); }

.flash { padding: 0.75rem 1rem; border-left: 5px solid var(--in); background: var(--surface); font-weight: 600; }
.flash.error { border-left-color: var(--out); }
.error { color: var(--out); font-weight: 600; }

.badge {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--out);
  color: var(--on-color);
  font-size: 0.8rem;
  text-align: center;
}

/* ---------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 var(--space);
  overflow-x: auto;
  border-bottom: 1px solid var(--rule);
  scrollbar-width: none;
}

.tab {
  flex: none;
  padding: 0.85rem 0.9rem 0.7rem;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  font-weight: 600;
  color: var(--muted);
}
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

.segmented { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.segmented button {
  min-height: 2.75rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--surface);
  font-weight: 600;
}
.segmented button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------------------------------------------------------------- the clock */

.stamp-clock {
  font-stretch: 62%;
  font-weight: 800;
  font-size: clamp(5.5rem, 26vw, 11rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  padding: 0.5rem 0 0.35rem;
  border-top: 3px double var(--ink);
  border-bottom: 3px double var(--ink);
  text-align: center;
}

.stamp-date {
  margin-top: 0.5rem;
  text-align: center;
  color: var(--muted);
  font-stretch: 87%;
  font-size: 1.1rem;
}

/* ---------------------------------------------------------------- login */

.login h1 { margin-top: 2rem; }

.people {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem;
}

.person {
  width: 100%;
  min-height: 7rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  text-align: left;
  border: 2px solid var(--ink);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.person-name { font-stretch: 80%; font-weight: 800; font-size: 1.6rem; line-height: 1.1; }
.person-role { color: var(--muted); }
.person-pin { margin-top: auto; font-size: 0.85rem; color: var(--brass); font-weight: 600; }

.pin-dialog {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space);
  background: rgb(18 26 22 / 0.6);
}

.pin-box {
  width: min(22rem, 100%);
  padding: 1.5rem;
  border-radius: 16px;
  background: var(--paper);
  text-align: center;
}
.pin-box h2 { margin: 0; font-stretch: 80%; font-weight: 800; font-size: 2rem; }

.pin-dots { display: flex; justify-content: center; gap: 0.9rem; margin: 1rem 0; }
.pin-dots span { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid var(--ink); }
.pin-dots span.filled { background: var(--ink); }

.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.pin-keys button {
  min-height: 4rem;
  border-radius: var(--radius-control);
  border: 1px solid var(--rule);
  background: var(--surface);
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pin-keys .pin-aux { font-size: 1rem; font-weight: 600; }

/* ---------------------------------------------------------------- punching */

.state { text-align: center; font-weight: 700; font-size: 1.2rem; margin: 1.25rem 0 1rem; }
.state.state-working { color: var(--in); }
.state.state-break { color: var(--pause); }
.state.state-out { color: var(--muted); }

.punch-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.punch-button {
  flex: 1 1 12rem;
  max-width: 20rem;
  min-height: 5.5rem;
  border: none;
  border-radius: 14px;
  color: var(--on-color);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: 0.01em;
}
.punch-clock_in { background: var(--in); }
.punch-clock_out { background: var(--out); }
.punch-break_start, .punch-break_end { background: var(--pause); }
.punch-button:active { transform: translateY(1px); }

.card-stamps { list-style: none; padding: 0; margin: 0 0 0.75rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.card-stamp {
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0.8rem 0.45rem;
  border-left: 5px solid var(--muted);
  background: var(--surface);
}
.card-stamp.stamp-clock_in { border-left-color: var(--in); }
.card-stamp.stamp-clock_out { border-left-color: var(--out); }
.card-stamp.stamp-break_start, .card-stamp.stamp-break_end { border-left-color: var(--pause); }
.card-time { font-stretch: 62%; font-weight: 800; font-size: 1.9rem; line-height: 1; font-variant-numeric: tabular-nums; }
.card-type { font-size: 0.9rem; color: var(--muted); }

/* ---------------------------------------------------------------- now */

.now-list { list-style: none; padding: 0; margin: 0; }
.now-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}
.now-name { font-stretch: 80%; font-weight: 800; font-size: 1.5rem; }
.now-row .state { margin: 0; font-size: 1rem; text-align: right; }

/* ---------------------------------------------------------------- month */

.month-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; margin: 1.5rem 0 0.75rem; }
.month-head h2 { margin: 0; font-stretch: 80%; font-weight: 800; font-size: 1.8rem; }
.month-head p { margin: 0; }

.month-nav { display: flex; align-items: center; gap: 0.75rem; font-weight: 600; margin: 0.5rem 0 1rem; }
.month-nav span { min-width: 10rem; text-align: center; }

.table-wrap { overflow-x: auto; margin-bottom: 1rem; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
thead th { font-size: 0.85rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--ink); white-space: nowrap; }
tbody th { font-weight: 600; white-space: nowrap; }
tfoot th, tfoot td { font-weight: 800; border-top: 2px solid var(--ink); border-bottom: none; }
.has-extra { color: var(--out); font-weight: 700; }

.segment { display: inline-block; margin-right: 0.6rem; white-space: nowrap; }
.segment.is-corrected { text-decoration: underline dotted var(--brass) 2px; text-underline-offset: 4px; }

.propose { margin-top: 2rem; padding-top: 0.5rem; border-top: 2px solid var(--ink); max-width: 34rem; }

/* ---------------------------------------------------------------- corrections */

.corrections { list-style: none; padding: 0; margin: 0; }
.correction { padding: 1rem 0 1rem 1rem; border-left: 4px solid var(--rule); border-bottom: 1px solid var(--rule); }
.correction.status-pending, .correction.status-disputed { border-left-color: var(--brass); }
.correction.status-applied { border-left-color: var(--in); }
.correction.with-discrepancy, .correction.status-rejected { border-left-color: var(--out); }
.correction p { margin: 0.25rem 0; }
.correction-head { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; align-items: baseline; }
.status { margin-left: auto; font-weight: 700; font-size: 0.9rem; }
.change { font-variant-numeric: tabular-nums; }
.history { margin: 0.25rem 0; padding-left: 1.2rem; color: var(--muted); font-size: 0.95rem; }
.discrepancy { padding: 0.5rem 0.75rem; background: var(--surface); border-left: 3px solid var(--out); }
.reject-form { margin-top: 0.75rem; max-width: 30rem; }

/* ---------------------------------------------------------------- warnings */

.warnings { list-style: none; padding: 0; margin: 0; }
.warning {
  display: grid;
  grid-template-columns: 6rem 6rem 1fr;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
}
.warning-when { color: var(--muted); }
.warning-who { font-weight: 700; }

@media (max-width: 34rem) {
  .warning { grid-template-columns: 1fr 1fr; }
  .warning > span:last-child { grid-column: 1 / -1; }
  .who { margin-left: 0; }
  .punch-button { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- print */

.print-area { display: none; }

@media print {
  @page { margin: 16mm; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .app { display: none; }
  .print-area { display: block; }
  .print-area h1 { font-size: 16pt; margin-bottom: 8pt; }
  .print-meta { display: grid; grid-template-columns: max-content 1fr; gap: 2pt 12pt; margin: 0 0 12pt; }
  .print-meta dt { font-weight: 700; }
  .print-meta dd { margin: 0; }
  .print-area th, .print-area td { border-bottom: 0.5pt solid #999; padding: 3pt 4pt; }
  .print-area thead th { color: #000; border-bottom: 1pt solid #000; }
  .print-area tfoot th { border-top: 1pt solid #000; }
  .print-note { font-size: 8.5pt; color: #333; margin-top: 8pt; }
  .print-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 24pt; margin-top: 36pt; }
  .print-signatures p { border-top: 0.5pt solid #000; padding-top: 4pt; }
}

/* ---------------------------------------------------------------- language */

.lang { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.lang button {
  min-width: 2.75rem;
  min-height: 2.25rem;
  padding: 0 0.6rem;
  border: none;
  background: transparent;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
}
.lang button.active { background: var(--ink); color: var(--paper); }
.topbar .lang { margin-left: auto; align-self: center; }
.topbar .who ~ .lang { margin-left: 0; }
