:root {
  --brand: #007dc1;
  --brand-dark: #004863;
  --brand-ring: #074e66;
  --orange: #dd5800;
  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f1f5f9;
  --softest: #f8fafc;
  --danger: #b91c1c;
  --success: #22c55e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: #fff;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; }
button { -webkit-touch-callout: none; }
[hidden] { display: none !important; }

.app-shell, .view { width: 100%; min-height: 100dvh; }

.network-pill {
  position: fixed;
  z-index: 30;
  top: calc(var(--safe-top) + 10px);
  right: calc(var(--safe-right) + 12px);
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  color: #14532d;
  background: rgb(240 253 244 / 92%);
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgb(15 23 42 / 8%);
  backdrop-filter: blur(8px);
}

.network-pill.offline { color: #7f1d1d; background: rgb(254 242 242 / 94%); border-color: #fecaca; }
.network-pill.syncing { color: #075985; background: rgb(240 249 255 / 94%); border-color: #bae6fd; }
.network-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; }
.offline .network-dot { background: #ef4444; }
.syncing .network-dot { background: var(--brand); animation: pulse 1s infinite; }
.queue-count { min-width: 19px; padding: 2px 5px; color: #fff; background: var(--brand); border-radius: 999px; text-align: center; }

.brand-header, .clock-topbar {
  height: calc(60px + var(--safe-top));
  padding: calc(var(--safe-top) + 10px) max(16px, var(--safe-right)) 8px max(16px, var(--safe-left));
  display: flex;
  align-items: center;
  background: #fff;
}

.brand-logo { display: block; width: auto; height: 32px; object-fit: contain; }
.brand-header .brand-logo { height: 28px; }
.install-link, .exit-button {
  margin-left: auto;
  margin-right: 142px;
  border: 0;
  color: var(--brand);
  background: transparent;
  font-weight: 750;
  cursor: pointer;
}

.login-main {
  min-height: calc(100dvh - 60px - var(--safe-top));
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(340px, 1fr);
  align-items: center;
  gap: clamp(28px, 7vw, 110px);
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px max(28px, var(--safe-right)) calc(32px + var(--safe-bottom)) max(28px, var(--safe-left));
}

.login-clock-block, .info-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.brand-clock {
  position: relative;
  width: clamp(170px, 24vw, 230px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  border: 11px solid var(--brand-ring);
  box-shadow: inset 0 0 0 8px #fff, inset 0 0 0 16px #b8c8cf, 0 14px 34px rgb(7 78 102 / 12%);
}

.clock-ring { position: absolute; inset: 22%; border: 1px solid transparent; border-radius: 50%; }
.clock-dot { position: absolute; width: 10%; height: 10%; margin: -5%; border-radius: 50%; background: var(--brand-dark); z-index: 2; }
.dot-12 { top: 16%; left: 50%; }
.dot-3 { top: 50%; left: 84%; }
.dot-6 { top: 84%; left: 50%; }
.dot-9 { top: 50%; left: 16%; }

.clock-hand {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 50%;
  width: 6px;
  height: 31%;
  margin-left: -3px;
  border-radius: 7px 7px 2px 2px;
  transform-origin: 50% 100%;
  background: var(--brand);
}

.hour-hand { height: 24%; width: 7px; margin-left: -3.5px; background: var(--orange); }
.clock-center { position: absolute; z-index: 4; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px; border: 3px solid #fff; border-radius: 50%; background: var(--brand-dark); }
.today-date { margin: 18px 0 2px; color: var(--muted); font-size: 14px; }
.today-time { margin: 0; color: var(--brand); font-size: clamp(42px, 7vw, 68px); font-weight: 800; letter-spacing: -0.045em; }

.login-card { width: min(100%, 430px); justify-self: center; }
.login-card h1, .step-panel h1 { margin: 0 0 22px; text-align: center; font-size: 21px; letter-spacing: .025em; }
.field { display: grid; gap: 7px; margin-bottom: 15px; color: var(--text); font-size: 13px; font-weight: 650; }
.field input {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  outline: none;
  font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(0 125 193 / 13%); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 78px; }
.show-password { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); padding: 8px; color: var(--brand); background: transparent; border: 0; font-size: 12px; font-weight: 700; }
.form-error { margin: -4px 0 12px; color: var(--danger); font-size: 13px; line-height: 1.4; }
.centered { text-align: center; }

.primary-button, .secondary-button {
  min-height: 54px;
  padding: 13px 18px;
  border-radius: 14px;
  font-weight: 750;
  cursor: pointer;
}
.primary-button { width: 100%; border: 1px solid var(--brand); color: #fff; background: var(--brand); box-shadow: 0 8px 22px rgb(0 125 193 / 18%); }
.primary-button:disabled { opacity: .58; cursor: wait; }
.secondary-button { border: 1px solid #cbd5e1; color: var(--brand); background: #fff; }
.tall-button { min-height: 62px; }
.login-links { display: flex; justify-content: space-between; margin-top: 12px; }
.login-links a { color: var(--brand); font-size: 13px; text-decoration: none; }
.version { margin: 42px 0 0; color: #94a3b8; font-size: 11px; text-align: center; }

.clock-view { height: 100dvh; overflow: hidden; }
.clock-topbar { position: absolute; z-index: 10; width: 100%; height: calc(54px + var(--safe-top)); background: linear-gradient(#fff 70%, rgb(255 255 255 / 0%)); pointer-events: none; }
.clock-topbar .brand-logo { height: 26px; opacity: .98; pointer-events: auto; }
.clock-topbar .exit-button { pointer-events: auto; }
.clock-layout {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  padding: calc(58px + var(--safe-top)) max(20px, var(--safe-right)) max(18px, var(--safe-bottom)) max(20px, var(--safe-left));
}
.layout-divider { width: 1px; height: 100%; background: var(--line); }
.info-panel, .action-panel { min-width: 0; min-height: 0; padding: 20px clamp(18px, 3vw, 42px); }
.info-panel { display: flex; align-items: center; justify-content: center; }
.info-state { width: 100%; height: 100%; }
.compact-clock { width: clamp(178px, 24vw, 250px); }
.collaborator-photo, .photo-preview {
  width: min(60%, 300px);
  aspect-ratio: 1;
  border: 6px solid #fff;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px #dbeafe, 0 14px 34px rgb(15 23 42 / 12%);
}
.collaborator-photo + h2 { margin: 22px 0 6px; font-size: clamp(25px, 4vw, 38px); }
.collaborator-meta { margin: 0; color: var(--muted); font-size: 16px; }
.camera-state { color: var(--text); }
.camera-state h2 { margin: 24px 0 8px; color: var(--ink); }
.camera-state p { margin: 0; color: var(--muted); }
.camera-glyph, .small-camera-glyph { position: relative; display: inline-block; background: var(--brand); border-radius: 14px; }
.camera-glyph { width: 126px; height: 86px; }
.camera-glyph::before, .small-camera-glyph::before { content: ""; position: absolute; left: 50%; top: 50%; width: 38%; aspect-ratio: 1; transform: translate(-50%, -50%); border: 7px solid #fff; border-radius: 50%; }
.camera-glyph::after, .small-camera-glyph::after { content: ""; position: absolute; left: 20%; top: -12%; width: 34%; height: 20%; background: inherit; border-radius: 7px 7px 0 0; }
.small-camera-glyph { width: 25px; height: 18px; margin-right: 10px; vertical-align: -4px; background: #fff; }
.small-camera-glyph::before { border-width: 2px; }

.action-panel { display: flex; overflow-y: auto; overscroll-behavior: contain; }
.step-panel { width: 100%; margin: auto; }
.digit-display { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 15px; }
.digit-slot { height: clamp(52px, 8.5vh, 76px); display: grid; place-items: center; color: var(--ink); background: var(--softest); border: 1px solid #bfdbfe; border-radius: 13px; font-size: clamp(25px, 4vw, 38px); font-weight: 800; }
.step-support { margin: -14px 0 18px; color: var(--muted); text-align: center; font-size: 13px; font-weight: 700; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(8px, 1.5vh, 14px); }
.key {
  min-height: clamp(50px, 9vh, 76px);
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--soft);
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 800;
  cursor: pointer;
}
.key:active { transform: scale(.97); background: #e2e8f0; }
.key.utility { color: var(--text); background: #e2e8f0; font-size: clamp(12px, 1.8vw, 16px); }
.key.back { color: var(--brand); background: #fff; border: 1px solid #cbd5e1; }
.direct-punch-button { width: min(100%, 330px); min-height: 168px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; border-radius: 24px; font-size: 20px; letter-spacing: .025em; }
.direct-punch-button .small-camera-glyph { width: 68px; height: 48px; margin: 0; border-radius: 11px; }
.direct-punch-button .small-camera-glyph::before { border-width: 5px; border-color: var(--brand); }
.direct-ready-clock { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.direct-ready-clock .today-date { margin-top: 12px; }
.direct-ready-clock .today-time { font-size: clamp(38px, 6vw, 58px); }
.direct-ready-clock + #camera-state-title { margin-top: 14px; }
.cancel-button { width: 100%; border: 0; color: var(--danger); background: transparent; font-weight: 750; cursor: pointer; }
.action-center { display: grid; gap: 14px; }
.review-title { margin-bottom: 26px !important; text-align: left !important; }
.review-row { display: flex; align-items: center; gap: 11px; min-height: 28px; margin: 11px 0; color: var(--text); }
.row-icon { flex: 0 0 20px; width: 20px; height: 20px; border: 2px solid var(--brand); border-radius: 5px; }
.location-icon { border-radius: 50% 50% 50% 0; transform: rotate(-45deg) scale(.8); }
.location-icon + span { transform: none; }
.text-button { margin: 0 0 8px 30px; padding: 3px 0; border: 0; color: var(--brand); background: transparent; font-size: 13px; font-weight: 700; }
.review-hint { margin: 12px 0 16px; color: var(--muted); font-size: 13px; }
#step-review .tall-button { width: 100%; margin-top: 10px; }
.feedback-panel { display: flex; min-height: 70%; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.feedback-panel h1 { margin: 22px 0 8px; font-size: clamp(24px, 4vw, 34px); }
.feedback-panel p { margin: 0; color: var(--muted); }
.spinner { width: 82px; height: 82px; border: 6px solid #dbeafe; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.success-check { width: 116px; height: 116px; display: grid; place-items: center; color: #fff; background: var(--success); border-radius: 50%; font-size: 72px; font-weight: 800; animation: pop .32s ease-out; }

.camera-overlay { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; overflow: hidden; background: #020617; }
.camera-overlay video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.face-guide { position: absolute; width: min(66vw, 360px); height: min(82vw, 450px); max-height: 62vh; border: 3px solid rgb(255 255 255 / 82%); border-radius: 48% 48% 44% 44%; box-shadow: 0 0 0 9999px rgb(2 6 23 / 24%); }
#camera-help { position: absolute; top: calc(var(--safe-top) + 22px); left: 50%; width: 90%; margin: 0; transform: translateX(-50%); color: #fff; text-align: center; font-weight: 700; text-shadow: 0 1px 5px #000; }
.camera-actions { position: absolute; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 24px max(20px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(20px, var(--safe-left)); background: linear-gradient(transparent, rgb(2 6 23 / 75%)); }
.camera-cancel { justify-self: start; border: 0; color: #fff; background: transparent; font-weight: 700; }
.camera-shutter { width: 76px; height: 76px; border: 7px solid #fff; border-radius: 50%; background: rgb(255 255 255 / 28%); box-shadow: 0 0 0 2px rgb(0 0 0 / 22%); }
.camera-shutter:active { transform: scale(.94); }

.app-dialog { width: min(92vw, 430px); padding: 0; border: 0; border-radius: 20px; color: var(--ink); box-shadow: 0 24px 70px rgb(15 23 42 / 26%); }
.app-dialog::backdrop { background: rgb(15 23 42 / 48%); backdrop-filter: blur(3px); }
.app-dialog form { padding: 24px; }
.app-dialog h2 { margin: 0 0 12px; }
.app-dialog p, .app-dialog li { color: var(--text); line-height: 1.5; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.toast { position: fixed; z-index: 150; left: 50%; bottom: calc(24px + var(--safe-bottom)); width: max-content; max-width: min(90vw, 480px); padding: 12px 16px; transform: translateX(-50%); color: #fff; background: rgb(15 23 42 / 94%); border-radius: 12px; text-align: center; box-shadow: 0 10px 35px rgb(15 23 42 / 28%); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 700px) and (orientation: portrait) {
  .brand-header { height: calc(50px + var(--safe-top)); padding-top: calc(var(--safe-top) + 7px); }
  .brand-header .brand-logo { height: 23px; }
  .network-pill { top: calc(var(--safe-top) + 7px); min-height: 29px; }
  .install-link, .exit-button { margin-right: 125px; font-size: 12px; }
  .login-main { min-height: calc(100dvh - 50px - var(--safe-top)); grid-template-columns: 1fr; gap: 12px; padding: 10px 20px calc(18px + var(--safe-bottom)); }
  .login-clock-block .brand-clock { width: min(36vw, 155px); border-width: 8px; box-shadow: inset 0 0 0 5px #fff, inset 0 0 0 11px #b8c8cf, 0 10px 25px rgb(7 78 102 / 10%); }
  .login-clock-block .today-date { margin-top: 8px; }
  .login-clock-block .today-time { font-size: 37px; }
  .login-card { max-width: 430px; }
  .login-card h1 { margin-bottom: 12px; font-size: 18px; }
  .field { margin-bottom: 10px; }
  .field input { min-height: 49px; }
  .primary-button { min-height: 50px; }
  .version { margin-top: 16px; }

  .clock-view { overflow-y: auto; }
  .clock-topbar { height: calc(50px + var(--safe-top)); padding-top: calc(var(--safe-top) + 7px); }
  .clock-topbar .brand-logo { height: 22px; }
  .clock-layout { height: auto; min-height: 100dvh; grid-template-columns: 1fr; grid-template-rows: minmax(210px, 38vh) 1px auto; padding: calc(52px + var(--safe-top)) 14px calc(16px + var(--safe-bottom)); }
  .layout-divider { width: 100%; height: 1px; }
  .info-panel { padding: 8px 12px 14px; }
  .action-panel { padding: 18px 8px 4px; overflow: visible; }
  .compact-clock { width: min(38vw, 170px); border-width: 8px; box-shadow: inset 0 0 0 5px #fff, inset 0 0 0 11px #b8c8cf, 0 10px 25px rgb(7 78 102 / 10%); }
  .info-state .today-date { margin-top: 8px; }
  .info-state .today-time { font-size: 38px; }
  .collaborator-photo, .photo-preview { width: min(43vw, 190px); }
  .collaborator-photo + h2 { margin-top: 10px; font-size: 24px; }
  .camera-glyph { width: 88px; height: 61px; }
  .camera-state h2 { margin-top: 14px; font-size: 20px; }
  .step-panel { max-width: 470px; }
  .step-panel h1 { margin-bottom: 13px; font-size: 18px; }
  .digit-slot { height: 49px; font-size: 24px; }
  .key { min-height: 49px; border-radius: 14px; font-size: 20px; }
  .feedback-panel { min-height: 42vh; }
}

@media (max-height: 540px) and (orientation: landscape) {
  .clock-topbar { height: calc(42px + var(--safe-top)); padding-top: calc(var(--safe-top) + 5px); }
  .clock-topbar .brand-logo { height: 21px; }
  .clock-layout { padding-top: calc(42px + var(--safe-top)); padding-bottom: max(8px, var(--safe-bottom)); }
  .info-panel, .action-panel { padding: 6px 16px; }
  .compact-clock { width: min(29vh, 145px); border-width: 7px; box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 10px #b8c8cf; }
  .info-state .today-date { margin-top: 5px; font-size: 11px; }
  .info-state .today-time { font-size: 30px; }
  .collaborator-photo, .photo-preview { width: min(45vh, 190px); }
  .collaborator-photo + h2 { margin: 8px 0 3px; font-size: 22px; }
  .camera-glyph { width: 80px; height: 54px; }
  .camera-state h2 { margin: 10px 0 4px; font-size: 17px; }
  .step-panel h1 { margin-bottom: 8px; font-size: 16px; }
  .step-support { margin: -4px 0 7px; }
  .digit-display { margin-bottom: 7px; }
  .digit-slot { height: 38px; font-size: 19px; }
  .keypad { gap: 6px; }
  .key { min-height: 38px; border-radius: 11px; font-size: 17px; }
  .review-title { margin-bottom: 8px !important; }
  .review-row { min-height: 20px; margin: 4px 0; font-size: 12px; }
  .review-hint { margin: 5px 0; }
  #step-review .tall-button { min-height: 40px; margin-top: 5px; padding: 7px; font-size: 12px; }
  .tall-button { min-height: 44px; }
  .success-check { width: 78px; height: 78px; font-size: 48px; }
  .spinner { width: 62px; height: 62px; }
}

@media (display-mode: standalone) {
  .install-link { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
