/* SJ Attendance — employee app */
:root {
  --ink: #1d3f8f;
  --ink-2: #2c55b3;
  --ink-soft: #e4eaf7;
  --paper: #f6f8fc;
  --card: #ffffff;
  --rule: #d8dfeb;
  --rule-2: #bfcae0;
  --text: #18233a;
  --muted: #5b6577;
  --p: #19734a;   --p-soft: #e2f2e9;
  --a: #b42318;   --a-soft: #fdecea;
  --hd: #9a5a06;  --hd-soft: #fcefdb;
  --l: #6b45b8;   --l-soft: #eee8fa;
  --h: #5d6b82;   --h-soft: #eaeef4;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Hind", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabbar: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--body);
  color: var(--text);
  background: var(--paper);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--text); }
:focus-visible { outline: 3px solid var(--ink-2); outline-offset: 2px; }

.screen { max-width: 480px; margin: 0 auto; min-height: 100vh; }
.muted { color: var(--muted); }
.center { text-align: center; }

.banner {
  margin: 0; padding: 10px 16px; background: var(--a-soft); color: var(--a);
  font-size: 14px; text-align: center;
}

/* ---------- buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 600; cursor: pointer;
  min-height: 48px;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:active { background: var(--ink-2); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--rule-2); }
.btn.danger { background: transparent; color: var(--a); box-shadow: inset 0 0 0 1.5px #efc2bd; }
.btn.big { width: 100%; font-size: 18px; min-height: 54px; }
.btn.wide { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink); cursor: pointer;
  fill: currentColor;
}
.icon-btn:active { background: var(--ink-soft); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--rule-2); border-radius: 10px; background: #fff;
  padding: 12px 14px; min-height: 50px; font-size: 18px;
}
.field textarea { min-height: 84px; font-size: 16px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--ink-soft); }
.field small { color: var(--muted); font-size: 13px; }
.form-error { margin: 0; min-height: 0; color: var(--a); font-size: 15px; }
.form-error:empty { display: none; }

/* ---------- login ---------- */
.login { padding: 40px 20px 32px; display: flex; flex-direction: column; gap: 28px; }
.login-top h1 { font-family: var(--display); font-size: 40px; line-height: 1.05; color: var(--ink); margin: 18px 0 6px; font-weight: 700; }
.login-top p { margin: 0; color: var(--muted); }
.login-logo { border-radius: 18px; display: block; }
.install-note { border-top: 1px solid var(--rule); padding-top: 18px; color: var(--muted); font-size: 15px; }
.install-note p { margin: 0 0 10px; }

/* ---------- app shell ---------- */
#screen-app { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 8px 10px 20px; border-bottom: 1px solid var(--rule);
  background: var(--paper); position: sticky; top: 0; z-index: 5;
}
.co-name { font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.hello { color: var(--muted); font-size: 15px; }
.tab { padding: 16px 20px; }

/* ---------- punch clock ---------- */
.clock-wrap { display: flex; flex-direction: column; align-items: center; padding: 12px 0 6px; }
.date-line { margin: 0 0 18px; font-family: var(--display); font-size: 22px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.punch {
  position: relative;
  width: min(70vw, 248px); aspect-ratio: 1 / 1; border-radius: 50%; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--display); background: var(--ink); color: #fff;
  box-shadow: 0 0 0 10px var(--ink-soft), 0 0 0 11.5px var(--rule-2), 0 14px 30px rgba(29, 63, 143, .22);
  transition: transform .12s ease;
}
.punch:active { transform: scale(.97); }
.punch-time { font-size: 68px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.punch-label { font-size: 24px; font-weight: 600; margin-top: 8px; }
.punch.out { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 5px var(--ink), 0 0 0 10px var(--ink-soft), 0 0 0 11.5px var(--rule-2), 0 14px 30px rgba(29, 63, 143, .14); }
.punch.done { background: var(--p-soft); color: var(--p); cursor: default; box-shadow: inset 0 0 0 5px var(--p), 0 0 0 10px #f0f7f3, 0 0 0 11.5px #cfe5d8; }
.punch.done .punch-label { font-size: 20px; }
.punch.busy { opacity: .9; cursor: progress; }
.punch.busy .punch-label { font-size: 19px; }
.punch::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 3px solid currentColor;
  opacity: 0; pointer-events: none;
}
.punch.stamp { animation: stamp .55s cubic-bezier(.3, .7, .3, 1); }
.punch.stamp::after { animation: ripple .8s ease-out; }
@keyframes stamp { 0% { transform: scale(1); } 30% { transform: scale(.9); } 65% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes ripple { 0% { opacity: .55; transform: scale(.92); } 100% { opacity: 0; transform: scale(1.25); } }
.punch-hint { margin: 26px 0 0; color: var(--muted); text-align: center; }
.punch-msg { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--a-soft); color: var(--a); text-align: center; font-size: 15px; max-width: 340px; }

.timecard {
  margin: 26px 0 0; display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 2px solid var(--text); border-bottom: 1px solid var(--rule-2);
}
.timecard > div { padding: 10px 6px 12px; text-align: center; }
.timecard > div + div { border-left: 1px solid var(--rule); }
.timecard span { display: block; font-size: 13px; color: var(--muted); }
.timecard b { font-family: var(--display); font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- month ---------- */
.month-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-head h2 { margin: 0; font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--ink); }
.month-sum { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 0 14px; border-bottom: 1px solid var(--rule); font-size: 15px; }
.month-sum b { font-family: var(--display); font-size: 22px; font-weight: 600; margin-right: 4px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 2px; }
.cal button {
  border: 0; background: #fff; border-radius: 8px; padding: 4px 0 6px; min-height: 52px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px; box-shadow: inset 0 0 0 1px var(--rule);
}
.cal button .dn { font-size: 13px; color: var(--muted); line-height: 1.2; }
.cal button .st { font-family: var(--display); font-size: 20px; font-weight: 700; line-height: 1; }
.cal button.off { background: var(--h-soft); box-shadow: none; }
.cal button.today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal button.sel { background: var(--ink-soft); }
.cal button .late { width: 6px; height: 6px; border-radius: 50%; background: var(--a); }
.s-p { color: var(--p); } .s-hd { color: var(--hd); } .s-a { color: var(--a); } .s-l { color: var(--l); }
.s-h { color: var(--h); } .s-mp { color: var(--hd); } .s-in { color: var(--ink); } .s-na { color: var(--rule-2); }
.day-detail { margin-top: 14px; padding: 12px 14px; background: #fff; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--rule); font-size: 15px; }
.day-detail h3 { margin: 0 0 6px; font-size: 16px; }
.day-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; }
.day-detail dt { color: var(--muted); }
.day-detail dd { margin: 0; font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.legend i { font-style: normal; font-family: var(--display); font-weight: 700; font-size: 16px; margin-right: 2px; }

/* ---------- advance and expense ---------- */
.balance { display: flex; flex-direction: column; align-items: flex-start; padding: 8px 0 18px; }
.balance span { color: var(--muted); font-size: 15px; }
.balance b { font-family: var(--display); font-size: 48px; font-weight: 700; color: var(--ink); line-height: 1.05; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 18px 0 0; padding: 0; border-top: 2px solid var(--text); }
.list li { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.list .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.list .amt { font-family: var(--display); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.list .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.list .note { font-size: 14px; margin-top: 6px; padding-left: 10px; border-left: 3px solid var(--rule-2); color: var(--text); }
.list .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.list .empty { color: var(--muted); text-align: center; padding: 28px 0; border-bottom: 0; }
.chip { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.chip.wait { background: var(--hd-soft); color: var(--hd); }
.chip.ok { background: var(--p-soft); color: var(--p); }
.chip.no { background: var(--a-soft); color: var(--a); }
.chip.done { background: var(--h-soft); color: var(--h); }
.chip.run { background: var(--ink-soft); color: var(--ink); }
.bill-preview { margin-top: 8px; max-width: 100%; max-height: 220px; border-radius: 8px; display: block; }
.photo-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.photo-pick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--rule);
  max-width: 480px; margin: 0 auto;
}
.tabbar button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 13px; font-weight: 500; position: relative;
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--ink); font-weight: 600; }
.tabbar button.on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--ink); }
.tabbar .dot { position: absolute; top: 8px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--a); }

/* ---------- camera ---------- */
.camera { position: fixed; inset: 0; z-index: 50; background: #0d1424; color: #fff; display: flex; flex-direction: column; }
.cam-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; font-family: var(--display); font-size: 22px; font-weight: 600; }
.cam-close { border: 0; background: rgba(255, 255, 255, .12); color: #fff; border-radius: 99px; padding: 8px 16px; font-size: 15px; cursor: pointer; }
.cam-view { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cam-view video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); background: #000; }
.cam-ring { position: absolute; width: min(68vw, 280px); aspect-ratio: 3 / 4; border-radius: 50%; box-shadow: 0 0 0 2000px rgba(13, 20, 36, .55); border: 3px solid rgba(255, 255, 255, .85); }
.cam-status { text-align: center; margin: 12px 16px 0; font-size: 16px; min-height: 24px; }
.cam-actions { display: flex; justify-content: center; padding: 18px 0 calc(22px + env(safe-area-inset-bottom)); }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: rgba(255, 255, 255, .25); cursor: pointer; }
.shutter:active { background: #fff; }
.cam-fallback { display: block; text-align: center; padding: 0 16px calc(18px + env(safe-area-inset-bottom)); color: #c9d6f5; text-decoration: underline; font-size: 15px; cursor: pointer; }
.cam-fallback input { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(13, 20, 36, .45); }
.sheet-panel {
  position: relative; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto;
  background: var(--paper); border-radius: 18px 18px 0 0; padding: 6px 20px calc(24px + env(safe-area-inset-bottom));
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--paper); padding: 8px 0; z-index: 1; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-size: 26px; color: var(--ink); }
.menu-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.menu-list button { width: 100%; text-align: left; border: 0; background: transparent; padding: 16px 4px; border-bottom: 1px solid var(--rule); font-size: 17px; cursor: pointer; }
.menu-list button.danger { color: var(--a); }
.sheet img.full { width: 100%; border-radius: 10px; display: block; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; background: var(--text); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 16px;
  max-width: calc(100% - 32px); text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.good { background: var(--p); }
.toast.bad { background: var(--a); }

@media (prefers-reduced-motion: reduce) {
  .punch.stamp, .punch.stamp::after, .sheet-panel { animation: none; }
  .punch { transition: none; }
}
