@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

:root {
  --ink: #1a1d26;
  --ink-light: #2d3142;
  --muted: #6b7394;
  --line: rgba(107, 115, 148, 0.15);
  --surface: rgba(255, 255, 255, 0.92);
  --surface-hover: rgba(255, 255, 255, 1);
  --bg: #f4f6fb;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.08);
  --accent: #f59e0b;
  --danger: #dc2626;
  --danger-light: rgba(220, 38, 38, 0.08);
  --success: #059669;
  --success-light: rgba(5, 150, 105, 0.08);
  --warning-light: rgba(245, 158, 11, 0.1);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: "Pretendard Variable", "Pretendard", -apple-system, "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.content { padding: 32px 40px; max-width: 1200px; }

/* ── Brand ── */
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
}

.brand h1 {
  font-size: 20px;
  font-weight: 800;
  margin: 6px 0 8px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand p {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Member card ── */
.member-card {
  margin: 16px 0 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary-light), rgba(124, 58, 237, 0.06));
  border: 1px solid rgba(37, 99, 235, 0.12);
}

.member-card strong { font-size: 14px; }
.member-card .muted { font-size: 12px; }

/* ── Navigation ── */
.nav { display: grid; gap: 2px; }

.nav a {
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--ink-light);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.nav a:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.1);
}

/* ── Nav Groups (collapsible submenus) ── */
.nav-group { display: grid; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--ink-light);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: inherit;
}

.nav-group-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.1);
}

.nav-chevron {
  transition: transform var(--transition);
  flex-shrink: 0;
}

.nav-group.open .nav-chevron { transform: rotate(90deg); }

.nav-submenu {
  display: grid;
  gap: 1px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 0;
}

.nav-group.open .nav-submenu {
  max-height: 300px;
  opacity: 1;
}

.nav-submenu a {
  text-decoration: none;
  padding: 8px 14px 8px 32px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.nav-submenu a:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.1);
}

/* ── Buttons ── */
button, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}

.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap input {
  flex: 1;
  padding-right: 40px;
}
.pw-eye {
  position: absolute;
  right: 6px;
  min-height: auto;
  padding: 4px;
  background: none;
  color: var(--text-secondary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.pw-eye:hover {
  opacity: 1;
  background: none;
  box-shadow: none;
  transform: none;
}
.pw-eye:active {
  transform: none;
}
.pw-eye.active {
  opacity: 1;
  color: var(--primary);
}

button:hover, .button-link:hover {
  background: var(--primary-strong);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  transform: translateY(-1px);
}

button:active, .button-link:active {
  transform: translateY(0);
}

.ghost {
  background: #fff;
  color: var(--ink-light);
  border: 1px solid var(--line);
}

.ghost:hover {
  background: var(--bg);
  border-color: rgba(107, 115, 148, 0.3);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.wide { width: 100%; }
.narrow { max-width: 560px; }

/* ── Hero section ── */
.hero {
  margin-bottom: 28px;
}

.hero h2 {
  font-size: clamp(24px, 2.5vw, 32px);
  font-weight: 800;
  line-height: 1.2;
  margin: 6px 0 8px;
  color: var(--ink);
}

.hero p {
  color: var(--muted);
  font-size: 14px;
  max-width: 600px;
}

.hero, .hero-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.hero-row { align-items: center; }

/* ── Panels / Cards ── */
.panel, .metric-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.panel:hover { box-shadow: var(--shadow); }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

/* ── Metrics ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.metric-value.small { font-size: 20px; font-weight: 700; }

/* ── Forms ── */
.form-stack { display: grid; gap: 20px; }
.grid.two, .grid.two-fixed { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-form { display: grid; gap: 14px; }

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-light);
}

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 24px;
  cursor: pointer;
}

input, select {
  font: inherit;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  font-size: 14px;
  transition: all var(--transition);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ── Flash messages ── */
.flash-stack { display: grid; gap: 10px; margin-bottom: 20px; }

.flash {
  padding: 14px 18px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.flash.success {
  border-left: 4px solid var(--success);
  background: var(--success-light);
}

.flash.error {
  border-left: 4px solid var(--danger);
  background: var(--danger-light);
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead {
  background: var(--bg);
}

th {
  padding: 12px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 2px solid var(--line);
}

td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: rgba(37, 99, 235, 0.03);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(107, 115, 148, 0.1);
  color: var(--muted);
  white-space: nowrap;
}

.badge-submitted { color: #065f46; background: var(--success-light); }
.badge-failed, .badge-submit_failed { color: #991b1b; background: var(--danger-light); }
.badge-running, .badge-handoff_launched { color: #92400e; background: var(--warning-light); }
.badge-completed, .badge-queued { color: #1e40af; background: var(--primary-light); }

.badge-node-completed { color: #065f46; background: var(--success-light); }
.badge-node-running { color: #92400e; background: var(--warning-light); }
.badge-node-failed { color: #991b1b; background: var(--danger-light); }
.badge-node-pending { color: var(--muted); background: rgba(107, 115, 148, 0.08); }

/* ── Detail list ── */
.detail-list { display: grid; gap: 10px; }
.detail-list div {
  display: grid;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.detail-list dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.detail-list dd { margin: 0; word-break: break-all; font-size: 14px; }

/* ── Artifacts ── */
.artifact-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.artifact-link {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--line);
  transition: all var(--transition);
}

.artifact-link:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ── Social login providers ── */
.provider-stack { display: grid; gap: 10px; }

.provider {
  text-decoration: none;
  padding: 12px 16px;
  border-radius: var(--radius);
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.provider:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.provider-kakao { background: #fee500; color: #191919; }
.provider-naver { background: #03c75a; color: white; }
.provider-pass { background: #2b4ea1; color: white; }
.provider.disabled { pointer-events: none; opacity: 0.4; filter: grayscale(0.5); }

/* ── Node cards ── */
.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.node-card, .monitor-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: #fff;
  transition: all var(--transition);
}

.node-card:hover, .monitor-card:hover {
  box-shadow: var(--shadow);
}

.node-top, .monitor-head, .timeline-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.node-card p, .monitor-current { margin: 10px 0 6px; font-size: 13px; color: var(--muted); }

.node-card.node-completed { border-left: 3px solid var(--success); }
.node-card.node-running { border-left: 3px solid var(--accent); }
.node-card.node-failed { border-left: 3px solid var(--danger); }
.node-card.node-pending { border-left: 3px solid var(--line); }

.node-payload summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  margin-top: 8px;
}

/* ── Node rail (monitor) ── */
.monitor-stack { display: grid; gap: 14px; }

.node-rail {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.node-pill {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 13px;
}

.node-pill small { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.node-pill-completed { border-color: rgba(5, 150, 105, 0.3); background: var(--success-light); }
.node-pill-running { border-color: rgba(245, 158, 11, 0.3); background: var(--warning-light); }
.node-pill-failed { border-color: rgba(220, 38, 38, 0.3); background: var(--danger-light); }

/* ── Timeline ── */
.timeline { display: grid; gap: 0; }

.timeline-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 14px;
  align-items: start;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 20px;
  background: rgba(107, 115, 148, 0.3);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(107, 115, 148, 0.15);
}

.timeline-dot-completed { background: var(--success); box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2); }
.timeline-dot-running { background: var(--accent); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
.timeline-dot-failed { background: var(--danger); box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2); }

.timeline-body {
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  margin-bottom: 8px;
}

/* ── Code blocks ── */
.code {
  overflow: auto;
  padding: 16px;
  border-radius: var(--radius);
  background: #1e1e2e;
  color: #cdd6f4;
  font-family: "Cascadia Code", "JetBrains Mono", "D2Coding", monospace;
  font-size: 13px;
  line-height: 1.6;
}

/* ── Danger panel ── */
.danger { border: 1px solid rgba(220, 38, 38, 0.2); background: var(--danger-light); }

/* ── Member table ── */
.member-table { display: grid; gap: 12px; }

.member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--line);
  transition: all var(--transition);
}

.member-row:hover {
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.member-actions { display: flex; gap: 8px; align-items: center; }

.inline-reset {
  display: flex;
  gap: 6px;
  align-items: center;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ── Hints / Muted ── */
.hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

/* ── Scrollbar (WebKit) ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(107, 115, 148, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(107, 115, 148, 0.35); }

/* ── BIB Form (특허출원서 서지사항 형식) ── */
.bib-form { padding: 0; overflow: hidden; }
.bib-form .panel-head {
  padding: 18px 24px;
  margin-bottom: 0;
  border-bottom: 2px solid var(--ink);
  background: var(--bg);
}

.bib-document {
  padding: 0;
  font-size: 14px;
}

.bib-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0;
}

.bib-row.bib-top {
  background: var(--bg);
  font-weight: 700;
}

.bib-label {
  padding: 10px 16px 10px 24px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  background: rgba(107, 115, 148, 0.04);
  border-right: 1px solid var(--line);
  align-self: stretch;
  display: flex;
  align-items: center;
}

.bib-label-sub {
  padding: 10px 16px 10px 40px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-light);
  white-space: nowrap;
  background: rgba(107, 115, 148, 0.02);
  border-right: 1px solid var(--line);
  align-self: stretch;
  display: flex;
  align-items: center;
}

.bib-value, .bib-value-static {
  padding: 8px 16px;
  display: flex;
  align-items: center;
}

.bib-value-static {
  font-weight: 700;
  font-size: 15px;
}

.bib-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
  transition: all var(--transition);
}

/* 미입력 필수 필드 노란 하이라이트 */
.bib-input.needs-input {
  background: #fffbe6;
  border-color: #fbbf24;
}
.bib-input.needs-input::placeholder { color: #b45309; opacity: .6; }

/* 일반 form-stack 내부 input/select도 동일 적용 */
.form-stack input.needs-input,
.form-stack select.needs-input,
.form-stack textarea.needs-input {
  background: #fffbe6 !important;
  border-color: #fbbf24 !important;
}

.bib-input:hover {
  background: rgba(37, 99, 235, 0.03);
  border-color: var(--line);
}
.bib-input.needs-input:hover {
  background: #fef9c3;
  border-color: #f59e0b;
}

.bib-input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
  outline: none;
}

.bib-section {
  border-bottom: none;
}

.bib-section-head {
  background: rgba(37, 99, 235, 0.03);
  border-bottom: 1px solid var(--line);
}

.bib-section-head .bib-label {
  background: rgba(37, 99, 235, 0.06);
  font-weight: 800;
}

.bib-indent {
  border-bottom: 1px solid rgba(107, 115, 148, 0.2);
}

.bib-indent .bib-row {
  grid-template-columns: 220px 1fr;
}

.bib-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-light);
  cursor: pointer;
  padding: 0;
}

.bib-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

@media (max-width: 640px) {
  .bib-row, .bib-indent .bib-row {
    grid-template-columns: 1fr;
  }
  .bib-label, .bib-label-sub {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 8px 16px;
  }
}

/* ── Responsive ── */
@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 20px;
  }

  .content { padding: 20px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .grid.two, .grid.two-fixed { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .metric-grid { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: start; }
  .hero-row { flex-direction: column; align-items: start; }
  .content { padding: 16px; }
  .metric-value { font-size: 28px; }
}
