/* ┌─ style.css ─ 웹 앱의 모양 ──────────────────────────────────────────
   │ 구성     : 색 변수(:root, 어두운 모드) → 기본 규칙 → 위쪽 바 → 오늘 매출 → 6칸 → MY SHOP 표 → 배송현황 → 경고 띠 → 로그인 → 팝업
   │ 용어     : CSS = 요소(HTML)를 어떻게 꾸밀지 정하는 언어.  '.이름' = class, '#이름' = id,  var(--이름) = 맨 위에서 정한 색 변수.
   └──────────────────────────────────────────────────────────────
*/

/* 알려줘 웹 앱 스타일. 색은 맨 위 :root 에서 한 번만 정하고, 아래에서는 이름(변수)으로만 씁니다. */
/* CSS 변수: --이름: 값 으로 한 번 정해 두고 var(--이름) 으로 가져다 씁니다. 색을 바꾸고 싶으면 여기 한 곳만 고치면 돼요. */
:root {
  --brand: #F0432B;        /* 로고의 주황빛 빨강 */
  --ink: #222;             /* 기본 글자색 */
  --muted: #666;
  --line: #e6e6e6;         /* 얇은 테두리 */
  --bg: #fff;
  --panel: #f8f8f8;
  --number: #d50000;       /* 건수 숫자 강조색 */
  --err-bg: #ffd6d6;       /* 연동 오류 행 */
  --ip-bg: #fff3e0;  --ip-ink: #e65100;     /* 허용 IP 경고 띠 */
  --key-bg: #ffebee; --key-ink: #d50000;    /* API 키 경고 띠 */
  --soon-bg: #e3f2fd; --soon-ink: #1565c0;  /* 곧 만료 예고 띠 */
}
/* 폰/브라우저가 어두운 화면 모드이면 색을 바꿔 줍니다 */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eee; --muted: #aaa; --line: #3a3a3a; --bg: #161616; --panel: #202020; --number: #ff6b5b;
    --err-bg: #4a2323; --ip-bg: #3d2a14; --ip-ink: #ffb74d; --key-bg: #3d1f23; --key-ink: #ff8a80; --soon-bg: #17283a; --soon-ink: #90caf9;
  }
}
/* box-sizing: border-box : 칸의 폭에 테두리와 안쪽 여백을 포함해서 계산합니다. 화면 폭을 넘치는 일이 줄어요. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  /* env(safe-area-inset-bottom) : 아이폰 아래쪽 홈 막대 같은 가려지는 영역만큼 여백을 줍니다. */
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* 위쪽 바 */
/* position: sticky : 스크롤해도 맨 위에 붙어 있습니다. display: flex 는 안의 요소를 가로로 나란히 놓는 레이아웃이에요. */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 22px; }
.brand img { width: 28px; height: 28px; border-radius: 6px; }
.icon-btn { border: 0; background: none; color: var(--ink); font-size: 14px; padding: 6px 10px; border-radius: 6px; }
.icon-btn:hover { background: var(--panel); }

/* 섹션 제목 줄 */
.sec-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 20px 16px 12px; }  /* 좁은 화면에서는 줄을 바꿔서 글자가 쪼개지지 않게 */
.sec-head h2 { margin: 0; font-size: 20px; font-weight: 800; white-space: nowrap; }
.sec-head .spacer { flex: 1; }
.sec-head .stamp { font-size: 11px; color: var(--muted); text-align: right; line-height: 1.4; margin-left: auto; }
.btn-black { background: #000; color: #fff; border: 0; padding: 8px 12px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn-black:disabled { opacity: .5; cursor: default; }
.btn-brand { background: var(--brand); color: #fff; border: 0; padding: 12px 16px; font-weight: 700; border-radius: 8px; width: 100%; font-size: 16px; }

.box { margin: 0 16px; border: 1px solid var(--line); }

/* 오늘의 매출 */
.today { display: flex; justify-content: space-around; padding: 16px 8px 8px; }
.big { text-align: center; }
.big .label { font-size: 13px; }
.big .num { font-size: 34px; font-weight: 800; color: var(--number); }
.big .unit { font-size: 16px; color: var(--ink); font-weight: 400; margin-left: 2px; }
.note { color: var(--number); font-size: 12px; text-align: center; padding: 0 12px 14px; }

/* 모든 마켓 주문: 3 x 2 칸 */
/* display: grid + repeat(3, 1fr) : 3열 격자(1fr = 남는 폭을 똑같이 나눔). 6칸이 3 × 2 로 놓여요. */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.cell { padding: 14px 4px; text-align: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
/* :nth-child(3n) : 3번째, 6번째... 칸. 오른쪽 줄(세로선)을 없애서 격자 끝이 깔끔하게 합니다. */
.cell:nth-child(3n) { border-right: 0; }
.cell:nth-child(n+4) { border-bottom: 0; }
.cell .ico { font-size: 28px; line-height: 1; }
.cell .name { font-size: 13px; color: var(--muted); margin-top: 4px; }
.cell .count { font-size: 28px; font-weight: 800; color: var(--number); }
.cell .count small { font-size: 14px; color: var(--ink); font-weight: 400; }

/* MY SHOP 표 */
/* 표 설정. border-collapse: collapse 는 칸 사이의 이중 테두리를 하나로 합쳐요. */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 2px; text-align: center; }
th { white-space: nowrap; font-size: 12px; }  /* 머리글이 세로로 쪼개지지 않게 */
td:first-child { word-break: keep-all; }
th { background: var(--panel); font-weight: 700; }
td:first-child, th:first-child { text-align: left; padding-left: 8px; }
th:first-child { text-align: center; }
tbody tr { border-top: 1px solid var(--line); }
tr.err { background: var(--err-bg); color: var(--number); }
tr.clickable { cursor: pointer; }
.shop { display: flex; align-items: center; gap: 6px; }
.shop span.name { text-decoration: underline; }
/* 마켓 배지(N, C, 11 ...). 작은 정사각형 안에 글자를 가운데 놓습니다. 색은 아래 줄에서 마켓마다 다르게 줘요. */
.badge { flex: none; width: 22px; height: 22px; border-radius: 4px; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.badge.naver { background: #03c75a; } .badge.coupang { background: #e52528; } .badge.st11 { background: #ff0038; }
.badge.auction { background: #e5001c; } .badge.gmarket { background: #00a651; } .badge.other { background: #888; }
.warn-ico { color: #ef6c00; }
.empty { padding: 20px; text-align: center; font-size: 14px; }
/* 보안 규칙(CSP)상 HTML 안에 style="..." 를 직접 쓸 수 없어서, 모양은 여기 CSS 에 둡니다 */
.empty.loading { padding-top: 80px; }

/* 배송현황 */
/* 배송현황 두 칸. grid-template-columns: 1fr 1fr = 같은 폭의 두 열. */
.ship { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 16px; }
.ship div { background: #000; color: #fff; text-align: center; padding: 22px 0; font-size: 16px; }
.ship b { display: block; font-size: 18px; font-weight: 400; margin-top: 4px; }

/* 경고 띠 */
.banner { display: block; width: 100%; text-align: left; border: 0; padding: 12px 16px; font-weight: 600; font-size: 14px; line-height: 1.5; }
.banner.error { background: var(--err-bg); color: var(--number); cursor: default; }
.banner.ip { background: var(--ip-bg); color: var(--ip-ink); }
.banner.key { background: var(--key-bg); color: var(--key-ink); }
.banner.soon { background: var(--soon-bg); color: var(--soon-ink); }

/* 아래 */
.foot { margin-top: 24px; padding: 20px 16px; background: var(--panel); color: var(--muted); font-size: 12px; display: flex; flex-direction: column; gap: 8px; }
.foot .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* 로그인 */
.login { padding: 64px 24px 24px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 16px; }
.login h1 { margin: 12px 0 4px; font-size: 26px; }
.login p { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.login input { width: 100%; padding: 14px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; background: var(--bg); color: var(--ink); }
.login .err { color: var(--number); font-size: 14px; margin: 0 0 12px; min-height: 1.2em; }

/* 팝업 상자와 안내 문구 */
/* 경고창(팝업 상자) 모양. ::backdrop 은 상자 뒤의 어두운 배경을 꾸미는 특수 선택자예요. */
dialog { border: 0; border-radius: 16px; padding: 20px; max-width: min(92vw, 420px); background: var(--bg); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog h3 { margin: 4px 0 12px; font-size: 20px; text-align: center; }
dialog .big-ico { text-align: center; font-size: 36px; }
dialog p { font-size: 14px; line-height: 1.6; margin: 8px 0; }
dialog .ipbig { font-size: 22px; font-weight: 800; color: var(--ip-ink); word-break: break-all; }
dialog ul { padding-left: 18px; margin: 6px 0; font-size: 13px; line-height: 1.6; }
dialog code { background: var(--panel); padding: 2px 6px; border-radius: 4px; font-weight: 700; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog .actions button { border: 0; background: none; color: var(--brand); font-weight: 700; padding: 8px 10px; }
/* 잠깐 떴다 사라지는 안내 문구. 평소엔 투명(opacity: 0)이고 .show 가 붙으면 보여요. */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #323232; color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
#toast.show { opacity: 1; }
