/* Attendance: minimal UI. One accent colour, system font, light + dark themes.
   Theme choice (Settings) sets <html data-theme="light|dark">; no attribute = follow the device. */
:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #6b6b76;
  --line: #e4e4e7;
  --accent: #2f55d4;
  --accent-text: #ffffff;
  --accent-soft: #eaefff;
  --danger: #c8322b;
  --ok: #1f7a46;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113; --surface: #1b1b1f; --text: #ececef; --muted: #9a9aa4; --line: #2d2d33;
    --accent: #8aa4ff; --accent-text: #0f1424; --accent-soft: #232a40; --danger: #ff7b72; --ok: #5fd08f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111113; --surface: #1b1b1f; --text: #ececef; --muted: #9a9aa4; --line: #2d2d33;
  --accent: #8aa4ff; --accent-text: #0f1424; --accent-soft: #232a40; --danger: #ff7b72; --ok: #5fd08f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 400 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
[hidden] { display: none !important; }
img { display: block; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── Motion: every animation answers something the person did ── */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); }

/* Page to page: the content fades and rises a little; top bar and bottom menu stay still.
   Works in Chrome/Android and Safari 18.2+; other browsers just switch pages instantly. */
@view-transition { navigation: auto; }
.appbar { view-transition-name: appbar; }
.bottomnav { view-transition-name: bottomnav; }
.page { view-transition-name: page; }
::view-transition-old(page) { animation: page-out .14s ease-in both; }
::view-transition-new(page) { animation: page-in .24s var(--ease-out) both; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .14s; }
@keyframes page-out { to { opacity: 0; } }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes slide-from-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes slide-from-left { from { opacity: 0; transform: translateX(-28px); } }

/* Pressing a button gives a small push-in */
.btn, .fab, .icon-act, .bottomnav a, .under-actions a, .under-actions button { transition: transform .12s var(--ease-out), background-color .12s, filter .12s; }
.btn:active:not(:disabled), .under-actions a:active, .under-actions button:active { transform: scale(.97); }
.fab:active { transform: scale(.92); }
.bottomnav a:active svg { transform: scale(.88); }
.bottomnav svg { transition: transform .12s var(--ease-out); }

/* ── Top bar (safe-area insets keep clear of the iPhone notch) ── */
.appbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
          padding-top: env(safe-area-inset-top); }
.appbar-inner { max-width: 720px; margin: 0 auto; height: 56px; display: flex; align-items: center; gap: 8px;
                padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.brand { font-weight: 600; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.appbar .title { font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-count { margin-left: 4px; font-size: .85rem; font-weight: 400; color: var(--muted); }
.icon-btn { width: 40px; height: 40px; margin-left: -10px; display: grid; place-items: center; border-radius: 50%;
            color: var(--text); text-decoration: none; }
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 22px; height: 22px; }

.tabs { display: flex; gap: 2px; margin-left: auto; }
.tabs a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.page { max-width: 720px; margin: 0 auto;
        padding: 20px max(16px, env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.page-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.page-head h1 { font-size: 1.5rem; }
.page-intro { margin: 0 0 16px; color: var(--muted); }

/* ── Bottom navigation (phones only) ── */
.bottomnav { display: none; }
@media (max-width: 700px) {
  .tabs { display: none; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface);
               border-top: 1px solid var(--line);
               padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .bottomnav a { flex: 1; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center;
                 gap: 3px; color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 500; }
  .bottomnav svg { width: 22px; height: 22px; }
  .bottomnav a[aria-current="page"] { color: var(--accent); }
  .with-bottomnav .page { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  .with-bottomnav .fab { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* ── Controls ── */
input, select {
  font: inherit; width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
input::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: .9rem; font-weight: 500; }
.err { margin: 0; min-height: 1.3em; font-size: .85rem; color: var(--danger); }
.has-error input, .has-error select { border-color: var(--danger); }
.form-error { margin: 0 0 10px; color: var(--danger); }
.form-error:empty { display: none; }

.btn { font: inherit; font-weight: 500; min-height: 44px; padding: 0 18px; border-radius: 8px; cursor: pointer;
       border: 1px solid var(--line); background: var(--surface); color: var(--text);
       display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: wait; }
.link-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }

.status { color: var(--muted); margin: 8px 0 16px; }
.status:empty { display: none; }
.empty { text-align: center; padding: 48px 16px; }
.empty p { color: var(--muted); margin: 6px 0 16px; }

/* ── Employee list, grouped by company ── */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.search { position: relative; margin-bottom: 20px; }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; border-radius: 22px; }

.group { margin-bottom: 16px; }
/* Company heading stays visible while scrolling through its people */
.group-head { position: sticky; top: calc(57px + env(safe-area-inset-top)); z-index: 5; display: flex; justify-content: space-between;
              align-items: baseline; padding: 10px 4px 8px; background: var(--bg); }
.group-head h2 { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.group-head span { color: var(--muted); font-size: .8rem; }
.emp-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
/* Compact rows: built for lists of 100+ people.
   .emp-front slides sideways over .swipe-under (Print on the left, Edit/Remove on the right). */
.emp { position: relative; overflow: hidden; }
.emp + .emp { border-top: 1px solid var(--line); }
.emp-front { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 10px;
             background: var(--surface); touch-action: pan-y; transition: transform .22s cubic-bezier(.2, .8, .2, 1), background-color .12s; }
@media (hover: hover) { .emp-front:hover { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); } }

.swipe-under { position: absolute; inset: 0; display: flex; }
.under-print { flex: 1; display: flex; align-items: center; gap: 8px; padding-left: 18px; background: var(--accent); color: var(--accent-text);
               font-weight: 600; font-size: .9rem; }
.under-print svg { width: 20px; height: 20px; transition: transform .15s; }
.print-armed .under-print svg { transform: scale(1.25); }
.under-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.under-actions a, .under-actions button { width: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
                                         border: 0; padding: 0; color: #fff; text-decoration: none; font: inherit; font-size: .75rem; font-weight: 600; cursor: pointer; }
.under-actions svg { width: 18px; height: 18px; }
.under-edit { background: #6b6b76; }
.under-remove { background: var(--danger); }
:root[data-theme="dark"] .under-remove { color: #1b1b1f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .under-remove { color: #1b1b1f; } }

/* Touch screens swipe; mouse users keep the icon buttons */
@media (hover: none) { .emp-front .emp-actions { display: none; } }
@media (hover: hover) { .emp .swipe-under { display: none; } }
.swipe-hint { margin: -8px 0 14px; color: var(--muted); font-size: .85rem; text-align: center; }

.avatar { position: relative; width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
          background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .75rem; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.emp-main { flex: 1; min-width: 0; }
.emp-name { font-weight: 600; font-size: .95rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-sub { color: var(--muted); font-size: .8rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.warn { color: var(--danger); }

.emp-side { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.emp-card { min-width: 4ch; margin-right: 2px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .95rem; }
.emp-actions { display: flex; gap: 0; }
.icon-act { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none;
            color: var(--muted); cursor: pointer; text-decoration: none; padding: 0; transition: background-color .12s, color .12s; }
.icon-act:hover, .icon-act:focus-visible { background: var(--accent-soft); color: var(--accent); }
.icon-act.danger:hover, .icon-act.danger:focus-visible { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.icon-act:active { transform: scale(.94); }
.icon-act svg { width: 18px; height: 18px; }
.icon-act:disabled { opacity: .5; cursor: wait; }
@media (max-width: 400px) {
  /* Small phones: squeeze the buttons a little so names still have room */
  .emp-front { gap: 8px; padding-left: 8px; }
  .icon-act { width: 32px; }
}
@media (hover: none) { .emp-front { padding: 8px 14px 8px 12px; } }

/* Removed employees: grey until the month ends */
.emp.is-inactive .emp-front { background: var(--bg); }
.emp.is-inactive .avatar { filter: grayscale(1); opacity: .55; }
.emp.is-inactive .emp-name, .emp.is-inactive .emp-card { color: var(--muted); font-weight: 500; }
.emp.is-inactive .emp-name { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.restore-btn { font: inherit; font-size: .8rem; font-weight: 500; min-height: 32px; padding: 0 10px; border-radius: 8px; cursor: pointer;
               border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.restore-btn:hover { border-color: var(--accent); color: var(--accent); }
.restore-btn:disabled { opacity: .5; cursor: wait; }
.toast-action { font: inherit; font-weight: 600; margin-left: 10px; padding: 2px 4px; border: 0; background: none; cursor: pointer;
                color: color-mix(in srgb, var(--accent) 55%, var(--bg)); text-transform: uppercase; letter-spacing: .03em; font-size: .85rem; }

/* Loading placeholders */
.skeleton .bar { height: 11px; border-radius: 6px; background: var(--line); margin: 5px 0; }
.skeleton .w30 { width: 30%; } .skeleton .w40 { width: 40%; } .skeleton .w50 { width: 50%; } .skeleton .w60 { width: 60%; } .skeleton .w70 { width: 70%; }
.skeleton .avatar { background: var(--line); }
.skeleton .emp { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.skeleton { animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .55; } }

/* Confirm dialog + short message */
.dialog { width: min(400px, calc(100% - 32px)); border: 0; border-radius: 16px; padding: 22px 20px 18px; background: var(--surface); color: var(--text);
          box-shadow: 0 10px 40px rgb(0 0 0 / .25); }
.dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog[open] { animation: pop-in .2s var(--ease-out); }
.dialog[open]::backdrop { animation: fade-in .2s ease-out; }
.dialog h2 { font-size: 1.15rem; margin-bottom: 6px; }
.dialog p { margin: 0 0 20px; color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
@media (max-width: 600px) { .dialog-actions .btn { flex: 1; } }
.toast { position: fixed; left: 50%; translate: -50% 0; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30; max-width: calc(100% - 32px);
         padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: .92rem; box-shadow: 0 4px 16px rgb(0 0 0 / .2);
         animation: rise-in .25s var(--ease-out); }
@media (max-width: 700px) { .with-bottomnav .toast { bottom: calc(76px + env(safe-area-inset-bottom)); } }

.fab { position: fixed; right: max(16px, calc(50% - 344px), env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom));
       width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
       background: var(--accent); color: var(--accent-text); box-shadow: 0 2px 10px rgb(0 0 0 / .18); }
.fab svg { width: 26px; height: 26px; }

/* ── Add employee ── */
.steps { display: flex; gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; font-size: .9rem; color: var(--muted); }
.steps li { flex: 1; padding-top: 8px; border-top: 3px solid var(--line); }
.steps li.is-active { color: var(--text); border-color: var(--accent); }
.steps li.is-done { border-color: var(--accent); }

.section { margin-bottom: 28px; }
.section > h2 { font-size: 1rem; margin-bottom: 12px; }
.optional { margin-left: 6px; font-size: .8rem; font-weight: 400; color: var(--muted); }
.who-grid { display: grid; grid-template-columns: 96px 1fr; gap: 0 16px; align-items: start; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row-3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 0 12px; }
.doc-type { max-width: 340px; }


.upload { position: relative; display: grid; place-items: center; overflow: hidden; cursor: pointer; text-align: center;
          border: 1px dashed var(--muted); border-radius: var(--r); background: var(--surface); color: var(--muted); font-size: .85rem; }
.upload:hover, .upload:focus-within { border-color: var(--accent); color: var(--accent); }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-empty { display: grid; justify-items: center; gap: 4px; padding: 8px; }
.upload-empty svg { width: 22px; height: 22px; }
.upload-preview { width: 100%; height: 100%; object-fit: cover; animation: fade-in .3s ease-out; }

/* Machines: the company's ranges as buttons ("1 to 6", "7 to 12" …) */
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }
.machine-field { grid-column: 1 / -1; }
.machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.machine { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 48px;
           padding: 6px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: center;
           transition: background-color .15s, border-color .15s, color .15s, transform .12s var(--ease-out); }
.machine input { position: absolute; opacity: 0; inset: 0; margin: 0; min-height: 0; cursor: pointer; }
.machine .range { font-weight: 600; font-variant-numeric: tabular-nums; }
.machine .who { max-width: 100%; font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.machine.is-taken { border-style: dashed; }
.machine:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.machine:has(input:checked) .who { color: inherit; opacity: .85; }
.machine:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.machine:active { transform: scale(.97); }
.has-error .machine { border-color: var(--danger); }
.machine-hint { margin: 0; font-size: .9rem; }
@media (max-width: 600px) { .machine-grid { grid-template-columns: repeat(3, 1fr); } }

/* ₹ in front of the salary box */
.money { position: relative; }
.money span { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.money input { padding-left: 28px; }

/* Job: search box with a dropdown list */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 4px); max-height: 248px; overflow-y: auto;
              margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
              box-shadow: 0 8px 24px rgb(0 0 0 / .14); animation: rise-in .15s var(--ease-out); }
.combo-list li { padding: 10px 12px; border-radius: 7px; cursor: pointer; }
.combo-list li b { font-weight: 700; }
.combo-list li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
@media (hover: hover) { .combo-list li:hover { background: var(--accent-soft); } }
.combo-list li.is-new { color: var(--accent); border-top: 1px solid var(--line); margin-top: 2px; }
.combo-list li.is-new:first-child { border-top: 0; margin-top: 0; }
.new-job { margin: 0; font-size: .85rem; color: var(--accent); }

/* Add employee: "Coming back?" */
.comeback { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.comeback-picked { margin: 0; padding: 12px 14px; border-radius: var(--r); background: var(--accent-soft); animation: rise-in .2s var(--ease-out); }
.comeback-picked .link-btn { display: block; margin-top: 4px; font-size: .9rem; }
.combo-list li[aria-disabled="true"] { cursor: default; }

/* Add employee: Next slides forward, Back slides back; Machines eases in for operators */
#employee-form[data-dir="next"] [data-step]:not([hidden]) { animation: slide-from-right .26s var(--ease-out); }
#employee-form[data-dir="back"] [data-step]:not([hidden]) { animation: slide-from-left .26s var(--ease-out); }
#machine-field:not([hidden]) { animation: rise-in .22s var(--ease-out); }
.steps li { transition: border-color .25s, color .25s; }
.done:not([hidden]) { animation: rise-in .3s var(--ease-out); }
.done-photo { animation: pop-in .35s var(--ease-out) .05s both; }
.upload.is-filled { border-style: solid; border-color: var(--line); }
.upload.is-busy::before { content: "Processing…"; position: absolute; inset: 0; z-index: 1; display: grid; place-items: center;
                          background: var(--surface); color: var(--text); }
.upload.has-error { border-color: var(--danger); }
.upload-id { width: 96px; aspect-ratio: 3 / 4; }
.upload-doc { width: 100%; aspect-ratio: 85.6 / 54; }
.upload-doc .upload-preview { object-fit: contain; }

.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line);
             padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.actionbar-inner { max-width: 688px; margin: 0 auto; }
.actionbar-buttons { display: flex; gap: 10px; justify-content: flex-end; }

.done { text-align: center; padding-top: 32px; }
.done-photo { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; margin: 0 auto 14px; background: var(--line); }
.done h1 { font-size: 1.35rem; }
.done p { color: var(--muted); margin: 4px 0 24px; }
.done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── Punch ── */
.scan { display: flex; flex-direction: column; gap: 14px; }
label.fab { cursor: pointer; }
.manual { display: flex; gap: 8px; }
.manual input { flex: 1; min-width: 0; }
.scan-msg { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
            color: var(--muted); text-align: center; }
.scan-msg:empty { display: none; }
.scan-msg.is-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
/* Full-screen scanner */
.scan-live { position: fixed; inset: 0; z-index: 50; background: #000; animation: fade-in .2s ease-out; }
.scan-live video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; left: 50%; top: 42%; translate: -50% -50%; width: min(68vw, 300px); aspect-ratio: 1;
              border: 3px solid rgb(255 255 255 / .9); border-radius: 22px; box-shadow: 0 0 0 9999px rgb(0 0 0 / .45); }
.scan-tip { position: absolute; left: 16px; right: 16px; top: calc(20px + env(safe-area-inset-top)); margin: 0;
            color: #fff; text-align: center; font-weight: 500; text-shadow: 0 1px 3px rgb(0 0 0 / .6); }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 10px;
               padding: 16px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.scan-bottom .manual { max-width: 480px; width: 100%; margin: 0 auto; }
.scan-bottom input { background: rgb(255 255 255 / .95); color: #18181b; border-color: transparent; }
.scan-cancel { align-self: center; min-width: 140px; background: rgb(255 255 255 / .16); color: #fff; border-color: rgb(255 255 255 / .35); }
.scan-bottom .manual .btn { background: #fff; color: #18181b; border-color: #fff; }

#punch-form:not([hidden]) { animation: rise-in .22s var(--ease-out); display: flex; flex-direction: column; gap: 10px; }
.who-card { display: flex; align-items: center; gap: 14px; padding: 14px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.who-card .link-btn { align-self: flex-start; font-size: .85rem; white-space: nowrap; }
.shift-summary { margin: -4px 0 6px; font-size: .9rem; color: var(--muted); }
.shift-summary b { color: var(--text); }
.shift-summary .done { color: var(--ok); }
.shift-summary .done b { color: inherit; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.1rem; }
.who-name { font-weight: 600; font-size: 1.1rem; line-height: 1.3; }
.who-card .emp-sub { font-size: .88rem; white-space: normal; }
.segmented-2 { grid-template-columns: repeat(2, 1fr); background: var(--surface); border: 1px solid var(--line); }
.segmented-2 label { min-height: 44px; font-size: 1rem; }
.value-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.value { position: relative; display: grid; place-items: center; min-height: 52px; border: 1px solid var(--line); border-radius: 10px;
         background: var(--surface); cursor: pointer; font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums;
         transition: background-color .15s, border-color .15s, color .15s, transform .12s var(--ease-out); }
.value input { position: absolute; inset: 0; opacity: 0; margin: 0; min-height: 0; cursor: pointer; }
.value:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.value:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.value:active { transform: scale(.95); }
/* Operators: machine lines [All] [1-3] [4-6] */
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: 0.8fr 1fr 1fr; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.line.is-own { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.line button { font: inherit; min-height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
               border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--text); cursor: pointer; padding: 4px;
               font-weight: 600; font-variant-numeric: tabular-nums;
               transition: background-color .15s, border-color .15s, color .15s, transform .12s var(--ease-out); }
.line button small { font-size: .7rem; font-weight: 500; color: var(--muted); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.line button[aria-pressed="true"] small { color: inherit; opacity: .85; }
.line button:active:not(:disabled) { transform: scale(.96); }
.line button:disabled { cursor: not-allowed; opacity: .45; background: var(--line); }
.line button.is-taken span { text-decoration: line-through; }
.line-all { font-size: .95rem; }
.lines-total { margin: 4px 0 0; font-size: .95rem; }
.already { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: .88rem; }
.btn-block { width: 100%; min-height: 52px; font-size: 1.05rem; }

/* ── Settings ── */
.setting { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin: 0 0 16px; }
.setting legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; font-weight: 500; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--bg); border-radius: 10px; clear: both; }
.segmented label { position: relative; display: grid; place-items: center; min-height: 40px; border-radius: 7px; cursor: pointer;
                   font-size: .92rem; color: var(--muted); text-align: center; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; min-height: 0; cursor: pointer; }
.segmented label:has(input:checked), .segmented label.is-checked { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.setting .hint { margin: 10px 0 0; color: var(--muted); font-size: .85rem; }

@media (max-width: 600px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .who-grid { grid-template-columns: 88px 1fr; gap: 0 14px; }
  .upload-id { width: 88px; }
  .actionbar .btn { flex: 1; }
}

/* ── Sign-in, waiting and Users pages ── */
.tabs a[hidden], .bottomnav a[hidden] { display: none !important; }
.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; padding: 32px 24px; border: 1px solid var(--line); border-radius: 18px;
             background: var(--surface); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
             animation: rise-in .25s var(--ease-out); }
.auth-card h1 { margin: 4px 0 0; font-size: 1.4rem; }
.auth-logo { border-radius: 16px; }
.auth-avatar { margin-bottom: 4px; }
.auth-sub { margin: 0 0 8px; color: var(--muted); line-height: 1.5; }
.auth-msg { margin: 4px 0 0; min-height: 1.3em; color: var(--muted); font-size: .9rem; }
.auth-msg:empty { min-height: 0; }
.google-btn { min-height: 44px; display: grid; place-items: center; }
.auth-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.dev-login { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 16px; border-top: 1px dashed var(--line); }
.dev-title { margin: 0; font-size: .8rem; color: var(--muted); }

.users-section { margin-bottom: 18px; }
.users-hint { margin: -2px 4px 8px; color: var(--muted); font-size: .85rem; }
.users-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.user-card { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
             display: flex; flex-direction: column; gap: 12px; }
.user-top { display: flex; align-items: center; gap: 10px; }
.user-top .avatar { width: 40px; height: 40px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
        font-size: .72rem; font-weight: 600; vertical-align: 2px; }
.access-boxes { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.access-box { position: relative; display: flex; gap: 8px; align-items: flex-start; padding: 9px 10px; border: 1px solid var(--line);
              border-radius: 10px; cursor: pointer; }
.access-box input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; padding: 0; flex-shrink: 0; accent-color: var(--accent); }
.access-box span { display: flex; flex-direction: column; line-height: 1.25; }
.access-box b { font-size: .9rem; font-weight: 600; }
.access-box small { color: var(--muted); font-size: .75rem; }
.access-box:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.user-actions { display: flex; gap: 8px; justify-content: flex-end; }
.user-actions .btn { min-width: 110px; }
@media (max-width: 600px) { .user-actions .btn { flex: 1; } }
.btn-danger-soft { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.account-row { display: flex; align-items: center; gap: 12px; }

/* "Offline: showing saved data" */
.offline-bar { position: fixed; left: 50%; translate: -50% 0; top: calc(64px + env(safe-area-inset-top)); z-index: 40; max-width: calc(100% - 32px);
               padding: 6px 14px; border-radius: 999px; background: #3f3f46; color: #fff; font-size: .82rem; font-weight: 500;
               box-shadow: 0 2px 8px rgb(0 0 0 / .2); }
.offline-bar[hidden] { display: none; }

/* ── Punch page: who's been punched (D = day, N = night) ── */
.punched { margin-top: 0; }
.punched-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.punched-head h2 { margin: 0; font-size: 1.05rem; }
/* ‹ 17/11/26 › date stepper */
.date-step { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.date-step-wide { display: flex; justify-content: space-between; }
.ds-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 9px; cursor: pointer;
          background: var(--accent-soft); color: var(--accent); transition: transform .12s var(--ease-out), opacity .12s; }
.ds-btn svg { width: 20px; height: 20px; }
.ds-btn:active:not(:disabled) { transform: scale(.92); }
.ds-btn:disabled { background: transparent; color: var(--muted); opacity: .35; cursor: default; }
.ds-label { min-width: 92px; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.ds-label b { font-size: 1.05rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.ds-label small { color: var(--muted); font-size: .72rem; min-height: 1em; }
.punched-count { margin: 6px 0 2px; color: var(--muted); font-size: .88rem; }
.punched .group-head { top: calc(57px + env(safe-area-inset-top)); }
.pl-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: var(--surface);
          color: inherit; font: inherit; text-align: left; cursor: pointer; }
.emp-list li + li .pl-row { border-top: 1px solid var(--line); }
.pl-row:active { background: var(--accent-soft); }
@media (hover: hover) { .pl-row:hover { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); } }
.pl-row .emp-name, .pl-row .emp-sub { display: block; }
.shift-tags { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.shift-tag { display: inline-flex; align-items: center; gap: 3px; min-height: 28px; padding: 0 9px; border-radius: 999px;
             font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shift-tag.is-day { background: var(--day-bg); color: var(--day-text); }
.shift-tag.is-night { background: var(--night-bg); color: var(--night-text); }
.shift-tag .edited-mark { width: 12px; height: 12px; margin-left: 1px; opacity: .8; }
.shift-tag.is-zero { background: var(--bg); color: var(--muted); font-weight: 500; }
.shift-total { font-weight: 700; font-size: .9rem; color: var(--text); white-space: nowrap; }
:root { --day-bg: #fff1c7; --day-text: #7a4d00; --night-bg: #e3e4ff; --night-text: #2b2f8f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --day-bg: #3d3014; --day-text: #ffd27a; --night-bg: #262a52; --night-text: #b9bdff; } }
:root[data-theme="dark"] { --day-bg: #3d3014; --day-text: #ffd27a; --night-bg: #262a52; --night-text: #b9bdff; }

/* ── Print cards: how many are waiting, shown on the nav ── */
.nav-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
             background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1; }
.nav-badge[hidden] { display: none; }
.tabs .nav-badge { margin-left: 4px; vertical-align: 1px; }
.nav-icon { position: relative; display: inline-grid; }
.nav-icon .nav-badge { position: absolute; top: -6px; left: 14px; }

/* ── Print cards page (/cards). The ID cards themselves are always white: they're for paper. ── */
.cards-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.cards-bar .cards-count { flex: 1 1 100%; margin: 0; color: var(--muted); }
.cards-bar .btn { flex: 1; }
@media (min-width: 601px) { .cards-bar .cards-count { flex: 1 1 auto; } .cards-bar .btn { flex: 0 0 auto; } }
.cards-sheet { display: grid; grid-template-columns: repeat(auto-fill, 85.6mm); gap: 14px; justify-content: center; }
.idcard-wrap { position: relative; }
.idcard { width: 85.6mm; height: 54mm; display: grid; grid-template-rows: 8mm 1fr; overflow: hidden;
          background: #fff; color: #18181b; border: .3mm solid #c9c9cf; border-radius: 3mm;
          -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.idc-head { display: flex; align-items: center; justify-content: space-between; gap: 2mm; padding: 0 3mm;
            background: #2f55d4; color: #fff; font-weight: 700; font-size: 3.4mm; letter-spacing: .02em; }
.idc-head span { font-weight: 500; font-size: 2.6mm; opacity: .9; }
.idc-body { display: grid; grid-template-columns: 19mm 1fr 26mm; gap: 2.5mm; padding: 2.5mm 3mm; min-height: 0; }
.idc-photo { position: relative; width: 19mm; height: 24mm; border-radius: 1.5mm; overflow: hidden; background: #e8e8ec;
             display: grid; place-items: center; color: #6b6b76; font-weight: 700; font-size: 6mm; }
.idc-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.idc-info { min-width: 0; display: flex; flex-direction: column; gap: .8mm; }
.idc-name { font-weight: 700; font-size: 3.7mm; line-height: 1.15; overflow-wrap: anywhere;
            display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.idc-job { font-size: 2.8mm; color: #52525b; line-height: 1.25; }
.idc-card { margin-top: auto; font-size: 2.5mm; color: #6b6b76; line-height: 1.1; }
.idc-card b { display: block; font-size: 6mm; color: #18181b; letter-spacing: .02em; }
.idc-qr { display: flex; flex-direction: column; align-items: center; gap: .6mm; }
.idc-qr svg { display: block; width: 26mm; height: 26mm; }
.idc-qr div { font: 600 1.85mm/1.2 ui-monospace, Consolas, monospace; color: #3f3f46; text-align: center; word-break: break-all; }
.idc-remove { position: absolute; top: -10px; right: -10px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
              border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; box-shadow: 0 1px 4px rgb(0 0 0 / .15); }
.idc-remove svg { width: 16px; height: 16px; }
.cards-note { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }

@media print {
  body.cards-page { background: #fff; }
  .cards-page .appbar, .cards-page .bottomnav, .cards-page .cards-bar, .cards-page .cards-note,
  .cards-page .idc-remove, .cards-page .toast, .cards-page .empty { display: none !important; }
  .cards-page .page { max-width: none; padding: 0; }
  .cards-page .cards-sheet { grid-template-columns: repeat(2, 85.6mm); gap: 2mm 6mm; }
  .cards-page .idcard-wrap { break-inside: avoid; }
}
