:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-soft: #64748b;
  --text-faint: #94a3b8;
  --brand: #0f4c81;
  --brand-soft: #e6eff6;
  --success: #15803d;
  --success-soft: #dcfce7;
  --failure: #b91c1c;
  --failure-soft: #fee2e2;
  --ongoing: #b45309;
  --ongoing-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(120deg, #0f4c81, #12395e);
  color: #fff;
  padding: 22px 0;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 26px;
  color: #7cc4ff;
  line-height: 1;
}
.site-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  color: #b8d3ea;
}
.header-meta {
  font-size: 12px;
  color: #b8d3ea;
  text-align: right;
}

/* ---------- KPI ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 26px 0 22px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi .k-label {
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 4px;
}
.kpi .k-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.kpi .k-sub { font-size: 11px; color: var(--text-faint); }
.kpi.is-success .k-value { color: var(--success); }
.kpi.is-failure .k-value { color: var(--failure); }
.kpi.is-ongoing .k-value { color: var(--ongoing); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.tab {
  appearance: none;
  border: none;
  background: none;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-search {
  flex: 1 1 240px;
  min-width: 0;
}
.filter-search, .filter-select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}
.filter-search:focus, .filter-select:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand);
}
.filter-reset {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
}
.filter-reset:hover { background: var(--surface-2); color: var(--text); }

.result-count {
  font-size: 12px;
  color: var(--text-faint);
  margin: 0 0 14px;
}

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding-bottom: 40px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  border-top: 3px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(15,23,42,.12); }
.card.s-success { border-top-color: var(--success); }
.card.s-failure { border-top-color: var(--failure); }
.card.s-ongoing { border-top-color: var(--ongoing); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
}
.card-country {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}
.flag { display: inline-block; line-height: 0; }
.flag svg {
  width: 1.35em; height: 0.9em;
  vertical-align: -0.16em;
  border-radius: 2px;
  box-shadow: 0 0 0 0.5px rgba(23, 33, 46, .2);
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.status-success { background: var(--success-soft); color: var(--success); }
.badge.status-failure { background: var(--failure-soft); color: var(--failure); }
.badge.status-ongoing { background: var(--ongoing-soft); color: var(--ongoing); }
.badge.type { background: var(--brand-soft); color: var(--brand); }
.badge.jv { background: #f1f5f9; color: var(--text-soft); }

.card-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12.5px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.spec .s-k { color: var(--text-faint); font-size: 11px; }
.spec .s-v { font-weight: 600; }

.card-note {
  font-size: 12.5px;
  color: var(--text-soft);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
}
.card-note.fail { background: var(--failure-soft); color: #7f1d1d; }
.card-note.ongoing { background: var(--ongoing-soft); color: #78350f; }

.card-foot {
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.confidence-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 4px;
}
.confidence-dot.low { background: #f59e0b; }
.confidence-dot.medium { background: #3b82f6; }
.confidence-dot.high { background: #10b981; }

.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 60px 0;
  font-size: 14px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-backdrop[hidden] {
  display: none;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  max-width: 760px;
  width: 100%;
  padding: 30px;
  position: relative;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 15px;
  cursor: pointer;
}
.modal-close:hover { background: var(--border); }

.modal h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -.02em;
  padding-right: 40px;
}
.modal .m-country { color: var(--text-soft); font-size: 13px; margin-bottom: 14px; }

.m-section { margin-top: 22px; }
.m-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  margin: 0 0 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.m-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 20px;
}
.m-field .f-k { font-size: 11px; color: var(--text-faint); }
.m-field .f-v { font-size: 14px; font-weight: 500; }

.m-fail {
  background: var(--failure-soft);
  border-radius: 12px;
  padding: 16px 18px;
}
.m-fail .fail-summary { font-weight: 600; color: #7f1d1d; margin-bottom: 10px; }
.m-fail ul { margin: 8px 0 0; padding-left: 18px; }
.m-fail li { margin-bottom: 5px; font-size: 13.5px; }
.m-fail .fail-narrative {
  margin-top: 12px;
  font-size: 13.5px;
  color: #641e1e;
  border-top: 1px solid rgba(185, 28, 28, .2);
  padding-top: 10px;
}
.fail-cat-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.fail-cat-tag {
  font-size: 11px; font-weight: 600;
  background: #fff; color: var(--failure);
  border: 1px solid rgba(185,28,28,.3);
  padding: 2px 8px; border-radius: 999px;
}

/* timeline */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 4px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--border);
}
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -20px; top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
}
.tl-item.tl-incident::before { background: var(--failure); }
.tl-item.tl-cod::before { background: var(--success); }
.tl-item.tl-delay_announced::before { background: var(--ongoing); }
.tl-date { font-size: 11px; color: var(--text-faint); font-weight: 600; }
.tl-title { font-size: 13.5px; }
.tl-auto {
  font-size: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}

.m-sources { list-style: none; padding: 0; margin: 0; }
.m-sources li {
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.m-sources li:last-child { border-bottom: none; }
.m-sources a { color: var(--brand); text-decoration: none; font-weight: 500; }
.m-sources a:hover { text-decoration: underline; }
.m-sources .src-meta { color: var(--text-faint); font-size: 11px; }
.src-auto-tag {
  font-size: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
}

.verify-note {
  margin-top: 20px;
  font-size: 11.5px;
  color: var(--text-faint);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
}

/* ---------- Footer ---------- */
.site-footer {
  background: #0f1f2e;
  color: #8fa9bd;
  font-size: 12px;
  padding: 20px 0;
  margin-top: 20px;
}
.site-footer p { margin: 4px 0; }

/* ---------- Loading ---------- */
.loading {
  text-align: center;
  padding: 80px 0;
  color: var(--text-faint);
}

@media (max-width: 640px) {
  .site-header h1 { font-size: 17px; }
  .modal { padding: 22px; }
  .card-specs { grid-template-columns: 1fr; }
}
