/* QR 발급 관리 — 화면 스타일
   🔑 표쌤코딩 브랜드 파랑을 강조색으로 쓴다. 색은 아래 변수 한 곳에서만 정의한다. */

:root {
  --brand:        #1d6fe0;
  --brand-dark:   #1558b3;
  --brand-soft:   #eaf2fe;
  --ink:          #1b2431;
  --ink-soft:     #5a6675;
  --ink-faint:    #8a94a3;
  --line:         #e2e7ee;
  --bg:           #f6f8fb;
  --panel:        #ffffff;
  --danger:       #d8443c;
  --sidebar-w:    240px;
  --radius:       10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Malgun Gothic", "맑은 고딕", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

/* ── 뼈대 ───────────────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  margin: 0;
  padding: 20px 18px 14px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--brand);
  border-bottom: 1px solid var(--line);
}

.cat-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 8px;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cat-item:hover { background: #f2f5f9; }

.cat-item.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 700;
}

.cat-item .label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-item .badge {
  flex: 0 0 auto;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 10px;
  background: #eef1f5;
  color: var(--ink-soft);
  font-size: 11px;
  text-align: center;
}

.cat-item.active .badge { background: #d6e6fc; color: var(--brand-dark); }

.cat-sep {
  height: 1px;
  margin: 8px 10px;
  background: var(--line);
}

.sidebar-foot {
  flex: 0 0 auto;
  padding: 10px;
  border-top: 1px solid var(--line);
}

/* ── 본문 ───────────────────────────────────────────────────────── */

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 18px 22px 40px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.main-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.count { color: var(--ink-faint); font-size: 13px; }
.spacer { flex: 1 1 auto; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}

table.list {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

table.list th,
table.list td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

table.list th {
  background: #fafbfd;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #fbfcfe; }

.c-name  { width: 17%; }
.c-cat   { width: 9%; }
/* 🔑 QR 이 가리키는 짧은 주소. 「복사」 버튼과 한 줄에 서야 하므로 줄바꿈을 막는다. */
.c-short { width: 20%; white-space: nowrap; }
.c-url   { width: 18%; }
.c-desc  { width: 13%; }
.c-note  { width: 11%; }
.c-date { width: 100px; white-space: nowrap; }
.c-act  { width: 210px; white-space: nowrap; text-align: right !important; }

.item-name { font-weight: 700; }

.item-url {
  color: var(--brand);
  text-decoration: none;
  word-break: break-all;
}
.item-url:hover { text-decoration: underline; }

.muted { color: var(--ink-soft); }
.dim   { color: var(--ink-faint); }

.empty {
  margin: 0;
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-faint);
}

/* ── 버튼 ───────────────────────────────────────────────────────── */

button { font-family: inherit; }

.btn-primary,
.btn-ghost,
.btn-danger-ghost,
.btn-mini {
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  padding: 9px 16px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-ghost {
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.btn-ghost:hover { background: #f2f5f9; }

.btn-danger-ghost {
  padding: 8px 14px;
  border: 1px solid #f0cfcd;
  background: #fff;
  color: var(--danger);
}
.btn-danger-ghost:hover { background: #fdf2f1; }

.btn-mini {
  padding: 6px 10px;
  margin-left: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
}
.btn-mini:hover { background: #f2f5f9; color: var(--ink); }

/* 🔴 QR 내려받기는 목록의 주 동작이라 유일하게 색을 준다. */
.btn-mini.download {
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 700;
}
.btn-mini.download:hover { background: var(--brand-soft); }

.btn-mini.danger:hover { background: #fdf2f1; color: var(--danger); }

.wide { width: 100%; }

.btn-close {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 4px;
}
.btn-close:hover { color: var(--ink); }

/* ── 겹창 ───────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 40, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.22);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; }

.modal-body { padding: 18px; }

.modal-body label {
  display: block;
  margin-bottom: 13px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.modal-body input,
.modal-body select,
.modal-body textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: #fff;
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.modal-body textarea { resize: vertical; }

.req { color: var(--danger); }

.preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafbfd;
}

.preview-box {
  width: 108px;
  height: 108px;
  flex: 0 0 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.preview-box canvas,
.preview-box img { width: 96px; height: 96px; display: block; }

.hint { margin: 0; font-size: 12px; color: var(--ink-faint); }

.form-error {
  margin: 0 0 12px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #fdf2f1;
  color: var(--danger);
  font-size: 13px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

#qrFactory {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ── 알림 ───────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 11px 18px;
  border-radius: 22px;
  background: rgba(27, 36, 49, 0.93);
  color: #fff;
  font-size: 13px;
  z-index: 90;
}

.toast.error { background: var(--danger); }

/* ── 좁은 화면 ──────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .cat-nav { max-height: 190px; }
  .main { padding: 14px; }
}

/* ── 🔴 hidden 속성이 항상 이기게 한다 (2026-08-27 버그 수정) ─────────
   🪤 함정 : 브라우저 기본 규칙은 `[hidden] { display: none }` 인데,
      이건 **클래스 선택자보다 우선순위가 낮다.**
      그래서 `.modal-backdrop { display: flex }` 가 `hidden` 을 이겨,
      첫 화면부터 QR 발급 겹창이 화면을 덮고 있었다
      (겹창이 사이드바를 가려 「카테고리를 만들 수 없다」로도 보였다).
   🔑 여기 한 줄로 전부 막는다 — 앞으로 어떤 요소에 display 를 넣어도
      `hidden` 을 붙이면 반드시 사라진다. */
[hidden] { display: none !important; }

/* 카테고리가 0개일 때 「＋ QR코드 발급」은 눌리지 않는다 — 그 이유가 보이게 한다. */
.btn-primary:disabled {
  background: #b9c6d8;
  border-color: #b9c6d8;
  cursor: not-allowed;
}

/* ── 짧은 주소 (단축 URL) ───────────────────────────────────────── */

/* 🪤 코드에는 0·O·1·I·L 을 넣지 않았지만, 그래도 사람이 보고 옮겨 적을 값이다.
   고정폭 글꼴로 두어 8 과 B, 5 와 S 를 눈으로 가릴 수 있게 한다. */
.scode {
  font-family: Consolas, "D2Coding", ui-monospace, monospace;
  font-size: 12.5px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.c-short .btn-mini { margin-left: 6px; }

/* 입력칸 아래에 붙는 한 줄 설명. 라벨은 굵고 이것은 가늘어야 구분된다. */
.field-note {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-faint);
}

.preview .hint code.scode { font-size: 12px; }

/* ── CSV 일괄 등록 ──────────────────────────────────────────────── */

/* 미리보기 표가 들어가므로 발급 창보다 넓어야 한다. */
.modal-wide { max-width: 820px; }

.csv-guide {
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafbfd;
  font-size: 13px;
  line-height: 1.6;
}
.csv-guide code {
  background: var(--brand-soft);
  color: var(--brand-dark);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12px;
}

.csv-pick {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.csv-pick input { display: block; margin-top: 6px; font: inherit; }

.csv-summary {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--brand-soft);
  font-size: 13px;
}
.csv-summary .bad { color: var(--danger); }

/* 🔑 「새로 만들어질 카테고리」는 눈에 띄어야 한다.
   오타 하나로 「홍보용」과 「홍보 용」이 따로 생기는 것을 등록 전에 잡는 자리다. */
.newcat { color: var(--brand-dark); }
.newcat-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 700;
}

/* 줄이 많아도 창이 화면을 넘지 않게 여기서만 스크롤한다. */
.csv-preview, .csv-result { max-height: 340px; overflow-y: auto; }

table.csv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-bottom: 8px;
}
table.csv-table th,
table.csv-table td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
table.csv-table th { background: #fafbfd; color: var(--ink-soft); font-size: 11.5px; position: sticky; top: 0; }
table.csv-table.bad td { color: var(--danger); }
table.csv-table.bad th { background: #fdf2f1; }

.csv-url { word-break: break-all; color: var(--ink-soft); }

.csv-badtitle { margin: 12px 0 6px; font-size: 13px; font-weight: 700; color: var(--danger); }
.csv-done     { margin: 0 0 10px; font-size: 14px; }

/* ── 로그인·소유권 (2026-08-28) ─────────────────────────────────── */

/* 🔑 지금 누구로 들어와 있는지 늘 보이게 한다.
   공용 PC 에서 앞사람 계정으로 발급하는 사고를 막는 가장 싼 장치다. */
.whoami {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.who-name { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-out  { color: var(--ink-faint); text-decoration: none; white-space: nowrap; }
.who-out:hover { color: var(--danger); text-decoration: underline; }

/* 🔑 Private 가 위, Public 이 아래 (팀장님 지시). */
.zone-title {
  padding: 14px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.zone-sub   { font-weight: 400; text-transform: none; letter-spacing: 0; }
.zone-empty { margin: 0; padding: 4px 14px 8px; font-size: 12px; color: var(--ink-faint); }

/* 내 것이 공개로 열려 있으면 Private 쪽에서도 그 사실이 보여야 한다. */
.mark-public,
.mark-owner {
  flex: 0 0 auto;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
}
.mark-public { background: var(--brand-soft); color: var(--brand-dark); }
.mark-owner  { background: #eef1f5; color: var(--ink-faint); font-weight: 400; }

.main-owner { font-size: 12.5px; color: var(--ink-faint); margin-left: 4px; }

.newcat-public {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
}
.newcat-public input { margin-right: 4px; }

/* ── 로그인 화면 ─────────────────────────────────────────────────── */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  padding: 30px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
}
.login-brand { margin: 0 0 6px; font-size: 19px; color: var(--brand); }
.login-sub   { margin: 0 0 20px; font-size: 13px; color: var(--ink-soft); }
.login-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.login-card input {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.login-card input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.btn-primary.wide { width: 100%; padding: 11px; }
.login-error {
  margin: 0 0 14px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #fdf2f1;
  color: var(--danger);
  font-size: 13px;
}
.login-note { margin: 18px 0 0; font-size: 12px; line-height: 1.6; color: var(--ink-faint); }
