/* 오늘의 장부(사원)·로그인 화면. 승인된 order-v4 시안 기준 + 라이트/다크 */
:root {
  --bg: #fff; --text: #191f28; --soft: #f2f4f6; --soft2: #f7f8fa; --muted: #6b7684; --line: #e9ecef;
  --blue: #3182f6; --blue-soft: #f5f9ff; --blue-icon: #e8f3ff;
  --red: #f04452; --red-icon: #ffeeee; --purple: #7c5cff; --purple-icon: #f3f0ff;
  --card: #fff; --err: #d92d35; --ring: #cdd3da; --live: #12a150;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #17171c; --text: #f2f4f6; --soft: #25252c; --soft2: #1e1e24; --muted: #9aa1ab; --line: #2e2e36;
  --blue: #4c8dff; --blue-soft: #1a2740; --blue-icon: #1d2d4d;
  --red: #ff6b75; --red-icon: #3a2024; --purple: #a08cff; --purple-icon: #2a2440;
  --card: #2a2a32; --err: #ff7a7a; --ring: #4a4a55; --live: #3ddc84;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0 auto; max-width: 520px; padding: 22px 16px 28px; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif; word-break: keep-all; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, .row:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
h1 { font-size: 19px; margin: 0; font-weight: 750; }
.top-right { display: flex; align-items: center; gap: 6px; }
.theme { display: flex; background: var(--soft); padding: 3px; border-radius: 20px; }
.theme button { border: 0; background: none; padding: 5px 10px; font-size: 12px; color: var(--muted); border-radius: 16px; }
.theme button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 4px #0002; }
.link { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 6px 2px; }

.meta { display: grid; grid-template-columns: 1fr 64px 1.45fr; gap: 8px; margin-bottom: 8px; }
.meta label { background: var(--soft); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.meta small { display: block; color: var(--muted); font-size: 11px; }
.meta strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta input { width: 100%; border: 0; background: none; font-size: 16px; font-weight: 700; padding: 0; outline: none; }
.meta label:nth-child(2), .meta label:nth-child(2) input { text-align: center; }
#book.draft .meta strong, #book:not(.draft) .meta input, #book.draft #close { display: none; } /* 시작 전 장부: 담당자·코드 입력칸, 마감 없음 */
.where { font-size: 12px; color: var(--muted); margin: 0 2px 14px; }
.where-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.where-row .where { margin-bottom: 6px; }
.where-row .hint { margin-bottom: 0; }
/* 라인 목록: 뒤로 가기처럼 생긴 큰 버튼(대장 지정 위치: 영업소·안내 문구 오른쪽) */
.lines-btn { flex: none; min-width: 40%; min-height: 52px; padding: 10px 16px; border: 1.5px solid var(--blue); border-radius: 14px;
  background: var(--blue-soft); color: var(--blue); font-size: 16px; font-weight: 700; white-space: nowrap; }
.link.strong { color: var(--blue); font-weight: 600; white-space: nowrap; }
.sub-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.sub-head h2 { font-size: 17px; margin: 0; }
.sub-head .boss { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.shift-block { padding: 6px 0 18px; border-bottom: 7px solid var(--soft2); margin-bottom: 14px; }
.shift-block h2 { font-size: 16px; margin: 0; }
.shift-block h2 span { font-size: 12px; font-weight: 500; color: var(--muted); }
.balance.small { margin-top: 6px; padding: 10px 2px 6px; }
.balance.small strong { --fs: 22px; }
.line-title { font-size: 18px; margin: 0; }
.start-btn { margin: 4px 0 18px; }

/* 기록 수정 창: 아래에서 올라오는 시트 */
dialog.sheet { width: 100%; max-width: 520px; margin: auto auto 0; padding: 20px 16px 24px; border: 0; border-radius: 22px 22px 0 0;
  background: var(--bg); color: var(--text); box-shadow: 0 -8px 30px #0004; }
dialog.sheet::backdrop { background: #0009; }
dialog.sheet h2 { font-size: 18px; margin: 0 0 4px; }
dialog.sheet .sub { margin-bottom: 14px; }
dialog.sheet .row { height: 58px; }
.dlg-actions { display: flex; gap: 8px; margin-top: 10px; }
.dlg-actions .send { flex: 2; margin: 0; }
.btn-ghost { flex: 1; border: 0; border-radius: 15px; background: var(--soft); color: var(--text); font-weight: 700; font-size: 16px; }
.hint { color: var(--muted); font-size: 12px; margin: 0 2px 10px; }

.row { display: flex; align-items: center; gap: 10px; border: 1.5px solid transparent; border-radius: 17px; padding: 13px 14px;
  background: var(--soft); margin-bottom: 9px; height: 66px; cursor: pointer; }
.row.active { border-color: var(--blue); background: var(--blue-soft); }
.icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 12px; font-size: 21px; font-weight: 700;
  background: var(--blue-icon); color: var(--blue); }
.icon.red { background: var(--red-icon); color: var(--red); }
.icon.purple { background: var(--purple-icon); color: var(--purple); }
.row b { font-size: 16px; }
.row .value { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); }
.row input { margin-left: auto; width: 55%; min-width: 0; text-align: right; font-size: 22px; font-weight: 700; border: 0; background: none; outline: none; }
.row input::placeholder { font-size: 13px; font-weight: 400; color: var(--muted); }
.row:not(.active) input, .row.active .value { display: none; }
.pick { width: 15px; height: 15px; border: 1.5px solid var(--ring); border-radius: 50%; flex: none; }
.active .pick { border: 4px solid var(--blue); }
/* 월드/메인/AK(맨 위)·현/계(입고 바로 아래) 고르기 */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; margin-bottom: 9px; }
.seg button { border: 1.5px solid transparent; border-radius: 14px; background: var(--soft); color: var(--text); font-size: 15px; font-weight: 700; padding: 11px 0; cursor: pointer; }
.seg button[aria-checked="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.seg[data-seg="pay"] { margin: -3px 0 9px 44px; }
.tag { font-style: normal; font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 4px; }

.send { margin-top: 8px; width: 100%; background: var(--blue); color: #fff; border: 0; border-radius: 15px; padding: 15px; font-weight: 700; font-size: 16px; }
.send:disabled { opacity: .45; cursor: not-allowed; }
.err { color: var(--err); font-size: 13px; min-height: 18px; margin: 8px 2px 0; }

.balance { margin-top: 8px; padding: 17px 2px 12px; border-top: 1px dashed var(--line); display: flex; align-items: baseline; justify-content: space-between; }
.balance span { color: var(--muted); font-size: 13px; }
.balance { container-type: inline-size; } /* 큰 잔고를 줄 너비에 맞추는 기준 */
.balance strong { --fs: 31px; font-size: min(var(--fs), 65cqi / var(--len, 1) / .6); letter-spacing: -.6px; }
.balance strong.neg { color: var(--err); }
.totals { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 0 2px 16px; }
.totals b { color: var(--text); margin-left: 4px; }

.history { margin-top: 18px; border-top: 7px solid var(--soft2); padding-top: 20px; }
.history-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.history h2 { font-size: 17px; margin: 0; }
.history h2 span { font-weight: 400; color: var(--muted); font-size: 13px; }
.sub { font-size: 12px; color: var(--muted); margin: 3px 0 0; }
.close-day { flex: none; border: 1px solid var(--blue); border-radius: 10px; background: var(--blue); color: #fff; font-weight: 650; font-size: 13px; min-height: 40px; padding: 8px 17px; }
.item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item .icon { width: 29px; height: 29px; font-size: 17px; border-radius: 10px; }
.item b { font-size: 14px; }
.item small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.item strong { margin-left: auto; font-size: 16px; white-space: nowrap; }
.item strong.plus { color: var(--blue); }
.edit { border: 0; background: var(--soft); color: var(--muted); padding: 6px 9px; border-radius: 8px; font-size: 12px; flex: none; }
.empty { color: var(--muted); font-size: 13px; padding: 18px 0; text-align: center; margin: 0; }

.lines { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 6px; }
.line { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 96px;
  border: 1.5px solid transparent; background: var(--soft); border-radius: 15px; padding: 10px 8px; text-align: center; min-width: 0; }
.line b { display: block; font-size: 16px; }
.line b.no { font-size: 30px; font-weight: 800; line-height: 1.15; }
/* '나' 표시는 모서리에 띄워서 숫자가 가운데에서 밀리지 않게 */
.line .me { position: absolute; top: 7px; right: 7px; padding: 1px 6px; border-radius: 6px; background: var(--blue); color: #fff; font-size: 11px; font-weight: 700; line-height: 1.5; }
.line small { display: block; max-width: 100%; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line small.wrap { white-space: normal; } /* 잔고가 길면(1억 단위) 숫자를 다음 줄로 */
.line.on { border-color: var(--blue); background: var(--blue-soft); }
.line:disabled { opacity: .45; cursor: not-allowed; }

/* 진행 중 라인: LED처럼 색이 계속 도는 테두리 */
@property --led { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.line.live {
  border: 2.5px solid transparent;
  background:
    linear-gradient(var(--soft), var(--soft)) padding-box,
    conic-gradient(from var(--led), #ff4d6d, #ffa94d, #ffe14d, #4dff91, #4dd8ff, #6f6bff, #e24dff, #ff4d6d) border-box;
  box-shadow: 0 0 14px rgba(120, 140, 255, .28);
  animation: led-spin 3s linear infinite;
}
.line.live.on { background: linear-gradient(var(--blue-soft), var(--blue-soft)) padding-box,
    conic-gradient(from var(--led), #ff4d6d, #ffa94d, #ffe14d, #4dff91, #4dd8ff, #6f6bff, #e24dff, #ff4d6d) border-box; }
.line.live:disabled { opacity: 1; }
/* 돌아가고 있는 라인 번호는 초록색으로 구분 */
.line.live b.no { color: var(--live); }
@keyframes led-spin { to { --led: 360deg; } }
@media (prefers-reduced-motion: reduce) { .line.live { animation: none; } }

.login { max-width: 380px; margin: 10vh auto 0; }
.field { display: block; background: var(--soft); border-radius: 14px; padding: 10px 14px; margin-bottom: 10px; }
.field small { display: block; color: var(--muted); font-size: 11px; }
.field input { width: 100%; border: 0; background: none; font-size: 16px; padding: 4px 0 0; outline: none; }
.field:focus-within { box-shadow: 0 0 0 2px var(--blue); }
.foot { font-size: 11px; text-align: center; color: var(--muted); margin-top: 18px; }
