* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --border: #21262d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #6b7280;
  --font-sans: "Inter", sans-serif;
  --font-mono: "MesloLGS NF", "Menlo", "Courier New", monospace;
}

html {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 12px/1.6 var(--font-mono);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  font-family: var(--font-sans);
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

h1 {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--accent);
  font-weight: bold;
  text-transform: uppercase;
}

#status {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--border);
  color: var(--muted);
}

#status.ok {
  background: #1a2a1a;
  color: #3fb950;
}

#status.err {
  background: #2a1a1a;
  color: #f85149;
}

#count {
  color: var(--muted);
  font-size: 11px;
}

#db-size {
  color: var(--muted);
  font-size: 11px;
}

#scroll-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  background: #21262d;
  border: 1px solid var(--border);
  color: var(--text);
  display: none;
}

#scroll-btn:hover {
  background: #30363d;
}

#user-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

#user-bar span {
  color: var(--muted);
  font-size: 11px;
}

#user-bar form {
  display: flex;
  align-items: center;
}

#user-bar button {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  background: #21262d;
  border: 1px solid var(--border);
  color: var(--text);
}

#user-bar button:hover {
  background: #30363d;
}

#filter-bar {
  font-family: var(--font-sans);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 5px 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

#filter-bar input,
#filter-bar select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font: var(--font-sans);
  padding: 2px 6px;
  border-radius: 3px;
  outline: none;
}

#filter-bar input:focus,
#filter-bar select:focus {
  border-color: var(--accent);
}

#f-search {
  flex: 1;
}

#filter-bar button {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  background: #21262d;
  border: 1px solid var(--border);
  color: var(--muted);
}

#filter-bar button:hover {
  background: #30363d;
}

#log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.row {
  display: grid;
  grid-template-columns: 120px 200px 180px 155px 60px 1fr;
  padding: 2px 12px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  align-items: baseline;
}

.row:hover {
  background: var(--bg2);
}

.ts {
  color: var(--muted);
  white-space: nowrap;
}

.sev {
  font-weight: bold;
}

.host {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #79c0ff;
}

.app {
  color: #d2a8ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.ip[data-ip] {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.ip[data-ip]:hover {
  color: #c9d1d9;
}

.ip-link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.ip-link:hover {
  color: #79c0ff;
}

.geo-popup {
  position: fixed;
  z-index: 1000;
  background: #1c2128;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  color: #c9d1d9;
  min-width: 200px;
  max-width: 300px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.geo-ip {
  font-weight: 600;
  color: #f0f6fc;
  margin-bottom: 4px;
}

.geo-row {
  color: #8b949e;
  margin-top: 2px;
}

.geo-err {
  color: #ffa198;
}

.msg {
  word-break: break-word;
}

.EMERG,
.ALERT,
.CRIT {
  color: #ff7b72;
}

.ERROR {
  color: #ffa198;
}

.WARN {
  color: #e3b341;
}

.NOTICE {
  color: #79c0ff;
}

.INFO {
  color: #3fb950;
}

.DEBUG {
  color: var(--muted);
}

mark {
  background: #3d2e00;
  color: #e3b341;
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
}

/* Transparent wrapper so ip/host/app remain direct grid items on desktop */
.meta {
  display: contents;
}

/* Otel page */

#summary-bar {
  font-family: var(--font-sans);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 4px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
}

#summary-bar strong {
  color: var(--text);
  font-weight: 600;
}

.sum-sep {
  color: var(--border);
}

#events-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.otel-row {
  display: grid;
  grid-template-columns: 140px 150px 195px 145px 65px 120px 70px;
  padding: 2px 12px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  align-items: baseline;
  cursor: pointer;
}

.otel-row:hover {
  background: var(--bg2);
}

.ev {
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev-req {
  color: #3fb950;
}

.ev-err {
  color: #f85149;
}

.ev-tool {
  color: #79c0ff;
}

.ev-dec {
  color: #e3b341;
}

.ev-prompt {
  color: #d2a8ff;
}

.ev-other {
  color: var(--muted);
}

.user-col {
  color: #79c0ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mdl {
  color: #d2a8ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cost {
  color: #3fb950;
}

.toks {
  color: var(--muted);
}

.dur {
  color: var(--muted);
}

.otel-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 8px 12px 8px 28px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Nav bar */

#site-nav {
  font-family: var(--font-sans);
  position: sticky;
  top: 0;
  z-index: 10;
  background: #1e3a8a;
  border-bottom: 1px solid #1a3278;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
  padding: 0 16px;
  display: flex;
  align-items: center;
  height: 44px;
  flex-shrink: 0;
}

#nav-brand {
  margin-right: 24px;
}

#nav-brand a {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#nav-brand a:hover {
  color: rgba(255, 255, 255, 0.8);
}

#nav-links {
  display: flex;
  align-items: center;
  height: 100%;
}

.nav-link {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.nav-link:hover {
  color: rgba(255, 255, 255, 0.85);
}

.nav-link.active {
  color: #fff;
  border-bottom-color: #e3b341;
}

/* Overview page */

body.overview {
  overflow: hidden;
}

#ov-filter-bar {
  font-family: var(--font-sans);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 5px 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

#ov-filter-bar button {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 3px;
  cursor: pointer;
  background: #21262d;
  border: 1px solid var(--border);
  color: var(--muted);
}

#ov-filter-bar button:hover:not(:disabled) {
  background: #30363d;
}

#ov-filter-bar button:disabled,
#ov-filter-bar input:disabled {
  opacity: 0.5;
  cursor: default;
}

#ov-filter-bar input[type="month"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font: var(--font-sans);
  padding: 2px 6px;
  border-radius: 3px;
  outline: none;
}

#ov-filter-bar input[type="month"]:focus {
  border-color: var(--accent);
}

.ov-loading[hidden] {
  display: none;
}

.ov-loading {
  font-size: 11px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ov-loading::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: ov-spin 0.7s linear infinite;
}

@keyframes ov-spin {
  to {
    transform: rotate(360deg);
  }
}

#overview-content.ov-loading-active {
  opacity: 0.5;
  pointer-events: none;
}

#overview-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  font-family: var(--font-sans);
}

.ov-section {
  max-width: 900px;
  margin: 0 auto 40px;
}

.ov-section h2 {
  font-size: 11px;
  font-weight: bold;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.bar-row {
  display: grid;
  grid-template-columns: 220px 1fr 55px 82px;
  gap: 8px;
  align-items: center;
  margin-bottom: 5px;
}

.bar-label {
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.bar-track {
  height: 10px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
}

.bar-pct {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

.bar-cost {
  font-size: 11px;
  color: #3fb950;
  text-align: right;
  font-family: var(--font-mono);
}

.ov-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-top: 14px;
}

.ov-table th {
  text-align: left;
  color: var(--muted);
  font-weight: normal;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}

.ov-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
}

.ov-table tr:hover td {
  background: var(--bg2);
}

.model-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

#cost-chart {
  width: 100%;
}

#cost-chart svg {
  display: block;
}

/* Setup page */

body.setup {
  overflow: auto;
}

body.setup header {
  position: static;
}

.setup-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.7;
}

.setup-content h2 {
  font-size: 13px;
  font-weight: bold;
  color: var(--accent);
  text-transform: uppercase;
  margin: 24px 0 8px;
  letter-spacing: 0.05em;
}

.setup-content h2:first-child {
  margin-top: 0;
}

.setup-content p {
  color: var(--text);
  margin-bottom: 8px;
}

.setup-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  color: #79c0ff;
}

.setup-content pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  overflow-x: auto;
  margin: 8px 0 16px;
}

.setup-content pre .comment {
  color: var(--muted);
}

.setup-content pre .keyword {
  color: #e3b341;
}

.setup-content pre .value {
  color: #3fb950;
}

.setup-content pre .placeholder {
  color: #ff7b72;
  font-style: italic;
}

.step {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  align-items: baseline;
}

.step-num {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
  width: 20px;
}

.note {
  background: #1a2a1a;
  border-left: 3px solid #3fb950;
  padding: 8px 12px;
  margin: 8px 0 16px;
  border-radius: 0 3px 3px 0;
}

.note p {
  margin: 0;
  color: #3fb950;
  font-size: 12px;
}

/* Auth pages (Login, ExternalLogin) */

body.login-page,
body.access-denied-page {
  font:
    14px/1.6 system-ui,
    sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  height: auto;
  min-height: 100vh;
  flex-direction: row;
  overflow: auto;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

body.login-page h1 {
  font-family: var(--font-sans);
  font-weight: bold;
  font-size: 24px;
  color: #58a6ff;
  text-transform: none;
  margin-bottom: 16px;
}

body.login-page p {
  color: #484f58;
  font-size: 13px;
  margin-bottom: 28px;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: #21262d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.google-btn:hover {
  background: #2d333b;
}

.google-btn svg {
  flex-shrink: 0;
}

.error {
  color: #f85149;
  font-size: 13px;
  line-height: 1.6;
}

.error code {
  background: #21262d;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

body.access-denied-page h1 {
  font-family: var(--font-sans);
  font-size: inherit;
  color: #f85149;
  font-weight: normal;
  text-transform: none;
  margin-bottom: 12px;
}

body.access-denied-page p {
  color: #484f58;
  margin-bottom: 20px;
}

body.access-denied-page a {
  color: #58a6ff;
}

@media (max-width: 640px) {
  .otel-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    padding: 6px 10px;
    gap: 2px 8px;
  }

  .otel-row .ev {
    grid-column: 1;
  }

  .otel-row .ts {
    grid-column: 2;
    font-size: 10px;
    color: var(--muted);
  }

  .otel-row .user-col {
    grid-column: 1 / -1;
    font-size: 10px;
  }

  .otel-row .mdl,
  .otel-row .cost,
  .otel-row .toks,
  .otel-row .dur {
    display: none;
  }
}

@media (max-width: 640px) {
  header {
    flex-wrap: wrap;
  }

  #count,
  #db-size {
    display: none;
  }

  #user-bar span {
    display: none;
  }

  #scroll-btn,
  #user-bar button,
  #filter-bar button {
    min-height: 32px;
    padding: 4px 10px;
  }

  #filter-bar input {
    padding: 6px 8px;
    font-size: 13px;
  }

  .row {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "sev ts"
      "meta meta"
      "msg msg";
    padding: 6px 10px;
    gap: 2px 8px;
  }

  .sev {
    grid-area: sev;
    align-self: center;
  }

  .ts {
    grid-area: ts;
    font-size: 10px;
    align-self: center;
  }

  .meta {
    display: flex;
    grid-area: meta;
    font-size: 10px;
    overflow: hidden;
  }

  .meta .ip,
  .meta .host,
  .meta .app {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
  }

  .meta .host::before,
  .meta .app::before {
    content: " \00b7 ";
    color: var(--muted);
  }

  .msg {
    grid-area: msg;
    padding-top: 2px;
  }
}
