:root {
  --bg: #f2f7f7;
  --panel: #ffffff;
  --panel-soft: #f8fbfb;
  --border: #d9e4e4;
  --text: #17333b;
  --muted: #5f7a80;
  --accent: #0f9f8f;
  --accent-2: #ff8c3a;
  --ok: #138f4f;
  --ng: #d83b45;
  --warn: #f0b429;
  --shadow: 0 12px 28px rgba(15, 55, 64, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Poppins", "Trebuchet MS", "Verdana", sans-serif;
  background: radial-gradient(circle at 0% 0%, #d7eeec 0, transparent 40%),
    radial-gradient(circle at 100% 100%, #ffe6d4 0, transparent 45%),
    var(--bg);
  color: var(--text);
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(70px);
  z-index: -1;
  opacity: 0.35;
}

.bg-shape-a {
  width: 340px;
  height: 340px;
  top: -120px;
  left: -80px;
  background: #2bc0b4;
}

.bg-shape-b {
  width: 320px;
  height: 320px;
  bottom: -120px;
  right: -60px;
  background: #ffb46b;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 14px;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.top-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-item {
  min-width: 132px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 9px 12px;
}

.meta-item span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.meta-item strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.layout {
  padding: 0 20px 20px;
}

.tabs {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(3px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tab-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(248, 251, 251, 0.92);
}

.tab-button {
  border: 1px solid #cbdadb;
  background: #f4f9f9;
  color: #37585f;
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}

.tab-button.active {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #0a8b7d);
}

.tab-panels {
  padding: 14px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-card {
  background: linear-gradient(160deg, #ffffff, #f4fbfb);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.metric-card h4 {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 12px;
}

.pc-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.pc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pc-title {
  margin: 0;
  font-size: 18px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
}

.status-chip.online {
  background: #e0f8ec;
  color: var(--ok);
}

.status-chip.offline {
  background: #fde7eb;
  color: var(--ng);
}

.pc-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.meta-mini {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
}

.meta-mini span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.meta-mini strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
}

.meta-mini.mqtt-fail {
  border-color: #f6bcc3;
  background: #fff1f3;
  box-shadow: inset 0 0 0 1px #ffd9de;
}

.meta-mini.mqtt-fail strong {
  color: var(--ng);
  font-weight: 800;
}

.metric-progress-card strong {
  margin-top: 1px;
}

.metric-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 1px;
}

.metric-value-row strong {
  margin: 0;
}

.metric-value-row em {
  margin: 0;
  font-size: 11px;
  font-style: normal;
  color: var(--muted);
  white-space: nowrap;
}

.metric-progress-track {
  margin-top: 6px;
  height: 8px;
  width: 100%;
  border-radius: 999px;
  background: #e3ecec;
  overflow: hidden;
}

.metric-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  will-change: width;
}

.metric-progress-fill.meter-ok {
  background: linear-gradient(90deg, #1fb86d, #0f8a50);
}

.metric-progress-fill.meter-warn {
  background: linear-gradient(90deg, #ffad33, #ea7a1f);
}

.metric-progress-fill.meter-ng {
  background: linear-gradient(90deg, #ff5a5f, #cc2d3a);
}

.table-scroll {
  overflow: auto;
  max-width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.table th,
.table td {
  border-bottom: 1px solid #ebf1f1;
  padding: 8px 7px;
  text-align: left;
  font-size: 12px;
  vertical-align: top;
}

.table thead th {
  position: sticky;
  top: 0;
  background: #f5faf9;
  z-index: 2;
}

.level-ok {
  color: var(--ok);
  font-weight: 700;
}

.level-ng {
  color: var(--ng);
  font-weight: 700;
}

.level-info {
  color: #2f4f56;
  font-weight: 700;
}

.log-message-ng {
  color: var(--ng);
  font-weight: 600;
}

.log-table-wrap {
  max-height: calc(100vh - 280px);
}

.log-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.log-filter-group {
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-filter-group label {
  font-size: 11px;
  color: var(--muted);
}

.log-filter-group select,
.log-filter-group input {
  height: 32px;
  border: 1px solid #cddcdd;
  border-radius: 8px;
  background: #f9fcfc;
  color: #18363d;
  padding: 6px 9px;
  font-size: 12px;
}

.log-filter-search {
  min-width: 220px;
  flex: 1;
}

.log-filter-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: flex-end;
  gap: 8px;
}

.log-clear-btn {
  min-width: 94px;
}

.log-filter-count {
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 6px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  align-items: center;
}

.btn {
  border: 1px solid #d3e0e0;
  background: #f5f9f9;
  color: #1d4148;
  border-radius: 10px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
}

.btn.primary {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-2), #f2781f);
}

.btn.danger {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #ff5a5f, #c92a36);
}

.btn:disabled {
  color: #6f8388;
  border-color: #d3e0e0;
  background: #e8efef;
  cursor: not-allowed;
}

.btn.danger:disabled {
  color: #6f8388;
  border-color: #d3e0e0;
  background: #e8efef;
}

.btn.icon-only {
  width: 42px;
  min-width: 42px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.icon-only img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}

.btn.icon-only svg {
  width: 24px;
  height: 24px;
  display: block;
}

.restart-pc-btn {
  margin-left: auto;
  background: #ffffff;
  border: 2px solid var(--ng);
  color: var(--ng);
  box-shadow: 0 0 0 1px rgba(216, 59, 69, 0.08);
}

.restart-pc-btn:hover {
  background: #fff3f4;
}

.restart-pc-btn:disabled {
  border-color: #e9a4a9;
  background: #ffffff;
  color: #e9a4a9;
}

.volume-card {
  min-height: 68px;
}

.disk-lines {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.disk-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.disk-line span {
  color: inherit;
}

.disk-line.tone-ok {
  color: var(--ok);
}

.disk-line.tone-warn {
  color: #d97706;
}

.disk-line.tone-ng {
  color: var(--ng);
}

.disk-line.tone-muted {
  color: var(--muted);
  font-weight: 500;
}

.table tbody tr.worker-row {
  cursor: pointer;
}

.table tbody tr.worker-row:hover {
  background: #f2f8f8;
}

.table tbody tr.worker-row.row-selected {
  background: #ffe9dd;
}

.screenshot-wrap {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fbfdfd;
}

.screenshot-open {
  display: block;
  width: 100%;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: zoom-in;
  background: transparent;
}

.screenshot-wrap img {
  width: 100%;
  max-height: 230px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.image-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.image-modal.active {
  display: flex;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 22, 0.78);
  backdrop-filter: blur(2px);
}

.image-modal-dialog {
  position: relative;
  z-index: 2;
  width: min(96vw, 1800px);
  height: min(96vh, 1100px);
  border-radius: 12px;
  border: 1px solid #bfd0d0;
  background: #0d1718;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-dialog img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

.image-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #334f53;
  background: rgba(16, 28, 30, 0.9);
  color: #d4efef;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.empty-state {
  padding: 24px 14px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #cad9d9;
  border-radius: 12px;
  background: #f9fcfc;
}

@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .pool-grid {
    grid-template-columns: 1fr;
  }

  .pc-meta {
    grid-template-columns: 1fr 1fr;
  }

  .log-filter-count {
    width: 100%;
    margin-left: 0;
    padding-bottom: 0;
  }
}
