@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --ink: #1e1f22;
  --ink-soft: #4c5563;
  --card: rgba(255, 255, 255, 0.92);
  --card-strong: rgba(255, 255, 255, 0.98);
  --border: rgba(30, 41, 59, 0.16);
  --accent: #0f766e;
  --accent-2: #eab308;
  --accent-3: #ef4444;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fef9ef 0%, #f3f6fb 45%, #e3f5f2 100%);
}

#root {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
  padding: 2.5rem clamp(1.5rem, 4vw, 4rem) 4rem;
  position: relative;
  overflow: hidden;
}

.app-shell::before,
.app-shell::after {
  content: '';
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(0px);
  opacity: 0.35;
  z-index: 0;
}

.app-shell::before {
  top: -180px;
  right: -160px;
  background: radial-gradient(circle, #fef08a 0%, rgba(250, 204, 21, 0.1) 65%, transparent 70%);
}

.app-shell::after {
  bottom: -220px;
  left: -160px;
  background: radial-gradient(circle, #99f6e4 0%, rgba(45, 212, 191, 0.12) 60%, transparent 70%);
}

.app-content,
.app-toolbar {
  position: relative;
  z-index: 1;
}

.app-toolbar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0.75rem 1.5rem;
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-avatar {
  background: var(--accent);
  color: white;
  font-weight: 700;
  border-radius: 14px;
}

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

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.toolbar-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.toolbar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(248, 250, 252, 0.7);
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  gap: 6px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(248, 250, 252, 0.95);
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  z-index: 20;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bottom-nav .p-button {
  width: 100%;
  min-width: 0;
  display: grid;
  place-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 11px;
}

.bottom-nav .p-button > span {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: grid;
  align-items: end;
  z-index: 50;
}

.sheet-card {
  background: var(--card-strong);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px 28px;
  border: 1px solid rgba(30, 41, 59, 0.16);
  max-height: 80vh;
  overflow-y: auto;
}

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

.icon-button {
  border: none;
  background: transparent;
  color: var(--ink-soft);
}

.drawer-system {
  display: grid;
  gap: 12px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drawer-section-title {
  font-weight: 700;
  color: var(--ink);
}

.drawer-form {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.drawer-actions {
  justify-content: flex-start;
  gap: 0.75rem;
}

.drawer-hint {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.drawer-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.drawer-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.35);
}

.drawer-list-item:last-child {
  border-bottom: none;
}

.drawer-list-label {
  font-weight: 600;
  color: var(--ink);
}

.app-content {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.hero-card {
  background: linear-gradient(120deg, #f8fafc 0%, #ecfeff 100%);
  border-radius: 22px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  box-shadow: var(--shadow);
  animation: float-in 0.8s ease;
}

.hero-card .p-card-body {
  padding: 1.6rem;
  display: grid;
  gap: 1.25rem;
}

.hero-card .p-card-content {
  padding: 0;
}

.hero-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  align-items: center;
}

.hero-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.hero-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 600;
  display: block;
  margin-top: 0.35rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-divider {
  margin: 0;
}

.status-message {
  width: 100%;
}

.error-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.summary-card {
  background: var(--card-strong);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: float-in 0.8s ease;
}

.summary-card .p-card-body {
  padding: 1.4rem;
  display: grid;
  gap: 0.85rem;
}

.summary-card .p-card-content {
  padding: 0;
}

.summary-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.summary-icon {
  font-size: 1.4rem;
  color: var(--accent);
}

.summary-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 600;
}

.summary-detail {
  display: block;
  margin-top: 0.4rem;
  color: var(--ink-soft);
}

.summary-top-title {
  align-items: baseline;
}

.summary-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.summary-overview {
  display: grid;
  gap: 0.65rem;
}

.summary-overview-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.summary-overview-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-overview-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.summary-progress {
  margin-top: 0;
}

.summary-card .summary-overview .summary-overview-value {
  font-size: 0.95rem;
}

.summary-card .summary-overview {
  margin-top: 0.6rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
}

.summary-progress-track {
  position: relative;
  margin-top: 1.0rem;
  padding-bottom: 1.1rem;
}

.summary-progress-label {
  position: absolute;
  left: var(--progress, 0%);
  top: -1.1rem;
  transform: translateX(-50%);
  font-size: 0.82rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.summary-progress-start,
.summary-progress-end {
  position: absolute;
  bottom: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.summary-progress-start {
  left: 0;
  transform: translateX(-10%);
}

.summary-progress-end {
  right: 0;
  transform: translateX(10%);
}

.servers-card {
  background: var(--card);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.servers-card .p-card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.servers-card .p-card-content {
  padding: 0;
  width: 100%;
}

.server-grid,
.server-grid .p-dataview-content {
  width: 100%;
}

.server-grid-inner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
  width: 100%;
}

.server-grid-inner > * {
  min-width: 0;
}

.server-grid-item {
  display: flex;
}

.server-grid-item.is-draggable {
  cursor: grab;
}

.server-grid-item.is-dragging {
  cursor: grabbing;
  opacity: 0.7;
}

.server-grid-item.is-drop-target .server-card {
  outline: 2px dashed rgba(59, 130, 246, 0.6);
  outline-offset: 4px;
}

.server-grid-item.is-resizing {
  cursor: col-resize;
}

.server-grid-item .server-card {
  position: relative;
  width: 100%;
}

.resize-handle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.25), rgba(59, 130, 246, 0.25));
  cursor: col-resize;
  display: grid;
  place-items: center;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.resize-handle::after {
  content: '';
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(15, 118, 110, 0.7);
  border-bottom: 2px solid rgba(15, 118, 110, 0.7);
  transform: rotate(45deg);
}

.server-grid-item.is-draggable .resize-handle:hover {
  opacity: 1;
}

.server-grid-empty {
  padding: 1rem;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 1200px) {
  .app-toolbar {
    display: none;
  }

  .bottom-nav {
    display: grid;
  }

  .app-shell {
    padding-top: 1.5rem;
    padding-bottom: calc(6rem + env(safe-area-inset-bottom));
  }

  .app-content {
    margin-top: 1rem;
  }

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

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

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .server-grid-inner {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .server-grid-inner {
    grid-template-columns: 1fr;
  }
}

.wizard-dialog .p-dialog-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.wizard-dialog {
  width: min(640px, 92vw);
}

.wizard-steps {
  margin-bottom: 0.5rem;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-field label {
  font-weight: 600;
  color: var(--ink);
}

.form-field .p-inputtext,
.form-field .p-inputnumber,
.form-field .p-dropdown {
  width: 100%;
}

.form-field .p-inputnumber .p-inputtext {
  width: 100%;
}

.form-hint {
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.3;
}

.form-error {
  background: #fee2e2;
  color: #b91c1c;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.form-actions-right {
  display: flex;
  gap: 0.75rem;
}

.server-card {
  height: 100%;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: white;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.server-card .p-card-body {
  padding: 1.1rem;
}

.server-card .p-card-title {
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

.server-card .p-card-subtitle {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.server-card .p-card-content {
  padding: 0;
}

.server-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
}

.server-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.server-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.server-action {
  width: 2rem;
  height: 2rem;
  padding: 0;
}

.server-name {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.server-id {
  font-weight: 700;
}

.server-cluster {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.platform-avatar {
  font-weight: 700;
  color: white;
}

.platform-avatar.proxmox {
  background: #f97316;
}

.platform-avatar.pbs {
  background: #22c55e;
}

.platform-avatar.truenas {
  background: #0284c7;
}

.platform-tag {
  font-weight: 600;
  border: 1px solid transparent;
}

.platform-tag.proxmox {
  background: rgba(249, 115, 22, 0.16);
  color: #c2410c;
  border-color: rgba(249, 115, 22, 0.3);
}

.platform-tag.pbs {
  background: rgba(34, 197, 94, 0.16);
  color: #15803d;
  border-color: rgba(34, 197, 94, 0.3);
}

.platform-tag.truenas {
  background: rgba(2, 132, 199, 0.16);
  color: #0369a1;
  border-color: rgba(2, 132, 199, 0.3);
}

.server-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pool-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.server-aggregate {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
}

.pool-toggle {
  align-self: flex-start;
  font-size: 0.85rem;
  padding: 0;
  color: var(--ink-soft);
}

.pool-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.pool-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.pool-name {
  font-weight: 500;
  color: var(--ink-soft);
}

.server-aggregate .pool-name {
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.9rem;
}

.server-aggregate .pool-numbers {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.pool-list .pool-name {
  font-size: 0.85rem;
}

.pool-list .pool-numbers {
  font-size: 0.82rem;
}

.pool-numbers {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.usage-bar {
  height: 0.55rem;
  border-radius: 999px;
}

.usage-low .p-progressbar-value {
  background: #22c55e;
}

.usage-mid .p-progressbar-value {
  background: var(--accent-2);
}

.usage-high .p-progressbar-value {
  background: var(--accent-3);
}

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

@media (max-width: 900px) {
  .hero-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 1.75rem 1.2rem 3rem;
  }

  .toolbar-actions {
    flex-direction: column;
    align-items: flex-end;
  }

  .brand-block {
    flex-wrap: wrap;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
