:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #14202b;
  --muted: #647282;
  --line: #d9e0e7;
  --brand: #0b75b7;
  --brand-ink: #ffffff;
  --good: #197a4a;
  --warn: #a56300;
  --danger: #b72d2d;
  --shadow: 0 10px 24px rgba(20, 32, 43, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-ink);
  min-height: 44px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #e7edf2;
  color: var(--ink);
}

button.danger-button,
.remove-job-button {
  background: #ffe4e4;
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  padding: 18px 16px 92px;
  max-width: 1180px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.topbar h1,
.login-panel h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button {
  min-width: 82px;
  padding: 0 12px;
  font-size: 14px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.chip {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  min-height: 40px;
  padding: 0 8px;
}

.chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.custom-range,
.upload-row,
.button-row,
.copy-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.custom-range,
.upload-row {
  margin-bottom: 12px;
}

.upload-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.copy-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.hidden {
  display: none;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.job-list {
  display: grid;
  gap: 10px;
}

.job-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px;
}

.job-card-main {
  display: grid;
  gap: 5px;
  text-align: left;
  width: 100%;
  min-height: 120px;
  background: transparent;
  color: var(--ink);
  padding: 4px;
}

.remove-job-button {
  align-self: start;
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
}

.job-card-main strong {
  font-size: 17px;
}

.job-card-main span,
.job-card-main small,
.muted {
  color: var(--muted);
}

.poster-meta {
  margin: 0;
  overflow-wrap: anywhere;
}

.poster-meta a {
  color: var(--brand);
  font-weight: 800;
}

.job-error {
  color: var(--danger);
  font-weight: 800;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.job-card-main .job-error {
  color: var(--danger);
  font-size: 12px;
}

.badge {
  justify-self: start;
  border-radius: 999px;
  background: #e8eef3;
  color: var(--ink);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.success {
  background: #dff2e9;
  color: var(--good);
}

.badge.warn {
  background: #fff1d8;
  color: var(--warn);
}

.badge.danger {
  background: #ffe4e4;
  color: var(--danger);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.image-frame {
  background: #0f1720;
  border-radius: 8px;
  min-height: 320px;
  overflow: hidden;
}

.image-frame img {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.edit-form,
.settings-form,
.login-panel {
  display: grid;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.wide {
  width: 100%;
}

.worker-panel {
  margin-bottom: 12px;
}

.worker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.worker-header strong {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--muted);
  margin-top: 6px;
  flex: 0 0 auto;
}

.status-dot.running {
  background: var(--good);
}

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

.status-dot.error {
  background: var(--danger);
}

.worker-log-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 2px;
}

.worker-log {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.worker-log.info {
  border-left-color: var(--brand);
}

.worker-log.warn {
  border-left-color: var(--warn);
}

.worker-log.error {
  border-left-color: var(--danger);
}

.worker-log strong {
  display: block;
  font-size: 14px;
}

.worker-log small {
  color: var(--muted);
}

.worker-log code {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-size: 12px;
}

.conversation-header {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 12px;
}

.conversation {
  display: grid;
  gap: 10px;
}

.bubble {
  width: min(86%, 620px);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.bubble.outbound {
  justify-self: end;
  background: #e4f1fb;
  border-color: #b8d9f0;
}

.bubble p {
  margin: 0 0 6px;
}

.bubble small {
  color: var(--muted);
}

.toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.toggle input {
  width: 20px;
  min-height: 20px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  z-index: 5;
}

.nav-button {
  border-radius: 0;
  min-height: 64px;
  padding: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.nav-button.active {
  color: var(--brand);
  box-shadow: inset 0 3px 0 var(--brand);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.empty.compact {
  padding: 14px 10px;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-shell {
  width: min(420px, 100%);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px 12px 86px;
  }

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

  .custom-range,
  .copy-row,
  .button-row,
  .split {
    grid-template-columns: 1fr;
  }

  .job-card {
    grid-template-columns: 1fr;
  }

  .remove-job-button {
    width: 100%;
  }

  .image-frame img {
    max-height: 52vh;
  }
}
