@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/InterVariable.woff2') format('woff2-variations'),
       url('/fonts/InterVariable.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('/fonts/JetBrainsMono.woff2') format('woff2-variations'),
       url('/fonts/JetBrainsMono.woff2') format('woff2');
}

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

:root {
  --bg: #09090b;
  --bg-subtle: #0f0f12;
  --card: #131316;
  --card-hover: #18181c;
  --border: #1e1e24;
  --border-hover: #2a2a33;
  --fg: #f4f4f5;
  --fg-secondary: #a1a1aa;
  --fg-dim: #6b6b75;
  --emerald: #10b981;
  --emerald-dim: rgba(16, 185, 129, 0.1);
  --cyan: #06b6d4;
  --cyan-dim: rgba(6, 182, 212, 0.1);
  --orange: #f97316;
  --orange-dim: rgba(249, 115, 22, 0.1);
  --violet: #8b5cf6;
  --violet-dim: rgba(139, 92, 246, 0.1);
  --rose: #f43f5e;
  --rose-dim: rgba(244, 63, 94, 0.1);
  --font-sans: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

body {
  font-family: var(--font-sans);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: 15px;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(16, 185, 129, 0.06), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(6, 182, 212, 0.04), transparent);
  pointer-events: none;
  z-index: 0;
}

.dashboard {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 36px 28px 56px;
}

.top-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 18px;
}
.top-left h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}
.top-left p {
  font-size: 14px;
  color: var(--fg-dim);
  margin-top: 8px;
  font-weight: 400;
}
.top-right {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.top-metric { text-align: right; }
.top-metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--fg-dim);
  font-weight: 600;
}
.top-metric-value {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--emerald);
  background: var(--emerald-dim);
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.15);
}
.status-indicator.warn {
  color: var(--orange);
  background: var(--orange-dim);
  border-color: rgba(249, 115, 22, 0.2);
}
.status-indicator.warn .pulse { background: var(--orange); }
.status-indicator .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  animation: breathe 2s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}
.cell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px 22px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s ease, background 0.25s ease;
  display: flex;
  flex-direction: column;
}
.cell:hover {
  border-color: var(--border-hover);
  background: var(--card-hover);
}

.cell-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  row-gap: 4px;
}
.cell-label-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--fg-dim);
}
.cell-label-name svg {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}
.cell-label-meta {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-secondary);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-cpu      { grid-column: span 3; }
.cell-ram      { grid-column: span 5; }
.cell-swap     { grid-column: span 4; }
.cell-disk     { grid-column: span 7; }
.cell-storage  { grid-column: span 5; }
.cell-services { grid-column: span 7; }
.cell-apps     { grid-column: span 5; }

.big-value {
  font-family: var(--font-mono);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.big-value .unit {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0;
  opacity: 0.5;
  margin-left: 3px;
}

.bar-track {
  width: 100%;
  height: 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  margin-top: auto;
  position: relative;
  overflow: hidden;
}
.cell-cpu .bar-track,
.cell-ram .bar-track,
.cell-swap .bar-track,
.cell-storage .bar-track {
  margin-top: 18px;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}
.bar-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: inherit;
  filter: blur(7px);
  opacity: 0.6;
}
.bar-emerald { background: var(--emerald); }
.bar-cyan    { background: var(--cyan); }
.bar-orange  { background: var(--orange); }
.bar-violet  { background: var(--violet); }

.ram-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.mini-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 46px;
  flex: 0 0 auto;
}
.mini-bar {
  flex: 1;
  border-radius: 2px;
  background: var(--cyan);
  opacity: 0.22;
  transition: opacity 0.3s ease, height 0.5s ease;
  min-height: 4px;
  min-width: 4px;
}
.cell:hover .mini-bar { opacity: 0.45; }

.disk-visual {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-top: 4px;
  flex: 1;
}
.disk-circle-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}
.disk-circle-wrap svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.disk-bg { fill: none; stroke: rgba(255,255,255,0.04); stroke-width: 8; }
.disk-fill {
  fill: none;
  stroke: var(--orange);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 201;
  stroke-dashoffset: 201;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.disk-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  color: var(--orange);
  font-variant-numeric: tabular-nums;
}
.disk-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.disk-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.disk-detail-row span:first-child { font-size: 14px; color: var(--fg-dim); }
.disk-detail-row span:last-child {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-secondary);
  font-variant-numeric: tabular-nums;
}

.service-table { width: 100%; border-collapse: collapse; }
.service-table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--fg-dim);
  font-weight: 600;
  text-align: left;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
}
.service-table thead th:last-child { text-align: right; }
.service-table tbody tr { transition: background 0.15s ease; }
.service-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.service-table tbody td {
  padding: 12px;
  font-size: 14.5px;
  border-bottom: 1px solid rgba(255,255,255,0.025);
}
.service-table tbody tr:last-child td { border-bottom: none; }
.service-table tbody td:last-child { text-align: right; }
.service-table .col-desc { color: var(--fg-dim); font-size: 13.5px; }
.svc-name {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.svc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}
.svc-dot.down { background: var(--rose); box-shadow: 0 0 8px rgba(244, 63, 94, 0.4); }
.svc-status {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--emerald);
}
.svc-status.down { color: var(--rose); }

.app-cards { display: flex; flex-direction: column; gap: 10px; }
.app-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}
.app-card:hover {
  border-color: var(--border-hover);
  background: var(--card-hover);
}
.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  flex-shrink: 0;
  color: #fff;
}
.icon-ai { background: linear-gradient(135deg, #0891b2, #22d3ee); box-shadow: 0 4px 18px rgba(6, 182, 212, 0.22); }
.icon-nc { background: linear-gradient(135deg, #0369a1, #38bdf8); box-shadow: 0 4px 18px rgba(3, 105, 161, 0.22); }
.icon-bk { background: linear-gradient(135deg, #7c3aed, #a78bfa); box-shadow: 0 4px 18px rgba(124, 58, 237, 0.22); }
.app-info { flex: 1; min-width: 0; }
.app-info-name { font-size: 15px; font-weight: 600; }
.app-info-sub { font-size: 12.5px; color: var(--fg-dim); margin-top: 3px; font-family: var(--font-mono); }
.app-tag {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 6px 11px;
  border-radius: 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.tag-live {
  background: var(--cyan-dim);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, 0.2);
  animation: tagPulse 2s ease-in-out infinite;
}
.tag-ok {
  background: var(--emerald-dim);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.tag-warn {
  background: var(--orange-dim);
  color: var(--orange);
  border: 1px solid rgba(249, 115, 22, 0.25);
}
.tag-down {
  background: var(--rose-dim);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.25);
}
@keyframes tagPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(6, 182, 212, 0.15); }
}

.last-backup {
  margin-top: 14px;
  padding: 13px 14px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.last-backup-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--fg-dim);
  font-weight: 600;
  margin-bottom: 9px;
}
.last-backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.last-backup-text { font-size: 14px; color: var(--fg-secondary); }
.last-backup-icon { font-size: 16px; font-weight: 700; }
.last-backup-icon.ok { color: var(--emerald); }
.last-backup-icon.fail { color: var(--rose); }
.last-backup-icon.unknown { color: var(--fg-dim); }

.cell {
  opacity: 0;
  transform: translateY(10px);
  animation: cellIn 0.45s ease forwards;
}
@keyframes cellIn {
  to { opacity: 1; transform: translateY(0); }
}
.cell:nth-child(1) { animation-delay: 0.03s; }
.cell:nth-child(2) { animation-delay: 0.07s; }
.cell:nth-child(3) { animation-delay: 0.11s; }
.cell:nth-child(4) { animation-delay: 0.15s; }
.cell:nth-child(5) { animation-delay: 0.19s; }
.cell:nth-child(6) { animation-delay: 0.23s; }
.cell:nth-child(7) { animation-delay: 0.27s; }

.footer-bar {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  flex-wrap: wrap;
  gap: 8px;
}
.footer-bar a { color: var(--fg-dim); text-decoration: none; transition: color 0.2s; }
.footer-bar a:hover { color: var(--cyan); }

@media (max-width: 1100px) {
  .cell-cpu      { grid-column: span 4; }
  .cell-ram      { grid-column: span 8; }
  .cell-swap     { grid-column: span 5; }
  .cell-disk     { grid-column: span 7; }
  .cell-storage  { grid-column: span 12; }
  .cell-services { grid-column: span 7; }
  .cell-apps     { grid-column: span 5; }
}

@media (max-width: 900px) {
  .dashboard { padding: 30px 22px 48px; }
  .cell-cpu      { grid-column: span 6; }
  .cell-ram      { grid-column: span 12; }
  .cell-swap     { grid-column: span 6; }
  .cell-disk     { grid-column: span 12; }
  .cell-storage  { grid-column: span 12; }
  .cell-services { grid-column: span 12; }
  .cell-apps     { grid-column: span 12; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .dashboard { padding: 22px 14px 40px; }

  .top-bar { gap: 14px; margin-bottom: 22px; }
  .top-left h1 { font-size: 26px; }
  .top-left p { font-size: 12.5px; }
  .top-right { gap: 16px; }
  .top-metric-value { font-size: 15px; }

  .cell { padding: 18px; border-radius: 14px; }
  .cell-cpu, .cell-swap { grid-column: span 6; }
  .cell-ram, .cell-disk, .cell-storage,
  .cell-services, .cell-apps { grid-column: span 12; }

  .cell-label { margin-bottom: 14px; }
  .cell-label-name { font-size: 11.5px; }
  .cell-label-meta { font-size: 12px; }

  .big-value { font-size: 36px; }
  .big-value .unit { font-size: 18px; }

  .ram-row { gap: 14px; }
  .mini-bars { height: 40px; }

  .disk-visual { gap: 18px; align-items: flex-start; }
  .disk-circle-wrap { width: 84px; height: 84px; }
  .disk-center { font-size: 16px; }
  .disk-details { gap: 9px; }
  .disk-detail-row span:first-child,
  .disk-detail-row span:last-child { font-size: 13.5px; }

  .service-table .col-desc,
  .service-table thead th:nth-child(2) { display: none; }
  .service-table tbody td { padding: 11px 8px; font-size: 14px; }

  .app-card { padding: 12px; gap: 12px; }
  .app-icon { width: 40px; height: 40px; font-size: 15px; }
  .app-info-name { font-size: 14.5px; }
}

@media (max-width: 420px) {
  .dashboard { padding: 18px 10px 36px; }
  .cell { padding: 16px; }
  .cell-cpu, .cell-swap { grid-column: span 12; }

  .top-left h1 { font-size: 24px; }
  .top-right { gap: 12px; width: 100%; justify-content: space-between; }

  .big-value { font-size: 32px; }
  .mini-bars { display: none; }

  .disk-circle-wrap { width: 76px; height: 76px; }
  .disk-center { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* === AKCJE / STEROWANIE === */
.svc-actions { display: flex; gap: 4px; justify-content: flex-end; }
.btn-act {
  background: var(--bg-subtle); color: var(--fg-secondary);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 8px; font-size: 11px; cursor: pointer;
  font-family: var(--font-mono); transition: all 0.12s;
}
.btn-act:hover { background: var(--card-hover); color: var(--fg); border-color: var(--border-hover); }
.btn-act.danger:hover { color: var(--rose); border-color: var(--rose); }
.btn-act:disabled { opacity: 0.4; cursor: wait; }

.cell-control .ctrl-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px;
}
.btn-ctrl {
  background: var(--bg-subtle); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 12px; cursor: pointer;
  font-family: var(--font-sans); font-weight: 500;
  transition: all 0.12s; text-align: center;
}
.btn-ctrl:hover { background: var(--card-hover); border-color: var(--border-hover); }
.btn-ctrl.primary { color: var(--cyan); border-color: rgba(6,182,212,0.3); }
.btn-ctrl.primary:hover { background: var(--cyan-dim); border-color: var(--cyan); }
.btn-ctrl.warn { color: var(--orange); border-color: rgba(249,115,22,0.3); }
.btn-ctrl.warn:hover { background: var(--orange-dim); border-color: var(--orange); }
.btn-ctrl.danger { color: var(--rose); border-color: rgba(244,63,94,0.3); }
.btn-ctrl.danger:hover { background: var(--rose-dim); border-color: var(--rose); }
.btn-ctrl:disabled { opacity: 0.4; cursor: wait; }
.ctrl-status { margin-top: 10px; font-size: 11px; color: var(--fg-dim); min-height: 14px; font-family: var(--font-mono); }
.ctrl-status.ok { color: var(--emerald); }
.ctrl-status.err { color: var(--rose); }

/* === MODAL === */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 1000; display: none; align-items: center; justify-content: center;
  padding: 16px; backdrop-filter: blur(3px);
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--card); border: 1px solid var(--border-hover);
  border-radius: 12px; max-width: 880px; width: 100%;
  max-height: 85vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h2 { font-size: 13px; font-weight: 600; color: var(--fg); margin: 0; }
.modal-close {
  background: none; border: none; color: var(--fg-secondary);
  font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--fg); }
.modal-body { padding: 14px 18px; overflow: auto; }
.log-pre {
  font-family: var(--font-mono); font-size: 11px; line-height: 1.5;
  color: var(--fg-secondary); white-space: pre-wrap; word-break: break-all;
  background: var(--bg-subtle); padding: 12px; border-radius: 6px;
  border: 1px solid var(--border); max-height: 60vh; overflow: auto; margin: 0;
}
.bans-list { display: flex; flex-direction: column; gap: 6px; }
.ban-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: var(--bg-subtle); border-radius: 6px;
  border: 1px solid var(--border); font-family: var(--font-mono); font-size: 12px;
}
.ban-row .ip { color: var(--fg); }
.ban-row .jail { color: var(--fg-dim); font-size: 10px; padding: 2px 6px; background: var(--card); border-radius: 4px; }
.bans-empty { color: var(--fg-dim); font-size: 12px; text-align: center; padding: 20px; }

@media (max-width: 640px) {
  .col-actions { display: none; }
}
