:root {
  color-scheme: dark;
  --app-font-sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --app-font-mono: "IBM Plex Mono", "Consolas", monospace;
  --app-bg-1: #07111d;
  --app-bg-2: #0b1523;
  --app-bg-3: #0e1a2b;
  --app-panel: rgba(10, 18, 31, 0.94);
  --app-panel-2: rgba(12, 21, 36, 0.98);
  --app-border: rgba(86, 108, 138, 0.28);
  --app-border-strong: rgba(104, 136, 176, 0.36);
  --app-text: #dce7f5;
  --app-text-dim: #8295af;
  --app-text-soft: #9eb0c7;
  --app-accent: #3b82f6;
  --app-accent-2: #0ea5e9;
  --app-danger: #ef4444;
  --app-radius-lg: 1rem;
  --app-radius-md: 0.8rem;
  --app-radius-sm: 0.6rem;
  --app-shadow: 0 18px 42px rgba(2, 6, 23, 0.34);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--app-font-sans);
  font-size: 0.92rem;
  line-height: 1.45;
  background:
    linear-gradient(rgba(59, 130, 246, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.045) 1px, transparent 1px),
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 26%),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.1), transparent 24%),
    linear-gradient(180deg, var(--app-bg-1) 0%, var(--app-bg-2) 52%, #060b13 100%);
  background-size: 32px 32px, 32px 32px, auto, auto, auto;
  color: var(--app-text);
}

code {
  color: #9dd6ff;
  font-family: var(--app-font-mono);
}

.app-main {
  padding: 5.5rem 1rem 1.5rem;
}

.content-panel {
  min-width: 0;
}

.sidebar-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  padding: 0;
  z-index: 1030;
}

.sidebar-card,
.hero-panel,
.metric-card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  background: linear-gradient(180deg, rgba(14, 23, 38, 0.97) 0%, rgba(8, 14, 24, 0.97) 100%);
  box-shadow: var(--app-shadow);
  backdrop-filter: blur(10px);
}

.sidebar-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 1.5rem;
  border: 0;
  border-right: 1px solid rgba(96, 165, 250, 0.16);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(10, 24, 44, 0.99) 0%, rgba(8, 19, 35, 0.99) 56%, rgba(6, 15, 27, 0.99) 100%);
  box-shadow: 18px 0 40px rgba(2, 6, 23, 0.3);
}

.mobile-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1035;
  padding: 0.8rem 1rem;
  border: 0;
  border-bottom: 1px solid rgba(96, 165, 250, 0.14);
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(9, 25, 45, 0.99) 0%, rgba(8, 23, 40, 0.99) 45%, rgba(6, 18, 31, 0.99) 100%);
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.24);
  backdrop-filter: blur(14px);
}

.mobile-topbar-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
}

.mobile-topbar-brand {
  min-width: 0;
}

.mobile-topbar-brand .fw-semibold,
.mobile-topbar-brand .small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-logout-form {
  margin: 0;
}

.menu-toggle-btn,
.nav-view-link {
  border: 1px solid rgba(96, 120, 152, 0.24);
  background: rgba(10, 24, 42, 0.88);
  color: #c7d7ea;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.menu-toggle-btn:hover,
.menu-toggle-btn:focus,
.nav-view-link:hover,
.nav-view-link:focus {
  background: rgba(18, 38, 66, 0.96);
  color: #f8fbff;
}

.mobile-menu-button {
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-logout-button {
  min-width: auto;
  padding: 0.7rem 0.85rem;
  border-radius: 0.85rem;
}

.mobile-menu-button::after {
  display: none;
}

.hamburger-lines {
  display: inline-flex;
  flex-direction: column;
  gap: 0.3rem;
}

.hamburger-lines span {
  display: block;
  width: 1.15rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.nav-view-link {
  display: block;
  width: 100%;
  padding: 0.82rem 0.95rem;
  border-radius: var(--app-radius-md);
  text-align: left;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: var(--app-font-mono);
}

.dropdown-item.nav-view-link {
  border: 0;
  background: transparent;
  border-radius: var(--app-radius-sm);
}

.nav-view-link.active {
  border-color: rgba(87, 153, 255, 0.38);
  background:
    linear-gradient(90deg, rgba(59, 130, 246, 0.16) 0 4px, transparent 4px),
    linear-gradient(135deg, rgba(20, 42, 72, 0.98), rgba(10, 28, 53, 0.98));
  color: #f8fbff;
}

.nav-danger-link {
  border-color: rgba(248, 113, 113, 0.18);
  background: rgba(69, 12, 20, 0.72);
  color: #fecaca;
}

.nav-danger-link:hover,
.nav-danger-link:focus {
  background: rgba(127, 29, 29, 0.88);
  color: #fff1f2;
}

.content-view {
  display: none;
}

.content-view.active {
  display: block;
}

.text-secondary,
.metric-help,
.chart-legend,
.torrent-table th,
.small.text-secondary {
  color: var(--app-text-dim) !important;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 10rem;
  padding: 0.72rem 0.95rem;
  border-radius: var(--app-radius-sm);
  font-weight: 600;
  font-size: 0.79rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--app-font-mono);
  background: rgba(8, 18, 33, 0.9);
  color: #cbd5e1;
  border: 1px solid rgba(96, 120, 152, 0.22);
}

.status-chip.connected {
  background: rgba(20, 83, 45, 0.45);
  color: #86efac;
}

.status-chip.reconnecting {
  background: rgba(133, 77, 14, 0.42);
  color: #fcd34d;
}

.status-chip.disconnected {
  background: rgba(127, 29, 29, 0.42);
  color: #fca5a5;
}

.app-modal {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: var(--app-radius-lg);
  background: rgba(9, 16, 29, 0.98);
  box-shadow: 0 24px 55px rgba(2, 6, 23, 0.55);
}

.app-modal-header,
.app-modal-footer {
  border-color: rgba(148, 163, 184, 0.12);
}

.restart-overlay {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(10px);
}

.restart-overlay-card {
  width: min(520px, 100%);
  padding: 2rem;
  border: 1px solid rgba(96, 165, 250, 0.16);
  border-radius: var(--app-radius-lg);
  background: linear-gradient(180deg, rgba(9, 16, 29, 0.98) 0%, rgba(6, 13, 24, 0.98) 100%);
  box-shadow: 0 30px 60px rgba(2, 6, 23, 0.48);
  text-align: center;
}

.restart-overlay-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #7dd3fc;
  font-family: var(--app-font-mono);
}

.metric-value {
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  font-weight: 700;
  line-height: 0.95;
  color: #f8fbff;
  letter-spacing: -0.04em;
}

.metric-value.metric-speed {
  font-size: clamp(1.7rem, 6vw, 2.45rem);
}

.metric-unit {
  font-size: 0.88rem;
  color: #94a3b8;
  font-family: var(--app-font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-progress {
  height: 0.7rem;
  border-radius: 999px;
  background-color: rgba(20, 31, 49, 0.9);
  overflow: hidden;
}

.chart-shell {
  position: relative;
  min-height: 280px;
  border: 1px solid rgba(90, 108, 132, 0.16);
  border-radius: var(--app-radius-md);
  background:
    linear-gradient(rgba(59, 130, 246, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.028) 1px, transparent 1px),
    linear-gradient(180deg, rgba(9, 17, 30, 0.92), rgba(8, 14, 24, 0.94));
  background-size: 20px 20px, 20px 20px, auto;
  padding: 0.35rem;
}

.chart-shell canvas {
  display: block;
  width: 100%;
  height: 280px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--app-font-mono);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
}

.cpu-dot {
  background: #3b82f6;
}

.memory-dot {
  background: #22c55e;
}

.qbittorrent-dot {
  background: #f59e0b;
}

.plex-dot {
  background: #a855f7;
}

.gpu-bar {
  background-color: #a855f7;
}

.download-dot {
  background: #22d3ee;
}

.upload-dot {
  background: #fb923c;
}

.network-upload-bar {
  background-color: #fb923c;
}

#networkChart {
  display: block;
}

.torrent-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--app-text);
}

.torrent-table th {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--app-font-mono);
  border-bottom-color: rgba(148, 163, 184, 0.18);
}

.torrent-table td {
  font-size: 0.84rem;
  padding-top: 0.78rem;
  padding-bottom: 0.78rem;
  border-bottom-color: rgba(148, 163, 184, 0.1);
}

.torrent-group:last-child {
  margin-bottom: 0 !important;
}

.torrent-name {
  min-width: 18rem;
  font-weight: 600;
  font-size: 0.86rem;
  color: #f8fbff;
}

.torrent-state {
  text-transform: capitalize;
  font-family: var(--app-font-mono);
  font-size: 0.78rem;
}

.torrent-row-error {
  background: rgba(127, 29, 29, 0.28);
}

.torrent-row-error td {
  border-bottom-color: rgba(248, 113, 113, 0.3);
}

.torrent-error-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 0.55rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.22);
  color: #fca5a5;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.plex-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--app-font-mono);
}

.plex-mode-directplay {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.plex-mode-directstream {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

.plex-mode-transcoding {
  background: rgba(251, 146, 60, 0.18);
  color: #fdba74;
}

.plex-mode-unknown {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

.progress.torrent-progress {
  min-width: 9rem;
  height: 0.55rem;
  background-color: rgba(20, 31, 49, 0.9);
}

.disk-card {
  height: 100%;
  padding: 1rem;
  border-radius: var(--app-radius-md);
  background: linear-gradient(180deg, rgba(13, 23, 39, 0.92), rgba(8, 15, 26, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.05);
}

.disk-letter {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fbff;
  font-family: var(--app-font-mono);
}

.disk-name {
  color: var(--app-text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

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

.disk-smart-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--app-font-mono);
}

.disk-smart-good {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.disk-smart-bad {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
}

.disk-smart-unknown {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

.disk-temperature {
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--app-font-mono);
}

.disk-meta {
  color: #cbd5e1;
  font-size: 0.78rem;
  font-family: var(--app-font-mono);
}

.alert.alert-warning {
  background: rgba(120, 53, 15, 0.45);
  border-color: rgba(251, 191, 36, 0.28);
  color: #fde68a;
}

.fw-semibold.text-dark {
  color: #f8fbff !important;
}

.login-shell {
  min-height: 100vh;
}

.login-card {
  width: min(440px, 100%);
}

.login-title,
.login-label {
  color: #f8fbff;
}

.login-title {
  letter-spacing: -0.04em;
}

.login-page .form-control,
.login-page .form-control:focus {
  border-color: rgba(148, 163, 184, 0.16);
  border-radius: var(--app-radius-md);
  background: rgba(10, 18, 32, 0.86);
  color: #f8fbff;
  box-shadow: none;
  font-size: 0.92rem;
}

.login-page .form-control::placeholder {
  color: #8ea3bf;
}

.btn-login {
  border: 0;
  border-radius: var(--app-radius-md);
  background: linear-gradient(135deg, rgba(31, 89, 207, 0.96), rgba(7, 121, 153, 0.92));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--app-font-mono);
}

.btn-login:hover,
.btn-login:focus {
  color: #fff;
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.96), rgba(14, 116, 144, 0.92));
}

.alert-login {
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: var(--app-radius-md);
  background: rgba(127, 29, 29, 0.42);
  color: #fecaca;
}

.badge,
.text-uppercase,
.small.fw-semibold,
.metric-card .text-uppercase,
.hero-panel .text-uppercase {
  font-family: var(--app-font-mono);
  letter-spacing: 0.11em;
  font-size: 0.7rem !important;
}

.hero-panel .display-6,
.hero-panel .h4,
.hero-panel .h5 {
  letter-spacing: -0.035em;
}

.metric-card,
.hero-panel,
.sidebar-card,
.app-modal,
.disk-card {
  position: relative;
}

.metric-card::before,
.sidebar-card::before,
.app-modal::before,
.disk-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.25), rgba(14, 165, 233, 0), rgba(14, 165, 233, 0));
  pointer-events: none;
}

.metric-help,
.disk-meta,
.disk-name,
.text-secondary,
.small.text-secondary {
  font-size: 0.8rem !important;
}

.metric-card .progress-bar,
.disk-card .progress-bar,
.torrent-progress .progress-bar {
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.18);
}

@media (min-width: 992px) {
  .app-main {
    padding: 1.5rem 1.5rem 1.5rem 304px;
  }

  .content-panel {
    max-width: none;
  }
}
