:root {
  --bg: #faf5ed;
  --card: #ffffff;
  --ink: #3a342c;
  --muted: #a3968a;
  --line: #f0e6d8;
  --accent: #f08434;
  --accent-deep: #d96a14;
  --accent-soft: #fdeedd;
  --ok: #3c8c5a;
  --danger: #cf4f43;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 3px rgba(190, 140, 80, 0.06), 0 8px 24px rgba(190, 140, 80, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 24px 40px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui,
    sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

/* ── 상단 바 ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1232px;
  margin: 16px auto 0;
  padding: 12px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.topbar h1 {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: -0.01em;
}
.api-status {
  margin-left: auto; /* 우측 그룹(API 상태·사용자·관리자·로그아웃)의 시작 */
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 999px;
}
.api-status.ok {
  background: #e2f0e6;
  color: var(--ok);
}
.api-status.bad {
  background: #f6e0da;
  color: var(--danger);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
}
.user-chip img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
}

/* ── 레이아웃 ───────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  max-width: 1232px;
  margin: 0 auto;
  padding: 20px 0;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── 패널 / 카드 ────────────────────────────────────────────────────── */
.panel,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel {
  padding: 16px;
}
.card {
  padding: 24px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.panel-head h2 {
  margin: 0;
  font-size: 0.98rem;
}
.card h2 {
  margin: 0 0 18px;
  font-size: 1.12rem;
}
.hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 10px 2px 0;
}

/* ── 목록 ───────────────────────────────────────────────────────────── */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  background: #fffdf9;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.list-item:hover {
  border-color: #f3cfa8;
  background: #fff8ef;
}
.list-item.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.list-item .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item .ops {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.12s, background 0.12s;
}
.icon-btn:hover {
  color: var(--accent);
  background: #fff;
}
.site-item {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.site-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.site-url {
  font-size: 0.74rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 빈 목록일 때 점선 등록 버튼 */
.empty-add {
  width: 100%;
  border: 1.5px dashed #ecd7bb;
  background: transparent;
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  transition: all 0.15s;
}
.empty-add:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ── 입력 요소 ──────────────────────────────────────────────────────── */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.muted {
  color: var(--muted);
  font-weight: 400;
}
input[type="text"],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fffdf9;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea {
  resize: vertical;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23f08434' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

/* ── 버튼 ───────────────────────────────────────────────────────────── */
.btn-primary,
.btn,
.btn-sm {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: all 0.15s;
}
.btn-primary {
  background: linear-gradient(135deg, #ffa14e, #f3741a);
  color: #fff;
  padding: 13px 30px;
  box-shadow: 0 6px 16px rgba(243, 116, 26, 0.32);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 22px rgba(243, 116, 26, 0.4);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn {
  background: #f2ebdf;
  color: var(--ink);
  padding: 11px 20px;
}
.btn:hover {
  background: #e9dfcd;
}
.btn-sm {
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 5px 13px;
  font-size: 0.8rem;
}
.btn-sm:hover {
  background: #fbdfc2;
}
.btn-sm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* ── 사이트에 연결된 저장 프롬프트 ──────────────────────────────────── */
.site-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.site-prompt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border: 1px solid #f6c89a;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.site-prompt-row .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.site-prompt-add {
  border: 1.5px dashed #ecd7bb;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  transition: all 0.15s;
}
.site-prompt-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ── 샘플 이미지 ────────────────────────────────────────────────────── */
.sample-category {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffdf9;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.sample-category:last-child {
  margin-bottom: 0;
}
.sample-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.sample-category-name {
  font-weight: 700;
  font-size: 0.92rem;
}
.sample-arrow {
  width: 17px;
  height: 17px;
  margin-left: 6px;
  vertical-align: -3px;
  color: var(--accent);
  cursor: pointer;
}
.sample-category-head:hover .sample-category-name {
  color: var(--accent-deep);
}
.sample-category-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.sample-del-mode.active {
  background: var(--danger);
  color: #fff;
}
.sample-edit {
  background: #e3eef9;
  color: #2b6cb0;
}
.sample-edit:hover {
  background: #d2e3f5;
}.sample-thumbs {
  margin-top: 10px;
}
.thumb.sample {
  width: 108px;
  height: 108px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.thumb.sample:hover {
  border-color: var(--accent);
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(190, 140, 80, 0.2);
}
/* ×는 평소엔 숨기고 삭제 모드에서만 표시 */
.thumb.sample .remove {
  display: none;
}
.sample-category.delete-mode .thumb.sample .remove {
  display: block;
}
.sample-copied {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(60, 140, 90, 0.85);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}
.sample-copied.hidden {
  display: none;
}
/* 마우스 오버 미리보기 */
#samplePreview {
  position: fixed;
  z-index: 1000;
  display: none;
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(80, 50, 20, 0.3);
}
#samplePreview.show {
  display: block;
}
#samplePreview img {
  display: block;
  max-width: min(480px, 45vw);
  max-height: 70vh;
}

/* ── 이미지 썸네일 공통 ─────────────────────────────────────────────── */
.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}
.thumb .remove:hover {
  background: var(--danger);
}

/* ── 드롭존 (사이트 모달) ───────────────────────────────────────────── */
.dropzone {
  border: 2px dashed #ecd7bb;
  border-radius: var(--radius-sm);
  padding: 28px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.dropzone p {
  margin: 0;
}
.dropzone.compact {
  padding: 14px;
  font-size: 0.85rem;
}

/* ── 결과 ───────────────────────────────────────────────────────────── */
.result {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.result-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  background: #fbf7ef;
  border-bottom: 1px solid var(--line);
}
.result-head h3 {
  margin: 0;
  font-size: 0.95rem;
}
.result-head-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.copy-btn {
  border: 1.5px solid var(--accent);
  background: #fff;
  color: var(--accent-deep);
  border-radius: 999px;
  padding: 5px 15px;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.12s;
}
.copy-btn:hover {
  background: var(--accent);
  color: #fff;
}
.copy-btn.done {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.result-body {
  padding: 16px 20px;
}
.result-body.content {
  white-space: pre-wrap;
  word-break: break-word;
}
.result-body.prompt {
  font-size: 0.88rem;
  line-height: 1.65;
  max-height: 420px;
  overflow-y: auto;
  background: #fffdf9;
}
.result-guide {
  margin: 0;
  padding: 13px 18px;
  background: var(--accent-soft);
  border: 1px solid #f6c89a;
  border-radius: var(--radius);
  color: var(--ink);
}

/* ── 모달 ───────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(58, 42, 24, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-box {
  background: var(--card);
  border-radius: 20px;
  padding: 26px;
  width: 460px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(80, 50, 20, 0.3);
}
.modal-box h3 {
  margin: 0 0 18px;
}
.modal-box.wide {
  width: 600px;
}
.login-box {
  width: 360px;
  text-align: center;
}
.login-box .actions {
  justify-content: center;
}
.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 10px;
}
.search-group {
  background: #fbf7ef;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.autofill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.autofill-row .muted {
  font-size: 0.76rem;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

/* ── 토스트 ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* ── 구글 로그인 / 권한 UI ──────────────────────────────────────────── */
body.readonly .admin-only {
  display: none !important;
}
.google-btn-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0;
  min-height: 44px;
}
.user-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.user-status.approved {
  background: #e3f0e8;
  color: var(--ok);
}
.user-status.pending {
  background: #fdf3d7;
  color: #9a7b1a;
}
.user-status.blocked {
  background: #f6dede;
  color: var(--danger);
}

/* ── 작업 기록 ──────────────────────────────────────────────────────── */
.task-add {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.task-add-row {
  display: flex;
  gap: 6px;
}
.task-add-row input {
  flex: 1;
}
.task-add-row .btn-sm {
  flex-shrink: 0;
}
.task-add input {
  padding: 8px 12px;
  font-size: 0.85rem;
}
.task-date {
  font-size: 0.75rem;
  flex-shrink: 0;
}
.task-user {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-deep);
  background: var(--accent-soft);
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 일자별 통계 */
#taskStatsBtn.active {
  background: var(--accent);
  color: #fff;
}
.task-stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffdf9;
  padding: 9px 12px;
  font-size: 0.9rem;
}
.task-stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}
.task-stat-head:hover .task-stat-date {
  color: var(--accent);
}
.task-stat-count {
  color: var(--accent-deep);
  font-weight: 700;
  font-size: 0.85rem;
}
.task-stat-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.task-stat-detail.hidden {
  display: none;
}
.task-stat-link {
  display: block;
  font-size: 0.82rem;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 8px;
  background: #faf5ec;
}
.task-stat-link:hover {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

/* ── 작업 기록 전용 페이지 (tasks.html) ─────────────────────────────── */
.panel-head-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.back-link {
  text-decoration: none;
  display: inline-block;
}
.tasks-page .back-link {
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}
.tasks-page .back-link:hover {
  background: #fbdfc2;
}
.tasks-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.task-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.task-summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 18px 12px;
}
.task-summary-card .num {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--accent-deep);
  line-height: 1.2;
}
.task-summary-card .label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.task-controls {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
}
.task-controls input {
  flex: 1;
}
.task-controls select {
  width: 200px;
  flex-shrink: 0;
}
.task-day {
  padding: 14px 16px;
}
.task-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.task-day-date {
  font-weight: 700;
  font-size: 0.95rem;
}
.task-num {
  flex-shrink: 0;
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.75rem;
  font-weight: 800;
}
/* 작업 기록의 연결 대상 태그 (🌐 사이트 / 🏪 소상공인) */
.task-target-tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: 1px;
}
.task-target {
  font-size: 0.85rem;
  padding: 9px 34px 9px 12px;
}

/* ── 기타 ───────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 880px) {
  body {
    padding: 0 12px 32px;
  }
  .layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ── 관리자 페이지 (작업 기록 통계) ────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.admin-tab {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 7px 16px;
  background: #f2ebdf;
  color: var(--muted);
  transition: all 0.15s;
}
.admin-tab:hover {
  color: var(--ink);
}
.admin-tab.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
#adminUsersPane .list {
  max-height: 52vh;
  overflow-y: auto;
}
.admin-stats-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.admin-stats-controls select {
  width: auto;
  flex: 1;
  min-width: 140px;
  padding: 7px 34px 7px 12px;
  font-size: 0.85rem;
}
/* 세그먼트 토글 (일별/월별/연도별/대상별) */
.seg {
  display: inline-flex;
  background: #f2ebdf;
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  transition: all 0.15s;
}
.seg-btn:hover {
  color: var(--ink);
}
.seg-btn.active {
  background: var(--card);
  color: var(--accent-deep);
  box-shadow: 0 1px 3px rgba(190, 140, 80, 0.18);
}
.admin-summary {
  margin: 0 0 12px;
  padding: 9px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--accent-deep);
}
.admin-stats {
  max-height: 52vh;
  overflow-y: auto;
}

.sample-desc {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}
