:root {
  --bg: #f5f2ea;
  --ink: #112523;
  --muted: #45615d;
  --panel: #fbf9f3;
  --line: #d4cdc0;
  --accent: #0f766e;
  --accent-soft: #d8f0ed;
  --warn: #a62f17;
  --warn-soft: #f9dfd8;
  --gold: #d88d20;
  --shadow: 0 10px 24px rgba(17, 37, 35, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 12% 8%, #f9efe0 0%, var(--bg) 44%),
    radial-gradient(circle at 90% 0%, #dff1ec 0%, transparent 30%),
    var(--bg);
  font-family: "Pretendard", "Noto Sans KR", "Segoe UI", sans-serif;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(135deg, rgba(216, 141, 32, 0.06) 25%, transparent 25%),
    linear-gradient(315deg, rgba(15, 118, 110, 0.05) 25%, transparent 25%);
  background-size: 28px 28px;
  opacity: 0.22;
}

.topbar {
  position: relative;
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(2px);
  animation: reveal 420ms ease-out;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  letter-spacing: -0.03em;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(310px, 380px) 1fr;
  gap: 18px;
  padding: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 92%, white 8%);
  box-shadow: var(--shadow);
}

.panel-form {
  padding: 14px;
  max-height: calc(100vh - 128px);
  overflow: auto;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.panel-title-row h2,
.panel-table h2 {
  margin: 0;
  font-size: 1.05rem;
}

.badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.panel-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.panel-controls label {
  font-size: 0.78rem;
  color: var(--muted);
}

.panel-controls select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  background: #fffef9;
}

.tiny-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn.tiny {
  padding: 7px 9px;
  font-size: 0.76rem;
}

.stage-guide {
  border: 1px solid #d8d0c3;
  border-radius: 10px;
  background: #fffdf7;
  padding: 9px 10px;
  font-size: 0.8rem;
  color: #29413f;
  margin-bottom: 10px;
}

.stage-guide strong {
  display: block;
  margin-bottom: 5px;
}

.stage-guide ul {
  margin: 6px 0 0 16px;
  padding: 0;
}

details.form-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 10px 0;
  background: #fffdf7;
}

details.form-section summary {
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 700;
  color: #183a37;
}

details.form-section[open] summary {
  border-bottom: 1px solid #e8e0d5;
}

.section-body {
  padding: 10px;
}

.form-section.hidden,
.field.hidden {
  display: none;
}

.inline-input {
  display: flex;
  gap: 6px;
}

.inline-input input {
  flex: 1;
}

.mini-btn {
  border: 1px solid #c9ddda;
  border-radius: 8px;
  padding: 0 10px;
  background: #eef4f3;
  color: #1f4542;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.field-help {
  display: block;
  margin-top: 5px;
  font-size: 0.74rem;
  color: #5d716d;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin: 10px 0;
}

legend {
  font-weight: 700;
  color: #183a37;
  padding: 0 6px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.field label,
.filter-grid label,
.search-wrap label {
  font-size: 0.78rem;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

.field input,
.field select,
.field textarea,
.search-wrap input,
.filter-grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  background: #fffef9;
  color: var(--ink);
}

.field textarea {
  min-height: 64px;
  resize: vertical;
}

.field.required label::after {
  content: " *";
  color: var(--warn);
}

.form-actions {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(251, 249, 243, 0.4), rgba(251, 249, 243, 0.98));
  padding-top: 8px;
}

.panel-table {
  display: grid;
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
  gap: 10px;
  padding: 14px;
  min-height: calc(100vh - 128px);
}

.toolbar {
  display: grid;
  gap: 10px;
}

.search-wrap input {
  font-size: 0.95rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 8px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.secondary {
  background: #eef4f3;
  border-color: #c9ddda;
  color: #1f4542;
}

.btn.danger {
  background: var(--warn-soft);
  border-color: #e9beb3;
  color: var(--warn);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fffcf5;
  animation: reveal 380ms ease-out;
}

.stat-card .k {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.stat-card .v {
  display: block;
  margin-top: 6px;
  font-size: 1.05rem;
  font-weight: 800;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

th,
td {
  border-bottom: 1px solid #e7dfd3;
  padding: 9px;
  font-size: 0.86rem;
  text-align: left;
  vertical-align: top;
}

thead th {
  background: #f3eee2;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr {
  cursor: pointer;
  transition: background-color 120ms ease;
}

tbody tr:hover {
  background: #f8f2e5;
}

tbody tr.active {
  background: #deefe9;
}

.detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffef9;
  padding: 10px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.detail-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.detail-actions {
  display: flex;
  gap: 6px;
}

.detail-body {
  margin-top: 8px;
  max-height: 220px;
  overflow: auto;
  font-size: 0.84rem;
}

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px dashed #e8e0d3;
}

.kv strong {
  color: #2e4d4a;
  font-weight: 600;
}

@keyframes reveal {
  from {
    transform: translateY(6px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel-form,
  .panel-table {
    max-height: none;
    min-height: auto;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .panel-controls {
    grid-template-columns: 1fr;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
