:root {
  --bg: #0b0d12;
  --surface: #14171f;
  --surface2: #1b1f29;
  --border: #292e3a;
  --text: #f5f7fa;
  --muted: #9299a8;
  --green: #35d07f;
  --orange: #ffb347;
  --red: #ff5e67;
  --blue: #6e9cff;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}


/* LOGIN */

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-box {
  width: min(100%, 380px);
  text-align: center;
}

.logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(145deg, #202634, #11141b);
  border: 1px solid var(--border);
  font-weight: 800;
  font-size: 25px;
}

.login-box h1 {
  margin: 0;
  font-size: 30px;
}

.login-box p {
  margin: 8px 0 28px;
  color: var(--muted);
}

.login-box input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 16px;
  border-radius: 14px;
  margin-bottom: 12px;
  outline: none;
}

.login-box input:focus {
  border-color: var(--blue);
}

.primary {
  border: 0;
  border-radius: 14px;
  padding: 15px 18px;
  background: var(--blue);
  color: white;
  font-weight: 700;
}

.wide {
  width: 100%;
}

.error {
  min-height: 24px;
  margin-top: 14px;
  color: var(--red);
}


/* APP */

.app {
  min-height: 100dvh;
  max-width: 720px;
  margin: auto;
  padding-bottom: calc(94px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  padding:
    calc(10px + env(safe-area-inset-top))
    18px
    10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(11, 13, 18, .92);
  backdrop-filter: blur(18px);
}

.brand {
  font-size: 21px;
  font-weight: 800;
}

.server-info {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.icon-button,
.small-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  font-size: 23px;
}

.small-button {
  width: 40px;
  height: 40px;
}

main {
  padding: 12px 16px 26px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}


/* HERO */

.hero {
  min-height: 155px;
  border-radius: 24px;
  padding: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  background: linear-gradient(145deg, #171b24, #11141a);
  margin-bottom: 14px;
}

.hero.status-ok {
  border-color: rgba(53, 208, 127, .35);
}

.hero.status-warning {
  border-color: rgba(255, 179, 71, .45);
}

.hero.status-critical {
  border-color: rgba(255, 94, 103, .50);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .13em;
}

.hero h1 {
  margin: 6px 0 7px;
  font-size: 27px;
}

.hero p {
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
  max-width: 270px;
}

.hero-icon {
  font-size: 40px;
  margin-left: 20px;
}


/* METRICS */

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.metric-card {
  min-height: 92px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  font-size: 24px;
}


/* SERVICES HOME */

.section-heading {
  margin: 25px 2px 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.section-heading h2 {
  margin: 0;
  font-size: 19px;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.service-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  padding: 15px;
  display: flex;
  gap: 13px;
  align-items: center;
}

.service-icon {
  font-size: 24px;
}

.service-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.service-card strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.good {
  color: var(--green) !important;
}

.bad {
  color: var(--red) !important;
}

.warn {
  color: var(--orange) !important;
}

.info-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
}

.info-card > div {
  padding: 15px 16px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.info-card > div:last-child {
  border-bottom: 0;
}

.info-card span {
  color: var(--muted);
}


/* PAGE */

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px 18px;
}

.page-title h1 {
  margin: 0;
  font-size: 28px;
}

.page-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}


/* CONTAINERS */

.container-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.container-item {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 17px;
  padding: 14px 15px;
}

.container-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.container-name-row {
  display: flex;
  gap: 9px;
  align-items: center;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.running {
  background: var(--green);
  box-shadow: 0 0 10px rgba(53,208,127,.55);
}

.dot.stopped {
  background: var(--red);
}

.container-name {
  font-weight: 700;
}

.container-image {
  color: var(--muted);
  font-size: 11px;
  margin: 5px 0 0 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.container-actions {
  display: flex;
  gap: 7px;
  margin-top: 12px;
  margin-left: 18px;
}

.container-actions button {
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
}

.container-actions .restart {
  color: var(--orange);
}


/* ACTIONS */

.action-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  margin-bottom: 10px;
}

.action-icon {
  font-size: 25px;
  width: 36px;
  text-align: center;
}

.action-content {
  flex: 1;
  min-width: 0;
}

.action-content h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.action-content p {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.action-card button {
  border: 0;
  border-radius: 11px;
  padding: 9px 11px;
  background: var(--surface2);
  color: var(--text);
}

.message {
  min-height: 28px;
  margin: 14px 3px;
  color: var(--muted);
}

.logout-button {
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,94,103,.3);
  background: transparent;
  color: var(--red);
}


/* LOGS */

.logs {
  min-height: 300px;
  max-height: calc(100dvh - 190px);
  overflow: auto;
  border: 1px solid var(--border);
  background: #07090d;
  border-radius: 15px;
  padding: 14px;
  color: #d6d9e0;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}


/* NAV */

.bottom-nav {
  position: fixed;
  z-index: 50;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 720px);
  padding:
    8px 10px
    calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  background: rgba(14, 16, 22, .96);
  backdrop-filter: blur(20px);
}

.nav-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.nav-button span {
  font-size: 23px;
  line-height: 25px;
}

.nav-button small {
  font-size: 10px;
}

.nav-button.active {
  color: var(--text);
}

@media (min-width: 600px) {
  .metrics {
    grid-template-columns: repeat(4, 1fr);
  }

  .service-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}


.service-card small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
  max-width: 145px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-card strong {
  text-align: right;
  margin-left: 16px;
  max-width: 60%;
}



/* ==========================================================
   V1.2
   ========================================================== */

.clickable,
.clickable-row {
  cursor: pointer;
  transition:
    transform .12s ease,
    background .12s ease;
}

.clickable:active,
.clickable-row:active {
  transform: scale(.985);
}

.clickable-row::after {
  content: "›";
  color: var(--muted);
  font-size: 22px;
  margin-left: 10px;
}

.activity-heading,
.actions-heading {
  margin-top: 26px;
}

.activity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

.activity-line {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
}

.activity-line:last-child {
  border-bottom: 0;
}

.activity-icon {
  width: 30px;
  text-align: center;
  font-size: 20px;
}

.activity-line div {
  min-width: 0;
}

.activity-line strong {
  display: block;
  font-size: 14px;
}

.activity-line small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.quick-action {
  width: 100%;
  min-height: 68px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface);
  color: var(--text);
}

.quick-action > span {
  width: 32px;
  font-size: 24px;
  text-align: center;
}

.quick-action div {
  flex: 1;
}

.quick-action strong {
  display: block;
  font-size: 14px;
}

.quick-action small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.quick-action::after {
  content: "↻";
  color: var(--orange);
  font-size: 20px;
}

.log-shortcuts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.log-shortcuts button {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}


/* DETAIL BOTTOM SHEET */

.modal-open {
  overflow: hidden;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .64);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.detail-sheet {
  width: min(100%, 720px);
  max-height: 80dvh;
  overflow: auto;
  padding:
    10px 18px
    calc(24px + env(safe-area-inset-bottom));
  background: #151820;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -20px 60px rgba(0,0,0,.45);
  animation: detailUp .18s ease-out;
}

@keyframes detailUp {
  from {
    transform: translateY(30px);
    opacity: .5;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.detail-handle {
  width: 42px;
  height: 4px;
  margin: 2px auto 18px;
  border-radius: 99px;
  background: #4b5261;
}

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

.detail-header h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

.detail-close {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  font-size: 25px;
  line-height: 1;
}

.detail-content {
  border: 1px solid var(--border);
  border-radius: 17px;
  overflow: hidden;
}

.detail-row {
  min-height: 57px;
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row span {
  color: var(--muted);
  font-size: 13px;
}

.detail-row strong {
  text-align: right;
  font-size: 13px;
}

.detail-block {
  padding: 15px;
}

.detail-block span {
  color: var(--muted);
  font-size: 12px;
}

.detail-block p {
  margin: 7px 0 0;
  line-height: 1.45;
}

.detail-action {
  width: calc(100% - 24px);
  margin: 12px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface2);
  color: var(--text);
  font-weight: 700;
}



/* ==========================================================
   V1.3 - MEDIA
   ========================================================== */

.media-live-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.media-live-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--surface);
}

.media-live-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.media-live-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.media-live-icon {
  width: 36px;
  text-align: center;
  font-size: 25px;
}

.media-live-title > div {
  min-width: 0;
}

.media-live-title span:not(.media-live-icon) {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.media-live-title strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.media-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 99px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.media-badge.good {
  color: var(--green);
  background: rgba(53,208,127,.10);
}

.media-badge.active {
  color: var(--blue);
  background: rgba(110,156,255,.12);
}

.media-badge.bad {
  color: var(--red);
  background: rgba(255,94,103,.12);
}

.media-live-content {
  margin-top: 14px;
}

.media-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 3px;
}

.media-empty > span {
  width: 36px;
  text-align: center;
  font-size: 22px;
}

.media-empty strong {
  display: block;
  font-size: 13px;
}

.media-empty small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.plex-session {
  padding: 11px 0;
  border-top: 1px solid var(--border);
}

.plex-session:first-child {
  padding-top: 3px;
  border-top: 0;
}

.plex-session:last-child {
  padding-bottom: 2px;
}

.plex-session-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.plex-session-top strong {
  min-width: 0;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plex-session-top span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.plex-session-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.progress-track {
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface2);
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--blue);
}

.transfer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-top: 15px;
}

.transfer-grid > div {
  padding: 11px 12px;
  border-radius: 13px;
  background: var(--surface2);
}

.transfer-grid span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.transfer-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.media-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 10px;
}

.media-stats-row strong {
  color: var(--text);
}

.detail-session {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.detail-session:last-child {
  border-bottom: 0;
}

.detail-session strong {
  display: block;
  font-size: 13px;
}

.detail-session small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

@media (min-width: 600px) {
  .media-live-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}



/* ==========================================================
   V1.3.2 - DELUGE LIVE
   ========================================================== */

.deluge-active-list {
  margin-top: 14px;
}

.deluge-idle {
  padding: 10px 0 2px;
  color: var(--muted);
  font-size: 11px;
}

.torrent-live {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.torrent-live:first-child {
  padding-top: 2px;
  border-top: 0;
}

.torrent-live:last-child {
  padding-bottom: 2px;
}

.torrent-live-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.torrent-live-top strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.torrent-live-top span {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.torrent-live-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}



/* Immich Machine Learning planifié */

.container-smart-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

