:root {
  --asphalt: #0c0e12;
  --asphalt-2: #141821;
  --lane: #f3c445;
  --lane-dim: rgba(243, 196, 69, 0.16);
  --paper: #f4efe4;
  --muted: #9aa4b3;
  --line: #262c38;
  --ok: #3ee0a4;
  --warn: #f3c445;
  --bad: #ff5d6c;
  --info: #79c7ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Outfit, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(243,196,69,0.05), transparent 180px),
    var(--asphalt);
  color: var(--paper);
}

a { color: var(--lane); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transition: grid-template-columns 0.2s ease;
}
html.rail-collapsed .shell { grid-template-columns: 76px 1fr; }
.rail {
  background: linear-gradient(180deg, #10141c, #0c0f14);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.rail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.rail-toggle {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
}
.rail-toggle svg { width: 16px; height: 16px; transition: transform 0.2s ease; }
.rail-toggle:hover { color: var(--paper); border-color: var(--lane); }
html.rail-collapsed .rail-toggle svg { transform: rotate(180deg); }
.brand, .brand-lg {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--paper);
  text-decoration: none;
  min-width: 0;
}
.brand strong, .brand-lg strong { display: block; font-size: 1.05rem; letter-spacing: 0.04em; }
.brand small, .brand-lg small { color: var(--muted); letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.68rem; }
.brand-mark { display: grid; gap: 4px; width: 22px; flex-shrink: 0; }
.brand-mark span {
  height: 4px;
  background: var(--lane);
  border-radius: 99px;
}
.brand-mark span:nth-child(2) { width: 70%; opacity: 0.7; }
.brand-mark span:nth-child(3) { width: 40%; opacity: 0.4; }

.rail nav { display: grid; gap: 6px; align-content: start; flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.rail nav::-webkit-scrollbar { width: 6px; }
.rail nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
.rail nav a {
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  position: relative;
}
.nav-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-label { min-width: 0; }
.rail nav a.is-active,
.rail nav a:hover {
  background: var(--lane-dim);
  color: var(--paper);
  text-decoration: none;
}
.rail nav em {
  background: var(--bad);
  color: white;
  font-style: normal;
  border-radius: 99px;
  min-width: 1.4rem;
  text-align: center;
  font-size: 0.75rem;
  margin-left: auto;
}
.rail-user {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  flex-shrink: 0;
}
.rail-user small { color: var(--muted); display: block; }
.rail-user button, .btn, .linkish {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.rail-user button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

html.rail-collapsed .rail {
  padding: 18px 10px;
  align-items: center;
}
html.rail-collapsed .rail-top { flex-direction: column; }
html.rail-collapsed .brand-copy,
html.rail-collapsed .nav-label,
html.rail-collapsed .rail-user-copy { display: none; }
html.rail-collapsed .brand { justify-content: center; }
html.rail-collapsed .rail nav { width: 100%; }
html.rail-collapsed .rail nav a {
  justify-content: center;
  padding: 10px 8px;
}
html.rail-collapsed .rail nav em {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
  min-width: 1.05rem;
  font-size: 0.65rem;
}
html.rail-collapsed .rail-user {
  flex-direction: column;
  align-items: center;
  width: 100%;
}
html.rail-collapsed .rail-user form,
html.rail-collapsed .rail-user button { width: 100%; }
html.rail-collapsed .rail-user button { justify-content: center; padding: 8px; }
.btn.primary { background: var(--lane); color: #1a1404; border-color: var(--lane); font-weight: 650; }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.linkish { border: 0; padding: 0; color: var(--lane); }

.stage { padding: 28px 36px 48px; min-height: 0; overflow: auto; }
.top { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; gap: 16px; }
.kicker { margin: 0; color: var(--lane); letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.72rem; }
h1 { margin: 4px 0 0; font-size: 2rem; font-weight: 650; }
.top-actions, .action-bar, .filters, .panel-head, .log-tools, .modal-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.action-bar { margin: 0 0 18px; }

.stat-row, .grid-cards, .split { display: grid; gap: 16px; margin-bottom: 18px; }
.stat-row { grid-template-columns: repeat(4, 1fr); }
.grid-cards { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.split {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
}
.split > .panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;
}
.split > .panel > .meta,
.split > .panel > .data,
.split > .panel > .timeline {
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
}
.split > .panel > .data {
  table-layout: fixed;
}
.split .data td:first-child {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}
.split .data td:nth-child(2) {
  white-space: nowrap;
  width: 5.2rem;
}
.split .data td:nth-child(3) {
  white-space: nowrap;
  width: 7.2rem;
}
.stat, .panel, .server-card, .login-card {
  background: var(--asphalt-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.stat { padding: 18px; }
.stat span, .muted, .hint { color: var(--muted); }
.stat strong { display: block; font-size: 1.7rem; margin-top: 6px; }
.stat small { display: block; color: var(--muted); margin-top: 4px; font-size: 0.85rem; }
.panel { padding: 18px; overflow: visible; }
.panel h2 { margin: 0 0 14px; font-size: 1.05rem; }
.panel-head {
  justify-content: space-between;
  margin-bottom: 12px;
  min-height: 38px;
  flex-wrap: nowrap;
}
.panel-head h2 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.server-card { padding: 18px; color: inherit; text-decoration: none; display: block; }
.server-card:hover { border-color: var(--lane); text-decoration: none; }
.server-card header, .server-card footer { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.server-card h2 { margin: 0; font-size: 1.15rem; }
.server-card p, .server-card footer { color: var(--muted); font-size: 0.9rem; }
.server-card .server-meta { margin: 6px 0 0; line-height: 1.45; }
.server-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  text-align: right;
}
.server-card .public-ip {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.2;
}
.avail {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}
.avail.online { color: var(--ok); }
.avail.unreachable,
.avail.failed { color: var(--bad); }
.meters { display: grid; gap: 8px; margin: 16px 0; }
.meters i { display: block; height: 7px; min-width: 0; background: #232833; border-radius: 99px; overflow: hidden; }
.meters em { display: block; height: 100%; background: var(--lane); }
.meters div {
  display: grid;
  grid-template-columns: 40px 8.75rem 1fr;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
}
.meters b { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.running, .pill.online, .pill.success { color: var(--ok); border-color: rgba(62,224,164,0.4); }
.pill.stopped, .pill.warning, .pill.warn { color: var(--warn); border-color: rgba(243,196,69,0.4); }
.pill.failed, .pill.unreachable, .pill.failure, .pill.denied, .pill.critical, .pill.error { color: var(--bad); border-color: rgba(255,93,108,0.45); }
.pill.running::before,
.pill.online::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  animation: blink-ok 1.1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes blink-ok {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--ok); }
  50% { opacity: 0.2; box-shadow: 0 0 0 0 var(--ok); }
}
@media (prefers-reduced-motion: reduce) {
  .pill.running::before,
  .status-led.online,
  .status-led.running { animation: none; opacity: 1; }
}

.status-led {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}
.status-led.online,
.status-led.running {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  animation: blink-ok 1.1s ease-in-out infinite;
}
.status-led.unreachable,
.status-led.failed {
  background: var(--bad);
  box-shadow: 0 0 6px var(--bad);
}
.conn-state {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.conn-state.online { color: var(--ok); }
.conn-state.unreachable,
.conn-state.failed { color: var(--bad); }

.data { width: 100%; border-collapse: collapse; }
.data th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.8rem; letter-spacing: 0.04em; }
.data td, .data th { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data td:first-child { white-space: nowrap; }
.data td.wrap { white-space: normal; word-break: break-word; }
.data td.cron-cmd { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.78rem; }
.data td small { display: block; margin-top: 4px; }
.actions-cell { display: flex; gap: 10px; flex-wrap: wrap; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.timeline li { display: flex; gap: 10px; align-items: start; }
.timeline small { display: block; color: var(--muted); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field-input, input, select, textarea {
  background: #0c1016;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
.form-panel { max-width: 720px; }
.filters .field-input { width: auto; min-width: 160px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.flash { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.flash-error, .flash-error { background: rgba(255,93,108,0.12); color: #ffb3bb; }
.flash-success { background: rgba(62,224,164,0.12); color: var(--ok); }
.meta { display: grid; gap: 10px; min-width: 0; }
.meta div {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}
.meta dt { color: var(--muted); }
.meta dd {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.log-view, #terminal {
  background: #07090d;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 280px;
  max-height: 460px;
  padding: 12px;
  overflow: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.terminal-panel #terminal { padding: 8px; max-height: none; min-height: 520px; height: 62vh; overflow: hidden; }

.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid; place-items: center;
  z-index: 20;
}
.modal-card {
  width: min(460px, 92vw);
  background: #151a23;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
}
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 30; }
.toast { background: #1b2230; border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(243,196,69,0.08) 46px 48px),
    radial-gradient(circle at 20% 20%, rgba(243,196,69,0.12), transparent 32%),
    var(--asphalt);
}
.login-wrap {
  width: min(980px, 92vw);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}
.login-hero h1 { font-size: 2.4rem; max-width: 14ch; }
.login-points { color: var(--muted); padding-left: 18px; }
.login-card { padding: 28px; }

@media (max-width: 980px) {
  .shell, html.rail-collapsed .shell, .login-wrap, .stat-row, .split { grid-template-columns: 1fr; }
  .shell, html.rail-collapsed .shell { grid-template-rows: auto 1fr; }
  .rail, html.rail-collapsed .rail {
    flex-direction: row;
    overflow: auto;
    align-items: center;
    padding: 12px 16px;
    height: auto;
  }
  .rail nav { grid-auto-flow: column; flex: none; overflow: visible; }
  .rail-user { margin: 0; }
  html.rail-collapsed .rail-top { flex-direction: row; }
  html.rail-collapsed .brand-copy,
  html.rail-collapsed .nav-label,
  html.rail-collapsed .rail-user-copy { display: none; }
}
