:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --border: #d8dde6;
  --primary: #155eef;
  --primary-dark: #0f47b8;
  --danger: #b42318;
  --success: #067647;
  --warning: #8a5a00;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 56px;
  padding: 10px 22px;
  background: #101828;
  color: #fff;
  border-bottom: 1px solid #101828;
}

.topbar nav {
  display: flex;
  flex: 1;
  gap: 6px;
  flex-wrap: wrap;
}

.topbar a {
  color: #d0d5dd;
  padding: 7px 9px;
  border-radius: 6px;
}

.topbar a.active,
.topbar a:hover {
  background: #344054;
  color: #fff;
  text-decoration: none;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px;
}

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

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin: 0 0 18px;
}

.narrow {
  max-width: 460px;
}

.narrow-wide {
  max-width: 860px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin-bottom: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stats.cost-stats {
  grid-template-columns: repeat(7, minmax(140px, 1fr));
}

.stats div {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.stats span {
  display: block;
  font-size: 28px;
  font-weight: 700;
}

.stats label,
.muted {
  color: var(--muted);
}

.hidden {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-weight: 400;
}

textarea {
  resize: vertical;
}

code {
  padding: 2px 4px;
  border-radius: 4px;
  background: #f2f4f7;
  color: #344054;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

pre {
  overflow-x: auto;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #101828;
  color: #f9fafb;
}

pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

button.secondary,
.button.secondary {
  background: #fff;
  color: var(--primary);
}

button.secondary:hover,
.button.secondary:hover {
  background: #eef4ff;
}

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

.link-button {
  background: transparent;
  border: 0;
  color: #d0d5dd;
  min-height: auto;
  padding: 0;
}

.link-button:hover {
  background: transparent;
  color: #fff;
}

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

.row-form,
.filters {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.row-form label,
.filters label {
  min-width: 220px;
}

.filters {
  align-items: end;
}

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

.inline {
  display: inline-flex;
  gap: 8px;
  margin: 0;
}

.find-form select {
  min-width: 160px;
}

.event-form input[type="text"] {
  min-width: 260px;
}

.account-title-form {
  display: grid;
  grid-template-columns: minmax(140px, 220px) auto;
  gap: 8px;
  align-items: center;
}

.account-title-form input {
  min-width: 0;
}

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

.profile-form {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.checkbox-label {
  align-content: center;
  grid-template-columns: auto 1fr;
  gap: 8px;
}

.checkbox-label input {
  width: auto;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 14px;
}

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

.asset-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 12px;
}

.asset-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f2f4f7;
}

.asset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.badge {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1849a9;
  font-weight: 700;
  white-space: nowrap;
}

.muted-badge {
  background: #f2f4f7;
  color: #475467;
}

.compact-table {
  margin-top: 14px;
}

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert.success {
  color: var(--success);
  background: #ecfdf3;
  border-color: #abefc6;
}

.alert.error {
  color: var(--danger);
  background: #fef3f2;
  border-color: #fecdca;
}

.alert.warning {
  color: var(--warning);
  background: #fffaeb;
  border-color: #fedf89;
}

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

.clip {
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-text {
  white-space: pre-wrap;
}

.timeline-panel {
  overflow: hidden;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.timeline-slot {
  min-width: 0;
}

.center-slot {
  position: relative;
}

.center-slot::before {
  content: "";
  position: absolute;
  top: -14px;
  bottom: -14px;
  left: 50%;
  width: 1px;
  background: var(--border);
  z-index: 0;
}

.bubble,
.event-card {
  position: relative;
  z-index: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.user-bubble {
  background: #f9fafb;
  margin-right: auto;
}

.oleg-bubble {
  background: #eef4ff;
  border-color: #c7d7fe;
  margin-left: auto;
}

.event-card {
  background: #fffdf7;
  border-color: #fedf89;
}

.bubble-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.bubble-title,
.event-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.event-payload,
.decision-details {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 4px 8px;
  margin: 10px 0 0;
}

.event-payload dt,
.decision-details dt {
  color: var(--muted);
  font-weight: 700;
}

.event-payload dd,
.decision-details dd {
  margin: 0;
  min-width: 0;
}

.event-status,
.decision-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.decision-box {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
}

.dev-alert-box {
  border: 1px solid #fecdca;
  border-radius: 8px;
  background: #fff8f7;
  margin-top: 10px;
  padding: 10px;
}

.decision-retry {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
}

.media-pill {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  background: #ecfdf3;
  color: #067647;
  font-weight: 700;
}

.message-media {
  max-width: min(520px, 100%);
  max-height: 520px;
  border: 1px solid var(--border);
  border-radius: 8px;
  object-fit: contain;
}

.details {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
}

.details dt {
  color: var(--muted);
  font-weight: 700;
}

.details dd {
  margin: 0;
}

.qr-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.qr-box {
  width: 280px;
  height: 280px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.qr-box svg {
  width: 250px;
  height: 250px;
}

.errors {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.two,
  .grid.three,
  .stats,
  .asset-grid,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  table {
    display: block;
    overflow-x: auto;
  }

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

	  .account-title-form {
	    grid-template-columns: 1fr;
	  }

  .qr-layout {
    grid-template-columns: 1fr;
  }

  .timeline-row {
    grid-template-columns: 1fr;
  }

  .center-slot::before {
    display: none;
  }
}
