:root {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --accent: #38bdf8;
  --low: #22c55e;
  --medium: #f59e0b;
  --high: #ef4444;
  --negative: #a855f7;
  --current: #38bdf8;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.page-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.page-content {
  padding: 1rem 1.25rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .dashboard-grid {
    grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.6fr);
    align-items: start;
  }
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.toolbar button {
  background: var(--accent);
  color: #04202c;
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.toolbar button:disabled {
  opacity: 0.6;
  cursor: default;
}

.toolbar .updated-at {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.day-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.day-tabs button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 0.5rem;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.day-tabs button.active {
  background: var(--accent);
  color: #04202c;
  border-color: var(--accent);
  font-weight: 600;
}

.day-tabs button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.summary-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.summary-item {
  flex: 1 1 120px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
}

.summary-item .label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.summary-item .value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
}

.legend {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

.legend .dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  margin-right: 0.3rem;
}

.chart-wrap {
  position: relative;
  height: 260px;
}

.no-data {
  color: var(--text-muted);
  font-style: italic;
}

.refresh-error {
  color: var(--high);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.stale-note {
  color: var(--medium);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

@media (max-width: 480px) {
  .chart-wrap {
    height: 220px;
  }
}

.device-status {
  margin: 0 0 12px;
  padding: 6px 10px;
  border-radius: 6px;
  border-left: 4px solid var(--text-muted);
  background: rgba(148, 163, 184, 0.1);
}

.device-status-online {
  border-left-color: var(--low);
}

.device-status-sofarnepripojen,
.device-status-sofarchybakomunikace {
  border-left-color: var(--medium);
}

.device-status-esp32offline {
  border-left-color: var(--high);
}

.toolbar-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.button-link {
  display: inline-block;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-weight: 600;
  text-decoration: none;
}

.button-link:hover {
  background: rgba(56, 189, 248, 0.12);
}

/* Historie stavů */

.filter-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.filter-row input,
.filter-row select,
.filter-row button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
  color-scheme: dark;
}

.filter-row button {
  cursor: pointer;
}

.filter-row button:hover {
  border-color: var(--accent);
}

.filter-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0.5rem 0 0.75rem;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  color: var(--text);
}

.data-table .sort-arrow {
  color: var(--accent);
  font-size: 0.7rem;
}

.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.state-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 0.35rem;
  border-left: 3px solid var(--text-muted);
  background: rgba(148, 163, 184, 0.1);
}

.state-online {
  border-left-color: var(--low);
}

.state-sofarnepripojen,
.state-sofarchybakomunikace {
  border-left-color: var(--medium);
}

.state-esp32offline {
  border-left-color: var(--high);
}

.state-webstart {
  border-left-color: var(--accent);
}

/* Test příkazů */

.card h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.test-warning {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--medium);
  background: rgba(245, 158, 11, 0.08);
  border-radius: 0.35rem;
  font-size: 0.9rem;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.command-item {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0.5rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.command-item h3 {
  margin: 0;
  color: var(--text);
}

.command-item p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.command-item label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.command-item input,
.command-item button,
.card .filter-row button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
  color-scheme: dark;
}

.command-item button {
  cursor: pointer;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.command-item button:disabled,
.card .filter-row button:disabled {
  opacity: 0.5;
  cursor: default;
}

.test-ok {
  color: var(--low);
  font-weight: 700;
}

.test-fail {
  color: var(--high);
  font-weight: 700;
}

.link-button {
  margin-top: 0.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
  font-size: 0.85rem;
}

.command-live {
  border: 1px solid var(--medium);
}

.live-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #1c1300;
  background: var(--medium);
  border-radius: 0.3rem;
  padding: 0.05rem 0.35rem;
  vertical-align: middle;
}

/* Historie */

.history-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: 0.35rem;
}
