:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-alt: #f9faf7;
  --text: #20231f;
  --muted: #667066;
  --border: #d8ded4;
  --accent: #1f7a5a;
  --accent-strong: #155c43;
  --warning: #a36517;
  --danger: #b23a48;
  --info: #276b8f;
  --shadow: 0 12px 30px rgba(27, 35, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(31, 122, 90, 0.08) 0, transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

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

button,
a,
select {
  min-height: 40px;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  position: relative;
  width: 48px;
  height: 48px;
  border: 1px solid #c6d5cd;
  border-radius: 8px;
  background: #eef6f1;
  overflow: hidden;
}

.brand-mark span {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.brand-mark span:nth-child(1) {
  left: 9px;
  top: 10px;
}

.brand-mark span:nth-child(2) {
  right: 8px;
  top: 14px;
  background: var(--info);
}

.brand-mark span:nth-child(3) {
  left: 16px;
  bottom: 9px;
  background: var(--warning);
}

.brand-mark span:nth-child(4) {
  right: 14px;
  bottom: 13px;
  background: var(--danger);
}

.brand h1,
.brand p,
.topbar h2,
.section-title h3 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.05;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

.nav-link.active,
.nav-link:hover {
  color: var(--text);
  background: #eef3ed;
}

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

.connection-panel {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  box-shadow: none;
}

.account-panel {
  display: grid;
  gap: 8px;
  padding: 14px;
  box-shadow: none;
}

.panel-heading,
.section-title,
.topbar,
.toolbar,
.inline-field,
.form-actions {
  display: flex;
  align-items: center;
}

.panel-heading,
.section-title,
.topbar {
  justify-content: space-between;
  gap: 16px;
}

.state-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8a938a;
}

.state-dot.ok {
  background: var(--accent);
}

.state-dot.fail {
  background: var(--danger);
}

.account-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
}

.account-state.ok {
  color: #176349;
  background: #e0f4ea;
}

.account-state.warn {
  color: #7a4f0e;
  background: #fff1d6;
}

.account-email,
.account-roles {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.account-email {
  font-size: 13px;
}

.account-roles {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-alt);
  font-size: 12px;
  line-height: 1.35;
}

.account-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar h2 {
  font-size: 28px;
}

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

.toolbar,
.form-actions {
  gap: 10px;
  flex-wrap: wrap;
}

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

.metric {
  padding: 14px 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.25fr) minmax(280px, 0.75fr);
  gap: 16px;
  margin-bottom: 16px;
}

.jobs-layout {
  display: grid;
  grid-template-columns: minmax(440px, 1.2fr) minmax(340px, 1fr);
  gap: 16px;
}

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

.section-title {
  margin-bottom: 16px;
}

.section-title.compact {
  margin-bottom: 12px;
}

.section-title h3 {
  font-size: 18px;
}

.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge {
  color: var(--accent-strong);
  background: #e7f4ee;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 10px;
}

textarea {
  min-height: 98px;
  resize: vertical;
  padding: 10px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.15);
}

.inline-field {
  gap: 8px;
}

.inline-field input {
  min-width: 0;
}

button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.secondary-button:hover {
  border-color: #afbaae;
  background: #f4f7f2;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.icon-button {
  flex: 0 0 auto;
  min-width: 46px;
}

[hidden] {
  display: none !important;
}

.form-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
}

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

.form-message.ok {
  color: var(--accent-strong);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #f3f8f4;
}

.mono,
td:nth-child(2),
td:nth-child(3),
dd,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

.empty {
  color: var(--muted);
  text-align: center;
}

.status-pill {
  color: #384037;
  background: #eef0ed;
}

.status-pill.created,
.status-pill.queued,
.status-pill.scheduled {
  color: #265f78;
  background: #e4f2f7;
}

.status-pill.validating,
.status-pill.running,
.status-pill.saving_artifacts {
  color: #7a4f0e;
  background: #fff1d6;
}

.status-pill.completed {
  color: #176349;
  background: #e0f4ea;
}

.status-pill.failed_preflight,
.status-pill.failed_runtime,
.status-pill.cancelled {
  color: #8d2434;
  background: #f8e3e6;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.detail-block {
  margin-top: 14px;
}

.detail-block span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

pre {
  min-height: 44px;
  max-height: 170px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-alt);
  white-space: pre-wrap;
}

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

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(260px, 1fr);
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav {
    display: none;
  }

  .connection-panel {
    margin-top: 0;
  }

  .account-panel {
    grid-column: span 2;
  }

  .jobs-layout,
  .work-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .sidebar,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .account-panel {
    grid-column: auto;
  }

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

  .topbar h2 {
    font-size: 24px;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  th,
  td {
    padding: 9px 8px;
  }
}
