:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #18202a;
  --muted: #647082;
  --line: #d8dee8;
  --primary: #2457c5;
  --primary-hover: #1f49a5;
  --danger: #b42318;
  --danger-hover: #8f1c13;
  --success-bg: #e8f5ee;
  --success-text: #175c35;
  --error-bg: #fdeceb;
  --error-text: #9f1f17;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 8px rgb(24 32 42 / 7%);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1720px;
  margin: 0 auto;
  padding: 12px 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-size: 13px;
  letter-spacing: .4px;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.nav-links a {
  padding: 7px 12px;
  border-radius: 7px;
  color: #344054;
  font-weight: 600;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--panel);
  color: var(--primary);
  box-shadow: 0 1px 4px rgb(24 32 42 / 10%);
}

.page {
  max-width: 1720px;
  margin: 0 auto;
  padding: 24px 32px;
}

.section-header,
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 28px;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

p,
.muted {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

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

th {
  background: #eef1f5;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.compact-table th,
.compact-table td {
  padding: 8px 12px;
  vertical-align: middle;
}

.dashboard-table table {
  table-layout: fixed;
}

.col-name {
  width: 190px;
}

.col-image {
  width: 310px;
}

.col-status {
  width: 105px;
}

.col-health {
  width: 95px;
}

.col-restart {
  width: 145px;
}

.col-details {
  width: 160px;
}

.col-actions {
  width: 280px;
}

.name-cell strong,
.name-cell .muted {
  display: block;
}

.name-cell strong {
  margin-bottom: 2px;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.action-buttons {
  align-items: center;
  gap: 6px;
}

.action-buttons button,
.action-buttons .button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 13px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

button:hover,
.button:hover {
  background: #eef1f5;
}

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.primary:hover {
  background: var(--primary-hover);
}

.secondary {
  color: var(--text);
}

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

.danger:hover {
  background: var(--danger-hover);
}

.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef1f5;
  color: #344054;
  font-size: 13px;
}

.pill.ok {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-running {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-exited,
.status-created,
.status-dead {
  background: #f4f4f5;
  color: #52525b;
}

.row-details {
  position: static;
}

.row-details summary {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #344054;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.row-details summary:hover {
  background: #eef1f5;
}

.detail-grid {
  display: grid;
  gap: 10px;
  width: min(620px, 70vw);
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 4px 14px rgb(24 32 42 / 10%);
}

.detail-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
}

.alert.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.alert.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.stack {
  display: grid;
  gap: 14px;
}

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

.ordered-list {
  margin: 0;
  padding-left: 22px;
}

.ordered-list li {
  margin: 6px 0;
}

.warning {
  color: var(--danger);
}

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

.form {
  display: grid;
  gap: 18px;
  max-width: 980px;
}

.form label,
fieldset {
  display: grid;
  gap: 7px;
}

fieldset {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.small-input {
  max-width: 96px;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.checkbox {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

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

.logs {
  overflow: auto;
  min-height: 260px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #f9fafb;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .topbar,
  .topbar-inner,
  .section-header,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .page {
    padding: 18px;
  }

  .nav-links {
    justify-content: stretch;
  }

  .nav-links a {
    flex: 1;
    text-align: center;
  }
}

/* Dashboard refresh */
body {
  background: radial-gradient(circle at top left, #e8f1ff 0, transparent 360px), #f3f6fb;
  color: #111827;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

.topbar {
  background: #0f172a;
  border-bottom: 1px solid rgb(255 255 255 / 10%);
  box-shadow: 0 10px 30px rgb(15 23 42 / 18%);
}

.topbar-inner {
  max-width: 1840px;
  padding: 14px 32px;
}

.brand,
.brand:hover {
  color: #ffffff;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  box-shadow: 0 10px 20px rgb(37 99 235 / 28%);
}

.brand-text {
  display: grid;
  gap: 1px;
  line-height: 1.1;
}

.brand-text small {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

.nav-links {
  padding: 5px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 14px;
  background: rgb(255 255 255 / 6%);
}

.nav-links a {
  padding: 9px 14px;
  border-radius: 10px;
  color: #cbd5e1;
  font-weight: 700;
}

.nav-links a:hover,
.nav-links a.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: none;
}

.page {
  max-width: 1840px;
  padding: 30px 32px;
}

.dashboard-hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

h1 {
  margin-bottom: 6px;
  color: #111827;
  font-size: 34px;
  line-height: 1.1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  min-width: min(640px, 100%);
}

.stat-card {
  display: grid;
  gap: 6px;
  min-height: 78px;
  padding: 14px 16px;
  border: 1px solid #d9e2ee;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgb(15 23 42 / 5%);
}

.stat-card span {
  color: #667085;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-card strong {
  color: #111827;
  font-size: 26px;
  line-height: 1;
}

.stat-card.good {
  border-color: #bbf7d0;
  background: linear-gradient(180deg, #ffffff, #ecfdf3);
}

.table-wrap {
  border: 1px solid #d9e2ee;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgb(15 23 42 / 8%);
}

table {
  min-width: 1160px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid #edf1f7;
}

th {
  position: sticky;
  top: 69px;
  z-index: 5;
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.compact-table th,
.compact-table td {
  padding: 10px 16px;
}

.container-row {
  transition: background .16s ease;
}

.container-row:hover {
  background: #f8fbff;
}

.col-name {
  width: 290px;
}

.col-image {
  width: 360px;
}

.col-status {
  width: 125px;
}

.col-health {
  width: 120px;
}

.col-restart {
  width: 170px;
}

.col-actions {
  width: 340px;
}

.name-cell {
  display: grid;
  gap: 5px;
}

.container-name {
  color: #0f172a;
  font-size: 15px;
  font-weight: 850;
}

.image-name {
  color: #1f2937;
  font-weight: 650;
}

.action-buttons {
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

button,
.button {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 9px;
  color: #344054;
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.action-buttons button,
.action-buttons .button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.btn-start {
  border-color: #bbf7d0;
  background: #ecfdf3;
  color: #15803d;
}

.btn-stop {
  border-color: #fecaca;
  background: #fef2f2;
  color: #dc2626;
}

.btn-restart {
  border-color: #fde68a;
  background: #fffbeb;
  color: #b45309;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.pill.ok,
.status-running {
  background: #ecfdf3;
  color: #15803d;
}

.status-exited,
.status-created,
.status-dead {
  background: #f2f4f7;
  color: #667085;
}

.row-details {
  width: fit-content;
}

.row-details summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #2563eb;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  list-style: none;
}

.row-details summary:hover {
  background: transparent;
}

.row-details summary::-webkit-details-marker {
  display: none;
}

.row-details summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: #dbeafe;
  color: #2563eb;
  font-size: 12px;
  font-weight: 900;
}

.row-details[open] summary::before {
  content: "-";
}

.detail-grid {
  width: min(720px, 72vw);
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #d9e2ee;
  border-radius: 12px;
  background: #f8fafc;
  box-shadow: none;
}

.detail-label {
  font-size: 11px;
  font-weight: 850;
}

.panel,
fieldset,
input,
select,
.logs {
  border-radius: 14px;
}

@media (max-width: 900px) {
  .topbar-inner,
  .section-header,
  .panel-header,
  .dashboard-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .page {
    padding: 20px;
  }

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

/* Layout fixes and dashboard tools */
.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #d9e2ee;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgb(15 23 42 / 5%);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(440px, 100%);
}

.search-box span,
.visible-count {
  color: #667085;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box input {
  min-height: 38px;
  border-radius: 10px;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid #d9e2ee;
  border-radius: 12px;
  background: #f8fafc;
}

.status-tabs button {
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #475467;
  font-size: 13px;
}

.status-tabs button.active,
.status-tabs button:hover {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 4px rgb(15 23 42 / 12%);
}

.dashboard-table th {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
}

.table-wrap th {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
}

.dashboard-table td.name-cell,
.dashboard-table td.action-cell,
td.actions {
  display: table-cell !important;
}

td.actions form,
td.actions .button {
  display: inline-flex;
  margin: 0 6px 6px 0;
}

.dashboard-table .action-cell {
  text-align: right;
}

.name-stack {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.container-detail-row td {
  padding: 0 16px 10px;
  background: #ffffff;
  border-bottom: 1px solid #edf1f7;
}

.container-details {
  margin: 0;
}

.container-details summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  color: #2563eb;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  list-style: none;
}

.container-details summary::-webkit-details-marker {
  display: none;
}

.container-details summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: #dbeafe;
  color: #2563eb;
  font-size: 12px;
  font-weight: 900;
}

.container-details[open] summary::before {
  content: "-";
}

.detail-panel {
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(420px, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid #d9e2ee;
  border-radius: 14px;
  background: #f8fafc;
}

.container-details .detail-grid {
  width: 100%;
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.log-preview {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.log-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.log-preview-header strong {
  display: block;
  color: #111827;
}

.refresh-log-preview {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.log-preview-output {
  overflow: auto;
  max-height: 220px;
  min-height: 96px;
  margin: 0;
  padding: 12px;
  border: 1px solid #1f2937;
  border-radius: 12px;
  background: #0b1120;
  color: #d1d5db;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.log-preview-output.has-error {
  border-color: #991b1b;
  background: #1f1111;
  color: #fecaca;
}

tr[hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  .dashboard-toolbar,
  .detail-panel {
    grid-template-columns: 1fr;
  }

  .dashboard-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    align-items: stretch;
    flex-direction: column;
  }
}

.status-success {
  background: #ecfdf3;
  color: #15803d;
}

.status-failed {
  background: #fef2f2;
  color: #dc2626;
}

.status-skipped {
  background: #fffbeb;
  color: #b45309;
}

.run-log-panel {
  margin-top: 18px;
}

.run-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.run-summary > div {
  padding: 12px;
  border: 1px solid #d9e2ee;
  border-radius: 12px;
  background: #f8fafc;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  border-color: rgb(255 255 255 / 14%);
  background: rgb(255 255 255 / 8%);
  color: #e5e7eb;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.nas-pill {
  background: #eff6ff;
  color: #1d4ed8;
}

.nas-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.form-help {
  margin: 0;
  font-size: 13px;
}

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

.status-list > div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf1f7;
}

.status-list > div:last-child {
  border-bottom: 0;
}

.status-list dt {
  color: #667085;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.status-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.plain-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list li:not(.empty) {
  padding: 10px 12px;
  border: 1px solid #d9e2ee;
  border-radius: 10px;
  background: #f8fafc;
  font-weight: 750;
}

.login-page {
  min-height: 100vh;
  background: radial-gradient(circle at top left, #dbeafe 0, transparent 420px), #0f172a;
}

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

.login-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgb(0 0 0 / 28%);
}

.login-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.login-brand h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.login-brand p {
  margin: 0;
}

@media (max-width: 900px) {
  .run-summary {
    grid-template-columns: 1fr;
  }

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

  .status-list > div {
    grid-template-columns: 1fr;
  }
}
