:root {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1b2740;
  --border: #2a3a5c;
  --text: #e6edf7;
  --muted: #93a4c0;
  --brand: #2563eb;
  --brand-2: #3b82f6;
  --ok: #16a34a;
  --warn: #f59e0b;
  --high: #f97316;
  --crit: #ef4444;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
/* The HTML `hidden` attribute must always win, even over elements that set an
   explicit display (.modal-backdrop uses grid, #key-box uses flex). */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #16223c 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; backdrop-filter: blur(8px); background: rgba(11,18,32,.7); z-index: 5;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand span { color: var(--text); }
.quota { font-size: 13px; color: var(--muted); }
.quota .pro { color: #fbbf24; font-weight: 600; }
.quota a { color: var(--brand-2); cursor: pointer; }

.container { max-width: 760px; margin: 0 auto; padding: 28px 18px 60px; }
.tagline { font-size: 30px; margin: 8px 0 4px; text-align: center; }
.sub { text-align: center; color: var(--muted); margin: 0 0 26px; }

.tabs { display: flex; gap: 8px; background: var(--surface); padding: 6px; border-radius: var(--radius); border: 1px solid var(--border); }
.tab {
  flex: 1; padding: 11px 8px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--brand); color: #fff; box-shadow: var(--shadow); }

.panel { display: none; margin-top: 22px; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel-help { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

textarea, input[type=text], input[type=email], select {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px;
  font-size: 15px; font-family: inherit; resize: vertical;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--brand-2); }
.row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.row label { flex: 1; min-width: 130px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
textarea { margin-bottom: 12px; }

button.primary {
  width: 100%; padding: 13px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 700; transition: .15s;
}
button.primary:hover { background: var(--brand-2); }
button.primary:disabled { opacity: .6; cursor: progress; }
button.secondary {
  padding: 11px 16px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  background: var(--surface-2); color: var(--text); font-weight: 600;
}

/* Results */
.result { margin-top: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.score-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.gauge { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 19px; color: #fff; flex-shrink: 0; }
.risk-LOW { background: var(--ok); } .risk-MEDIUM { background: var(--warn); }
.risk-HIGH { background: var(--high); } .risk-CRITICAL { background: var(--crit); }
.score-head h3 { margin: 0 0 2px; }
.score-head .lvl-LOW { color: #4ade80; } .score-head .lvl-MEDIUM { color: #fbbf24; }
.score-head .lvl-HIGH { color: #fb923c; } .score-head .lvl-CRITICAL { color: #f87171; }

.flag { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.flag:first-of-type { border-top: 0; }
.sev { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; height: fit-content; text-transform: uppercase; }
.sev.critical { background: var(--crit); color:#fff; } .sev.high { background: var(--high); color:#fff; }
.sev.medium { background: var(--warn); color:#222; } .sev.low { background: var(--surface-2); color: var(--muted); }

.block { margin-top: 14px; }
.block h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.copybox { position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.copybtn { position: absolute; top: 8px; right: 8px; font-size: 12px; padding: 4px 9px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.copybtn:hover { color: var(--text); }
.pricetag { display: flex; gap: 10px; margin-top: 6px; }
.pricetag div { flex: 1; text-align: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.pricetag .v { font-size: 19px; font-weight: 800; }
.pricetag .k { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 4px 11px; font-size: 13px; color: var(--muted); }
.acct { font-size: 13px; border-radius: 9px; padding: 9px 12px; margin-bottom: 14px; border: 1px solid var(--border); line-height: 1.45; }
.acct-trusted, .acct-established { color: #4ade80; border-color: #1f6f3f; background: rgba(22,163,74,.08); }
.acct-new { color: #fb923c; border-color: #7c3a12; background: rgba(249,115,22,.10); }
.acct-neutral { color: var(--muted); }
.share-btn { display: block; width: 100%; margin-top: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer; transition: .15s; }
.share-btn:hover { border-color: var(--brand-2); }
.share-btn.done { color: #4ade80; border-color: #4ade80; }
.shared-banner { background: rgba(37,99,235,.12); border: 1px solid var(--brand); color: #93c5fd; border-radius: 9px; padding: 10px 13px; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.disclaimer { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.degraded { font-size: 12px; color: var(--warn); margin-top: 8px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 26px; max-width: 420px; width: 100%; position: relative; box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 8px; }
.modal p { color: var(--muted); font-size: 14px; }
.modal-close { position: absolute; top: 12px; right: 14px; background: 0; border: 0; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.perks { list-style: none; padding: 0; margin: 14px 0; }
.perks li { padding: 5px 0; font-size: 14px; }
.modal input { margin: 10px 0; }
.have-key { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; font-size: 13px; }
.have-key a { color: var(--brand-2); }
#key-box { display: flex; gap: 8px; margin-top: 10px; }
.modal-note { font-size: 13px; min-height: 18px; }
.modal-note.err { color: #f87171; } .modal-note.ok { color: #4ade80; }

.footer { max-width: 760px; margin: 0 auto; padding: 24px 18px 40px; color: var(--muted); font-size: 12px; text-align: center; line-height: 1.6; }
.footer a { color: var(--brand-2); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 80; font-size: 14px; }

@media (max-width: 560px) {
  .tagline { font-size: 24px; }
  .tab { font-size: 12px; padding: 10px 4px; }
}
