:root {
  --surface: rgba(255, 255, 255, 0.95);
  --surface-2: rgba(245, 249, 252, 0.95);
  --border: rgba(16, 33, 49, 0.12);
  --text: #102131;
  --muted: #5b7184;
  --ok: #0c8f67;
  --warn: #d58b11;
  --alarm: #bf4d3a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

.tc-monitor-body {
  overflow: hidden;
}

#tc-app {
  height: 100dvh;
  max-width: none;
  width: 100%;
  padding: 6px;
  gap: 6px;
}

.tc-shell .shell-header {
  padding: 8px 10px;
  gap: 6px;
}

.tc-shell .shell-brand-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: stretch;
  gap: 10px;
}

.tc-status-cluster {
  width: 100%;
  min-width: 0;
}

.tc-shell .shell-title {
  margin: 4px 0 1px;
  font-size: clamp(1.14rem, 1.72vw, 1.82rem);
}

.tc-shell .shell-subtitle {
  max-width: 700px;
  font-size: 0.72rem;
  line-height: 1.28;
}

.tc-shell .shell-status-card {
  align-items: center;
  text-align: center;
  padding: 6px 8px;
}

.tc-shell .shell-status-label {
  font-size: 0.54rem;
}

.tc-shell .shell-status-value {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tc-shell .shell-nav {
  gap: 6px;
}

.tc-shell .shell-nav-link,
.tc-shell .panel-button {
  min-height: 36px;
}

.tc-shell .shell-nav-link {
  padding: 6px 12px;
}

.tc-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 6px;
}

.tc-config-cluster {
  min-width: 0;
}

.tc-meta-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.tc-action-cluster {
  min-width: 0;
}

.meta-item {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  min-height: 0;
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.meta-k {
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
}

.meta-v {
  font-size: 0.74rem;
}

.tc-meta-action {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border-radius: 16px;
  border: 1px solid rgba(0, 94, 137, 0.22);
  box-shadow: 0 10px 22px rgba(0, 94, 137, 0.18);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}

.tc-meta-action:disabled {
  opacity: 0.62;
  box-shadow: none;
}

.tc-meta-action:not(:disabled) {
  cursor: pointer;
}

#tc-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.tc-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  padding: 7px 8px;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 5px;
  min-height: 0;
  box-shadow: 0 10px 26px rgba(15, 33, 49, 0.08);
}

.tc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 0.66rem;
  color: var(--muted);
}

.tc-head > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-head-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tc-chan-check {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: #4aa8ff;
  cursor: pointer;
}

.tc-card.selected {
  border-color: rgba(74, 168, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(74, 168, 255, 0.45) inset;
}

.tc-value {
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: clamp(0.96rem, 1.04vw, 1.14rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ok);
  line-height: 1.1;
  white-space: pre;
  display: inline-block;
  min-width: 9ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.tc-card.warn .tc-value {
  color: var(--warn);
}

.tc-card.alarm .tc-value {
  color: var(--alarm);
}

.tc-foot {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  font-size: 0.58rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.tc-foot span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-trend-panel {
  position: fixed;
  inset: 0;
  background: rgba(16, 33, 49, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 14px;
}

.tc-trend-panel.hidden {
  display: none;
}

.tc-trend-card {
  width: min(1600px, 98vw);
  height: min(820px, 94vh);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.98), rgba(243, 247, 250, 0.98));
  box-shadow: 0 20px 80px rgba(15, 33, 49, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tc-trend-toolbar {
  min-height: 46px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.tc-trend-title {
  font-size: 0.98rem;
  letter-spacing: 0.05em;
  color: var(--text);
}

.tc-trend-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.66rem;
}

.tc-window-select {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.74rem;
  padding: 8px 10px;
  outline: none;
}

#tc-trend-canvas {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: block;
  background: radial-gradient(600px 320px at 0% 0%, rgba(76, 120, 255, 0.08), transparent 65%);
}

.tc-trend-legend {
  min-height: 56px;
  max-height: 112px;
  overflow: auto;
  border-top: 1px solid var(--border);
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tc-trend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.62rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.86);
}

.tc-trend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.tc-shell-status {
  gap: 6px;
  grid-template-columns: minmax(116px, 1.18fr) repeat(2, minmax(88px, 1fr));
  width: 100%;
  min-width: 0;
}

.tc-shell .shell-status-card {
  min-width: 0;
}

.tc-shell .shell-status-value {
  overflow-wrap: normal;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
}

@media (max-width: 1320px), (max-height: 900px) {
  #tc-app {
    padding: 6px;
    gap: 5px;
  }

  .tc-shell .shell-header {
    padding: 7px 8px;
    gap: 5px;
  }

  .tc-shell .shell-title {
    font-size: clamp(1rem, 1.42vw, 1.5rem);
  }

  .tc-shell .shell-subtitle {
    font-size: 0.66rem;
  }

  .tc-shell .shell-brand-row {
    grid-template-columns: minmax(0, 1fr) minmax(244px, 320px);
  }

  .tc-toolbar {
    grid-template-columns: minmax(0, 1fr) 196px;
  }

  .tc-meta-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .meta-item {
    padding: 6px 7px;
  }

  .meta-k {
    font-size: 0.54rem;
  }

  .meta-v {
    font-size: 0.68rem;
  }

  .tc-shell .shell-status-label {
    font-size: 0.5rem;
  }

  .tc-shell .shell-status-value {
    font-size: 0.66rem;
  }

  .tc-shell-status {
    gap: 5px;
    grid-template-columns: minmax(110px, 1.14fr) repeat(2, minmax(82px, 1fr));
  }

  #tc-grid {
    gap: 6px;
  }

  .tc-card {
    border-radius: 18px;
    padding: 6px 7px;
    gap: 3px;
  }

  .tc-head {
    font-size: 0.58rem;
  }

  .tc-value {
    font-size: clamp(0.82rem, 0.96vw, 0.98rem);
    min-width: 8ch;
  }

  .tc-foot {
    font-size: 0.52rem;
    gap: 4px;
  }

  .tc-chan-check {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 900px) {
  .tc-shell .shell-brand-row {
    grid-template-columns: 1fr;
  }

  .tc-toolbar {
    grid-template-columns: 1fr;
  }

  .tc-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tc-meta-action {
    min-height: 38px;
  }

  #tc-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: none;
  }
}

@media (max-width: 700px) {
  .tc-monitor-body {
    overflow: auto;
  }

  #tc-app {
    height: auto;
    min-height: 100dvh;
  }

  .tc-meta-grid {
    grid-template-columns: 1fr;
  }

  #tc-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
