:root {
  --bg-body: #020617;
  --bg-elevated: rgba(15, 23, 42, 0.9);
  --bg-elevated-soft: rgba(15, 23, 42, 0.7);
  --bg-accent: #1d4ed8;
  --bg-accent-soft: rgba(37, 99, 235, 0.15);
  --border-subtle: rgba(148, 163, 184, 0.3);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --text-soft: #6b7280;
  --danger: #ef4444;
  --success: #22c55e;
  --radius-lg: 16px;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.65);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at top, #0f172a 0, #020617 50%, #020617 100%);
}

/* ------------------- LOGIN OVERLAY ------------------- */

.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(37, 99, 235, 0.2), transparent 60%)
      fixed,
    radial-gradient(circle at bottom, rgba(94, 234, 212, 0.18), transparent 60%) fixed,
    #020617;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.login-card {
  width: 360px;
  padding: 28px 26px 22px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow-soft);
}

.login-header {
  margin-bottom: 20px;
}

.login-logo {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.login-logo span {
  color: #60a5fa;
}

.login-subtitle {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.login-form input {
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-main);
  outline: none;
}

.login-form input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
}

.login-hint {
  margin-top: 14px;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.form-error {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--danger);
}

/* ------------------- APP SHELL ------------------- */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  height: 56px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to right, #020617, #020617dd);
  border-bottom: 1px solid rgba(55, 65, 81, 0.9);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: radial-gradient(circle at 20% 20%, #22c55e, transparent 60%),
    radial-gradient(circle at 80% 80%, #3b82f6, transparent 60%),
    #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 0.96rem;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-soft);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
}

.topbar-item {
  color: var(--text-soft);
}

.user-email {
  color: var(--text-main);
}

/* ------------------- LAYOUT ------------------- */

.main-layout {
  display: flex;
  height: calc(100vh - 56px);
}

.sidebar {
  width: 220px;
  padding: 14px 10px;
  border-right: 1px solid rgba(31, 41, 55, 0.9);
  background: linear-gradient(
    to bottom,
    rgba(15, 23, 42, 0.98),
    rgba(15, 23, 42, 0.95)
  );
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-soft);
  margin: 0 8px 2px;
}

.nav-item {
  width: 100%;
  border: none;
  padding: 6px 10px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
}

.nav-item:hover {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
}

.nav-item.active {
  background: radial-gradient(circle at 0 0, rgba(59, 130, 246, 0.9), transparent 60%),
    linear-gradient(to right, #1e293b, #020617);
  color: #eff6ff;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.7);
}

.nav-item.active .nav-dot {
  background: #60a5fa;
}

.sidebar-footer {
  margin-top: auto;
}

.sidebar-mini {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(55, 65, 81, 0.7);
}

.mini-label {
  font-size: 0.72rem;
  color: var(--text-soft);
}

.mini-value {
  font-size: 0.8rem;
  margin-top: 4px;
}

/* MAIN VIEW */

.main-view {
  flex: 1;
  padding: 14px 18px 18px;
  overflow-y: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.view-header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.view-subtitle {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.view-actions {
  display: flex;
  gap: 8px;
}

/* CARDS / GRID */

.card {
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid rgba(31, 41, 55, 0.95);
  padding: 14px 14px 10px;
}

.glass {
  background: var(--bg-elevated-soft);
  backdrop-filter: blur(18px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 500;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.card-actions {
  display: flex;
  gap: 8px;
}

.card-subsection-header {
  margin-top: 10px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.grid {
  display: grid;
  gap: 12px;
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.mt-lg {
  margin-top: 18px;
}

/* STATS */

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at 10% 0%, rgba(59, 130, 246, 0.3), transparent 60%),
    radial-gradient(circle at 90% 100%, rgba(34, 197, 94, 0.3), transparent 60%);
  opacity: 0.4;
  pointer-events: none;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-soft);
  position: relative;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 4px;
  position: relative;
}

.stat-suffix {
  font-size: 0.9rem;
  margin-left: 6px;
}

.stat-footer {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  position: relative;
}

/* SPLIT LAYOUT */

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.5fr);
  gap: 12px;
}

.split-left,
.split-right {
  min-height: 340px;
}

/* TABLES */

.table-wrapper {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: rgba(15, 23, 42, 0.9);
}

.table-wrapper.small {
  max-height: 260px;
  overflow-y: auto;
}

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

.data-table th,
.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(31, 41, 55, 0.8);
}

.data-table th {
  background: rgba(15, 23, 42, 0.95);
  text-align: left;
  color: var(--text-soft);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.85);
}

.data-table tr:hover td {
  background: rgba(30, 64, 175, 0.45);
}

.data-table.compact th,
.data-table.compact td {
  padding: 5px 7px;
}

/* BUTTONS */

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  background: #1d4ed8;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn.primary {
  background: linear-gradient(to right, #2563eb, #4f46e5);
  border-color: rgba(129, 140, 248, 0.6);
}

.btn.ghost {
  background: transparent;
  color: var(--text-main);
  border-color: rgba(148, 163, 184, 0.4);
}

.btn.small {
  padding: 4px 9px;
  font-size: 0.78rem;
}

.btn.full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* DEVICE DETAIL */

.device-detail {
  font-size: 0.8rem;
  margin-top: 6px;
}

.device-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
}

.device-meta-item {
  padding: 6px 7px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(31, 41, 55, 0.9);
}

.device-meta-label {
  font-size: 0.72rem;
  color: var(--text-soft);
}

.device-meta-value {
  margin-top: 2px;
}

/* SETTINGS */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.settings-label {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.settings-value {
  font-size: 0.86rem;
}

/* TOOLBAR */

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.toolbar input[type="text"] {
  flex: 1;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
  font-size: 0.8rem;
}

/* MODAL */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-root.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
}

.modal {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 90vw);
  background: rgba(15, 23, 42, 0.98);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow-soft);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 0.96rem;
  font-weight: 500;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-body {
  margin-top: 10px;
  font-size: 0.8rem;
}

.modal-footer {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.modal-body input[type="text"],
.modal-body textarea {
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
  font-size: 0.8rem;
}

.modal-body textarea {
  resize: vertical;
  min-height: 70px;
}

.modal-body .checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

/* TOASTS */

.toast-container {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 60;
}

.toast {
  min-width: 220px;
  max-width: 320px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.98);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  animation: toast-in 0.2s ease-out;
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.7);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.7);
}

.toast-message {
  flex: 1;
}

.toast-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* API DOCS */

.api-docs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.api-group {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: rgba(15, 23, 42, 0.9);
  padding: 10px 12px;
}

.api-group-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.api-endpoint {
  border-radius: 12px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  padding: 8px 9px;
  margin-top: 6px;
}

.api-line {
  font-size: 0.78rem;
  margin-bottom: 2px;
}

.api-method {
  display: inline-block;
  min-width: 50px;
  text-align: center;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 6px;
}

.api-method.POST {
  background: rgba(22, 163, 74, 0.15);
  color: #4ade80;
}

.api-method.GET {
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
}

.api-method.PATCH {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}

.api-method.DELETE {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
}

.api-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 0.68rem;
  background: rgba(31, 41, 55, 0.95);
  color: var(--text-soft);
  margin-left: 4px;
}

/* UTILITIES */

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .main-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    height: auto;
  }

  .sidebar-section {
    flex: 1;
  }

  .sidebar-footer {
    display: none;
  }

  .split-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* -------- DEVICE CHART -------- */

.device-chart-card {
  margin-top: 6px;
  border-radius: 14px;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: rgba(15, 23, 42, 0.9);
  padding: 10px 10px 8px;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.chart-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chart-toolbar-label {
  font-size: 0.75rem;
  color: var(--text-soft);
}

.chart-wrapper {
  position: relative;
  width: 100%;
  min-height: 140px;
}

.chart-stats {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.chart-stat-item {
  padding: 4px 6px;
  border-radius: 999px;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: rgba(15, 23, 42, 0.95);
}

/* -------- CHIPS (filtry) -------- */

.chip {
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  padding: 4px 9px;
  font-size: 0.75rem;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-muted);
  cursor: pointer;
}

.chip:hover {
  border-color: rgba(96, 165, 250, 0.8);
  color: var(--text-main);
}

.chip-active {
  background: radial-gradient(circle at 0 0, rgba(59, 130, 246, 0.9), transparent 60%),
    linear-gradient(to right, #1d4ed8, #4f46e5);
  border-color: rgba(129, 140, 248, 0.9);
  color: #eff6ff;
}

/* -------- ENVIRONMENT EVAL -------- */

.env-eval {
  border-radius: 14px;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: rgba(15, 23, 42, 0.9);
  padding: 8px 10px;
  font-size: 0.8rem;
}

.env-eval-main {
  margin-bottom: 6px;
}

.env-eval-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.env-tag {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.7rem;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.95);
}

.env-tag.good {
  border-color: rgba(34, 197, 94, 0.8);
}

.env-tag.warn {
  border-color: rgba(234, 179, 8, 0.9);
}

.env-tag.bad {
  border-color: rgba(248, 113, 113, 0.9);
}

/* ===== DASHBOARD – POSLEDNÍ HODNOTY ===== */

.latest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.latest-tile {
  position: relative;
  border-radius: 16px;
  padding: 10px 12px;
  background: radial-gradient(circle at 0 0, rgba(59,130,246,0.35), transparent 55%),
              linear-gradient(135deg, rgba(15,23,42,0.95), rgba(15,23,42,0.85));
  border: 1px solid rgba(37,99,235,0.55);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.latest-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(15,23,42,0.9);
  border-color: rgba(129,140,248,0.9);
}

.latest-header {
  font-size: 0.8rem;
  font-weight: 500;
  color: #e5e7eb;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.latest-values {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.latest-value {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.latest-icon {
  font-size: 1rem;
  opacity: 0.85;
  margin-bottom: 2px;
}

.latest-number {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.1;
}

.latest-label {
  font-size: 0.7rem;
  color: #9ca3af;
}

.latest-footer {
  margin-top: 6px;
  font-size: 0.7rem;
  color: #9ca3af;
}

.latest-empty {
  font-size: 0.8rem;
  color: #9ca3af;
  padding: 4px 2px 8px;
}

/* Stav zařízení – tečka online/deepsleep/offline */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot.online {
  background: #22c55e; /* zelená */
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.status-dot.deepsleep {
  background: #eab308; /* žlutá */
  box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.25);
}

.status-dot.offline {
  background: #ef4444; /* červená */
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.30);
}

