@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --sky: #38bdf8;
  --ink: #111827;
  --body: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --amber: #ea580c;
  --green: #059669;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* hidden 속성이 아래 클래스들의 display 값(flex/block)에 밀리지 않도록 고정.
   이 줄이 없으면 hidden 처리한 모달과 iframe이 화면에 그대로 남아 클릭을 가로챕니다. */
[hidden] { display: none !important; }

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

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ---------- 로그인 ---------- */

.login-shell {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  width: 100%;
  max-width: 420px;
  padding: 40px;
  border-radius: 12px;
  border-top: 5px solid var(--blue);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.wordmark {
  color: var(--blue);
  font-size: 3.4rem;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  margin: 0;
}

.wordmark-sub {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 0.4px;
  margin: 8px 0 32px;
}

/* ---------- 폼 ---------- */

label {
  display: block;
  font-weight: 700;
  color: var(--ink);
  font-size: 0.86rem;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field { margin-bottom: 18px; }

button {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  transition: background-color 0.15s ease;
}

button:hover:not(:disabled) { background: var(--blue-dark); }
button:disabled { background: var(--line); color: #9ca3af; cursor: not-allowed; border-color: transparent; }

button.ghost { background: #fff; color: var(--body); border-color: var(--line); }
button.ghost:hover:not(:disabled) { background: #f9fafb; color: var(--ink); }
button.danger { background: #fff; color: #b91c1c; border-color: #fecaca; }
button.danger:hover:not(:disabled) { background: #fef2f2; }
button.block { width: 100%; padding: 14px; font-size: 1rem; }
button.sm { padding: 6px 10px; font-size: 0.8rem; }

.msg {
  margin-top: 16px;
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 1.2em;
}
.msg.error { color: var(--amber); }
.msg.ok { color: var(--blue); }

.hint { color: var(--muted); font-size: 0.82rem; }

/* ---------- 상단 바 ---------- */

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand {
  color: var(--blue);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -1px;
  text-decoration: none;
}

.topbar .brand small {
  display: block;
  font-size: 0.62rem;
  font-weight: 300;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.topbar .spacer { flex: 1; }

.who { font-size: 0.85rem; color: var(--muted); }
.who b { color: var(--ink); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: 1px;
}
.badge.admin { background: #eff6ff; color: var(--blue); }
.badge.guest { background: #f3f4f6; color: var(--muted); }
.badge.ready { background: #ecfdf5; color: var(--green); }
.badge.processing { background: #fff7ed; color: var(--amber); }
.badge.failed { background: #fef2f2; color: #b91c1c; }

/* ---------- 레이아웃 ---------- */

.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-head h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 700;
}

.panel-body { padding: 16px; }

/* ---------- 리포트 목록 ---------- */

.list-search { padding: 12px 16px; border-bottom: 1px solid var(--line); }

.report-list { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 260px); overflow-y: auto; }

.report-list li {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.report-list li:hover { background: #f9fafb; }
.report-list li[aria-current="true"] { background: #eff6ff; box-shadow: inset 3px 0 0 var(--blue); }

.report-list .t {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.9rem;
  display: block;
  margin-bottom: 4px;
  word-break: keep-all;
}
.report-list .m { font-size: 0.76rem; color: var(--muted); }
.report-list .saved { color: var(--amber); font-weight: 700; }

.pager { padding: 12px 16px; display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 0.82rem; color: var(--muted); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 0.88rem; }

/* ---------- 상세 ---------- */

.detail-head { padding: 16px; border-bottom: 1px solid var(--line); }
.detail-head h2 { margin: 0 0 6px; font-size: 1.15rem; color: var(--ink); word-break: keep-all; }
.detail-meta { font-size: 0.8rem; color: var(--muted); }

.toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #fcfcfd;
}
.toolbar .sep { width: 1px; background: var(--line); margin: 2px 4px; }

.tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--line); }
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 0.86rem;
  font-weight: 700;
}
.tab:hover:not(:disabled) { background: none; color: var(--ink); }
.tab[aria-selected="true"] { color: var(--blue); border-bottom-color: var(--blue); }

.stage { padding: 0; background: #fafafa; }
.stage iframe { width: 100%; height: 70vh; border: 0; display: block; background: #fff; }
.stage textarea {
  width: 100%;
  height: 70vh;
  border: 0;
  border-radius: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  resize: vertical;
}
.editing-note {
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 0.82rem;
  padding: 9px 16px;
}

/* ---------- 모달 ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  padding: 28px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { margin: 0 0 4px; font-size: 1.2rem; color: var(--ink); }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }

.steps { list-style: none; margin: 18px 0 0; padding: 0; font-size: 0.88rem; }
.steps li { padding: 7px 0; color: var(--muted); }
.steps li[data-state="doing"] { color: var(--blue); font-weight: 700; }
.steps li[data-state="done"] { color: var(--green); }
.steps li[data-state="error"] { color: var(--amber); font-weight: 700; }
.steps li::before { content: "○ "; }
.steps li[data-state="done"]::before { content: "● "; }
.steps li[data-state="doing"]::before { content: "◐ "; }
.steps li[data-state="error"]::before { content: "✕ "; }

.thumb { width: 100%; border: 1px solid var(--line); border-radius: 6px; margin-top: 14px; display: none; }

/* ---------- 표 ---------- */

table.grid { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: middle; }
table.grid th { background: #f9fafb; color: var(--ink); font-weight: 700; white-space: nowrap; }
table.grid td.nowrap, table.grid th.nowrap { white-space: nowrap; }
table.grid tbody tr:hover { background: #fcfcfd; }
.table-scroll { overflow-x: auto; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 140px; }
.filters .field label { font-size: 0.78rem; }

.section-nav { display: flex; gap: 6px; padding: 0 16px; }

/* ---------- 반응형 ---------- */

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .report-list { max-height: 340px; }
  .stage iframe, .stage textarea { height: 60vh; }
  .login-card { padding: 28px; }
  .wordmark { font-size: 2.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
