.fleet-root {
  --fleet-gap: 12px;
  --fleet-pad: 16px;
  color: var(--text);
}

.fleet-root * { box-sizing: border-box; }
.fleet-root h1,
.fleet-root h2,
.fleet-root p { margin: 0; }

.fleet-view-head,
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--fleet-gap);
  padding: var(--fleet-pad);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.fleet-view-head h1,
.detail-head h1 {
  font-size: 20px;
  line-height: 1.15;
}

.fleet-view-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.fleet-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fleet-age,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.mono {
  font-family: var(--font-mono);
}

.hidden { display: none !important; }

.fleet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: calc(var(--radius) - 3px);
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.fleet-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 26%, var(--panel));
}

.fleet-btn.secondary {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.fleet-btn.danger {
  border-color: color-mix(in srgb, var(--danger) 60%, var(--line));
  background: color-mix(in srgb, var(--danger) 18%, var(--panel));
}

.fleet-btn.sleep {
  border-color: color-mix(in srgb, #5b78a6 60%, var(--line));
  background: color-mix(in srgb, #5b78a6 13%, var(--panel));
  color: color-mix(in srgb, #91add6 80%, var(--text));
}

.fleet-btn.sleep:hover:not(:disabled) {
  border-color: #7f9cc8;
  background: color-mix(in srgb, #5b78a6 22%, var(--panel));
}

.fleet-btn.icon { min-width: 46px; }
.fleet-btn:disabled { opacity: .55; cursor: not-allowed; }

.fleet-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: var(--fleet-gap);
  padding: var(--fleet-pad);
  background: var(--bg);
}

.fleet-stat-tile {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  background: var(--panel);
}

.fleet-stat-tile .label,
.fleet-stat-tile .note {
  color: var(--muted);
  font-size: 12px;
}

.fleet-stat-tile .value {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
}

.fleet-stat-tile.ok .value { color: var(--ok); }
.fleet-stat-tile.warn .value { color: var(--warn); }
.fleet-stat-tile.danger .value { color: var(--danger); }
.fleet-stat-tile.info .value { color: var(--accent); }
.fleet-stat-tile.neutral .value { color: var(--muted); }
.fleet-stat-tile.sleeping .value { color: #7f9cc8; }

.fleet-table-wrap {
  margin: 0 var(--fleet-pad) var(--fleet-pad);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.fleet-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.fleet-table th,
.fleet-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.fleet-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.fleet-table th.sortable { cursor: pointer; }
.fleet-table tr:last-child td { border-bottom: 0; }
.fleet-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.fleet-table tbody tr.attention td { background: color-mix(in srgb, var(--warn) 6%, var(--panel)); }
.fleet-table tbody tr.sleeping td { background: color-mix(in srgb, #5b78a6 5%, var(--panel)); }

.sort-glyph {
  color: var(--accent);
  font-size: 10px;
}

.instance-ident {
  display: grid;
  gap: 2px;
  min-width: 120px;
}

.instance-ident strong { font-size: 14px; }

.fleet-pill,
.fleet-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 3px 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.fleet-pill.ok,
.fleet-badge.production { color: var(--ok); }
.fleet-pill.drift,
.fleet-badge.other { color: var(--warn); }
.fleet-pill.degraded { color: var(--degraded); }
.fleet-pill.down { color: var(--danger); }
.fleet-pill.auth { color: var(--info); }
.fleet-pill.noversion,
.fleet-badge.test { color: var(--muted); }
.fleet-pill.sleeping,
.fleet-pill.stopping { color: #7f9cc8; }

.drift-text { color: var(--warn); }
.warn-text { color: var(--warn); }
.error { color: var(--danger); }

.fleet-row-spark,
.detail-spark {
  display: block;
  width: 120px;
  height: 28px;
}

.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark-empty {
  stroke: var(--line);
  stroke-width: 1;
}

.spark-down {
  stroke: var(--danger);
  stroke-width: 1.5;
  opacity: .9;
}

.fleet-empty,
.fleet-empty-cell {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.detail-root { background: var(--bg); }

.detail-head {
  position: sticky;
  top: 0;
  z-index: 3;
}

.detail-head > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.detail-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: var(--fleet-gap);
  padding: var(--fleet-pad);
}

.detail-sidebar,
.detail-main,
.feedback-section,
.feedback-item,
.ce-item,
.fleet-form,
.broadcast-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.detail-sidebar {
  display: grid;
  align-content: start;
  gap: var(--fleet-gap);
  padding: 12px;
}

.snapshot-field {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  font-size: 12px;
}

.snapshot-field span { color: var(--muted); }
.snapshot-field strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.detail-dots {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 8px;
}

.fleet-dot-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.fleet-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.fleet-dot.on { background: var(--ok); }
.fleet-dot.off { background: var(--danger); }
.fleet-dot.unknown { background: var(--line); }

.detail-panel {
  display: grid;
  gap: 8px;
}

.detail-panel-head,
.spark-card,
.feedback-section-head,
.ce-head,
.feedback-head,
.tab-toolbar,
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-panel-head { justify-content: space-between; }
.detail-panel h2 { font-size: 13px; }

.spark-card {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.detail-errors {
  display: grid;
  gap: 6px;
}

.detail-error {
  padding: 8px;
  border-left: 2px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--panel-2));
  color: var(--text);
  font-size: 12px;
}

.detail-main {
  min-width: 0;
  overflow: hidden;
}

.detail-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.tab-btn,
.segment {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.tab-btn {
  min-height: 38px;
  padding: 9px 12px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel-host {
  padding: var(--fleet-pad);
}

.tab-toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.fleet-input {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 3px);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

textarea.fleet-input {
  min-height: 150px;
  resize: vertical;
}

.fleet-form,
.broadcast-box {
  display: grid;
  gap: 12px;
  max-width: 620px;
  padding: 14px;
}

.field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
}

.segment {
  min-width: 42px;
  padding: 5px 9px;
}

.segment.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--accent);
}

.usage-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.pagination {
  justify-content: flex-end;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.fleet-wide-list {
  min-height: 100%;
  background: var(--bg);
}

.feedback-list {
  display: grid;
  gap: var(--fleet-gap);
  padding: var(--fleet-pad);
}

.feedback-section {
  padding: 12px;
}

.feedback-section-head {
  margin-bottom: 10px;
}

.feedback-section-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.feedback-item,
.ce-item {
  display: grid;
  gap: 7px;
  margin-top: 8px;
  padding: 10px;
  background: var(--panel-2);
}

.feedback-head {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.feedback-head time { margin-left: auto; }
.feedback-item p { white-space: pre-wrap; font-size: 13px; }

.feedback-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feedback-photos img {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 3px);
}

.ce-head {
  justify-content: space-between;
  align-items: flex-start;
}

.fleet-count {
  color: var(--warn);
  font-family: var(--font-mono);
}

.ce-item pre {
  max-height: 240px;
  overflow: auto;
  padding: 8px;
  border-radius: calc(var(--radius) - 4px);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.access-status {
  padding: 10px;
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
}

.fleet-toast-zone {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.fleet-toast {
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--bg) 78%, transparent);
}

.fleet-toast.error { border-color: var(--danger); }
.fleet-toast.success { border-color: var(--ok); }

@media (max-width: 900px) {
  .fleet-summary-strip,
  .usage-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-head,
  .fleet-view-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .fleet-summary-strip {
    grid-template-columns: 1fr;
  }

  .tab-panel-host,
  .feedback-list,
  .fleet-summary-strip,
  .detail-layout,
  .fleet-view-head,
  .detail-head {
    padding: 12px;
  }

  .snapshot-field {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* Dense mobile fleet overview */
.fleet-compact-list {
  display: grid;
  gap: 9px;
  padding: 0 var(--fleet-pad) var(--fleet-pad);
}

.fleet-compact-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  background: var(--panel);
  cursor: pointer;
}

.fleet-compact-card:focus-visible,
.fleet-compact-card:hover {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}

.fleet-compact-card.attention {
  border-color: color-mix(in srgb, var(--warn) 55%, var(--line));
}

.compact-card-head,
.compact-badges,
.compact-actions,
.fleet-modal-head,
.fleet-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-card-head {
  justify-content: space-between;
}

.compact-ident {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.compact-ident strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.compact-badges {
  flex: 0 0 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.compact-version {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.compact-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.compact-metric {
  display: grid;
  min-width: 0;
  gap: 1px;
  padding: 5px 6px;
  border-radius: calc(var(--radius) - 4px);
  background: var(--panel-2);
}

.compact-metric span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.compact-metric strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
}

.compact-actions {
  justify-content: flex-end;
}

.fleet-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, .62);
}

.fleet-modal {
  width: min(100%, 460px);
  max-height: min(82vh, 620px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
}

.fleet-modal-head {
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.fleet-modal-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}

.fleet-modal-body > .fleet-pill,
.fleet-modal-body > .fleet-badge {
  justify-self: start;
}

.quick-field {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: calc(var(--radius) - 4px);
  background: var(--panel-2);
}

.quick-field span {
  color: var(--muted);
  font-size: 11px;
}

.quick-field strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.fleet-modal-actions {
  justify-content: flex-end;
  padding: 0 12px 12px;
  flex-wrap: wrap;
}

@media (max-width: 760px) {
  .fleet-root {
    --fleet-gap: 8px;
    --fleet-pad: 10px;
  }

  .fleet-view-head,
  .detail-head {
    gap: 8px;
  }

  .fleet-view-head h1,
  .detail-head h1 {
    font-size: 18px;
  }

  .fleet-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: var(--fleet-pad);
  }

  .fleet-stat-tile {
    min-height: 54px;
    padding: 8px;
  }

  .fleet-stat-tile .value {
    margin-top: 2px;
    font-size: 18px;
  }

  .fleet-stat-tile .label,
  .fleet-stat-tile .note {
    font-size: 11px;
  }

  .fleet-stat-tile:nth-child(5) {
    grid-column: 1 / -1;
  }

  .fleet-table-wrap {
    margin: 0 var(--fleet-pad) var(--fleet-pad);
    overflow: visible;
  }

  .detail-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    gap: 1px;
    padding: 6px;
  }

  .tab-btn {
    min-height: 34px;
    padding: 7px 6px;
    border-radius: calc(var(--radius) - 4px);
    background: var(--panel);
    font-size: 12px;
    text-align: center;
    white-space: normal;
  }

  .tab-btn.active {
    background: color-mix(in srgb, var(--accent) 14%, var(--panel));
    border-bottom-color: transparent;
  }

  .tab-panel-host {
    padding: 10px;
  }

  .detail-root .fleet-table-wrap {
    margin: 0;
    overflow-x: hidden;
  }

  .detail-root .fleet-table {
    min-width: 0;
    table-layout: auto;
  }

  .detail-root .fleet-table th,
  .detail-root .fleet-table td {
    padding: 7px 6px;
    overflow-wrap: anywhere;
    font-size: 12px;
  }

  .row-actions {
    gap: 5px;
  }

  .row-actions .fleet-btn,
  .tab-toolbar .fleet-btn,
  .pagination .fleet-btn {
    min-height: 28px;
    padding: 5px 8px;
    font-size: 12px;
  }

  .usage-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .fleet-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .compact-metric:nth-child(5) {
    grid-column: span 2;
  }

  .fleet-modal-body {
    grid-template-columns: 1fr;
  }
}
