/* ============================================================
   수영원예 거래처 주문관리 — 디자인 시스템
   Pretendard / 블랙앤화이트 / 텍스트 위주
   ============================================================ */

:root {
  --primary: #111417;
  --primary-dark: #000000;
  --primary-soft: #f1f2f3;
  --primary-softer: #f7f7f8;

  --bg: #fafafa;
  --card: #ffffff;
  --line: #e4e4e7;
  --line-soft: #efeff1;

  --text: #111417;
  --text-sub: #55585e;
  --text-faint: #9a9da3;

  --danger: #111417;
  --danger-soft: #f1f2f3;
  --warning: #111417;
  --warning-soft: #f4f4f5;
  --info: #111417;
  --info-soft: #f1f2f3;
  --gray-soft: #f1f2f3;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: none;
  --nav-h: 58px;
  --header-h: 54px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.01em;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  color: inherit;
}

/* ---------- 레이아웃 ---------- */
.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: calc(var(--nav-h) + 24px);
  position: relative;
}
.app.wide { max-width: 860px; }

.page { display: none; padding: 16px 16px 8px; }
.page.active { display: block; }

/* ---------- 상단 헤더 ---------- */
.header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--text);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.header .brand {
  display: flex; align-items: baseline; gap: 7px;
  font-weight: 800; font-size: 17px; letter-spacing: -0.02em;
}
.header .brand small { font-weight: 600; color: var(--text-faint); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  position: relative;
  height: 34px; padding: 0 10px; border-radius: 8px;
  border: none; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  color: var(--text); font-size: 13px; font-weight: 700;
}
.icon-btn:active { background: var(--gray-soft); }
.icon-btn .badge-dot {
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--text); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
}

/* ---------- 하단 네비게이션 (텍스트) ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; height: var(--nav-h);
  background: #fff;
  border-top: 1px solid var(--text);
  display: flex; z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav.wide { max-width: 860px; }
.bottom-nav button {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 13.5px; font-weight: 600;
  border-top: 2px solid transparent; margin-top: -1px;
}
.bottom-nav button.active {
  color: var(--text); font-weight: 800;
  border-top-color: var(--text);
}

/* ---------- 카드 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}
.card.flat { border: 1px solid var(--line); }
.card.tight { padding: 14px 16px; }

.card-title {
  font-size: 15px; font-weight: 800; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title .more { font-size: 12.5px; font-weight: 600; color: var(--text-faint); cursor: pointer; background: none; border: none; text-decoration: underline; }

.section-label {
  font-size: 13px; font-weight: 800; color: var(--text);
  margin: 22px 2px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-label .more { font-size: 12px; font-weight: 600; color: var(--text-faint); cursor: pointer; background: none; border: none; text-decoration: underline; }

/* ---------- 히어로(잔액) 카드 ---------- */
.hero {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
  margin-bottom: 12px;
}
.hero .hero-label { font-size: 13px; color: var(--text-sub); font-weight: 500; }
.hero .hero-amount { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin: 2px 0 16px; font-variant-numeric: tabular-nums; }
.hero .hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-soft); border-top: 1px solid var(--line); padding-top: 1px; }
.hero .hero-cell { background: var(--card); padding: 10px 2px 2px; }
.hero .hero-cell .k { font-size: 11.5px; color: var(--text-faint); }
.hero .hero-cell .v { font-size: 16px; font-weight: 700; margin-top: 1px; font-variant-numeric: tabular-nums; }
.hero .hero-cell .v.warn { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 통계 그리드 ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-grid.cols3 { grid-template-columns: 1fr 1fr 1fr; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px;
}
.stat .k { font-size: 12px; color: var(--text-sub); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--text-faint); }
.stat .v.danger, .stat .v.primary, .stat .v.warning { color: var(--text); }
.stat .v.danger { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--text); cursor: pointer; font-weight: 700;
  border-radius: 10px; padding: 12px 18px; font-size: 15px;
  background: var(--text); color: #fff;
  text-decoration: none;
}
.btn:active { opacity: .85; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 8px; font-weight: 600; }
.btn.xs { padding: 4px 10px; font-size: 12px; border-radius: 7px; font-weight: 600; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--text); }
.btn.outline { background: #fff; color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.danger { background: var(--text); color: #fff; }
.btn.danger-ghost { background: #fff; color: var(--text); border: 1px solid var(--text); }
.btn.gray { background: var(--gray-soft); color: var(--text-sub); border-color: var(--gray-soft); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ---------- 폼 ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 700; color: var(--text-sub);
  margin-bottom: 6px;
}
.field label .req { color: var(--text); margin-left: 2px; }
.input, .field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  background: #fff;
  outline: none;
}
.field textarea { resize: vertical; min-height: 84px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--text);
}
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

/* ---------- 검색 ---------- */
.search-wrap {
  position: sticky; top: var(--header-h); z-index: 30;
  padding: 10px 0 12px; margin: -16px -16px 4px; padding-left: 16px; padding-right: 16px;
  background: var(--bg);
}
.search-box { position: relative; }
.search-box input {
  width: 100%; border: 1px solid var(--text); background: #fff;
  border-radius: 10px; padding: 12px 42px 12px 14px; font-size: 15px; outline: none;
}
.search-box .clear-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: var(--gray-soft); color: var(--text-sub);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: 13px;
  display: none;
}

/* ---------- 리스트 아이템 ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.item-card.clickable { cursor: pointer; }
.item-card.clickable:active { background: var(--primary-softer); }
.item-main { flex: 1; min-width: 0; }
.item-main .t { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.item-main .s { font-size: 12.5px; color: var(--text-sub); margin-top: 2px; }
.item-main .s b { color: var(--text); }
.item-side { text-align: right; flex-shrink: 0; }
.item-side .amount { font-weight: 800; font-size: 15.5px; font-variant-numeric: tabular-nums; }
.item-side .amount.minus { color: var(--text); }
.item-side .amount.plus { color: var(--text-sub); }
.item-side .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }

/* ---------- 배지 (흑백 위계) ---------- */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  white-space: nowrap; border: 1px solid transparent;
}
.badge.green { background: var(--text); color: #fff; }
.badge.red { background: #fff; color: var(--text); border-color: var(--text); }
.badge.amber { background: #fff; color: var(--text-sub); border-color: var(--text-faint); }
.badge.blue { background: var(--gray-soft); color: var(--text); }
.badge.gray { background: var(--gray-soft); color: var(--text-faint); }

/* ---------- 키/값 테이블 ---------- */
.kv { width: 100%; }
.kv .row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft); gap: 12px;
}
.kv .row:last-child { border-bottom: none; }
.kv .row .k { font-size: 13px; color: var(--text-sub); flex-shrink: 0; }
.kv .row .v { font-size: 14px; font-weight: 600; text-align: right; word-break: break-all; font-variant-numeric: tabular-nums; }
.kv .row .v.big { font-size: 17px; font-weight: 800; }
.kv .row .v.danger { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.kv .row .v.primary { color: var(--text); }

/* ---------- 탭 ---------- */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px;
  margin-bottom: 12px; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: #fff; border: 1px solid var(--line);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--text-sub); cursor: pointer; white-space: nowrap;
}
.tabs button.active { background: var(--text); color: #fff; border-color: var(--text); }

/* ---------- 모달 ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(17, 20, 23, .45);
  z-index: 100; display: none; align-items: flex-end; justify-content: center;
}
.modal-back.open { display: flex; }
.modal {
  background: #fff; width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0;
  max-height: 88vh; overflow-y: auto;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--text);
}
.modal .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 14px; }
.modal h3 { font-size: 17px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 토스트 ---------- */
#toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 18px);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: max-content; max-width: 92vw;
}
.toast {
  background: var(--text); color: #fff;
  padding: 11px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
}
.toast.error { background: #fff; color: var(--text); border: 1px solid var(--text); }

/* ---------- 수량 스테퍼 ---------- */
.stepper { display: flex; align-items: center; border: 1px solid var(--text); border-radius: 10px; overflow: hidden; }
.stepper button {
  width: 44px; height: 44px; border: none; background: #fff;
  font-size: 20px; font-weight: 700; cursor: pointer; color: var(--text);
}
.stepper input {
  width: 64px; height: 44px; border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  text-align: center; font-size: 17px; font-weight: 800; outline: none;
}

/* ---------- 장바구니 바 ---------- */
.cart-bar {
  position: fixed; bottom: calc(var(--nav-h) + 10px); left: 50%; transform: translateX(-50%);
  width: calc(100% - 24px); max-width: 536px;
  background: #fff; color: var(--text);
  border: 1px solid var(--text);
  border-radius: 12px; padding: 12px 16px;
  display: none; align-items: center; justify-content: space-between;
  cursor: pointer; z-index: 45;
  box-shadow: 0 4px 16px rgba(17, 20, 23, .08);
}
.cart-bar.show { display: flex; }
.cart-bar .c-info { font-size: 12.5px; color: var(--text-sub); }
.cart-bar .c-total { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cart-bar .c-cta { background: var(--text); color: #fff; border-radius: 8px; padding: 8px 14px; font-weight: 800; font-size: 14px; }

/* ---------- 빈 상태 ---------- */
.empty {
  text-align: center; padding: 40px 16px; color: var(--text-faint);
}
.empty .emoji { display: none; }
.empty .msg { font-size: 14px; font-weight: 700; color: var(--text-sub); }
.empty .sub { font-size: 12.5px; margin-top: 4px; }

/* ---------- 알림 패널 ---------- */
.notif-item {
  display: flex; gap: 10px; padding: 12px 4px;
  border-bottom: 1px solid var(--line-soft); align-items: flex-start;
}
.notif-item:last-child { border-bottom: none; }
.notif-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); margin-top: 7px; flex-shrink: 0; }
.notif-item.read .dot { background: var(--line); }
.notif-item .n-msg { font-size: 13.5px; font-weight: 600; }
.notif-item.read .n-msg { color: var(--text-sub); font-weight: 500; }
.notif-item .n-time { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

/* ---------- 테이블 (정산 등) ---------- */
.table-scroll { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px;
}
table.data th {
  text-align: left; font-size: 11.5px; color: var(--text-sub); font-weight: 700;
  padding: 8px 10px; border-bottom: 1px solid var(--text); white-space: nowrap;
}
table.data td { padding: 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr:last-child td { border-bottom: none; }

/* ---------- 로그인 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 20px;
  background: var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: #fff; border: 1px solid var(--text); border-radius: 16px;
  padding: 34px 28px 28px;
}
.login-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 26px; text-align: center; }
.login-logo .wordmark {
  font-size: 13px; font-weight: 800; letter-spacing: .28em; text-indent: .28em;
  border: 1px solid var(--text); padding: 6px 12px; margin-bottom: 14px;
}
.login-logo h1 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.login-logo p { font-size: 13px; color: var(--text-sub); margin-top: 3px; }
.login-tabs {
  display: flex; border: 1px solid var(--text); border-radius: 10px; overflow: hidden; margin-bottom: 20px;
}
.login-tabs button {
  flex: 1; border: none; background: #fff; padding: 10px;
  font-weight: 700; font-size: 14px; color: var(--text-sub); cursor: pointer;
}
.login-tabs button + button { border-left: 1px solid var(--text); }
.login-tabs button.active { background: var(--text); color: #fff; }
.demo-box {
  margin-top: 18px; background: var(--primary-softer); border: 1px dashed var(--text-faint);
  border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: var(--text-sub); line-height: 1.7;
}
.demo-box b { color: var(--text); }

/* ---------- 기타 ---------- */
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; }
.muted { color: var(--text-faint); font-size: 12.5px; }
.txt-r { text-align: right; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb0 { margin-bottom: 0; }
.star-btn {
  border: none; background: none; cursor: pointer; font-size: 17px;
  color: #d9d9dc; padding: 4px; line-height: 1;
}
.star-btn.on { color: var(--text); }

.notice-banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fff; border: 1px solid var(--text); border-left: 4px solid var(--text);
  border-radius: 10px; padding: 13px 15px;
  color: var(--text); font-size: 13.5px; font-weight: 600; margin-bottom: 12px;
}
.notice-banner.warn, .notice-banner.info { background: var(--primary-softer); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-sub);
}
.chip:active { background: var(--gray-soft); border-color: var(--text); color: var(--text); }

@media (min-width: 640px) {
  .page { padding: 20px 24px 8px; }
  .search-wrap { margin: -20px -24px 4px; padding-left: 24px; padding-right: 24px; }
  .modal { border-radius: 16px; margin-bottom: 4vh; border: 1px solid var(--text); }
  .modal-back { align-items: center; }
}
