body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  color-scheme: dark;
  margin: 24px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 24px 0;
}

.stat {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 14px 18px;
  min-width: 140px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: bold;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.7;
}


/* -----------------------------------------------
   Landstatistik
   ----------------------------------------------- */

.countries {
  max-width: 900px;
  margin: 20px 0 32px 0;
}

.country-row {
  display: grid;
  grid-template-columns: 32px 190px 1fr 80px;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
}

.country-flag {
  width: 28px;
  height: 21px;
  object-fit: cover;
  display: block;
  border: 1px solid #30363d;
  box-sizing: border-box;
  border-radius: 4px;
}

.country-flag-unknown {
  width: 28px;
  height: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #30363d;
  box-sizing: border-box;
  font-size: 12px;
  background: #21262d;
  color: #c9d1d9;
  border-radius: 4px;
}

.country-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-background {
  height: 18px;
  background: #21262d;
  border-radius: 4px;
  overflow: hidden;
}

.bar {
  height: 100%;
  background: #58a6ff;
  border-radius: 4px;
  min-width: 2px;
}

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


/* -----------------------------------------------
   Live terminal
   ----------------------------------------------- */

.terminal {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 16px;
  max-width: 1100px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.terminal-header {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 10px 14px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.terminal-title {
  color: #c9d1d9;
  font-weight: bold;
  letter-spacing: 0.04em;
}

.terminal-live {
  color: #3fb950;
  font-size: 12px;
}

.terminal-live::before {
  content: "●";
  margin-right: 6px;
}

.terminal-body {
  height: 550px;
  overflow-y: auto;
  overflow-x: auto;
}

.terminal-columns {
  display: grid;

  grid-template-columns:
    150px
    135px
    120px
    65px
    minmax(180px, 1fr)
    55px
    minmax(220px, 1.5fr);

  gap: 12px;

  min-width: 1050px;

  padding: 8px 12px;

  background: #161b22;
  border-bottom: 1px solid #30363d;

  color: #8b949e;

  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;

  position: sticky;
  top: 0;
  z-index: 2;
}

.event-row {
  display: grid;

  grid-template-columns:
    150px
    135px
    120px
    65px
    minmax(180px, 1fr)
    55px
    minmax(220px, 1.5fr);

  gap: 12px;

  min-width: 1050px;

  padding: 7px 12px;

  border-bottom: 1px solid #21262d;

  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.35;

  color: #c9d1d9;
}

.event-row:hover {
  background: #161b22;
}

.event-time {
  color: #8b949e;
  white-space: nowrap;
}

.event-ip {
  color: #58a6ff;
  white-space: nowrap;
}

.event-country {
  color: #c9d1d9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-method {
  font-weight: bold;
  white-space: nowrap;
}

.method-get {
  color: #3fb950;
}

.method-post {
  color: #d29922;
}

.method-other {
  color: #a371f7;
}

.event-path {
  color: #f0f6fc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-status {
  font-weight: bold;
  white-space: nowrap;
}

.status-2xx {
  color: #3fb950;
}

.status-3xx {
  color: #d29922;
}

.status-4xx {
  color: #f85149;
}

.status-5xx {
  color: #ff7b72;
}

.status-other {
  color: #c9d1d9;
}

.event-ua {
  color: #8b949e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.terminal-error {
  color: #f85149;
  padding: 16px;
  font-family: Consolas, "Courier New", monospace;
}


/* -----------------------------------------------
   Övrigt
   ----------------------------------------------- */

.muted {
  opacity: 0.75;
}

/* -----------------------------------------------
   Projektintro
   ----------------------------------------------- */

.project-intro {
  max-width: 900px;
  margin: 14px 0 30px 0;
  padding: 18px 20px;
  border-left: 4px solid #58a6ff;
  background: #161b22;
  border-radius: 0 8px 8px 0;
}

.project-intro .lead {
  margin-top: 0;
  font-size: 1.08rem;
  line-height: 1.6;
}

.project-intro p {
  line-height: 1.6;
}

.project-intro .tagline {
  margin-bottom: 0;
  font-weight: 700;
}

.project-tech {
  max-width: 900px;
  margin: 30px 0 34px 0;
  padding-top: 4px;
}

.project-tech p {
  line-height: 1.6;
}

code {
  background: rgba(127, 127, 127, .12);
  padding: 2px 6px;
  border-radius: 6px;
}


/* -----------------------------------------------
   Intro med Mordor-öga
   ----------------------------------------------- */

.intro-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 36px;
  align-items: center;
  margin-bottom: 28px;
}

.intro-layout .project-intro {
  margin-bottom: 0;
}

.intro-image {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.intro-image img {
  display: block;
  width: 100%;
  max-width: 280px;
  max-height: 320px;
  object-fit: contain;
}

/* -----------------------------------------------
   Dashboard-layout
   ----------------------------------------------- */

.dashboard {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.7fr);
  grid-template-areas:
    "summary live"
    "countries live";
  gap: 0 28px;
  align-items: start;
  max-width: 1400px;
}

.dashboard-summary {
  grid-area: summary;
}

.dashboard-countries {
  grid-area: countries;
}

.dashboard-live {
  grid-area: live;
  min-width: 0;
}

.dashboard .stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 28px 0;
}

.dashboard .stat {
  min-width: 0;
}

.dashboard .countries {
  max-width: none;
}

.dashboard .country-row {
  grid-template-columns: 32px minmax(95px, 145px) 1fr 62px;
  gap: 8px;
}

.dashboard .terminal {
  max-width: none;
}

.dashboard .terminal-columns,
.dashboard .event-row {
  grid-template-columns:
    145px
    125px
    105px
    60px
    minmax(180px, 1fr)
    50px
    minmax(200px, 1.2fr);
  min-width: 980px;
  gap: 10px;
}

/* -----------------------------------------------
   Mindre skärmar
   ----------------------------------------------- */

@media (max-width: 900px) {

  .intro-layout {
    display: block;
    margin-bottom: 0;
  }

  .intro-image {
    display: none;
  }

  body {
    margin: 14px;
  }

  .dashboard {
    display: flex;
    flex-direction: column;
  }

  .dashboard-summary {
    order: 1;
    width: 100%;
  }

  .dashboard-live {
    order: 2;
    width: 100%;
  }

  .dashboard-countries {
    order: 3;
    width: 100%;
  }

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

  .dashboard .country-row {
    grid-template-columns: 32px 120px 1fr 65px;
  }

  .terminal-body {
    height: 450px;
  }

  .dashboard .terminal-columns,
  .dashboard .event-row {
    grid-template-columns:
      150px
      135px
      120px
      65px
      minmax(180px, 1fr)
      55px
      minmax(220px, 1.5fr);
    min-width: 1050px;
    gap: 12px;
  }

  .dashboard .terminal-columns > div:last-child,
  .dashboard .event-row .event-ua {
    display: block;
  }

}

@media (max-width: 520px) {

  .dashboard .stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat {
    padding: 12px 14px;
  }

  .stat-value {
    font-size: 1.55rem;
  }

  .project-intro {
    padding: 16px;
  }

}
