/* =========================================
   INVAR CONTROL
   Black + Electric Blue Theme
   ========================================= */

:root {
  --invar-bg: #02050a;
  --invar-panel: #07101a;
  --invar-panel-2: #0a1522;
  --invar-blue: #0a84ff;
  --invar-blue-bright: #22a2ff;
  --invar-blue-soft: rgba(10, 132, 255, 0.18);
  --invar-border: rgba(34, 162, 255, 0.28);
  --invar-text: #f5f9ff;
  --invar-muted: #9aa9bb;
}

/* Page background */
body,
#__next,
main {
  background:
    radial-gradient(
      circle at top center,
      rgba(10, 132, 255, 0.08),
      transparent 30%
    ),
    var(--invar-bg) !important;

  color: var(--invar-text) !important;
}

/* Main page width */
#page_wrapper {
  max-width: 1800px !important;
  margin: 0 auto !important;
}

/* Header / top widgets */
#information-widgets {
  border-bottom: 1px solid var(--invar-border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

/* Search bar */
input {
  background: rgba(2, 7, 13, 0.92) !important;
  border: 1px solid var(--invar-border) !important;
  color: var(--invar-text) !important;
}

input:focus {
  border-color: var(--invar-blue) !important;
  box-shadow:
    0 0 0 1px var(--invar-blue),
    0 0 18px var(--invar-blue-soft) !important;
}

/* Section/group headings */
h1,
h2,
h3 {
  color: var(--invar-text) !important;
}

.services-group h2,
.bookmarks-group h2 {
  color: var(--invar-blue-bright) !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em;
}

/* Electric blue marker beside group headings */
.services-group h2::before,
.bookmarks-group h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 1.1em;
  margin-right: 10px;
  vertical-align: -0.1em;

  background: var(--invar-blue);
  border-radius: 999px;

  box-shadow:
    0 0 8px rgba(10, 132, 255, 0.8),
    0 0 18px rgba(10, 132, 255, 0.35);
}

/* Service cards */
.service-card,
.bookmark-card {
  background:
    linear-gradient(
      145deg,
      rgba(10, 21, 34, 0.96),
      rgba(4, 10, 17, 0.96)
    ) !important;

  border: 1px solid rgba(120, 170, 220, 0.16) !important;
  border-radius: 14px !important;

  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.02);

  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease !important;
}

/* Card hover */
.service-card:hover,
.bookmark-card:hover {
  transform: translateY(-2px);

  border-color: var(--invar-blue) !important;

  box-shadow:
    0 0 0 1px rgba(10, 132, 255, 0.20),
    0 0 22px rgba(10, 132, 255, 0.20),
    0 12px 30px rgba(0, 0, 0, 0.42) !important;
}

/* Service names */
.service-name,
.bookmark-name {
  color: var(--invar-text) !important;
  font-weight: 600 !important;
}

/* Descriptions */
.service-description,
.bookmark-description {
  color: var(--invar-muted) !important;
}

/* Icons */
.service-icon,
.bookmark-icon {
  filter: drop-shadow(0 0 7px rgba(10, 132, 255, 0.16));
}

/* Status dots / indicators */
.status,
[class*="status"] {
  accent-color: var(--invar-blue) !important;
}

/* Resource widget progress bars */
[class*="progress"] > div,
[class*="bar"] > div {
  background: linear-gradient(
    90deg,
    var(--invar-blue),
    var(--invar-blue-bright)
  ) !important;

  box-shadow: 0 0 8px rgba(10, 132, 255, 0.35);
}

/* Links */
a {
  transition:
    color 0.18s ease,
    opacity 0.18s ease;
}

a:hover {
  color: var(--invar-blue-bright) !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #02050a;
}

::-webkit-scrollbar-thumb {
  background: #12345a;
  border-radius: 999px;
  border: 2px solid #02050a;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--invar-blue);
}

/* Mobile */
@media (max-width: 768px) {
  .service-card,
  .bookmark-card {
    border-radius: 12px !important;
  }
}

/* =========================================
   Put top resource widgets inline with H1
   ========================================= */

@media (min-width: 900px) {

  /* Give the H1 section room for the widgets */
  .services-group:first-of-type {
    position: relative;
  }

  /* Move resource widgets down beside H1 heading */
  #information-widgets {
    position: absolute !important;
    top: 135px !important;
    right: 7% !important;
    width: auto !important;
    z-index: 20;

    border-bottom: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #information-widgets > div {
    gap: 24px !important;
  }

  /* Keep H1 heading on same visual row */
  .services-group:first-of-type h2 {
    min-height: 54px;
    display: flex;
    align-items: center;
  }

  /* Remove the empty header space left behind */
  #page_wrapper {
    padding-top: 20px !important;
  }
}


/* =========================================
   FIX: Resource widgets inline with H1 title
   ========================================= */

@media (min-width: 900px) {

  /* Reset the previous absolute placement */
  #information-widgets {
    position: absolute !important;
    top: 38px !important;
    right: 70px !important;

    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;

    border: 0 !important;
    z-index: 50;
  }

  /* Keep widgets compact */
  #information-widgets > div {
    gap: 20px !important;
    align-items: center !important;
  }

  /* Give the first section/header enough room */
  .services-group:first-of-type {
    position: relative !important;
    padding-top: 0 !important;
  }

  .services-group:first-of-type h2 {
    min-height: 46px !important;
    display: flex !important;
    align-items: center !important;
    margin-bottom: 16px !important;
  }

  /* Search bar is not part of the H1 stats row */
  #information-widgets form,
  #information-widgets [class*="search"] {
    display: none !important;
  }
}


/* =========================================
   FIX: Resource widgets inline with H1 title
   ========================================= */

@media (min-width: 900px) {

  /* Reset the previous absolute placement */
  #information-widgets {
    position: absolute !important;
    top: 38px !important;
    right: 70px !important;

    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;

    border: 0 !important;
    z-index: 50;
  }

  /* Keep widgets compact */
  #information-widgets > div {
    gap: 20px !important;
    align-items: center !important;
  }

  /* Give the first section/header enough room */
  .services-group:first-of-type {
    position: relative !important;
    padding-top: 0 !important;
  }

  .services-group:first-of-type h2 {
    min-height: 46px !important;
    display: flex !important;
    align-items: center !important;
    margin-bottom: 16px !important;
  }

  /* Search bar is not part of the H1 stats row */
  #information-widgets form,
  #information-widgets [class*="search"] {
    display: none !important;
  }
}


/* =========================================
   INVAR collapsible app groups
   ========================================= */

.invar-group-header {
  cursor: pointer !important;
  user-select: none !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
}

.invar-group-header:hover {
  color: var(--invar-blue-bright) !important;
}

.invar-group-arrow {
  font-size: 0.65em;
  color: var(--invar-blue-bright);
  opacity: 0.85;
  transition: transform 0.2s ease;
}

.invar-group-content {
  overflow: hidden;
  max-height: 5000px;
  opacity: 1;
  transition:
    max-height 0.28s ease,
    opacity 0.2s ease;
}

.invar-group-content.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* =========================================================
   INVAR CPU GRAPH
   ========================================================= */

#invar-cpu-graph {
  margin: 10px 0 30px;
  padding: 18px 22px;

  background:
    linear-gradient(
      145deg,
      rgba(6, 15, 25, 0.98),
      rgba(1, 5, 10, 0.98)
    );

  border:
    1px solid rgba(0, 140, 255, 0.30);

  border-radius: 16px;

  box-shadow:
    0 12px 30px rgba(0,0,0,0.40),
    0 0 25px rgba(0,140,255,0.07);
}


.invar-graph-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;

  margin-bottom: 12px;
}


.invar-graph-title h2 {
  margin: 0;

  color: #f4f9ff !important;

  font-size: 1.2rem;
  font-weight: 700;
}


.invar-graph-title span {
  display: block;

  margin-top: 3px;

  color: #7890a8;

  font-size: 0.78rem;
}


.invar-live-values {
  display: flex;
  align-items: center;
  gap: 28px;
}


.invar-live-host {
  display: flex;
  align-items: center;
  gap: 8px;

  font-size: 0.9rem;
}


.invar-live-host strong {
  color: #f5faff;
}


.invar-live-host .invar-value {
  min-width: 58px;

  color: var(--host-color);

  font-weight: 600;

  text-align: right;
}


.invar-dot {
  width: 9px;
  height: 9px;

  border-radius: 50%;

  background:
    var(--host-color);

  box-shadow:
    0 0 7px var(--host-color),
    0 0 15px var(--host-color);
}


.invar-live-host.offline
.invar-dot {
  background: #555;
  box-shadow: none;
}


.invar-live-host.offline
.invar-value {
  color: #777;
}


.invar-canvas-wrap {
  width: 100%;
  height: 260px;
}


#invar-cpu-canvas {
  display: block;

  width: 100%;
  height: 100%;
}


@media (max-width: 700px) {

  .invar-graph-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .invar-live-values {
    width: 100%;
    justify-content: space-between;
  }

  .invar-canvas-wrap {
    height: 220px;
  }
}

/* ===== INVAR CPU GRAPH ===== */

#invar-cpu-graph {
  margin: 20px auto 30px !important;
  padding: 20px !important;
  width: calc(100% - 64px) !important;

  background: linear-gradient(
    145deg,
    #07111c,
    #02070c
  ) !important;

  border: 1px solid rgba(0,140,255,.35) !important;
  border-radius: 16px !important;

  box-shadow:
    0 0 25px rgba(0,140,255,.08),
    0 12px 30px rgba(0,0,0,.4) !important;
}

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

.invar-graph-header h2 {
  margin: 0 !important;
  color: white !important;
  font-size: 20px !important;
}

.invar-graph-header > div:first-child > span {
  color: #7890a8;
  font-size: 13px;
}

.invar-live-values {
  display: flex;
  gap: 28px;
}

.invar-live-host {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invar-live-host .invar-value {
  min-width: 58px;
}

.invar-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.invar-dot.h1 {
  background: #008cff;
  box-shadow: 0 0 10px #008cff;
}

.invar-dot.h2 {
  background: #00e5ff;
  box-shadow: 0 0 10px #00e5ff;
}

.invar-canvas-wrap {
  height: 260px;
}

#invar-cpu-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* =========================================================
   COMPACT CPU GRAPH
   ========================================================= */

#invar-cpu-graph {
  width: calc(100% - 64px) !important;

  margin:
    8px auto
    20px !important;

  padding:
    12px 16px
    10px !important;

  border-radius: 12px !important;
}


/* Header */

.invar-graph-header {
  margin-bottom: 4px !important;
}

.invar-graph-header h2 {
  font-size: 16px !important;
  line-height: 20px !important;
}

.invar-graph-header > div:first-child > span {
  font-size: 11px !important;
}


/* H1 / H2 current values */

.invar-live-values {
  gap: 20px !important;
}

.invar-live-host {
  gap: 6px !important;
  font-size: 13px !important;
}

.invar-live-host .invar-value {
  min-width: 45px !important;
}


/* THE IMPORTANT PART */

.invar-canvas-wrap {
  height: 125px !important;
}


/* Slightly smaller indicators */

.invar-dot {
  width: 7px !important;
  height: 7px !important;
}


/* =========================================================
   INVAR - UNRAID STYLE MONITORING GRID
   ========================================================= */

#invar-monitor-grid {
  width: calc(100% - 64px);
  margin: 10px auto 24px;

  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr);
  gap: 14px;
}


.invar-monitor-card {
  min-width: 0;

  background:
    linear-gradient(
      145deg,
      rgba(8, 17, 27, .98),
      rgba(3, 8, 14, .98)
    );

  border: 1px solid rgba(100, 160, 210, .18);

  border-radius: 8px;

  box-shadow:
    0 8px 20px rgba(0,0,0,.25);

  padding: 12px 14px;
}


/* Header */

.invar-monitor-title {
  min-height: 28px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  border-bottom: 1px solid rgba(120,170,210,.10);

  margin-bottom: 8px;
  padding-bottom: 7px;

  font-size: 13px;
}


.invar-monitor-title > div {
  display: flex;
  align-items: center;
  gap: 7px;
}


.invar-monitor-title strong {
  color: #eef7ff;
  font-size: 13px;
  letter-spacing: .03em;
}


.invar-title-icon {
  color: #31a9ff;
  font-size: 16px;
}


.invar-history-label,
.invar-system-label {
  color: #8195a8;
  font-size: 11px;
}


/* =========================================================
   PROCESSOR
   ========================================================= */

.invar-cpu-current {
  display: flex;
  gap: 24px;

  margin: 4px 0 5px;
}


.invar-host-current {
  display: flex;
  align-items: center;
  gap: 6px;

  font-size: 12px;
}


.invar-host-current strong {
  color: #e9f5ff;
}


.invar-host-cpu {
  color: var(--host-color);

  min-width: 43px;

  font-weight: 600;
}


.invar-host-dot,
.invar-memory-host .invar-host-dot {
  display: inline-block;

  width: 7px;
  height: 7px;

  border-radius: 50%;

  background: var(--host-color);

  box-shadow:
    0 0 6px var(--host-color);
}


.invar-cpu-chart-wrap {
  height: 120px;
  width: 100%;
}


#invar-cpu-chart {
  width: 100%;
  height: 100%;

  display: block;
}


/* =========================================================
   SYSTEM / RAM
   ========================================================= */

.invar-memory-grid {
  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  gap: 10px;
}


.invar-memory-host {
  display: flex;
  flex-direction: column;
  align-items: center;

  min-width: 0;
}


.invar-memory-name {
  width: 100%;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 6px;

  color: #e7f2fc;
  font-size: 12px;

  margin-bottom: 5px;
}


/* RAM circle */

.invar-memory-gauge {
  --ram-percent: 0;

  width: 82px;
  height: 82px;

  border-radius: 50%;

  display: grid;
  place-items: center;

  background:
    conic-gradient(
      var(--host-color)
        calc(var(--ram-percent) * 1%),

      rgba(100,120,140,.22)
        0
    );

  position: relative;
}


.invar-memory-gauge::after {
  content: "";

  position: absolute;

  inset: 9px;

  border-radius: 50%;

  background: #07101a;
}


.invar-memory-inner {
  position: relative;
  z-index: 2;

  display: grid;
  place-items: center;
}


.invar-memory-percent {
  color: #f4faff;

  font-size: 17px;
  font-weight: 700;
}


.invar-memory-detail {
  display: flex;
  justify-content: center;
  gap: 4px;

  margin-top: 6px;

  color: #8499ad;

  font-size: 10px;
}


.invar-memory-used {
  color: #cdeaff;
}


.invar-memory-total {
  color: #a9bbcb;
}


/* Offline */

.invar-host-current.offline,
.invar-memory-host.offline {
  opacity: .45;
}


/* Responsive */

@media (max-width: 950px) {

  #invar-monitor-grid {
    grid-template-columns: 1fr;
  }

}


@media (max-width: 600px) {

  #invar-monitor-grid {
    width: calc(100% - 24px);
  }

  .invar-memory-gauge {
    width: 72px;
    height: 72px;
  }

}

/* =========================================================
   INVAR LAYOUT FIX
   Remove giant empty gap
   ========================================================= */

/* Monitoring should flow normally into app groups */
#invar-monitor-grid {
  margin-bottom: 18px !important;
}

/* Undo any old full-height/flex positioning */
#page_wrapper,
main {
  min-height: 0 !important;
  height: auto !important;
}

/* Homepage services area */
.services-list,
#services,
.services {
  min-height: 0 !important;
  height: auto !important;
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* Groups should stay in normal document flow */
.services-group {
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin-top: 8px !important;
  margin-bottom: 8px !important;
}

/* Collapsed groups take up header height only */
.invar-group-content.collapsed {
  display: none !important;
}

/* Expanded content */
.invar-group-content:not(.collapsed) {
  display: block !important;
}

/* Keep headers compact */
.invar-group-header {
  margin: 0 !important;
  padding: 7px 0 !important;
  min-height: 0 !important;
}



/* =========================================================
   INVAR HOST OVERVIEW / DETAIL PAGES
   ========================================================= */


/* Disable old custom monitoring blocks */

#invar-monitor-grid,
#invar-cpu-graph {
  display: none !important;
}


/* Main shell */

#invar-host-shell {
  width: calc(100% - 80px);
  max-width: 1700px;

  margin:
    18px auto
    24px;
}


/* =========================================================
   HOME
   ========================================================= */

.invar-home-title {
  margin-bottom: 16px;
}


.invar-home-title h1 {
  margin: 0 !important;

  color: #f4f9ff !important;

  font-size: 21px !important;
  font-weight: 700;

  letter-spacing: .06em;
}


.invar-home-title span {
  color: #7890a8;

  font-size: 12px;
}


.invar-host-grid {
  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  gap: 14px;
}


.invar-host-card {
  position: relative;

  display: block;

  min-height: 170px;

  padding: 14px;

  background:
    linear-gradient(
      145deg,
      rgba(7,17,28,.98),
      rgba(2,8,14,.98)
    ) !important;

  border:
    1px solid rgba(100,160,210,.20) !important;

  border-radius: 10px;

  color: inherit !important;

  text-decoration: none !important;

  overflow: hidden;

  transition:
    border-color .18s ease,
    transform .18s ease,
    box-shadow .18s ease;
}


.invar-host-card:hover {
  transform: translateY(-2px);

  border-color:
    var(--host-color) !important;

  box-shadow:
    0 0 22px
    color-mix(
      in srgb,
      var(--host-color) 20%,
      transparent
    );
}


.invar-host-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding-bottom: 10px;

  border-bottom:
    1px solid rgba(120,170,210,.10);
}


.invar-host-card-header > div {
  display: flex;
  align-items: center;

  gap: 8px;
}


.invar-host-card-header strong {
  color: #eef8ff;

  font-size: 15px;
}


.invar-open-host {
  color: var(--host-color);

  font-size: 10px;
  font-weight: 700;

  letter-spacing: .08em;
}


.invar-status-dot {
  width: 8px;
  height: 8px;

  border-radius: 50%;

  display: inline-block;

  background: var(--host-color);

  box-shadow:
    0 0 8px var(--host-color);
}


.invar-host-stats {
  display: flex;

  gap: 42px;

  padding:
    11px 0
    4px;
}


.invar-host-stats > div {
  display: flex;
  align-items: baseline;

  gap: 8px;
}


.invar-host-stats span {
  color: #7890a8;

  font-size: 10px;

  letter-spacing: .06em;
}


.invar-host-stats strong {
  color: var(--host-color);

  font-size: 18px;
}


.invar-host-mini-chart {
  height: 75px;

  width: 100%;
}


.invar-host-mini-chart canvas {
  width: 100%;
  height: 100%;

  display: block;
}


.invar-monitor-pending {
  margin-top: 30px;

  color: #596b7b;

  font-size: 12px;
}


/* =========================================================
   HOST DETAIL
   ========================================================= */

.invar-detail-page {
  width: 100%;
}


.invar-detail-topbar {
  display: flex;
  align-items: center;

  gap: 18px;

  padding-bottom: 13px;

  border-bottom:
    1px solid rgba(120,170,210,.12);
}


.invar-back-button {
  padding:
    6px 10px;

  border:
    1px solid rgba(120,170,210,.25);

  border-radius: 6px;

  color: #8fa8bc !important;

  font-size: 11px;
  font-weight: 700;

  text-decoration: none !important;
}


.invar-back-button:hover {
  border-color:
    var(--host-color);

  color:
    var(--host-color) !important;
}


.invar-detail-name {
  display: flex;
  align-items: center;

  gap: 9px;
}


.invar-detail-name h1 {
  margin: 0 !important;

  color: #f3f9ff !important;

  font-size: 21px !important;
}


.invar-detail-monitoring {
  display: flex;

  gap: 12px;

  margin:
    14px 0;
}


.invar-detail-stat {
  min-width: 130px;

  padding:
    10px 13px;

  background:
    rgba(7,17,28,.95);

  border:
    1px solid rgba(110,160,205,.16);

  border-radius: 8px;
}


.invar-detail-stat span {
  display: block;

  color: #70869a;

  font-size: 9px;

  letter-spacing: .08em;
}


.invar-detail-stat strong {
  display: block;

  margin-top: 2px;

  color: var(--host-color);

  font-size: 19px;
}


.invar-detail-stat.ram-detail {
  min-width: 200px;
}


.invar-detail-stat.ram-detail strong {
  color: #d6e8f6;

  font-size: 14px;
}


.invar-detail-chart-card {
  padding: 12px;

  background:
    linear-gradient(
      145deg,
      rgba(7,17,28,.96),
      rgba(2,8,14,.96)
    );

  border:
    1px solid rgba(100,160,210,.18);

  border-radius: 9px;
}


.invar-detail-chart-header {
  display: flex;
  justify-content: space-between;

  padding-bottom: 6px;

  color: #d8e8f5;

  font-size: 11px;
}


.invar-detail-chart-header span {
  color: #6f8497;
}


.invar-detail-chart {
  height: 145px;

  width: 100%;
}


.invar-detail-chart canvas {
  display: block;

  width: 100%;
  height: 100%;
}


.invar-detail-offline {
  margin:
    16px 0;

  padding: 14px;

  border:
    1px solid rgba(110,150,180,.16);

  border-radius: 8px;

  color: #65798b;
}


.invar-apps-divider {
  margin:
    20px 0
    10px;

  padding-bottom: 7px;

  border-bottom:
    1px solid rgba(100,160,210,.14);
}


.invar-apps-divider span {
  color: var(--host-color);

  font-size: 11px;
  font-weight: 700;

  letter-spacing: .08em;
}


/* Homepage groups beneath host page */

.services-group {
  max-width: 1700px !important;

  margin-left: auto !important;
  margin-right: auto !important;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {

  #invar-host-shell {
    width: calc(100% - 28px);
  }

  .invar-host-grid {
    grid-template-columns: 1fr;
  }

}


@media (max-width: 600px) {

  .invar-detail-monitoring {
    display: grid;

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

  .invar-detail-stat,
  .invar-detail-stat.ram-detail {
    min-width: 0;
  }

  .invar-detail-stat.ram-detail {
    grid-column: 1 / -1;
  }

}
