:root {
  --bg: #0f1722;
  --bg-soft: #162231;
  --panel: rgba(15, 25, 36, 0.84);
  --line: rgba(255, 255, 255, 0.08);
  --text: #eff4fb;
  --muted: #98a9bc;
  --accent: #4ec7a4;
  --accent-2: #f4b860;
  --danger: #ef6b73;
  --ok: #65d996;
  --warn: #f4b860;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  --radius: 24px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(78, 199, 164, 0.14), transparent 26%),
    radial-gradient(circle at bottom right, rgba(244, 184, 96, 0.12), transparent 24%),
    linear-gradient(135deg, #09111a 0%, #111d2b 46%, #0a1420 100%);
  color: var(--text);
  font-family: var(--font);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  padding: 0.82rem 1.15rem;
  background: linear-gradient(135deg, var(--accent), #2e9dff);
  color: #08131c;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.06);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 14, 21, 0.72);
  color: var(--text);
  padding: 0.82rem 0.95rem;
}

textarea {
  resize: vertical;
}

.shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 2rem 1.4rem;
  background: rgba(5, 12, 18, 0.46);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  backdrop-filter: blur(18px);
}

.sidebar h1 {
  margin: 0.2rem 0 0.6rem;
  font-size: 2rem;
  line-height: 1.05;
}

.sidebar-box {
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.sidebar-box h3 {
  margin-top: 0;
}

.sidebar-box ul {
  margin: 0;
  padding-left: 1rem;
  color: var(--muted);
}

.main {
  padding: 1.5rem;
}

.hero,
.section-head,
.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.hero {
  margin-bottom: 1.3rem;
}

.hero h2,
.section-head h3,
.login-card h2 {
  margin: 0.2rem 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.section-card {
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}

.login-card {
  width: min(460px, 100%);
  margin: 8vh auto;
  padding: 1.6rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.stat-card {
  padding: 1.15rem;
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.stat-card strong {
  font-size: 1.45rem;
}

.layout-split {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 1.2rem;
}

.machines-layout {
  align-items: start;
}

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

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem;
}

.stack-form {
  display: grid;
  gap: 0.85rem;
}

.compact-form {
  position: sticky;
  top: 1rem;
}

label span {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.checkbox-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.full-span {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.9rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}

.subtext {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.87rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge.ok {
  background: rgba(101, 217, 150, 0.14);
  color: var(--ok);
}

.badge.warn {
  background: rgba(244, 184, 96, 0.16);
  color: var(--warn);
}

.badge.muted {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.meter {
  width: 100%;
  height: 7px;
  margin-top: 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-btn {
  background: rgba(239, 107, 115, 0.14);
  color: var(--danger);
  border: 1px solid rgba(239, 107, 115, 0.24);
}

.small-btn,
.tiny-btn {
  padding: 0.55rem 0.78rem;
  font-size: 0.86rem;
}

.tiny-btn {
  margin-bottom: 0.45rem;
  width: 100%;
}

.action-cell {
  min-width: 170px;
}

.action-stack {
  display: grid;
  gap: 0.45rem;
}

.upstream-detail-cell {
  padding: 1rem 0.7rem 1.15rem;
  background: rgba(255, 255, 255, 0.025);
}

.upstream-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.upstream-machine-list {
  display: grid;
  gap: 0.7rem;
}

.upstream-machine-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.upstream-machine-side {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
  min-width: 220px;
}

.audit-list {
  display: grid;
  gap: 0.75rem;
}

.audit-item {
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.audit-item div {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.audit-item p {
  margin: 0.45rem 0;
  color: var(--muted);
}

.audit-item time {
  color: var(--muted);
  font-size: 0.86rem;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-size: 0.78rem;
}

.muted,
.error-text,
.muted-row {
  color: var(--muted);
}

.error-text {
  color: #ff9298;
}

.hidden {
  display: none !important;
}

@media (max-width: 1240px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .layout-split {
    grid-template-columns: 1fr;
  }

  .compact-form {
    position: static;
  }
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .main {
    padding: 1rem;
  }

  .upstream-detail-head,
  .upstream-machine-item {
    flex-direction: column;
  }

  .upstream-machine-side {
    justify-content: flex-start;
    min-width: 0;
  }
}
