:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f0f4f5;
  --text: #172023;
  --muted: #687579;
  --line: #dce4e6;
  --green: #1f8a5b;
  --green-soft: #dff3ea;
  --amber: #a66b00;
  --amber-soft: #fff0cc;
  --red: #bd3b3b;
  --red-soft: #f9dddd;
  --blue: #2866a8;
  --blue-soft: #dfeeff;
  --ink: #1d2c34;
  --shadow: 0 16px 40px rgba(23, 32, 35, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

h1 {
  font-size: 28px;
  font-weight: 750;
}

h2 {
  font-size: 17px;
  font-weight: 720;
}

h3 {
  font-size: 13px;
  color: var(--muted);
  font-weight: 680;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.icon-button,
.ghost-button,
.login-row button,
.segmented button,
.tabs button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  min-height: 38px;
}

.icon-button {
  width: 38px;
  font-size: 20px;
  line-height: 1;
}

.ghost-button {
  padding: 0 14px;
}

.hidden {
  display: none !important;
}

.login-panel {
  min-height: 58vh;
  display: grid;
  place-items: center;
}

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

.login-form label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

.login-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.login-row input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 12px;
}

.login-row button {
  padding: 0 18px;
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.form-error {
  margin-top: 10px;
  color: var(--red);
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-height: 92px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
}

.metric-queued strong {
  color: var(--amber);
}

.metric-running strong {
  color: var(--blue);
}

.metric-succeeded strong,
.metric-workers strong {
  color: var(--green);
}

.metric-failed strong {
  color: var(--red);
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.panel-head.compact {
  padding: 14px 16px;
}

.segmented {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.segmented button,
.tabs button {
  padding: 0 12px;
  min-height: 34px;
  font-size: 13px;
}

.segmented button.active,
.tabs button.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.task-list,
.worker-list,
.event-list {
  display: grid;
}

.task-card {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 160px 120px;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  text-align: left;
  width: 100%;
}

.task-card:hover {
  background: var(--panel-soft);
}

.task-main {
  min-width: 0;
}

.task-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.task-meta,
.worker-meta,
.event-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.status-queued {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-running {
  color: var(--blue);
  background: var(--blue-soft);
}

.status-succeeded,
.status-online {
  color: var(--green);
  background: var(--green-soft);
}

.status-failed,
.status-offline,
.status-cancelled {
  color: var(--red);
  background: var(--red-soft);
}

.worker-item,
.event-item {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.worker-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.tag {
  color: var(--muted);
  background: var(--panel-soft);
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
}

.empty {
  color: var(--muted);
  padding: 24px 16px;
  text-align: center;
}

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 20;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 35, 0.42);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(760px, 100%);
  height: 100%;
  overflow: auto;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.drawer-head h2 {
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.drawer-grid div {
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}

.drawer-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.drawer-grid strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.drawer-section {
  padding: 0 16px 16px;
}

pre {
  margin: 10px 0 0;
  background: #10191d;
  color: #eaf2f2;
  border-radius: 8px;
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.55;
  max-height: 360px;
  overflow: auto;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.log-view {
  min-height: 240px;
}

@media (max-width: 980px) {
  .shell {
    padding: 16px;
  }

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

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

  .task-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .task-title {
    white-space: normal;
  }

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

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

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  h1 {
    font-size: 24px;
  }

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

  .metric {
    min-height: 78px;
  }

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

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