:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #15171a;
  --muted: #65717f;
  --line: #dbe1e8;
  --accent: #167c68;
  --accent-strong: #0f5d4e;
  --nav-active: #52766f;
  --danger: #b42318;
  --warn: #9a6700;
  --code: #23272f;
  --shadow: 0 8px 24px rgba(18, 24, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-strong);
}

button.danger {
  border-color: #f0b8b2;
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand {
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 112px;
  max-width: 100%;
  height: auto;
  margin-bottom: 8px;
}

.brand h1,
.page-title h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand span,
.page-title span,
.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 14px;
}

.layout {
  height: 100vh;
  display: grid;
  grid-template-columns: 252px 1fr;
  overflow: hidden;
}

.sidebar {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  border-right: 1px solid #e7ecef;
  background: #fbfcfd;
  color: var(--ink);
  padding: 26px 22px;
  box-shadow: 10px 0 28px rgba(20, 32, 42, 0.05);
  overflow: hidden;
}

.sidebar-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 0 4px 8px;
  text-align: center;
}

.sidebar-logo {
  width: 132px;
  height: auto;
  display: block;
}

.sidebar-brand strong {
  display: block;
  color: #172026;
  font-size: 18px;
  line-height: 1.2;
}

.nav {
  align-content: start;
  display: grid;
  gap: 12px;
  overflow: auto;
  min-height: 0;
}

.nav button {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  border-color: transparent;
  background: transparent;
  color: #8a9298;
  font-weight: 700;
  text-align: left;
  padding: 0 16px;
  border-radius: 8px;
}

.nav button.active,
.nav button:hover {
  background: #fff;
  border-color: #eef2f3;
  color: var(--nav-active);
  box-shadow: 0 12px 28px rgba(25, 42, 52, 0.12);
}

.nav-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-account {
  display: grid;
  gap: 10px;
  justify-items: center;
  border-top: 1px solid #e8eef1;
  padding-top: 18px;
  text-align: center;
}

.account-name {
  max-width: 100%;
  color: #35434d;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  min-height: 34px;
  min-width: 112px;
  color: #65717f;
  background: #fff;
}

.logout-button:hover {
  border-color: #cfd8de;
  color: #172026;
}

.main {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.content {
  min-width: 0;
  padding: 24px;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
}

.toolbar,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.toolbar .wide,
.form-grid .wide {
  grid-column: span 2;
}

.tag-filter-control {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-height: 36px;
  padding: 0;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #fbfcfd;
}

td.message {
  max-width: 520px;
  white-space: pre-wrap;
  word-break: break-word;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #eef2f5;
  color: #29313a;
  font-size: 12px;
  font-weight: 700;
}

.pill.error,
.pill.fatal {
  background: #fee4e2;
  color: var(--danger);
}

.pill.warn {
  background: #fff3c4;
  color: var(--warn);
}

.panel-pad {
  padding: 16px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.token-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 16px;
}

.stream-head {
  display: grid;
  grid-template-columns: minmax(180px, 320px) auto auto 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.status-dot {
  display: inline-flex;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.on {
  background: var(--accent);
}

.error-text {
  color: var(--danger);
  font-weight: 650;
}

@media (max-width: 900px) {
  .layout {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    min-height: auto;
    grid-template-rows: auto auto;
    gap: 10px;
    border-right: 0;
    padding: 12px;
    box-shadow: 0 8px 20px rgba(20, 32, 42, 0.08);
    overflow: visible;
  }

  .main {
    overflow: visible;
  }

  .sidebar-brand {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: 8px;
    overflow: visible;
  }

  .nav button {
    grid-template-columns: 22px 1fr;
    min-height: 44px;
    padding: 0 10px;
    gap: 8px;
  }

  .nav-icon,
  .nav-icon svg {
    width: 22px;
    height: 22px;
  }

  .sidebar-account {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid #e8eef1;
    padding-top: 10px;
    text-align: left;
  }

  .account-name {
    min-width: 0;
  }

  .logout-button {
    min-width: 88px;
  }

  .toolbar,
  .form-grid,
  .stream-head {
    grid-template-columns: 1fr;
  }

  .toolbar .wide,
  .form-grid .wide {
    grid-column: auto;
  }

  .content {
    padding-left: 16px;
    padding-right: 16px;
  }
}
