/* 시도시도 매장비서 — 밝은 단일 테마, 모바일 우선
   토큰만 바꾸면 전체 색이 바뀐다. 다크모드는 두지 않는다(대표님 선호). */
:root {
  --brand: #6D28D9;          /* 글자·링크용 보라 */
  --brand-solid: #7C3AED;    /* 채운 버튼 배경 */
  --brand-weak: #F3EEFF;
  --brand-line: #DCCFFB;
  --ink: #1D1A2B;
  --ink-2: #4A4660;
  --ink-3: #78738F;
  --line: #E3E0EC;
  --bg: #F6F5FA;
  --card: #FFFFFF;
  --ok: #047857;  --ok-weak: #E7F7F0;
  --warn: #B45309; --warn-weak: #FEF4E3;
  --danger: #C81E1E; --danger-weak: #FDECEC;
  --info: #1D4ED8; --info-weak: #EAF0FE;
  --part-음료: #2563EB; --part-제빵: #D97706; --part-홀: #059669; --part-주방: #DB2777; --part-관리: #7C3AED;
  --r: 14px;
  --r-sm: 10px;
  --shadow: 0 1px 2px rgba(29,26,43,.06), 0 4px 14px rgba(29,26,43,.06);
  --tabbar-h: 64px;
  --header-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: Pretendard, "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
          "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  /* 한국어는 어절 단위로 줄바꿈('58.5시|간'·'베러먼|데이' 방지). 넘칠 때만 아무 데서나 끊어 가로 넘침을 막는다 */
  word-break: keep-all; overflow-wrap: anywhere; }
/* 표의 숫자·금액은 글자 중간에서 끊지 않는다(넘치면 .table-wrap 이 가로 스크롤) */
.r-table th, .r-table td, .num, .nowrap { overflow-wrap: normal; }
body { min-height: 100dvh; overscroll-behavior-y: contain; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
mark { background: #FFE58F; color: inherit; border-radius: 3px; padding: 0 1px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h2 { font-size: 20px; font-weight: 750; }
h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.hide { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 상단바 */
.app-header { position: sticky; top: 0; z-index: 30; height: var(--header-h); display: flex; align-items: center;
  gap: 8px; padding: 0 12px 0 16px; background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.app-header .title { flex: 1; font-size: 18px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header .back { border: 0; background: none; font-size: 24px; padding: 0; cursor: pointer; flex: none;
  min-width: 44px; min-height: 44px; display: grid; place-items: center; margin-left: -12px; border-radius: 12px; }
.app-header .back:active { background: var(--brand-weak); }
.icon-btn { position: relative; border: 0; background: none; font-size: 21px; width: 44px; height: 44px; flex: none;
  border-radius: 12px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:active { background: var(--brand-weak); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center; }
.store-chip { position: relative; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px;
  min-height: 36px; font-size: 13px; font-weight: 650; cursor: pointer; white-space: nowrap; flex: none; }
.store-chip::after { content: ""; position: absolute; left: 0; right: 0; top: -5px; bottom: -5px; }  /* 터치 영역 44px: ::after는 테두리 안쪽(34px) 기준이라 5px씩 = 테두리 밖 4px */

/* ── 본문 */
main#view { padding: 14px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px); max-width: 760px; margin: 0 auto; }
/* 떠 있는 버튼(FAB)이 있는 화면: 끝까지 내렸을 때 마지막 항목이 FAB(58px+18px)에 가리지 않게 */
main#view:has(.fab), main#view.has-fab { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 96px); }
.stack > * + * { margin-top: 12px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 8px;
  font-size: 15px; font-weight: 750; color: var(--ink-2); }
.section-title a, .section-title button { font-size: 13px; font-weight: 600; }

/* ── 카드·목록 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.card.tap, button.card { cursor: pointer; text-align: left; width: 100%; box-shadow: var(--shadow); }
.card.tap:active, button.card:active { transform: scale(.995); background: #FCFBFF; }
.card.flat { box-shadow: none; }
.card.brand { background: var(--brand-weak); border-color: var(--brand-line); }
.card.warn { background: var(--warn-weak); border-color: #F6D9A8; }
.card.danger { background: var(--danger-weak); border-color: #F5C2C2; }
.card.ok { background: var(--ok-weak); border-color: #B9E5D2; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); min-height: 56px; }
.list > .item:first-child { border-top: 0; }
.list > .item.tap { cursor: pointer; }
.list > .item.tap:active { background: #FAF8FF; }
.item .title { font-weight: 650; }
.item .sub { font-size: 13px; color: var(--ink-3); }
.empty { text-align: center; color: var(--ink-3); padding: 34px 12px; }
.empty .big { font-size: 38px; margin-bottom: 6px; }

/* ── 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 700; cursor: pointer;
  white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand-solid); border-color: var(--brand-solid); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.soft { background: var(--brand-weak); border-color: var(--brand-line); color: var(--brand); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.sm { position: relative; min-height: 40px; min-width: 44px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.sm::after { content: ""; position: absolute; left: 0; right: 0; top: -3px; bottom: -3px; }  /* 터치 영역 44px: 테두리 안쪽 38px + 3px×2 */
.btn.lg { min-height: 54px; font-size: 17px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

/* ── 칩·배지·세그먼트 */
.chip { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; min-height: 36px;
  border-radius: 999px; font-size: 13px; font-weight: 650; background: #F1F0F6; color: var(--ink-2);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
/* 터치 영역 44px(R1-core-5): .chips 밖 칩(.row 안·시트 안·화면별 칩 줄)도 칩 높이와 상관없이 가운데 기준 44px.
   예전엔 아래 .chips 규칙만 있어서 그 밖의 칩은 36px였다. (가운데 맞춤이라 테두리 두께와 무관) */
.chip::after { content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 22px); height: 44px; }
/* 가로 스크롤 줄(.chips) 안: 확장이 위아래 여백 4px 안에만 있어야 스크롤 영역에 잘리지 않는다 → 테두리 안쪽 34px + 5px×2 = 테두리 밖 4px */
.chips > .chip::after { content: ""; position: absolute; left: 0; right: 0; top: -5px; bottom: -5px; height: auto; }
.chip.on { background: var(--brand-solid); color: #fff; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }  /* 위아래 4px = 칩 터치 여백(스크롤 영역 안) */
.chips::-webkit-scrollbar { display: none; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #F1F0F6; color: var(--ink-2); }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }
.badge.info { background: var(--info-weak); color: var(--info); }
.badge.brand { background: var(--brand-weak); color: var(--brand); }
.seg { display: flex; background: #EEEDF4; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 6px; min-height: 44px; font-weight: 700; font-size: 14px; color: var(--ink-3); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ── 입력 */
.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 650; color: var(--ink-2); margin: 0 0 5px 2px; }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; font-size: 16px; outline: none; }
.input:focus { border-color: var(--brand-solid); box-shadow: 0 0 0 3px rgba(124,58,237,.14); }
textarea.input { min-height: 90px; resize: vertical; }
/* 체크박스: 기본 13px → 22px, 체크박스를 감싼 label 전체가 44px 탭 영역 */
/* :where() = 우선순위 0 → 화면별 스타일(.ct-check input 등)이 있으면 그쪽이 이긴다 */
:where(input[type=checkbox], input[type=radio]) { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--brand-solid); cursor: pointer; }
:where(label:has(> input[type=checkbox]), label:has(> input[type=radio])) { min-height: 44px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
/* 접기·펼치기 머리줄(summary): 글자 한 줄이어도 44px(R1-core-5 — 급여 '확인할 것'·영업시간·설정 '더 보기').
   :where() = 우선순위 0 → 화면이 min-height를 직접 정했으면 그쪽이 이긴다. display는 그대로(펼침 표시 ▶ 유지),
   글자는 align-content로 가운데(지원 안 하는 옛 브라우저는 위쪽에 붙을 뿐 터치 영역은 같다) */
:where(details) > :where(summary) { min-height: 44px; align-content: center; cursor: pointer; }
.search-box { position: relative; }
.search-box .input { padding-left: 40px; }
.search-box::before { content: "🔍"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .6; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }   /* minmax(0) — 날짜칸 등이 좁은 폰에서 넘치지 않게 */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ── 숫자 카드(KPI) */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi .label { font-size: 12.5px; color: var(--ink-3); font-weight: 650; }
.kpi .value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .delta { font-size: 12.5px; font-weight: 700; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); }

/* ── 타일(더보기) */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px 6px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; text-align: center;
  font-size: 13.5px; font-weight: 650; color: var(--ink); min-height: 92px; }
.tile .ic { font-size: 28px; line-height: 1; }
.tile:active { background: var(--brand-weak); }

/* ── 하단 탭바 */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b); background: rgba(255,255,255,.97); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11.5px; font-weight: 650; color: var(--ink-3); }
.tabbar a .ic { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabbar a.on { color: var(--brand); }
.tabbar a.on .ic { filter: none; opacity: 1; }

/* ── 떠있는 버튼 */
.fab { position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); z-index: 35; width: 58px; height: 58px;
  border-radius: 50%; border: 0; background: var(--brand-solid); color: #fff; font-size: 30px; box-shadow: 0 8px 22px rgba(124,58,237,.38); cursor: pointer; }
.fab.wide { width: auto; border-radius: 29px; padding: 0 22px; font-size: 16px; font-weight: 750; }

/* ── 바텀시트·모달 */
.backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(20,16,35,.42); animation: fade .15s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 92dvh; display: flex; flex-direction: column;
  background: #fff; border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + var(--safe-b)); animation: up .2s ease-out;
  max-width: 760px; margin: 0 auto; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #DAD7E3; margin: 2px auto 10px; }
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet .sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
.sheet.full { top: 0; max-height: none; border-radius: 0; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ── 토스트 */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 90;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: #221E33; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14.5px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(0,0,0,.2); animation: up .18s; max-width: 92vw; pointer-events: auto; }
.toast.ok { background: var(--ok); } .toast.warn { background: var(--warn); } .toast.danger { background: var(--danger); }
.toast button { background: none; border: 0; color: #FFE58F; font-weight: 800; margin-left: 10px; cursor: pointer; }

/* ── 로그인·PIN 패드 */
.login-wrap { max-width: 460px; margin: 0 auto; padding: 28px 18px 40px; }
.login-brand { text-align: center; margin: 10px 0 22px; }
.login-brand .logo { width: 64px; height: 64px; border-radius: 18px; background: var(--brand-solid); color: #fff;
  display: grid; place-items: center; font-size: 30px; font-weight: 800; margin: 0 auto 10px; }
.people { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.person { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; }
.person.on { border-color: var(--brand-solid); box-shadow: 0 0 0 3px rgba(124,58,237,.16); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px; background: var(--brand-solid); flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand-solid); }
.pin-dots i.on { background: var(--brand-solid); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button { height: 60px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font-size: 24px; font-weight: 700; cursor: pointer; }
.pinpad button:active { background: var(--brand-weak); }

/* ── 채팅 카드(봇 답변) */
.cards > * + * { margin-top: 8px; }
.r-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.r-table th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.r-table td { padding: 7px 8px; border-bottom: 1px solid #F0EEF5; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); }
.copy-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; }
.copy-row:active { background: var(--ok-weak); }
.copy-row .v { font-weight: 750; font-variant-numeric: tabular-nums; }
.notice { padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px; background: var(--info-weak); color: #1E3A8A; }
.notice.warn { background: var(--warn-weak); color: #7C2D12; }
.notice.ok { background: var(--ok-weak); color: #064E3B; }

/* ── 선택 상태(발주보드 다중선택 등) */
.sel { outline: 3px solid var(--brand-solid); outline-offset: -1px; background: var(--brand-weak) !important; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--brand-line); border-top-color: var(--brand-solid); border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { padding: 60px 0; }
/* 연결 끊김 안내 */
.card.offline { line-height: 1.55; }
.card.danger .btn-row { margin-top: 10px; }

@media (min-width: 760px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  /* PC(R1-core-9): 머리줄·하단 탭바·떠 있는 버튼을 본문(가운데 760px)과 같은 폭에 맞춘다.
     예전엔 본문만 가운데라 제목은 왼쪽 끝, 알림 종은 오른쪽 끝, 탭 5개는 화면 전체에 퍼져 시선이 흩어졌다. */
  .app-header { padding-left: calc((100% - 760px) / 2 + 16px); padding-right: calc((100% - 760px) / 2 + 12px); }
  .tabbar { padding-left: calc((100% - 760px) / 2); padding-right: calc((100% - 760px) / 2); }
  .fab { right: calc((100% - 760px) / 2 + 18px); }
}

/* 통합 보정: 토스트가 아래 버튼 탭을 막지 않게(글자는 통과, 토스트 안 버튼만 눌림).
   시트가 열려 있을 때 자리는 app.js placeToastWrap()이 시트 바로 위(또는 시트 머리줄)로 정한다(R1-core-6).
   .top 은 예전 방식(머리줄 아래 고정) — 지금은 쓰지 않지만 화면 코드가 붙여도 깨지지 않게 남겨 둔다. */
.toast-wrap.top { bottom: auto; top: calc(var(--header-h) + 10px); }
.toast-wrap.on-sheet { z-index: 95; }
.toast { pointer-events: none; }
.toast button { pointer-events: auto; }

/* ── 매장 코드(기기 등록) 화면 — 클라우드(인터넷) 서버에서 처음 쓰는 기기 */
.join-form { margin-top: 4px; }
.join-code { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: 6px; text-transform: uppercase;
  font-variant-numeric: tabular-nums; min-height: 56px; padding-left: 12px; padding-right: 6px; }
.join-code::placeholder { color: #C9C5D6; letter-spacing: 6px; font-weight: 700; }
.join-msg { color: var(--danger); min-height: 20px; }
.join-help { margin-top: 18px; }
.join-help > * + * { margin-top: 6px; }
.login-left { min-height: 18px; margin: 2px 0 10px; font-weight: 650; }
