/* KeyScout styles */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #0f1419;
  --text-2: #4b5563;
  --muted: #6b7280;
  --brand: #2a78d6;
  --brand-dark: #1c5cab;
  --brand-soft: #e8f1fc;
  --good: #0f7b3e;
  --good-soft: #e6f4ec;
  --warn: #a15c00;
  --warn-soft: #fdf3e1;
  --bad: #c02a2a;
  --bad-soft: #fbeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* chart roles */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #eceef1;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4vw, 44px); letter-spacing: -.02em; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
pre { background: #0f1419; color: #e5e7eb; padding: 14px 16px; border-radius: 10px; overflow: auto; font-size: 13px; }
pre code { background: none; padding: 0; color: inherit; }

/* layout */
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.page { padding: 32px 0 64px; min-height: calc(100vh - 140px); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.center { text-align: center; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; gap: 16px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 30px; height: 30px; }
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link { color: var(--text-2); padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: 14px; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-link.active { color: var(--brand); background: var(--brand-soft); }
.credits-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; margin-left: 6px; white-space: nowrap; }
.credits-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 18px; cursor: pointer; }
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .site-nav { display: none; position: absolute; top: 62px; left: 0; right: 0; background: var(--surface); flex-direction: column; align-items: stretch; padding: 10px 20px 16px; border-bottom: 1px solid var(--border); }
  .site-nav.open { display: flex; }
  .credits-chip { align-self: flex-start; margin: 6px 0 0; }
}
.announce { background: #102a4c; color: #fff; text-align: center; font-size: 14px; padding: 8px 16px; }

/* footer */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: 13px; background: var(--surface); }
.site-footer .container { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.tight { padding: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.hero { padding: 12px 0 22px; }
.hero .eyebrow { color: var(--brand); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.hero p.lead { font-size: 18px; color: var(--text-2); max-width: 680px; }

/* forms */
.field { margin-bottom: 14px; }
label, .label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-2); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid #cfd4dc; border-radius: 9px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(42, 120, 214, .18); }
textarea { resize: vertical; min-height: 90px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.check input { width: 16px; height: 16px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px; border-radius: 9px; padding: 10px 18px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: #cfd4dc; }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--brand); border-color: transparent; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: #f0c4c4; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.good { background: var(--good); border-color: var(--good); }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.lg { padding: 13px 24px; font-size: 16px; }

/* pills (mode selector) */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pill span { display: block; padding: 9px 14px; border: 1px solid #cfd4dc; border-radius: 10px; font-weight: 600; font-size: 14px; background: var(--surface); cursor: pointer; }
.pill span small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.pill input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); box-shadow: 0 0 0 1px var(--brand) inset; }
.pill input:focus-visible + span { box-shadow: 0 0 0 3px rgba(42, 120, 214, .3); }

/* status / alerts */
.alert { border-radius: 10px; padding: 11px 14px; font-size: 14px; margin: 10px 0; border: 1px solid; }
.alert.error { background: var(--bad-soft); border-color: #f0c4c4; color: #8a1f1f; }
.alert.ok { background: var(--good-soft); border-color: #bfe3cd; color: #0b5c2e; }
.alert.info { background: var(--brand-soft); border-color: #c5dbf6; color: #164b8c; }
.alert.warn { background: var(--warn-soft); border-color: #f1d9ac; color: #7a4600; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.blue { background: var(--brand-soft); color: var(--brand-dark); }
.badge.green { background: var(--good-soft); color: var(--good); }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--bad-soft); color: var(--bad); }

/* progress */
.progress { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 12px 0; }
.progress span { display: block; height: 100%; width: 35%; background: var(--brand); border-radius: 4px; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.kw-table td:first-child { font-weight: 500; }
.kw-table { max-height: 520px; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; }

/* results */
.results-tools { display: grid; grid-template-columns: 2fr 2fr 1fr 1fr; gap: 10px; margin: 12px 0; }
@media (max-width: 760px) { .results-tools { grid-template-columns: 1fr 1fr; } }
.output { font-family: var(--mono); font-size: 13px; min-height: 320px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab { background: none; border: none; font: inherit; font-weight: 600; font-size: 14px; color: var(--text-2); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* list items */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: none; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { color: var(--muted); font-size: 13px; }

/* stat tiles */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .stat-label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.stat .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* pricing */
.price-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; background: var(--surface); cursor: pointer; position: relative; }
.price-card input { position: absolute; opacity: 0; }
.price-card.selected, .price-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; background: #fbfdff; }
.price-name { font-weight: 700; }
.price-now { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.price-was { color: var(--muted); text-decoration: line-through; margin-left: 6px; }
.price-credits { color: var(--text-2); font-weight: 600; }

/* feature grid */
.feature { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.feature .icon { width: 36px; height: 36px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; margin-bottom: 10px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; padding-left: 40px; position: relative; margin-bottom: 14px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px; }

/* auth */
.auth-wrap { max-width: 440px; margin: 20px auto; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 20, 25, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 860px; padding: 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.modal.narrow { max-width: 480px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.x { margin-left: auto; background: none; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #0f1419; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: #c9ced6; stroke-width: 1; }
.chart .tip { position: absolute; pointer-events: none; background: #0f1419; color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 7px; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: 0 6px 18px rgba(0, 0, 0, .2); z-index: 5; }
.chart .tip b { font-weight: 700; }
.chart-title { font-weight: 700; font-size: 15px; margin: 0; }
.chart-sub { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; padding: 5px 0; }
.hbar .hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hbar .hb-track { height: 12px; background: transparent; position: relative; }
.hbar .hb-fill { height: 12px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .hb-val { color: var(--text-2); font-variant-numeric: tabular-nums; font-weight: 600; }

/* admin */
.admin-layout { display: grid; grid-template-columns: 210px 1fr; gap: 20px; }
.admin-side { position: sticky; top: 80px; align-self: start; display: flex; flex-direction: column; gap: 2px; }
.admin-side button { text-align: left; background: none; border: none; font: inherit; font-weight: 600; font-size: 14px; color: var(--text-2); padding: 9px 12px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.admin-side button:hover { background: var(--surface-2); color: var(--text); }
.admin-side button.active { background: var(--brand-soft); color: var(--brand-dark); }
.admin-side .count { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 7px; }
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-side { position: static; flex-direction: row; overflow-x: auto; }
  .admin-side button { white-space: nowrap; }
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 150px; padding: 8px 10px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
@media (max-width: 700px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-section { grid-column: 1 / -1; font-weight: 800; font-size: 15px; margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.settings-section:first-child { margin-top: 0; }
