/* Fleet (/devices) — follows the admin theme (light / dark). Only the pixel-office iframe stays pixel-dark. */
:root {
  --pixel-bg: var(--bg-secondary);
  --pixel-surface: var(--bg-primary);
  --pixel-border: var(--border-color);
  --pixel-text: var(--text-primary);
  --pixel-muted: var(--text-muted);
  --pixel-accent: var(--accent);
  --pixel-online: var(--success-text);
  --pixel-offline: var(--text-muted);
  --fleet-tint-standard: transparent;
  --fleet-tint-nobreaks: rgba(250, 204, 21, 0.12);
  --fleet-tint-nosleep: rgba(239, 68, 68, 0.12);
  --office-bg: #1a1c2c;
}

.fleet-page {
  min-height: 100vh;
  background: var(--fleet-tint-standard);
  transition: background 0.3s ease;
}

.fleet-page.mode-nobreaks {
  background: linear-gradient(180deg, var(--fleet-tint-nobreaks), transparent 30%);
}

.fleet-page.mode-nosleep {
  background: linear-gradient(180deg, var(--fleet-tint-nosleep), transparent 30%);
}

/* —— Summary in the toolbar —— */
.fleet-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.fleet-stat {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.fleet-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.fleet-stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.fleet-stat.is-ok .fleet-stat-value { color: var(--success-text); }
.fleet-stat.is-info .fleet-stat-value { color: var(--info-text); }
.fleet-stat.is-warn .fleet-stat-value { color: var(--warning-text); }
.fleet-stat.is-bad .fleet-stat-value { color: var(--danger-text); }

.fleet-summary-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

/* Devices page is as wide as the table, and grows with the browser when there is room. */
.admin-content:has(.fleet-page) {
  max-width: none;
}

.fleet-page > .surface-card:has(.pixel-fleet-table) {
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

/* —— Agents table —— */
.pixel-fleet-table-wrap {
  overflow-x: visible;
}

.pixel-fleet-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.84rem;
  color: var(--text-primary);
}

.pixel-fleet-table th,
.pixel-fleet-table td {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  vertical-align: middle;
  text-align: left;
}

.pixel-fleet-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.pixel-fleet-table tbody tr:hover > td {
  background: var(--bg-secondary);
}

.pixel-fleet-table tbody tr:last-child > td {
  border-bottom: 0;
}

.pixel-fleet-table td.fleet-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.fleet-models-detail td {
  white-space: normal;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
}

.device-enroll-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.device-enroll-meta code {
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
}

.fleet-copy-btn,
button.btn.fleet-copy-btn {
  padding: 0.1rem 0.45rem !important;
  font-size: 0.68rem !important;
  line-height: 1.3;
  min-width: auto;
  border: 1px solid var(--border-color) !important;
  border-radius: 6px;
  background: var(--bg-primary) !important;
  color: var(--accent) !important;
  box-shadow: none !important;
  cursor: pointer;
}

.fleet-copy-btn:hover:not(:disabled) {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
}

.fleet-copy-btn:disabled,
.fleet-copy-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--text-muted) !important;
}

.fleet-scrape-note {
  margin-top: 0.15rem;
  max-width: 12rem;
  font-size: 0.65rem;
  line-height: 1.25;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.7rem;
}

.rank-pro { background: var(--info-light); color: var(--info-text); }
.rank-max5 { background: var(--warning-light); color: var(--warning-text); }
.rank-max20 { background: var(--danger-light); color: var(--danger-text); }

.behavior-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  vertical-align: middle;
}

.behavior-sleep, .behavior-forcesleep { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.behavior-break { background: var(--warning-light); color: var(--warning-text); border-color: transparent; }
.behavior-waiting { background: var(--info-light); color: var(--info-text); border-color: transparent; }
.behavior-working { background: var(--success-light); color: var(--success-text); border-color: transparent; }
/* ReadyReason claude_signed_out — Claude на экране входа, задачи не берёт */
.behavior-signed-out { background: var(--danger-light); color: var(--danger-text); border-color: var(--danger-color); }

.sparkline {
  display: block;
  width: 80px;
  height: 24px;
}

.limit-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
  font-size: 0.7rem;
}

.limit-bar-track {
  width: 48px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.limit-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

/* Метод последнего подсчёта токенов (общий для платформы, считает Api) */
.token-src-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: help;
}

.token-src-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.token-src-ok { background: var(--success-light); color: var(--success-text); }
.token-src-warn { background: var(--warning-light); color: var(--warning-text); }
.token-src-err { background: var(--danger-light); color: var(--danger-text); }
.token-src-none { background: var(--bg-tertiary); color: var(--text-muted); }

.fleet-mode-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-weight: 900;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
}

.fleet-mode-btn.mode-nobreaks { background: var(--warning-light); color: var(--warning-text); border-color: var(--warning-color); }
.fleet-mode-btn.mode-nosleep { background: var(--danger-light); color: var(--danger-text); border-color: var(--danger-color); }

/* —— Pixel office below the table —— */
.pixel-office-card {
  overflow: hidden;
}

.pixel-office-frame {
  display: block;
  width: 100%;
  height: 60vh;
  min-height: 320px;
  border: 0;
  background: var(--office-bg);
  image-rendering: pixelated;
}

/* —— Modals —— */
.pixel-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pixel-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 1.25rem 1.4rem;
  max-width: 520px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  color: var(--text-primary);
}

.pixel-modal label {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pixel-modal input,
.pixel-modal select {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.pixel-modal input[type="checkbox"] {
  width: auto;
  margin-top: 0;
}

.pixel-modal .buffer-multiselect {
  min-height: 7.5rem;
}

.pixel-modal .buffer-checklist {
  max-height: 10rem;
  overflow-y: auto;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fleet-device-menu-wrap {
  position: relative;
  display: inline-block;
}

.fleet-device-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 12.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding: 0.25rem;
}

.fleet-device-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text-primary);
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.fleet-device-menu-item:hover {
  background: var(--accent-soft);
}

a.fleet-device-menu-item,
a.fleet-device-menu-item:hover,
a.fleet-device-menu-item:visited {
  color: var(--text-primary);
  text-decoration: none;
  box-sizing: border-box;
}

.device-artifact-img {
  max-width: 100%;
  height: auto;
  display: block;
  margin-top: 8px;
}

.device-artifact-log {
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
  line-height: 1.35;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 8px;
}

/* proxy-file-* styles live in admin-theme.css (light /proxies page; do not override here) */
