/* ---- Tokens ---- */
:root {
  --bg: #EEF0EA;
  --surface: #FFFFFF;
  --ink: #1E2321;
  --muted: #6B7268;
  --line: #D8DCD2;
  --brass: #9C7A3C;
  --brass-dark: #7C5F2C;
  --teal: #2B4C4A;
  --danger: #A6432F;
  --danger-bg: #F5E4DF;
  --success-bg: #E4EDE3;
  --success-ink: #2F5233;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", "IBM Plex Sans", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1 {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-weight: 600;
  font-size: 1.6rem;
  margin: 0 0 0.2rem 0;
  letter-spacing: -0.01em;
}

.subtle { color: var(--muted); margin: 0; font-size: 0.92rem; }

/* ---- Top bar ---- */
.topbar { background: var(--teal); padding: 0.9rem 2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.topbar-account { display: flex; align-items: center; }
.topbar-logout { display: inline-block; margin-left: 1rem; }

/* Sign-in page: one card, centered -- the whole page is this one action. */
.login-card {
  max-width: 22rem;
  margin: 3rem auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.5rem 2rem;
}
.login-card h1 { margin-top: 0; }

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: #F4F5F0;
}

.brand-mark {
  font-family: Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--brass);
  color: #1E1A10;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.85rem;
}

.brand-name {
  font-family: Georgia, serif;
  font-size: 1.05rem;
}

/* ---- Page shell ---- */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.4rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-head-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.flashes { margin-bottom: 1rem; }

.flash {
  padding: 0.65rem 1rem;
  border-radius: 4px;
  font-size: 0.92rem;
  margin-bottom: 0.5rem;
}

.flash-success { background: var(--success-bg); color: var(--success-ink); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* ---- Buttons & links ---- */
.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.92rem;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--brass);
  color: #1E1A10;
  font-weight: 600;
}
.btn-primary:hover { background: var(--brass-dark); }

.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-quiet:hover { border-color: var(--muted); }

.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--teal);
  text-decoration: none;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
  margin-right: 0.75rem;
}
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }

.inline-form { display: inline; }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  font-family: inherit;
}

.filter-search { flex: 1 1 220px; min-width: 180px; }

/* ---- Ledger table ---- */
.ledger {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.ledger th {
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--ink);
}

/* ---- Column sort/filter menus ---- */
.ledger th.col-menu {
  position: relative;
  padding-right: 1.6rem;
}

.col-heading {
  vertical-align: middle;
}

.col-caret {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  padding: 0.1rem 0.25rem;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
}

.col-caret:hover,
.col-caret:focus-visible {
  color: var(--ink);
}

.col-popover {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
  min-width: 11rem;
  max-height: 22rem;
  overflow-y: auto;
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 0.4rem;
  text-align: left;
  white-space: nowrap;
}

.col-popover[hidden] {
  display: none;
}

.col-popover-sort {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.35rem;
  margin-bottom: 0.35rem;
}

.pop-link {
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.82rem;
}

.pop-link:hover {
  background: var(--line);
}

.pop-link.is-active {
  font-weight: 600;
}

.col-popover-filter {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.col-popover-values {
  display: flex;
  flex-direction: column;
  max-height: 12rem;
  overflow-y: auto;
}

.pop-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
}

.pop-check:hover {
  background: var(--line);
}

.col-popover-actions {
  display: flex;
  gap: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}

.ledger td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.chip {
  display: inline-block;
  padding: 0.1em 0.65em;
  border-radius: 999px;
  font-size: 0.9em;
  line-height: 1.5;
  white-space: nowrap;
}

/* Colors off: strip the chips back to plain text cells. The overrides
   must beat the inline styles the chips carry, which is why !important. */
body.colors-off .chip {
  background: transparent !important;
  color: inherit !important;
  padding: 0;
  font-size: inherit;
}

/* Manage lists: each lookup value keeps its own row of assignable colors.
   Every palette entry is a submit button carrying its hex, so assigning is
   one click with no script at all; the outline shows which is live. */
.color-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  align-items: center;
}

.color-strip .swatch {
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 3px;
  cursor: pointer;
}

.color-strip input[type="color"] {
  width: 1.05rem;
  height: 1.4rem;
  margin-left: 0.3rem;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.btn-tiny { padding: 0.05rem 0.45rem; font-size: 0.78rem; }

.ledger tbody tr:hover { background: #F7F8F4; }

.col-no { width: 3rem; }
.col-photo { width: 3.5rem; }
.col-actions { width: 10rem; text-align: right; white-space: nowrap; }

/* Photo (or its initials-circle stand-in) on each row. object-fit: cover
   crops any aspect ratio into the same circle, so wildly different source
   files still land as one uniform column. */
.emp-photo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.emp-photo-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: #E4E7DD;
}

/* Buttons reset their own styling, which the row thumbnail inherits. */
.emp-photo-btn {
  border: 0;
  padding: 0;
  background: none;
  cursor: zoom-in;
  display: block;
}

/* The full-screen photo view. `hidden` would be overridden by the flex
   display below, so the two are kept in agreement explicitly. */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(24, 26, 20, 0.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
}
#lightbox[hidden] { display: none; }

#lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 0.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* Photo and record card side by side: the comparison the confirm button
   vouches for -- right face on the left, right data on the right. */
.lightbox-stage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  max-width: 94vw;
}

#lightbox-record {
  min-width: 15rem;
  max-width: 94vw;
  background: rgba(24, 26, 20, 0.65);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  color: #F0F2E9;
}

/* The card photograph sits beside the record: the "right card under the
   right code" comparison, made in one glance. The wrapper is the swap
   button -- clicking it trades places with the big photo. Sized like a
   real card is, tall and narrow; clicking the other photo swaps back. */
#lightbox-card {
  height: 14rem;
  width: auto;
  border-radius: 0.35rem;
}

.lightbox-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem;
  border: 1px dashed rgba(240, 242, 233, 0.35);
  border-radius: 0.5rem;
  background: transparent;
  color: #F0F2E9;
  font: inherit;
  cursor: pointer;
}

.lightbox-thumb:disabled {
  cursor: default;
  opacity: 0.65;
}

.lightbox-thumb:not(:disabled):hover #lightbox-card,
.lightbox-thumb:not(:disabled):focus-visible #lightbox-card {
  outline: 2px solid #F0F2E9;
  outline-offset: 2px;
}

#lightbox-swap-label {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* The ID column: narrow, mono, and deliberately quiet -- the number photo
   files are named after, present for cross-reference, not for scanning. */
.col-id {
  width: 5rem;
}

/* The "= ID" hint: a card number that merely copies the employee code --
   every SSL-era row. Muted and unselectable-feeling so the number itself
   stays copyable, while the bare mono numbers on screen stay reserved for
   the Employee ID (the thing photo files are named after). */
.same-as-id::after {
  content: " \00b7  = ID";
  color: var(--muted, #888);
  font-size: 0.8em;
  margin-left: 0.35em;
  user-select: none;
}

#lightbox-record h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.record-lines {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.record-line dt {
  display: inline;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #B9BFAF;
  margin-right: 0.5rem;
}

.record-line dd {
  display: inline;
  margin: 0;
}

.record-verify {
  margin-top: 0.85rem;
  border: 1px solid #6f9d63;
  border-radius: 0.4rem;
  background: rgba(63, 157, 77, 0.18);
  color: #CDE8C7;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.record-verify:hover { background: rgba(63, 157, 77, 0.35); }
.record-verify[aria-pressed="true"] { background: #3f9d4d; color: #fff; }

/* The mismatch judgment wears its own color, so the two buttons read
   as the two outcomes they record, never as generic siblings. */
.record-mismatch {
  border-color: #b06868;
  background: rgba(214, 69, 69, 0.18);
  color: #EFC9C9;
}
.record-mismatch:hover { background: rgba(214, 69, 69, 0.35); }
.record-mismatch[aria-pressed="true"] { background: #d64545; color: #fff; }

.record-judgments {
  margin-top: 0.85rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.record-judgments .record-verify { margin-top: 0; }

.record-confirmed {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: #9FBF97;
}

/* The judgment resting on its circle: a colored ring hugging the edge,
   green for confirmed, red for a reported mismatch. A box-shadow, so
   the ring adds no size and shifts no layout. The circle shape is often
   a photo thumbnail but can also be an initials circle when a judged
   photo has left the folder -- the judgment lives on the employee, so
   the ring shows either way. Circles without a ring are the
   not-yet-checked queue. */
.emp-photo-btn { position: relative; }

.photo-ring-confirmed {
  box-shadow: 0 0 0 3px #3f9d4d;
  border-radius: 50%;
}

.photo-ring-mismatch {
  box-shadow: 0 0 0 3px #d64545;
  border-radius: 50%;
}

#lightbox-caption {
  color: #F0F2E9;
  font-size: 0.95rem;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  border: 0;
  background: none;
  color: #F0F2E9;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

/* Stepping controls for the enlarged view: the same moves as the Left and
   Right arrow keys, drawn so they work on a touch screen too. A dark disc
   mutes them against the dimmed backdrop; a step that has nowhere to go
   ("stop at the ends") is faded out by the disabled state. */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: rgba(24, 26, 20, 0.55);
  color: #F0F2E9;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-nav:hover { background: rgba(24, 26, 20, 0.85); }
.lightbox-nav:disabled { opacity: 0.25; cursor: default; }
.lightbox-prev { left: 1.25rem; }
.lightbox-next { right: 1.25rem; }

.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.muted { color: var(--muted); }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem !important;
}

.footnote {
  margin-top: 1rem;
  font-size: 0.85rem;
}
.footnote a { color: var(--muted); }

/* ---- Form ---- */
.record-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.5rem;
  max-width: 640px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.field input,
.field select {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.95rem;
  color: var(--ink);
  font-family: inherit;
}

/* A native date input is drawn in the browser's own locale, so the ISO
   value that will actually be saved is echoed underneath it. */
.date-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.date-echo {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

.form-actions form.inline-form { margin: 0; }

/* ---- Import preview ---- */
.preview-summary {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.pill-create { background: var(--success-bg); color: var(--success-ink); }
.pill-update { background: #EFE7D6; color: var(--brass-dark); }
.pill-neutral { background: var(--bg); color: var(--muted); }
.pill-skip { background: var(--danger-bg); color: var(--danger); }

.section-heading {
  font-family: Georgia, serif;
  font-size: 1.1rem;
  margin: 2rem 0 0.8rem;
}

@media (max-width: 640px) {
  .page { padding: 1.2rem; }
  .field-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0.8rem 1.2rem; }
}
