:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-strong: #101828;
  --text: #1d2939;
  --muted: #667085;
  --line: #d9dee8;
  --blue: #2563eb;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #b42318;
  --green: #15803d;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
}

* {
  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;
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

.side-panel {
  background: #121826;
  color: #eef2ff;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #2dd4bf;
  color: #0f172a;
  font-weight: 800;
}

.brand-block h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.brand-block p,
.muted,
.site-main small,
.job-head small {
  color: var(--muted);
}

.brand-block p {
  margin: 3px 0 0;
  color: #aab4c8;
  font-size: 0.86rem;
}

.nav-list {
  display: grid;
  gap: 6px;
  margin-top: 32px;
}

.nav-item,
.link-button {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.nav-item {
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
}

.nav-item.is-active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.side-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #aab4c8;
  font-size: 0.9rem;
}

.link-button {
  color: #67e8f9;
  padding: 0;
}

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

.topbar,
.toolbar,
.section-heading,
.job-head,
.detail-header,
.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

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

h2,
h3 {
  margin: 0;
  color: var(--panel-strong);
}

h2 {
  font-size: 1.8rem;
}

h3 {
  font-size: 1.05rem;
}

.topbar-actions,
.site-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  min-height: 38px;
  padding: 0 14px;
  font-weight: 700;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.button.ghost {
  background: transparent;
}

.button.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 1rem;
}

.notice,
.auth-panel,
.metric,
.site-row,
.job-item,
.detail-panel,
.settings-grid section,
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.notice {
  padding: 16px;
  margin-bottom: 18px;
}

.notice.warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.auth-panel {
  max-width: 440px;
  padding: 24px;
}

.login-form,
.form-grid,
.settings-grid,
.action-grid,
.tenant-facts,
.settings-list {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
  font-size: 0.9rem;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--text);
}

.form-error {
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.toolbar {
  margin-bottom: 18px;
}

.search-wrap {
  flex: 1;
  min-width: 220px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--panel-strong);
  font-size: 1.35rem;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.site-list,
.job-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.site-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.site-row.is-selected {
  border-color: var(--blue);
}

.site-main {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  padding: 0;
}

.site-main strong,
.site-main small {
  display: block;
  overflow-wrap: anywhere;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #94a3b8;
}

.status-dot.running,
.status-pill.running {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-dot.completed,
.status-pill.completed,
.status-pill.idle {
  background: #dcfce7;
  color: var(--green);
}

.status-dot.failed,
.status-pill.failed {
  background: #fee2e2;
  color: var(--red);
}

.status-pill.maintenance {
  background: #fef3c7;
  color: var(--amber);
}

.status-pill {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.job-item {
  padding: 12px;
  overflow: hidden;
}

.job-head strong,
.job-head small {
  display: block;
}

.job-head small {
  margin-top: 3px;
  overflow-wrap: anywhere;
}

pre {
  max-height: 260px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #d1fae5;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.detail-empty,
.empty-state {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.detail-panel {
  padding: 18px;
}

.detail-header a {
  display: inline-block;
  margin-top: 6px;
  color: var(--blue);
  overflow-wrap: anywhere;
}

.action-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.tenant-facts,
.settings-list {
  grid-template-columns: 150px minmax(0, 1fr);
  margin: 0;
}

.tenant-facts dt,
.settings-list dt {
  color: var(--muted);
  font-weight: 800;
}

.tenant-facts dd,
.settings-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

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

.settings-grid section {
  padding: 18px;
}

.modal {
  width: min(760px, calc(100vw - 28px));
  padding: 0;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.modal form {
  padding: 18px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
  min-height: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.toast.success {
  background: var(--teal);
}

.toast.error {
  background: var(--red);
}

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

  .side-panel {
    position: static;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 18px;
  }

  .side-footer {
    margin-top: 18px;
  }

  .split-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .main-panel {
    padding: 18px;
  }

  .topbar,
  .toolbar,
  .site-row,
  .detail-header,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .tenant-facts,
  .settings-list {
    grid-template-columns: 1fr;
  }

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