:root {
  --bg: #eef2f3;
  --ink: #172126;
  --muted: #66727a;
  --line: #d8e0df;
  --panel: #ffffff;
  --accent: #167b68;
  --accent-2: #f4b841;
  --danger: #d94b3d;
  --watch: #f0a429;
  --safe: #4b9a74;
  --infected: #1f2528;
  --shadow: 0 18px 45px rgba(34, 52, 59, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Noto Sans KR", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.15;
}

h2 {
  font-size: 24px;
  margin-bottom: 6px;
}

.brand p,
.topbar p,
.note,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 25px rgba(42, 58, 61, 0.06);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 700;
}

.compact {
  margin-top: auto;
}

.scenario-board {
  margin-bottom: 16px;
  padding: 14px 16px 16px;
}

.scenario-board .panel-title {
  margin-bottom: 10px;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(150px, 0.75fr) repeat(3, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 0;
  color: #334047;
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

output {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #a9b9b6;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.scenario-reset {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge {
  border-radius: 999px;
  background: #e5f3ef;
  color: var(--accent);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
}

.badge.running {
  background: #fff4d8;
  color: #8b5f00;
}

.badge.done {
  background: #e5f3ef;
  color: var(--accent);
}

.model-detail {
  min-height: 42px;
  margin-bottom: 12px;
  border: 1px solid #dbe6e3;
  border-radius: 6px;
  background: #f4f8f6;
  padding: 10px;
  color: #334047;
  font-size: 13px;
  line-height: 1.45;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.utility-actions {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.utility-link {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.utility-link:hover {
  border-color: #a9b9b6;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(105px, 1fr));
  gap: 10px;
}

.status-strip div {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.status-strip strong {
  display: block;
  font-size: 22px;
}

.status-strip span {
  color: var(--muted);
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 420px;
  gap: 20px;
  align-items: start;
  min-height: 0;
}

.map-panel {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 980 / 620;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe9e6;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 980 / 620;
}

.legend {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 10px;
  font-size: 12px;
  font-weight: 700;
}

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

.legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.safe { background: var(--safe); }
.watch { background: var(--watch); }
.danger { background: var(--danger); }
.infected,
.source { background: var(--infected); }

.farm-tooltip {
  position: absolute;
  z-index: 2;
  width: 176px;
  border: 1px solid rgba(23, 33, 38, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(23, 33, 38, 0.16);
  padding: 10px;
  color: var(--ink);
  pointer-events: auto;
}

.farm-tooltip strong,
.farm-tooltip span,
.farm-tooltip small {
  display: block;
}

.farm-tooltip strong {
  font-size: 13px;
}

.farm-tooltip span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.farm-tooltip small {
  margin-top: 6px;
  color: #4a5960;
  font-size: 11px;
  line-height: 1.35;
}

.farm-tooltip button {
  width: 100%;
  min-height: 32px;
  margin-top: 9px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.side-stack {
  display: grid;
  grid-template-rows: minmax(320px, 0.8fr) minmax(250px, 0.7fr);
  gap: 20px;
  min-height: 620px;
}

.table-panel,
.api-panel {
  min-height: 0;
  overflow: hidden;
}

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

th,
td {
  border-bottom: 1px solid #edf1f0;
  padding: 10px 6px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
}

.risk-pill {
  display: inline-block;
  min-width: 52px;
  border-radius: 999px;
  padding: 5px 8px;
  color: #fff;
  text-align: center;
  font-weight: 800;
}

pre {
  height: calc(100% - 42px);
  overflow: auto;
  margin: 0;
  border-radius: 6px;
  background: #152024;
  color: #dce9e4;
  padding: 14px;
  font-size: 12px;
  line-height: 1.5;
}

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

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

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

  .content-grid,
  .topbar {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .side-stack {
    grid-template-rows: auto auto;
  }
}

@media (max-width: 680px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .utility-actions {
    position: static;
    justify-content: flex-start;
    margin-bottom: 8px;
  }
}

.help-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.help-header h1 {
  font-size: clamp(28px, 5vw, 42px);
}

.help-grid {
  display: grid;
  gap: 14px;
}

.help-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 20px;
}

.help-card h2 {
  font-size: 20px;
}

.help-card p,
.help-card li {
  color: #4a5960;
  line-height: 1.7;
}

.help-card ul {
  margin: 12px 0 0;
  padding-left: 20px;
}
