/* Панель питания KVM.
   Тон задаёт предмет: консоль гипервизора, а не дашборд. Моноширинный набор,
   волосяные линии, цвет несёт только смысл состояния — больше нигде. */

:root {
  --ink:        #0e1317;
  --surface:    #151d23;
  --surface-2:  #1b252c;
  --line:       #24313a;
  --line-soft:  #1e2930;
  --text:       #c6d3dc;
  --text-dim:   #6e8494;
  --text-faint: #4a5b68;

  --on:      #4fbf8b;
  --off:     #55666f;
  --pending: #d3a13f;
  --bad:     #d2604f;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --gap: 18px;
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    linear-gradient(180deg, rgba(79, 191, 139, .035), transparent 320px);
}

button { font: inherit; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--on);
  outline-offset: 2px;
}

/* --- вход --------------------------------------------------------------- */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate__card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 26px 26px;
}

.gate__eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.gate__title {
  margin: 6px 0 22px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.gate__error {
  margin: 14px 0 0;
  padding: 9px 11px;
  font-size: 12.5px;
  color: var(--bad);
  border-left: 2px solid var(--bad);
  background: rgba(210, 96, 79, .07);
}

.field { display: block; margin-bottom: 14px; }

.field__label {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field__input {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  color: var(--text);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.field__input:focus {
  border-color: var(--text-dim);
  outline: none;
}

/* --- шапка -------------------------------------------------------------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.top__id { display: flex; align-items: baseline; gap: 10px; min-width: 0; }

.top__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--off);
  transform: translateY(-1px);
  transition: background .2s;
}
.top__dot[data-link="up"]   { background: var(--on); box-shadow: 0 0 0 3px rgba(79,191,139,.14); }
.top__dot[data-link="down"] { background: var(--bad); }

.top__host { font-weight: 600; letter-spacing: -.01em; }

.top__uri {
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top__right { display: flex; align-items: center; gap: 12px; }
.top__user { font-size: 12.5px; color: var(--text-dim); }

/* --- доска -------------------------------------------------------------- */

.board {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 22px 8px;
}

.board__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.board__title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-dim);
}

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

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--pending);
  border-left: 2px solid var(--pending);
  background: rgba(211, 161, 63, .07);
}

.empty {
  padding: 28px 0;
  text-align: center;
  color: var(--text-faint);
}

.vms { list-style: none; margin: 0; padding: 0; }

/* --- строка ВМ ---------------------------------------------------------- */

.vm {
  position: relative;
  display: grid;
  grid-template-columns: 3px minmax(0, 1fr) 150px 130px auto;
  align-items: center;
  gap: 16px;
  padding: 13px 16px 13px 0;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

/* Сигнатура интерфейса: цветная рейка слева — единственный крупный носитель
   состояния, читается боковым зрением при сканировании списка. */
.vm__rail {
  align-self: stretch;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--off);
}
.vm[data-state="running"]   .vm__rail { background: var(--on); }
.vm[data-state="blocked"]   .vm__rail { background: var(--on); }
.vm[data-state="shutdown"]  .vm__rail { background: var(--pending); }
.vm[data-state="paused"]    .vm__rail { background: var(--pending); }
.vm[data-state="suspended"] .vm__rail { background: var(--pending); }
.vm[data-state="crashed"]   .vm__rail { background: var(--bad); }

.vm__id { min-width: 0; }

.vm__name {
  display: block;
  font-weight: 600;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vm__uuid {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vm__state { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.vm__led {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--off);
  flex: none;
}
.vm[data-state="running"] .vm__led { background: var(--on); animation: breathe 2.6s ease-in-out infinite; }
.vm[data-state="shutdown"] .vm__led,
.vm[data-state="paused"] .vm__led,
.vm[data-state="suspended"] .vm__led { background: var(--pending); }
.vm[data-state="crashed"] .vm__led { background: var(--bad); }

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 191, 139, .45); }
  50%      { box-shadow: 0 0 0 4px rgba(79, 191, 139, 0); }
}

.vm__specs { display: flex; flex-direction: column; font-size: 12px; color: var(--text-dim); }

.vm__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* --- кнопки ------------------------------------------------------------- */

.btn {
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: #212d35; border-color: #33434e; }

.btn:disabled {
  color: var(--text-faint);
  background: transparent;
  border-color: var(--line-soft);
  cursor: not-allowed;
}

.btn--primary {
  color: var(--ink);
  background: var(--on);
  border-color: var(--on);
  font-weight: 600;
}
.btn--primary:hover:not(:disabled) { background: #5fcf9a; border-color: #5fcf9a; }

.btn--wide { width: 100%; margin-top: 6px; padding: 10px; }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }

.btn--danger { color: var(--bad); border-color: rgba(210, 96, 79, .3); }
.btn--danger:hover:not(:disabled) { background: rgba(210, 96, 79, .12); border-color: var(--bad); }

.btn[data-confirm="1"] {
  color: var(--ink);
  background: var(--bad);
  border-color: var(--bad);
  font-weight: 600;
}

.btn--busy { opacity: .55; pointer-events: none; }

/* --- подвал и тост ------------------------------------------------------ */

.foot {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 22px 40px;
}

.foot__note {
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--text-faint);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 16px;
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left-width: 2px;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.toast[data-kind="ok"]   { border-left-color: var(--on); }
.toast[data-kind="fail"] { border-left-color: var(--bad); }

/* --- узкие экраны ------------------------------------------------------- */

@media (max-width: 720px) {
  .vm {
    grid-template-columns: 3px minmax(0, 1fr);
    gap: 10px 14px;
    padding: 14px 14px 14px 0;
  }
  .vm__state, .vm__specs, .vm__actions { grid-column: 2; }
  .vm__specs { flex-direction: row; gap: 14px; }
  .vm__actions { justify-content: flex-start; }
  .top { padding: 12px 16px; }
  .board { padding: 20px 16px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
