:root {
  --green-900: #14532d;
  --green-800: #1b5e20;
  --green-050: #eef6ef;
  --orange-500: #f57c00;
  --orange-400: #ff9800;
  --cream: #fff8f0;
  --text: #1f2937;
  --muted: #5b6472;
  --border: #e3e0d8;
  --danger-bg: #fdecea;
  --danger: #8a1c12;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: var(--cream);
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; padding-top: 32px; padding-bottom: 48px; }
.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }

a { color: var(--green-800); }
h1, h2, h3 { color: var(--green-900); line-height: 1.25; }
.muted { color: var(--muted); }

/* header */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--green-900); color: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.15); }
.site-header .bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.2rem; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--orange-500); color: #fff; }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav a, .link-btn { color: #fff; text-decoration: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.nav a:hover, .link-btn:hover { text-decoration: underline; }
.inline { display: inline; margin: 0; }
.langs { display: flex; gap: 4px; margin-left: 4px; }
.langs a { padding: 2px 8px; border-radius: 6px; font-size: .8rem; border: 1px solid rgba(255,255,255,.35); }
.langs a.active { background: #fff; color: var(--green-900); border-color: #fff; }

/* buttons */
.btn { display: inline-block; padding: 10px 20px; border-radius: 8px; border: 2px solid transparent; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn-sm { padding: 4px 14px; }
.btn-primary { background: var(--green-900); color: #fff; }
.btn-primary:hover { background: var(--green-800); }
.btn-accent { background: var(--orange-500); color: #fff; }
.btn-accent:hover { background: var(--orange-400); }
.btn-ghost { background: transparent; color: var(--green-900); border-color: var(--green-900); }
.btn.block { display: block; width: 100%; margin-top: 16px; }
.nav .btn-accent { color: #fff; }
:focus-visible { outline: 3px solid var(--orange-400); outline-offset: 2px; }

/* layout */
.hero { text-align: center; padding: 40px 0 32px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); max-width: 760px; margin: 0 auto 16px; }
.hero .lead { max-width: 640px; margin: 0 auto 24px; font-size: 1.1rem; }
.hero .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.card h3 { margin-top: 0; }

/* forms */
.auth-card { max-width: 420px; margin: 24px auto; }
.auth-card h1 { margin-top: 0; }
label { display: block; margin: 14px 0 4px; font-weight: 600; }
input { width: 100%; padding: 10px 12px; border: 1px solid #c9c5ba; border-radius: 8px; font: inherit; }
input:focus { border-color: var(--green-800); outline: 2px solid var(--green-050); }
.alert { background: var(--danger-bg); color: var(--danger); border-radius: 8px; padding: 10px 12px; }

select, textarea { width: 100%; padding: 10px 12px; border: 1px solid #c9c5ba; border-radius: 8px; font: inherit; background: #fff; }
textarea { resize: vertical; }
select:focus, textarea:focus { border-color: var(--green-800); outline: 2px solid var(--green-050); }
.card form .btn { margin-top: 16px; }

.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin: 24px 0 12px; }
.section-head h1, .section-head h2 { margin: 0; }
.project-card { display: block; text-decoration: none; color: inherit; }
.project-card { transition: border-color .15s, box-shadow .15s, transform .15s; }
.project-card:hover { border-color: var(--orange-500); box-shadow: 0 4px 14px rgba(20,83,45,.12); transform: translateY(-1px); }
.project-card h3 { margin: 0 0 4px; color: var(--green-900); word-break: break-all; }
.project-card p { margin: 4px 0 0; }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.notice { background: var(--green-050); color: var(--green-900); border-radius: 8px; padding: 10px 12px; }

/* project page */
.back { margin: 0 0 8px; }
.page-head h1 { margin: 0; font-size: clamp(1.5rem, 5vw, 2.1rem); overflow-wrap: anywhere; }
.page-head p { margin: 4px 0 16px; }

.up { color: #1b7a2f; }
.down { color: var(--danger); }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.head-actions .btn { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0 0 12px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.kpi-label { color: var(--muted); font-size: .78rem; }
.kpi strong { font-size: 1.5rem; line-height: 1.2; color: var(--green-900); }
.kpi strong.moves { font-size: 1.2rem; }
.kpi .delta { font-size: .8rem; }
.kpis.mini { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } .kpis.mini { grid-template-columns: repeat(3, 1fr); } }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; font-size: 1rem; }
.range { display: flex; gap: 4px; }
.range a { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: .8rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.range a.active { background: var(--green-900); border-color: var(--green-900); color: #fff; }

.bars { display: block; width: 100%; max-width: 640px; height: auto; margin: 0 auto; }
.bars .grid { stroke: #ebe8df; stroke-width: 1; }
.bars .axis { fill: var(--muted); font-size: 11px; }
.bar.b0 { fill: #14532d; } .bar.b1 { fill: #7fb069; } .bar.b2 { fill: #e9c46a; } .bar.b3 { fill: #f4a261; } .bar.b4 { fill: #c0504d; }
.sw { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; }
.sw.b0 { background: #14532d; } .sw.b1 { background: #7fb069; } .sw.b2 { background: #e9c46a; } .sw.b3 { background: #f4a261; } .sw.b4 { background: #c0504d; }

.toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.toolbar input[type="search"], .toolbar .btn { grid-column: 1 / -1; }
.toolbar .btn { margin: 0; }
@media (min-width: 640px) {
  .toolbar { grid-template-columns: 1fr 150px 190px auto; }
  .toolbar input[type="search"], .toolbar .btn { grid-column: auto; }
}
.kw-main { min-width: 0; }
.kw-url { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; color: var(--green-800); }
.spark path { stroke: var(--green-800); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--green-800); }
.spark-gap { display: block; width: 64px; }
@media (max-width: 519px) { .spark, .spark-gap { display: none; } }
@media (min-width: 520px) { .kw { grid-template-columns: 1fr auto auto auto; } }

.add-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.add-box > summary { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; font-weight: 700; color: var(--green-900); cursor: pointer; list-style: none; }
.add-box > summary::-webkit-details-marker { display: none; }
.add-box > summary::after { content: "+"; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--orange-500); color: #fff; font-size: 1.1rem; line-height: 1; }
.add-box[open] > summary::after { content: "−"; }
.add-body { padding: 0 16px 16px; }
.add-body textarea { margin-bottom: 4px; }
.add-actions { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.add-actions label { margin-top: 10px; }
.add-actions .btn { padding: 10px 24px; }

.list-title { margin: 24px 0 10px; font-size: 1.15rem; }
.kw-list { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.kw { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.kw:last-child { border-bottom: 0; }
.kw-text { display: block; font-weight: 600; overflow-wrap: anywhere; }
.kw-meta { display: block; color: var(--muted); font-size: .8rem; }
.kw-rank { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.delta { font-size: .85rem; font-weight: 700; white-space: nowrap; }
.pill { min-width: 54px; padding: 3px 10px; border-radius: 999px; text-align: center; font-weight: 700; background: #eceae3; color: var(--text); }
.pill.t3 { background: var(--green-900); color: #fff; }
.pill.t10 { background: #d6ebd9; color: var(--green-900); }
.pill.t30 { background: #ffe6c7; color: #8a4b00; }
.pill.out { background: transparent; border: 1px dashed #cfcab9; color: var(--muted); font-weight: 600; }
.pill.err { background: var(--danger-bg); color: var(--danger); }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--danger-bg); color: var(--danger); }
.note { font-size: .85rem; margin-top: 12px; }
.danger-zone { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }
a.kw-text { color: var(--text); text-decoration: none; }
a.kw-text:hover { color: var(--green-800); text-decoration: underline; }
.page-head .btn { margin-bottom: 4px; }

/* comparison page */
.tabs { display: flex; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.tabs a { flex: 1 1 0; display: flex; align-items: center; justify-content: center; padding: 10px 4px; text-align: center; font-size: .9rem; line-height: 1.25; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--green-900); }
.tabs a.active { color: var(--green-900); border-bottom-color: var(--orange-500); }
.card.tight { padding: 14px 16px; margin-bottom: 12px; }
.card.tight .alert { margin-top: 0; }
.inline-form { display: flex; gap: 8px; margin-bottom: 6px; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form .btn { margin: 0; white-space: nowrap; }
.date-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 6px; }
.date-form label { margin: 0; flex: 1; min-width: 130px; font-size: .85rem; }
.date-form input { margin-top: 4px; }
.date-form .btn { margin: 0; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 16px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; background: #fff; border: 1px solid var(--border); border-radius: 999px; font-size: .9rem; }
.chip-x { border: 0; background: transparent; width: 24px; height: 24px; border-radius: 50%; color: var(--muted); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.chip-x:hover { background: var(--danger-bg); color: var(--danger); }

.table-scroll { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.cmp { width: 100%; border-collapse: collapse; }
.cmp th, .cmp td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
.cmp tr:last-child td { border-bottom: 0; }
.cmp th { font-size: .8rem; color: var(--green-900); vertical-align: bottom; }
.cmp th small, .cmp td small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.cmp th:first-child, .cmp td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; text-align: left; white-space: normal; min-width: 92px; max-width: 120px; overflow-wrap: anywhere; box-shadow: 1px 0 0 var(--border); }
.cmp td.best { background: #f1f8f2; }
.legend-best { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #f1f8f2; border: 1px solid #b9d9bd; vertical-align: -1px; }

.chart-card { padding: 12px; margin-bottom: 16px; }
.chart { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; }
.chart .grid { stroke: #ebe8df; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 13px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 4px 0; padding: 0; font-size: .85rem; }
.legend li { display: flex; align-items: center; gap: 6px; }

/* report (also printable) */
.report-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.report-actions .range { margin-left: auto; }
.report-actions .btn { margin: 0; }
.report-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 3px solid var(--orange-500); }
.report-head h1 { margin: 0 0 4px; }
.report-brand { margin: 0; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--orange-500); }
.report-meta { margin: 0; font-size: .85rem; }
.report-meta div { margin-bottom: 4px; }
.report-meta dt { display: inline; margin-right: 6px; color: var(--muted); }
.report-meta dd { display: inline; margin: 0; font-weight: 600; }
.movers { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 16px 0; }
.movers h2 { margin: 0 0 8px; font-size: 1rem; }
.mover-list { list-style: none; margin: 0; padding: 0; }
.mover-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.mover-list li > span:first-child { flex: 1; overflow-wrap: anywhere; }
.report-table th.left, .report-table td.left { text-align: left; }
.url-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: .85rem; }
.report-foot { text-align: center; margin-top: 24px; }
@media print {
  .site-header, .site-footer, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .card, .kpi, .table-scroll { border-color: #ccc; break-inside: avoid; }
  .table-scroll { overflow: visible; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* landing page */
.preview { max-width: 560px; margin: 0 auto 40px; padding: 14px; background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 18px 40px rgba(20, 83, 45, .15); }
.preview-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: .9rem; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: #d9d5c8; }
.preview .kpi strong { font-size: 1.2rem; }
.preview .bars { max-width: 100%; margin: 4px 0 8px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-bottom: 40px; }
.feature { padding: 20px; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.feature h3 { margin: 12px 0 4px; }
.feature p { margin: 0; color: var(--muted); }
.feature-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--green-050); color: var(--green-900); }
.steps { margin-bottom: 40px; }
.steps h2 { text-align: center; }
.steps ol { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.steps h3 { margin: 0 0 4px; }
.steps p { margin: 0; color: var(--muted); }
.step-no { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--orange-500); color: #fff; font-weight: 800; }
.cta-band { padding: 32px 20px; text-align: center; background: var(--green-900); border-radius: 16px; }
.cta-band h2 { margin-top: 0; color: #fff; }
.cta-band p { margin: 0 0 16px; color: #cfe3d2; }

.demo-note { margin: -4px 0 10px; font-size: .85rem; color: var(--muted); }
.badge { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--orange-400); color: #fff; font-size: .7rem; font-weight: 700; vertical-align: middle; }

.site-footer { background: var(--green-900); color: #cfe3d2; padding: 16px 0; font-size: .9rem; }
