/* ==========================================================================
   NetScope - Network & Website Diagnostics Toolkit
   Shared stylesheet. No external libraries.
   ========================================================================== */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --border: #e2e8f0;
  --text: #1b2733;
  --muted: #5b6b7b;
  --primary: #0b5cad;
  --primary-dark: #0a4587;
  --primary-soft: #e7f0fb;
  --accent: #0e9f6e;
  --accent-soft: #e5f7f0;
  --warn: #d97706;
  --warn-soft: #fdf1e0;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --info: #2563eb;
  --info-soft: #e8effd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 14px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 30px rgba(16, 24, 40, .12);
  --header-bg: #0d1726;
  --header-fg: #eaf1fa;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
img { max-width: 100%; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
main.container { padding-top: 28px; padding-bottom: 56px; }

/* ---------- Header / Nav ---------- */
.site-header {
  background: var(--header-bg);
  color: var(--header-fg);
  position: sticky; top: 0; z-index: 50;
}
.nav-wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; }
.brand svg { width: 26px; height: 26px; }
.brand .brand-sub { display: block; font-size: 11px; font-weight: 500; color: #9db4cc; letter-spacing: .02em; }
.nav-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-links a {
  color: #d6e2f0; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 14.5px; font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-toggle {
  display: none; background: none; border: 1px solid rgba(255,255,255,.35); color: #fff;
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 14px;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #0d1726 0%, #123157 100%);
  color: #fff;
  padding: 46px 0 40px;
  margin-bottom: 40px;
}
.hero h1 { font-size: clamp(1.6rem, 3.5vw, 2.5rem); margin: 0 0 10px; line-height: 1.2; }
.hero p.lead { font-size: 1.05rem; color: #c3d3e6; max-width: 760px; margin: 0 0 22px; }
.ip-widget {
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius); padding: 18px 20px; max-width: 680px;
}
.ip-widget .ip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; }
.ip-widget .ip-item label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #9db4cc; margin-bottom: 2px; }
.ip-widget .ip-item .val { font-weight: 700; font-size: 17px; word-break: break-word; }
.ip-widget .loading { color: #c3d3e6; font-size: 14px; }

/* ---------- Section headings ---------- */
h2.section-title { font-size: 1.45rem; margin: 0 0 6px; }
p.section-sub { color: var(--muted); margin: 0 0 22px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 10px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tool-card .tc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tool-icon {
  width: 44px; height: 44px; border-radius: 10px; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tool-icon svg { width: 24px; height: 24px; }
.tool-card h3 { margin: 0; font-size: 17px; line-height: 1.3; }
.tool-card p { margin: 0; font-size: 14px; color: var(--muted); flex: 1; }
.tool-card .status-avail { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.tool-card .status-soon { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-2); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff; border: 1px solid var(--primary);
  padding: 10px 18px; border-radius: 9px; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .12s ease;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 13.5px; border-radius: 7px; }
.btn-lg { padding: 13px 26px; font-size: 16px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14.5px; }
.field .help { font-size: 13px; color: var(--muted); margin-top: 5px; }
.input {
  width: 100%; padding: 11px 14px; font-size: 15px; border: 1px solid var(--border);
  border-radius: 9px; background: #fff; color: var(--text); font-family: var(--mono);
}
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 240px; margin-bottom: 0; }

/* ---------- Status / result elements ---------- */
.result-box { margin-top: 22px; display: none; }
.result-box.show { display: block; }
.source-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--primary-dark); background: var(--primary-soft); border: 1px solid #cfe0f4;
  padding: 3px 10px; border-radius: 999px; margin: 2px 0 4px; white-space: normal;
}
.source-tag svg { width: 13px; height: 13px; flex-shrink: 0; }
.notice {
  border: 1px solid var(--border); border-left: 4px solid var(--info); background: var(--info-soft);
  border-radius: 8px; padding: 12px 16px; font-size: 14px; margin: 12px 0;
}
.notice.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.notice.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.notice.ok { border-left-color: var(--accent); background: var(--accent-soft); }
.notice.small { font-size: 13px; padding: 9px 14px; }
.notice .n-title { font-weight: 700; display: block; margin-bottom: 2px; }

.error-msg {
  border: 1px solid #f3c2c2; background: var(--danger-soft); color: #7f1d1d;
  padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-size: 14px;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 14px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; background: #fff; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.mono, th.mono { font-family: var(--mono); font-size: 13px; word-break: break-all; }

/* ---------- Status pills (Passed / Warning / Needs attention) ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.pass { color: var(--accent); background: var(--accent-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.attention { color: var(--danger); background: var(--danger-soft); }
.pill.info { color: var(--info); background: var(--info-soft); }
.pill.neutral { color: var(--muted); background: var(--surface-2); }

/* ---------- Metrics / big readouts ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 16px 0; }
.metric {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; text-align: center; box-shadow: var(--shadow);
}
.metric .m-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.metric .m-value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.15; }
.metric .m-unit { font-size: 13px; color: var(--muted); font-weight: 500; }
.metric .m-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.speed-big {
  font-size: clamp(2.2rem, 6vw, 3.4rem); font-weight: 800; line-height: 1;
  color: var(--primary); display: block; margin: 10px 0 4px;
}
.speed-unit { font-size: 1rem; color: var(--muted); font-weight: 600; }

/* ---------- Progress bars ---------- */
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), #3b8bd6); width: 0; border-radius: 999px; transition: width .15s linear; }
.progress-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.progress-label b { color: var(--text); }

/* ---------- Labels / kbd ---------- */
kbd { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); border-radius: 4px; padding: 1px 5px; }

/* ---------- Content sections (educational) ---------- */
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 26px; }
@media (max-width: 820px) { .content-grid { grid-template-columns: 1fr; } }
.content-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.content-block h3 { margin: 0 0 10px; font-size: 1.05rem; }
.content-block h4 { margin: 14px 0 4px; font-size: .98rem; }
.content-block p, .content-block li { font-size: 14.5px; }
.content-block ul { margin: 6px 0 0; padding-left: 20px; }
.content-block li { margin-bottom: 4px; }

dl.terms { margin: 0; }
dl.terms dt { font-weight: 700; margin-top: 12px; font-size: 14.5px; }
dl.terms dd { margin: 2px 0 0; font-size: 14px; color: #33475b; }

/* ---------- FAQ ---------- */
.faq details { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 10px; }
.faq summary { cursor: pointer; padding: 12px 16px; font-weight: 600; font-size: 14.5px; list-style-position: outside; }
.faq summary::-webkit-details-marker { color: var(--primary); }
.faq .faq-body { padding: 0 16px 14px; font-size: 14.5px; color: #33475b; }

/* ---------- Breadcrumbs ---------- */
.breadcrumb { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }

/* ---------- Footer ---------- */
.site-footer { background: var(--header-bg); color: #aebfd4; font-size: 14px; padding: 34px 0; margin-top: 20px; }
.site-footer .fgrid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 26px; }
@media (max-width: 820px) { .site-footer .fgrid { grid-template-columns: 1fr; } }
.site-footer h4 { color: #fff; margin: 0 0 10px; font-size: 15px; }
.site-footer a { color: #b9ccea; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer .copy { border-top: 1px solid rgba(255,255,255,.12); margin-top: 24px; padding-top: 16px; font-size: 13px; }

/* ---------- Misc utilities ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 820px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.lead-text { font-size: 1.02rem; color: #33475b; max-width: 820px; }
.check-list { list-style: none; padding: 0; margin: 8px 0; }
.check-list li { padding-left: 26px; position: relative; margin-bottom: 8px; font-size: 14.5px; }
.check-list li::before { content: ""; position: absolute; left: 0; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent-soft); }
.check-list li:has(> .ck)::before { display: none; }

/* Result section blocks */
.result-section { margin-top: 20px; }
.result-section > h3 { font-size: 1rem; margin: 0 0 10px; padding-bottom: 8px; border-bottom: 2px solid var(--surface-2); }
.score-ring {
  width: 120px; height: 120px; border-radius: 50%; margin: 8px auto;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  color: #fff; font-weight: 800; font-size: 30px; line-height: 1.1;
  box-shadow: var(--shadow);
}
.score-ring small { font-size: 12px; font-weight: 500; opacity: .9; }
.band-table td:first-child { white-space: nowrap; font-weight: 600; }

.log-line { font-family: var(--mono); font-size: 13px; padding: 3px 0; color: #33475b; display: flex; gap: 8px; align-items: baseline; }
.log-line .t { color: var(--muted); width: 86px; flex-shrink: 0; font-size: 12px; }
.log-line .m-bad { color: var(--danger); font-weight: 600; }
.log-line .m-ok { color: var(--accent); font-weight: 600; }

/* Speed test UI */
.speed-stage { margin-top: 8px; }
.stage-list { margin-top: 12px; }
.stage-item { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.stage-item:last-child { border-bottom: none; }
.stage-item .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.stage-item.done .dot { background: var(--accent); }
.stage-item.active .dot { background: var(--warn); animation: pulse 1s infinite; }
.stage-item.failed .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }
.stage-item .s-name { font-weight: 600; width: 130px; flex-shrink: 0; }
.stage-item .s-value { color: var(--muted); font-size: 13.5px; }

@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .nav-links { display: none; width: 100%; flex-direction: column; padding-bottom: 12px; }
  .nav-links.open { display: flex; }
  .nav-wrap { flex-wrap: wrap; }
  .tool-grid { grid-template-columns: 1fr; }
}