/* ===== Design tokens ===== */
:root {
  --red: #e63946;
  --red-soft: #fde8ea;
  --red-deep: #b81d2a;
  --ink: #111418;
  --ink-2: #2b2f36;
  --muted: #6b7280;
  --line: #eceef1;
  --bg: #ffffff;
  --bg-soft: #fafbfc;
  --green: #16a34a;
  --amber: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(17, 20, 24, 0.04), 0 1px 1px rgba(17, 20, 24, 0.03);
  --shadow-md: 0 8px 24px rgba(17, 20, 24, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
               "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ===== Layout ===== */
.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}
.site-header .row {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 18px; letter-spacing: -0.01em;
}
.brand-mark {
  width: 30px; height: 30px;
  /* Works for both an <img> (logo image) and a <span> with text inside.
     The image already has its own rounded corners, but we mask just in
     case a future file isn't pre-rounded. */
  border-radius: 8px;
  object-fit: cover;
  display: grid; place-items: center;
  background: var(--red);
  color: #fff; font-weight: 900; font-size: 14px;
}
img.brand-mark {
  background: transparent;   /* let the image art show through */
}
.nav { display: flex; gap: 28px; font-size: 14px; color: var(--muted); }
.nav a:hover { color: var(--ink); }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .05s ease, box-shadow .2s ease, background .2s ease;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-deep); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-soft); }

/* ===== Hero ===== */
.hero { padding: 84px 0 56px; text-align: center; }
.hero .eyebrow {
  display: inline-block;
  padding: 6px 12px; border-radius: 999px;
  background: var(--red-soft); color: var(--red-deep);
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  margin-bottom: 22px; text-transform: uppercase;
}
.hero h1 {
  font-size: 52px; line-height: 1.1; letter-spacing: -0.03em;
  margin: 0 0 16px; font-weight: 800;
}
.hero h1 .accent { color: var(--red); }
.hero p.lead {
  color: var(--muted); font-size: 17px; max-width: 560px;
  margin: 0 auto 36px;
}

/* ===== Search ===== */
.search-wrap {
  max-width: 640px; margin: 0 auto;
  display: flex; gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px; padding: 8px;
  box-shadow: var(--shadow-md);
}
.search-wrap input {
  flex: 1; border: 0; outline: 0; font-size: 16px;
  padding: 14px 16px; background: transparent;
  color: var(--ink);
}
.search-wrap input::placeholder { color: #9aa0a6; }
.search-wrap .btn-primary { padding: 14px 22px; }

/* ===== Popular keywords ===== */
.chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-top: 22px;
}
.chip {
  padding: 8px 14px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--line);
  font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.chip:hover { border-color: var(--red); color: var(--red); }
.chip .count { color: var(--muted); margin-left: 6px; font-size: 12px; }

/* ===== Stat cards row ===== */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px; margin: 64px 0 0;
}
.stats.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--red-soft); color: var(--red);
  display: grid; place-items: center; margin-bottom: 14px;
  font-size: 18px;
}
.stat-num {
  font-size: 32px; font-weight: 800; letter-spacing: -0.02em;
  line-height: 1; margin-bottom: 6px;
}
.stat-label { font-size: 13px; color: var(--muted); }
.stat-sub { font-size: 12px; color: var(--green); margin-top: 8px; font-weight: 600; }
.stat-sub.warn { color: var(--amber); }
.stat-sub.danger { color: var(--red); }

/* ===== Section title ===== */
.section { margin-top: 80px; }
.section-head {
  display: flex; justify-content: space-between; align-items: end;
  margin-bottom: 18px;
}
.section-head h2 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0;
}
.section-head .link {
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.section-head .link:hover { color: var(--red); }

/* ===== Recent tracked list ===== */
.tracked {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.tracked .row-item {
  display: grid;
  grid-template-columns: 40px 1fr 160px 110px 80px;
  align-items: center; gap: 14px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.tracked .row-item:last-child { border-bottom: 0; }
.tracked .row-head {
  background: var(--bg-soft);
  color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.kw-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--red-soft); color: var(--red);
  display: grid; place-items: center; font-weight: 800; font-size: 12px;
}
.row-domain { color: var(--ink-2); font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 13px; }
.row-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.dot.warn { background: var(--amber); }
.dot.danger { background: var(--red); }
.row-time { color: var(--muted); font-size: 12px; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 96px; padding: 28px 0;
  color: var(--muted); font-size: 13px;
}
.site-footer .row { display: flex; justify-content: space-between; align-items: center; }

/* ===== Result page specific ===== */
.result-header {
  background: var(--bg-soft); border-bottom: 1px solid var(--line);
  padding: 28px 0 24px;
}
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumbs a:hover { color: var(--red); }
.result-title { display: flex; align-items: center; gap: 14px; }
.result-title h1 { font-size: 28px; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.badge.danger { background: var(--red-soft); color: var(--red-deep); }
.badge.ok { background: #e6f7ec; color: #15803d; }
.badge.warn { background: #fef3c7; color: #92400e; }

.domain-card {
  margin-top: 18px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
}
.domain-card .left { display: flex; gap: 16px; align-items: center; }
.domain-logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
  display: grid; place-items: center; color: #fff;
  font-weight: 800; font-size: 22px;
}
.domain-info .url {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 18px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.01em;
}
.domain-info .meta {
  margin-top: 4px; color: var(--muted); font-size: 13px;
  display: flex; gap: 12px; flex-wrap: wrap;
}
.domain-info .meta .sep { color: var(--line); }

.charts {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-top: 24px;
}
.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}
.card-head h3 {
  font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -0.01em;
}
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 4px 10px; border-radius: 6px;
  background: var(--bg-soft); color: var(--muted);
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.tab.active { background: var(--red); color: #fff; }

/* sparkline area chart (pure SVG) */
.chart-svg { width: 100%; height: 240px; display: block; }

/* timeline */
.timeline { padding-left: 4px; }
.tl-item {
  position: relative; padding-left: 22px; padding-bottom: 16px;
  border-left: 2px solid var(--line); margin-left: 6px;
}
.tl-item:last-child { padding-bottom: 0; border-left-color: transparent; }
.tl-dot {
  position: absolute; left: -7px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--line); border: 2px solid #fff;
}
.tl-item.current .tl-dot { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.tl-domain {
  font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  font-weight: 700; color: var(--ink);
}
.tl-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-item.current .tl-domain { color: var(--red); }

/* warning list */
.warn-list { display: flex; flex-direction: column; gap: 10px; }
.warn-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
}
.warn-item .ic {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--red-soft); color: var(--red);
  display: grid; place-items: center; flex-shrink: 0; font-size: 16px;
}
.warn-item .ic.amber { background: #fef3c7; color: #92400e; }
.warn-item .title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.warn-item .desc { font-size: 13px; color: var(--muted); }

/* ===== Health-check badge (used everywhere) ===== */
.hc-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.hc-badge.ok      { background: #e6f7ec; color: #15803d; }
.hc-badge.blocked { background: #fef3c7; color: #92400e; }
.hc-badge.risk    { background: #ffedd5; color: #9a3412; }
.hc-badge.down    { background: var(--red-soft); color: var(--red-deep); }
.hc-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.hc-meta {
  font-size: 12px; color: var(--muted); margin-top: 6px;
}

/* ===== Not-ready page ===== */
.notice {
  max-width: 540px; margin: 80px auto;
  text-align: center; padding: 40px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius);
}
.notice .ic {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--red-soft); color: var(--red);
  display: grid; place-items: center; margin: 0 auto 18px;
  font-size: 26px;
}
.notice h2 { font-size: 22px; margin: 0 0 8px; }
.notice p { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

/* ===== Admin layout ===== */
.admin-shell {
  display: grid; grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 64px);
}
.admin-side {
  background: var(--bg-soft); border-right: 1px solid var(--line);
  padding: 24px 16px;
}
.admin-side .seg-title {
  font-size: 11px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 12px 12px 6px;
}
.admin-side a {
  display: block; padding: 9px 12px; border-radius: 8px;
  font-size: 14px; color: var(--ink-2);
}
.admin-side a:hover { background: #fff; color: var(--red); }
.admin-side a.active { background: var(--red); color: #fff; }
.admin-main { padding: 28px 32px 48px; }
.admin-h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 4px; }
.admin-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* admin grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* compact stat */
.kpi {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.kpi .val { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -0.02em; }
.kpi .delta { font-size: 12px; color: var(--green); font-weight: 600; margin-top: 6px; }
.kpi .delta.warn { color: var(--amber); }
.kpi .delta.danger { color: var(--red); }

/* bar list (sources/devices/countries) */
.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-row { font-size: 13px; }
.bar-row .top { display: flex; justify-content: space-between; margin-bottom: 4px; color: var(--ink-2); }
.bar-row .top .pct { color: var(--muted); font-weight: 600; }
.bar-row .track {
  height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden;
}
.bar-row .fill {
  height: 100%; background: linear-gradient(90deg, var(--red), var(--red-deep));
  border-radius: 999px;
}

/* table */
.table-wrap {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap th, .table-wrap td {
  padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line);
}
.table-wrap th {
  background: var(--bg-soft); color: var(--muted); font-weight: 600;
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
}
.table-wrap tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

/* result actions */
.dom-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* responsive */
@media (max-width: 880px) {
  .stats, .stats.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .hero h1 { font-size: 38px; }
  .domain-card { flex-direction: column; align-items: flex-start; }
  .tracked .row-item { grid-template-columns: 28px 1fr 90px; }
  .tracked .row-item .col-hide { display: none; }
  .nav { display: none; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
