:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #f0f2f4;
  --text: #17191c;
  --muted: #656b73;
  --border: #d9dde3;
  --accent: #1769ff;
  --accent-weak: #e8f0ff;
  --ok: #18794e;
  --warn: #a15c00;
  --danger: #c9372c;
  --danger-weak: #fff1f0;
  --shadow: 0 1px 2px rgba(20, 24, 31, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  min-height: 32px;
  border: 1px solid #0f58dd;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.97);
}

button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

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

input {
  height: 32px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

input:focus {
  outline: 2px solid var(--accent-weak);
  border-color: var(--accent);
}

.is-hidden {
  display: none !important;
}

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

.login-panel {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

.login-panel label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.error-text {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 14px;
}

.sidebar-brand {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sidebar-brand strong {
  display: block;
  line-height: 18px;
}

.sidebar-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: var(--text);
  color: var(--surface);
  font-weight: 800;
}

.nav-link {
  height: 28px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  color: var(--muted);
  padding: 0 10px;
  text-decoration: none;
  font-weight: 650;
}

.nav-link.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.workspace {
  min-width: 0;
  padding: 18px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 28px;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions,
.toolbar,
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.view {
  display: none;
}

.view.is-active,
.jobs-layout {
  display: grid;
  gap: 14px;
}

.metric-grid,
.overview-grid {
  display: grid;
  gap: 12px;
}

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

.overview-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
}

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

.metric {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px;
}

.metric span,
.metric small {
  color: var(--muted);
}

.metric strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
}

.ok {
  color: var(--ok);
}

.fail,
.failed {
  color: var(--danger);
}

.running {
  color: var(--accent);
}

.panel {
  overflow: hidden;
}

.panel-header {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
}

.panel-header h2 {
  margin: 0;
  font-size: 14px;
}

.panel > .toolbar,
.panel > .inline-form,
.item-list,
.status-list,
.compact-summary {
  padding: 12px 14px;
}

.danger-panel {
  border-color: #f0b8b4;
  background: var(--danger-weak);
}

.pill {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.pill.ok {
  border-color: #b7dfc8;
  background: #effaf3;
  color: var(--ok);
}

.pill.fail,
.pill.failed {
  border-color: #f0b8b4;
  background: var(--danger-weak);
  color: var(--danger);
}

.pill.running {
  border-color: #b8cdf7;
  background: var(--accent-weak);
  color: var(--accent);
}

.status-list,
.item-list {
  display: grid;
  gap: 8px;
}

.status-row,
.item-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  padding: 8px 10px;
}

.status-row strong,
.status-row small {
  display: block;
}

.status-row small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--border);
}

.compact-summary span,
.compact-summary small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.compact-summary strong {
  display: block;
  margin: 1px 0;
}

.event-stream {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 10px 14px;
  background: #101418;
  color: #d6dde6;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.event-line {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(214, 221, 230, 0.08);
}

.event-line time {
  color: #8b949e;
}

.event-line span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.event-line code {
  grid-column: 2;
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  border: 1px solid rgba(214, 221, 230, 0.14);
  border-radius: 5px;
  background: rgba(214, 221, 230, 0.08);
  color: #c8d3df;
  padding: 2px 6px;
  font: inherit;
}

.event-line.ok span {
  color: #87d39b;
}

.event-line.failed span {
  color: #ffb4ad;
}

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

.item-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

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

.row-actions button {
  min-height: 28px;
  padding: 0 9px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }

  .sidebar-brand {
    height: 34px;
    margin: 0;
  }

  .sidebar nav {
    display: flex;
    justify-content: flex-end;
    overflow-x: auto;
    gap: 4px;
  }

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

  .workspace {
    padding: 14px 12px 18px;
  }

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

@media (max-width: 680px) {
  body {
    font-size: 13px;
  }

  button,
  input {
    min-height: 34px;
  }

  .login {
    padding: 14px;
  }

  .login-panel {
    padding: 18px;
  }

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

  .sidebar nav {
    justify-content: flex-start;
    padding-bottom: 2px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .metric {
    min-height: 76px;
  }

  .panel-header {
    min-height: 40px;
    padding: 0 10px;
  }

  .panel > .toolbar,
  .panel > .inline-form,
  .item-list,
  .status-list,
  .compact-summary {
    padding: 10px;
  }

  .toolbar,
  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .compact-summary,
  .status-row,
  .item-row {
    grid-template-columns: 1fr;
  }

  .compact-summary {
    align-items: stretch;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .row-actions button {
    width: 100%;
  }

  .event-stream {
    min-height: 220px;
    max-height: 52vh;
    padding: 8px 10px;
  }

  .event-line {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 4px 8px;
  }
}

@media (max-width: 380px) {
  .row-actions {
    grid-template-columns: 1fr;
  }
}
