:root {
  color-scheme: light;
  --page: #f5f8f6;
  --ink: #202522;
  --muted: #66706a;
  --line: #d7dfda;
  --surface: #ffffff;
  --green: #16866f;
  --cyan: #0b7792;
  --coral: #c94f45;
  --gold: #b58700;
  --shadow: 0 12px 32px rgba(32, 37, 34, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, "Noto Sans Thai", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px auto;
  gap: 20px;
  align-items: center;
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--green);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.88rem;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 1.8rem;
}

h2 {
  font-size: 1.1rem;
}

.statusText,
.panelHeader p {
  margin: 8px 0 0;
  color: var(--muted);
}

.networkPhoto {
  width: 148px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.rangeButton,
.refreshButton,
.viewButton {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.rangeButton.active,
.refreshButton,
.viewButton.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.pageNav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.pageView.hidden {
  display: none;
}

.metricGrid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.metricTile {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metricTile span {
  color: var(--muted);
  font-weight: 700;
}

.metricTile strong {
  font-size: 2rem;
  line-height: 1;
}

.dangerTile {
  border-color: color-mix(in srgb, var(--coral), var(--line) 40%);
  border-left: 6px solid var(--coral);
}

.securityMetrics .metricTile:nth-child(2) {
  border-left: 6px solid var(--gold);
}

.securityMetrics .metricTile:nth-child(3) {
  border-left: 6px solid var(--cyan);
}

.panel,
.split {
  margin-top: 16px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panelHeader {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

#securityPage .split {
  grid-template-columns: minmax(0, 1fr);
}

#bruteForcePage .split {
  grid-template-columns: minmax(0, 1fr);
}

#ipPage .split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lookupForm {
  display: grid;
  grid-template-columns: minmax(180px, 420px) auto;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.lookupForm input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.timelineChart {
  height: 240px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(14px, 1fr);
  align-items: end;
  gap: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  overflow-x: auto;
}

.tallChart {
  height: 300px;
  grid-auto-columns: minmax(8px, 1fr);
}

.timelineBar {
  min-width: 14px;
  height: var(--bar-height, 2%);
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  background: var(--cyan);
  position: relative;
}

.timelineBar.drop {
  background: var(--coral);
}

.timelineBar span {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 32px;
  padding: 3px 5px;
  border-radius: 6px;
  background: #202522;
  color: #fff;
  font-size: 0.74rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.timelineBar:hover span {
  opacity: 1;
}

.barList {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.barRow {
  display: grid;
  grid-template-columns: minmax(92px, 150px) minmax(120px, 1fr) 72px;
  gap: 10px;
  align-items: center;
  min-height: 34px;
}

.barLabel,
.barValue {
  overflow-wrap: anywhere;
  color: var(--ink);
}

.barTrack {
  height: 12px;
  border-radius: 8px;
  background: #e9efec;
  overflow: hidden;
}

.barFill {
  width: var(--bar-width, 0%);
  height: 100%;
  border-radius: 8px;
  background: var(--green);
}

.barRow:nth-child(3n + 2) .barFill {
  background: var(--cyan);
}

.barRow:nth-child(3n + 3) .barFill {
  background: var(--gold);
}

.tableWrap {
  overflow-x: auto;
  margin-top: 14px;
  max-width: 100%;
}

table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  white-space: nowrap;
}

.wideTable table {
  min-width: 1280px;
}

#securityPage .wideTable table {
  min-width: 1560px;
}

#bruteForcePage .wideTable table {
  min-width: 1500px;
}

#ipPage .wideTable table {
  min-width: 1500px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.88rem;
}

td {
  overflow-wrap: normal;
  word-break: normal;
}

.numCell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sampleCell {
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portSampleCell {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ipSampleCell {
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emptyState {
  min-height: 72px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.poolList {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.poolList span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  color: var(--ink);
  font-size: 0.92rem;
}

.keyValueGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.keyValueItem {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
}

.keyValueItem span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.keyValueItem strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .networkPhoto {
    width: 100%;
    height: 140px;
  }

  .controls {
    justify-content: flex-start;
  }

  .metricGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split {
    grid-template-columns: 1fr;
  }

  #ipPage .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .topbar,
  .panel,
  .metricTile {
    padding: 14px;
  }

  h1 {
    font-size: 1.45rem;
  }

  .metricGrid {
    grid-template-columns: 1fr;
  }

  .panelHeader {
    display: block;
  }

  .barRow {
    grid-template-columns: minmax(80px, 110px) minmax(90px, 1fr) 56px;
  }

  .lookupForm,
  .keyValueGrid {
    grid-template-columns: 1fr;
  }
}
