:root {
  color-scheme: light;
  --bg: #f3f7fc;
  --bg-soft: #edf4ff;
  --surface: #ffffff;
  --surface-2: #f6f9fd;
  --surface-3: #eef5ff;
  --text: #142033;
  --muted: #667085;
  --line: #d9e3f0;
  --line-strong: #c8d6e8;
  --brand: #2563eb;
  --brand-2: #0ea5e9;
  --brand-dark: #1d4ed8;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --fail: #b42318;
  --fail-bg: #fee4e2;
  --filter: #b45309;
  --filter-bg: #fef3c7;
  --idle: #475467;
  --idle-bg: #eef2f7;
  --shadow: 0 18px 45px rgba(16, 24, 40, .08);
  --shadow-soft: 0 10px 28px rgba(16, 24, 40, .06);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f;
  --bg-soft: #0b1d33;
  --surface: #101b2d;
  --surface-2: #15233a;
  --surface-3: #162b49;
  --text: #f3f7ff;
  --muted: #a6b3c8;
  --line: #263a59;
  --line-strong: #345072;
  --brand: #65a5ff;
  --brand-2: #39c2ff;
  --brand-dark: #4f8ff2;
  --ok: #86efac;
  --ok-bg: rgba(22, 101, 52, .35);
  --fail: #fca5a5;
  --fail-bg: rgba(127, 29, 29, .38);
  --filter: #fbbf24;
  --filter-bg: rgba(113, 63, 18, .42);
  --idle: #cbd5e1;
  --idle-bg: rgba(51, 65, 85, .72);
  --shadow: 0 22px 55px rgba(0, 0, 0, .30);
  --shadow-soft: 0 12px 34px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, rgba(37, 99, 235, .18) 0, transparent 31%),
    radial-gradient(circle at 92% -4%, rgba(14, 165, 233, .17) 0, transparent 29%),
    linear-gradient(180deg, var(--bg-soft), var(--bg) 390px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px clamp(16px, 3vw, 46px);
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
:root[data-theme="dark"] .topbar { background: rgba(10, 19, 34, .84); }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  font-weight: 950;
  box-shadow: 0 10px 22px rgba(37, 99, 235, .24);
}
.brand strong { display: block; font-size: 18px; line-height: 1; letter-spacing: -.2px; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(16, 24, 40, .05);
}
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }

.shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: clamp(14px, 2.2vw, 30px) clamp(14px, 3vw, 46px) 58px;
}
.hero-card {
  display: grid;
  align-items: end;
  gap: 24px;
  padding: clamp(22px, 3.2vw, 42px);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255,255,255,.97), rgba(239,246,255,.88));
  border-radius: 30px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
:root[data-theme="dark"] .hero-card { background: linear-gradient(135deg, rgba(16,27,45,.98), rgba(16,43,73,.70)); }
.hero-card::after {
  content: "";
  position: absolute;
  width: 330px;
  height: 330px;
  border-radius: 999px;
  right: -90px;
  top: -150px;
  background: radial-gradient(circle, rgba(37,99,235,.22), transparent 66%);
  pointer-events: none;
}
.hero-content { position: relative; z-index: 1; min-width: 0; }
.hero-card p {
  margin: 0 0 10px;
  color: var(--brand);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .10em;
  font-size: 12px;
}
.hero-card h1 {
  margin: 0;
  max-width: 1180px;
  font-size: clamp(30px, 3.7vw, 58px);
  line-height: 1.03;
  letter-spacing: -1.6px;
}
.hero-subtitle {
  display: block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) minmax(360px, 460px);
  gap: clamp(16px, 2vw, 28px);
  margin-top: clamp(16px, 2vw, 26px);
  align-items: start;
}
.side-menu {
  position: sticky;
  top: 92px;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 10px;
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 8px;
}
:root[data-theme="dark"] .side-menu { background: rgba(16,27,45,.88); }
.menu-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 18px;
  padding: 13px 14px;
  cursor: pointer;
  text-align: left;
  transition: .15s ease;
}
.menu-item span {
  display: block;
  font-weight: 950;
  letter-spacing: -.2px;
}
.menu-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 750;
}
.menu-item:hover { border-color: var(--line); background: var(--surface-2); }
.menu-item.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  border-color: transparent;
  box-shadow: 0 14px 24px rgba(37, 99, 235, .22);
}
.menu-item.active small { color: rgba(255,255,255,.84); }

.panel-stack { min-width: 0; }
.tool-section {
  display: none;
  animation: sectionIn .18s ease;
}
.tool-section.active { display: block; }
@keyframes sectionIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.section-head {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.78);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}
:root[data-theme="dark"] .section-head { background: rgba(16,27,45,.78); }
.section-head span {
  display: inline-flex;
  color: var(--brand);
  background: var(--surface-3);
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
  margin-bottom: 10px;
}
.section-head h2 { margin: 0; font-size: clamp(24px, 2vw, 34px); letter-spacing: -.8px; }
.section-head p { margin: 8px 0 0; color: var(--muted); line-height: 1.45; }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  gap: clamp(14px, 1.6vw, 22px);
}
.single-grid { grid-template-columns: minmax(0, 620px); }
.tool-card, .result-card {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
}
:root[data-theme="dark"] .tool-card,
:root[data-theme="dark"] .result-card { background: rgba(16,27,45,.92); }
.tool-card {
  padding: clamp(17px, 1.8vw, 22px);
  scroll-margin-top: 92px;
  min-width: 0;
}
.tool-card:hover { border-color: var(--line-strong); }
.full-card { min-height: 310px; display: flex; flex-direction: column; justify-content: center; }

.tool-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.tool-head h2 { margin: 0; font-size: 21px; letter-spacing: -.35px; }
.tool-head small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.35; }
.tool-head span {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
  color: var(--brand);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 7px 10px;
}

label { display: block; color: var(--muted); font-weight: 800; font-size: 13px; }
input, select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  padding: 14px 14px;
  outline: none;
  font-size: 15px;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(37,99,235,.13); }
.form-row { display: grid; gap: 12px; }
.form-row.two { grid-template-columns: minmax(0, 1fr) minmax(120px, .36fr); }

.chips-title { margin: 13px 0 8px; color: var(--muted); font-size: 12px; font-weight: 900; }
.chips, .hint-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}
.chips button, .hint-grid span {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 850;
  font-size: 12px;
  transition: .15s ease;
}
.chips button { cursor: pointer; }
.chips button:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.hint-grid span { color: var(--brand); background: var(--surface-3); border-color: transparent; }

.action {
  width: 100%;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  padding: 14px 16px;
  font-weight: 950;
  cursor: pointer;
  margin-top: 15px;
  box-shadow: 0 15px 28px rgba(37, 99, 235, .20);
  transition: transform .15s ease, filter .15s ease;
}
.action:hover { filter: brightness(1.03); transform: translateY(-1px); }
.big-action { padding: 17px 18px; font-size: 17px; }

.result-card {
  position: sticky;
  top: 92px;
  padding: clamp(18px, 1.8vw, 24px);
  min-height: 360px;
  overflow: hidden;
}
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.falha { color: var(--fail); background: var(--fail-bg); }
.badge.filtrada, .badge.parcial { color: var(--filter); background: var(--filter-bg); }
.badge.idle { color: var(--idle); background: var(--idle-bg); }
.copy {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 850;
  cursor: pointer;
}
.copy:hover { border-color: var(--brand); color: var(--brand); }
.result-card h2 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.55px; }
.result-card p { margin: 10px 0 0; color: var(--muted); line-height: 1.5; }
.meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
}
.meta-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  padding: 11px 12px;
  min-width: 0;
}
.meta-item dt { color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.meta-item dd { margin: 4px 0 0; font-size: 14px; font-weight: 850; overflow-wrap: anywhere; }
.records { display: grid; gap: 10px; margin-top: 16px; max-height: 56vh; overflow: auto; padding-right: 4px; }
.record-row {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 5px;
}
.record-row strong { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.record-row span { font-weight: 900; overflow-wrap: anywhere; }
.record-row small { color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.record-good { border-color: color-mix(in srgb, var(--ok) 32%, var(--line)); background: color-mix(in srgb, var(--ok-bg) 45%, var(--surface)); }
.record-bad { border-color: color-mix(in srgb, var(--fail) 30%, var(--line)); background: color-mix(in srgb, var(--fail-bg) 45%, var(--surface)); }
.record-warn { border-color: color-mix(in srgb, var(--filter) 35%, var(--line)); background: color-mix(in srgb, var(--filter-bg) 50%, var(--surface)); }
.hop-row { grid-template-columns: minmax(88px, .28fr) minmax(0, 1fr); align-items: start; }
.hop-row small { grid-column: 2; }

@media (min-width: 1600px) {
  .workspace { grid-template-columns: 300px minmax(0, 1.1fr) minmax(440px, .55fr); }
  .tools-grid { grid-template-columns: repeat(2, minmax(360px, 1fr)); }
}
@media (max-width: 1240px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .result-card { position: relative; top: auto; grid-column: 1 / -1; }
  .records { max-height: none; }
}
@media (max-width: 900px) {
  .shell { padding-inline: 12px; }
  .topbar { padding-inline: 12px; }
  .workspace { display: block; }
  .side-menu {
    position: sticky;
    top: 72px;
    z-index: 15;
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 8px;
    margin-bottom: 14px;
    border-radius: 18px;
    scrollbar-width: none;
  }
  .side-menu::-webkit-scrollbar { display: none; }
  .menu-item { min-width: 170px; }
  .result-card { margin-top: 14px; }
  .hero-card { border-radius: 22px; }
}
@media (max-width: 640px) {
  .brand small { display: none; }
  .theme-toggle { padding: 9px 11px; font-size: 13px; }
  .hero-card h1 { font-size: 28px; letter-spacing: -.9px; }
  .form-row.two { grid-template-columns: 1fr; }
  .tools-grid, .single-grid { grid-template-columns: 1fr; }
  .meta-list { grid-template-columns: 1fr; }
  .hop-row { grid-template-columns: 1fr; }
  .hop-row small { grid-column: auto; }
}
