:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101214;
  color: #f1f4f7;
  --bg: #101214;
  --panel: #1a1d20;
  --panel-2: #191b20;
  --line: #2b3137;
  --text: #f1f4f7;
  --muted: #aeb7c1;
  --good: #54c6a2;
  --warn: #f2bd5c;
  --bad: #ff7777;
  --accent: #54c6a2;
  --green-soft: rgba(84, 198, 162, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

button,
a.open-link,
.jobs-inline,
input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #17191e;
  color: var(--text);
  font: inherit;
}

button,
a.open-link,
.jobs-inline {
  font-weight: 700;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
a.open-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.accent-button {
  border-color: var(--accent);
  color: var(--accent);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0 44px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 11px;
}

h1, h2, p { margin: 0; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: fit-content;
  min-width: 0;
}

.brand-mark {
  display: block;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  align-self: center;
  filter: drop-shadow(0 0 4px rgba(166, 221, 255, .42)) drop-shadow(0 0 8px rgba(78, 170, 255, .24));
}

h1 {
  font-family: "Bahnschrift SemiCondensed", "Bahnschrift", "Arial Narrow", sans-serif;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  line-height: 1;
  font-weight: 700;
  font-stretch: condensed;
  letter-spacing: -.025em;
  text-transform: uppercase;
  color: #f2f9ff;
  text-shadow:
    0 0 2px rgba(255, 255, 255, .38),
    0 0 8px rgba(151, 211, 255, .42),
    0 0 16px rgba(75, 166, 255, .18);
}

.status-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.status-summary strong { color: var(--text); }

.top-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 1.35rem;
  background: transparent;
}

.apps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.app-card {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 16px 16px;
  display: grid;
  gap: 12px;
}

.app-card:nth-child(odd) { border-right: 1px solid var(--line); }

.app-head {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.status-light {
  width: 12px;
  height: 12px;
  border-radius: 99px;
  background: var(--bad);
}

.app-card.online .status-light { background: var(--good); }
.app-card.port-open .status-light { background: var(--warn); }

.app-title { min-width: 0; }

.title-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.app-title h2 {
  font-size: 1rem;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.latency-value {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  flex: 0 0 auto;
}

.jobs-inline,
.settings-toggle {
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 800;
  flex: 0 0 auto;
}

.jobs-inline::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transform: translateY(-1px);
}

.jobs-inline[aria-expanded="true"]::before {
  transform: translateY(-1px) rotate(90deg);
}

.settings-toggle {
  width: 26px;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
}

.settings-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.details {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.details:empty { display: none; }

.detail-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.detail-row > span:first-child {
  color: var(--text);
  font-weight: 800;
}

.detail-row a,
.detail-row span:last-child { overflow-wrap: anywhere; }

.worker-list { display: grid; gap: 6px; }
.worker-list:empty { display: none; }

.worker {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 8px;
  font-size: 0.84rem;
}

.worker span { overflow-wrap: anywhere; }

.actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  font-size: 0.82rem;
}

.actions button,
.actions .open-link {
  min-width: 0;
  min-height: 34px;
  padding: 0 5px;
}

.actions [data-action="pull-restart"] {
  border-color: var(--accent);
  color: var(--accent);
}

.activity {
  margin-top: 22px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title h2 { font-size: 1rem; }
.section-title span { color: var(--muted); }

.activity-log {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.activity-item {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #141519;
  color: var(--muted);
  font-size: 0.9rem;
}

.activity-item strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

dialog {
  width: min(540px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0,0,0,.48);
}

dialog::backdrop { background: rgba(0,0,0,.66); }

#create-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.dialog-head h2 { font-size: 1.25rem; }

.eyebrow {
  color: var(--accent);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
  margin-bottom: 3px;
}

.dialog-copy {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}

#create-form label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: .84rem;
  font-weight: 800;
}

#create-form label small {
  color: var(--muted);
  font-weight: 500;
}

#create-form input {
  width: 100%;
  padding: 0 10px;
  outline: none;
}

#create-form input:focus { border-color: var(--accent); }

.create-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 7px;
  background: #141519;
}

.create-preview div {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 8px;
  font-size: .78rem;
}

.create-preview span { color: var(--muted); }
.create-preview strong { overflow-wrap: anywhere; }

.form-status {
  min-height: 20px;
  color: var(--warn);
  font-size: .84rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 820px) {
  .shell {
    width: 100%;
    padding: 12px 0 44px;
  }

  .apps { grid-template-columns: 1fr; }
  .app-card:nth-child(odd) { border-right: 0; }

  .topbar,
  .activity {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .brand { gap: 1px; }
  .brand-mark {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .status-summary {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: space-between;
    white-space: normal;
  }

  .top-actions {
    justify-content: flex-end;
  }

  .top-actions button:not(.icon-button) {
    min-height: 34px;
    padding: 0 9px;
    font-size: .8rem;
  }
}
