:root {
  color-scheme: light;
  --bg: #edf1f4;
  --surface: #ffffff;
  --surface-alt: #f7f9fb;
  --ink: #18212b;
  --muted: #627082;
  --line: #d8e0e8;
  --focus: #1f6feb;
  --accent: #0d7a68;
  --accent-soft: #e0f2ee;
  --warn: #a45f14;
  --warn-soft: #fff1d8;
  --danger: #b42318;
  --danger-soft: #ffe4df;
  --ok: #247044;
  --ok-soft: #e5f4ea;
  --queue: #5a4ca7;
  --shadow: 0 1px 2px rgb(24 33 43 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100vh;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

h3 {
  font-size: 0.95rem;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field input,
.search-box input,
.filter-bar input,
.filter-bar select,
.action-row input,
.action-row select,
.action-row textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input,
.search-box input,
.filter-bar input,
.filter-bar select,
.action-row input,
.action-row select {
  height: 38px;
  padding: 0 10px;
}

.action-row textarea {
  min-height: 74px;
  padding: 9px 10px;
  resize: vertical;
}

.field input:focus,
.search-box input:focus,
.filter-bar input:focus,
.filter-bar select:focus,
.action-row input:focus,
.action-row select:focus,
.action-row textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(31 111 235 / 18%);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}

.primary-action,
.text-button,
.mini-button,
.danger-button,
.ghost-button,
.icon-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.primary-action {
  min-height: 40px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.text-button,
.mini-button,
.danger-button,
.ghost-button {
  padding: 0 11px;
}

.compact-action {
  min-width: 82px;
  white-space: nowrap;
}

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

.ghost-button {
  background: var(--surface-alt);
}

.icon-button {
  width: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.form-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.86rem;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(240px, 1.2fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.identity {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.identity span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
}

.alert-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.volume-control {
  width: 126px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.volume-control input {
  width: 100%;
}

.workspace {
  display: grid;
  grid-template-columns: 168px minmax(380px, 1fr) minmax(330px, 0.78fr);
  gap: 10px;
  min-height: 0;
  padding: 10px;
}

.rail,
.list-pane,
.detail-pane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.rail {
  display: grid;
  grid-auto-rows: minmax(34px, max-content);
  align-content: start;
  gap: 5px;
  padding: 8px;
}

.rail-link,
.rail-link:visited,
.nav-button {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  text-align: left;
  text-decoration: none;
}

.nav-button.active,
.rail-link:hover,
.nav-button:hover {
  border-color: var(--line);
  background: var(--surface-alt);
}

.nav-button.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.list-pane,
.detail-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.detail-pane {
  grid-template-rows: auto minmax(0, 1fr);
}

.pane-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}

.pane-head.compact {
  min-height: 54px;
}

.counter-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.status-chip,
.count-chip,
.priority-chip,
.state-chip {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-chip.online,
.state-chip.open {
  border-color: #acd5bb;
  background: var(--ok-soft);
  color: var(--ok);
}

.status-chip.warn,
.priority-chip.high,
.priority-chip.urgent {
  border-color: #edc17f;
  background: var(--warn-soft);
  color: var(--warn);
}

.priority-chip.urgent,
.state-chip.failed {
  border-color: #e0a39d;
  background: var(--danger-soft);
  color: var(--danger);
}

.state-chip.queued,
.state-chip.retrying,
.state-chip.running {
  border-color: #c4bdf0;
  background: #efedff;
  color: var(--queue);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.list-body,
.detail-body {
  min-height: 0;
  overflow: auto;
}

.list-body.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-content: start;
  gap: 10px;
  padding: 10px;
}

.list-body.avatar-grid .empty-state {
  grid-column: 1 / -1;
}

.list-row {
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.list-row:hover,
.list-row.selected {
  background: #f4faf8;
}

.list-row[role="button"]:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--focus);
}

.row-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.row-title {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.row-meta,
.detail-grid dd,
.empty-state span,
.muted {
  color: var(--muted);
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.avatar-tile {
  min-width: 0;
  display: grid;
  gap: 7px;
  align-content: start;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.avatar-tile:hover,
.avatar-tile.selected {
  border-color: #98cec3;
  background: #f4faf8;
}

.profile-image {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f6f8fa, #dfe8ee);
}

.profile-image.tile {
  aspect-ratio: 1;
}

.profile-image.large {
  width: min(420px, 100%);
  aspect-ratio: 1;
}

.profile-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.profile-image.large img {
  object-fit: contain;
}

.profile-image:not(.loaded)::after {
  content: "loading";
  position: absolute;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.profile-image.no-media::after {
  content: "no image";
}

.profile-image.failed::after {
  content: "unavailable";
  color: var(--danger);
}

.profile-image-button {
  width: min(420px, 100%);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.image-flyout {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.image-flyout-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(12 21 31 / 0.64);
}

.image-flyout-panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: min(86vh, 920px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgb(12 21 31 / 0.28);
}

.image-flyout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.image-flyout-head h3 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
}

.image-flyout-body {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #0c151f;
}

.image-flyout-body img {
  max-width: 100%;
  max-height: calc(86vh - 72px);
  object-fit: contain;
}

.image-flyout-status {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  margin: 0;
  color: #fff;
  font-weight: 800;
  text-align: center;
}

.tile-title,
.tile-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-title {
  font-weight: 800;
}

.tile-meta,
.tile-value {
  color: var(--muted);
  font-size: 0.76rem;
}

.tile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.detail-body {
  padding: 12px;
}

.detail-section {
  display: grid;
  gap: 9px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.detail-section:first-child {
  padding-top: 0;
}

.detail-section:last-child {
  border-bottom: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(110px, 0.36fr) minmax(0, 1fr);
  gap: 7px 10px;
  margin: 0;
}

.detail-grid dt {
  color: var(--muted);
  font-weight: 800;
}

.detail-grid dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.action-row {
  display: grid;
  gap: 8px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.event-log {
  display: grid;
  gap: 8px;
}

.event-item {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-alt);
  overflow-wrap: anywhere;
}

.empty-state {
  min-height: 160px;
  display: grid;
  place-content: center;
  gap: 4px;
  padding: 24px;
  color: var(--ink);
  text-align: center;
}

.alert-flash {
  animation: alert-flash 800ms ease-out 1;
}

@keyframes alert-flash {
  0% {
    background: var(--warn-soft);
  }
  100% {
    background: #fff;
  }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 158px minmax(330px, 1fr) minmax(300px, 0.88fr);
  }
}

@media (min-width: 901px) {
  .app-shell {
    height: 100vh;
    overflow: hidden;
  }

  .workspace {
    height: 100%;
    overflow: hidden;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
  }

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

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(420px, 1fr) minmax(360px, 0.9fr);
  }

  .rail {
    display: flex;
    overflow-x: auto;
  }

  .rail-link,
  .nav-button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

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

@media (max-width: 560px) {
  .workspace {
    padding: 8px;
  }

  .filter-bar,
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

  .row-actions {
    justify-content: flex-start;
  }
}
