/* ========== LUNARA NOVA — чистый авторский тёмный UI ========== */
:root {
    --bg: #06080d;
    --bg-2: #090d14;
    --panel: #0b1019;
    --glass: #0d1420a6;
    --ink: #e7edf6;
    --muted: #9fb0c7;
    --line: #1a2433;
    --shadow: 0 10px 36px rgba(0, 0, 0, .5);
    --accent: #6aa6ff;
    --accent-2: #2dd4bf;
    --ok: #22c55e;
    --err: #ef4444;
    --warn: #f59e0b;
    --code: #0a0f18;
    --radius: 14px;
    --rsm: 10px;
    --font: ui-sans-serif, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    background: radial-gradient(1200px 600px at -20% -30%, #11203d66, transparent), radial-gradient(1000px 500px at 120% 130%, #0d3b2e66, transparent), var(--bg);
    color: var(--ink);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale
}

a {
    color: var(--accent);
    text-decoration: none
}

a:hover {
    opacity: .9
}

/* Layouts */
.nova-auth {
    display: grid;
    grid-template-columns: 264px 1fr;
    min-height: 100vh
}

.nova-guest {
    display: grid;
    place-items: center;
    min-height: 100vh
}

/* Rail */
.nv-rail {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 16px;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, var(--panel), var(--bg-2));
    box-shadow: inset -1px 0 0 var(--line)
}

.nv-brand {
    padding: 6px 8px;
    margin-bottom: 8px
}

.nv-brand-link {
    display: flex;
    align-items: center;
    gap: 10px
}

.nv-logo {
    font-size: 22px
}

.nv-name {
    font-weight: 800;
    letter-spacing: .3px;
    color: #fff
}

.nv-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px
}

.nv-item {
    padding: 10px 12px;
    border-radius: var(--rsm);
    color: var(--ink);
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px
}

.nv-item:hover {
    background: rgba(255, 255, 255, .04);
    border-color: var(--line)
}

.nv-item.is-active {
    background: linear-gradient(180deg, #121c2c, #0e1624);
    border-color: #2c3a55;
    box-shadow: 0 8px 24px rgba(22, 34, 54, .35)
}

.nv-rail-foot {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 0 12px;
    background: transparent
}

.btn-ghost:hover {
    color: #fff
}

/* Stage / top */
.nv-stage {
    display: grid;
    grid-template-rows: 56px 1fr
}

.nv-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .00))
}

.crumbs {
    opacity: .9
}

.nv-content {
    padding: 18px 22px;
    width: 100%
}

.nv-flash {
    margin: 12px 22px 0
}

/* Cards / callouts */
.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .00));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow)
}

.pad16 {
    padding: 16px
}

.pad20 {
    padding: 20px
}

.pad24 {
    padding: 24px
}

.callout {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .04);
    margin-bottom: 8px
}

.callout.success {
    border-left: 3px solid var(--ok)
}

.callout.danger {
    border-left: 3px solid var(--err)
}

.callout.info {
    border-left: 3px solid var(--accent)
}

.callout.warning {
    border-left: 3px solid var(--warn)
}

/* KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px
}

.kpi {
    padding: 16px
}

.kpi .v {
    font-size: 28px;
    font-weight: 800
}

.kpi .l {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px
}

/* Inputs / buttons */
.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center
}

.input,
.select {
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--code);
    color: var(--ink);
    padding: 0 10px
}

.btn {
    height: 38px;
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700
}

.btn-primary {
    background: linear-gradient(90deg, var(--accent), #89bbff);
    color: #fff
}

.btn-outline {
    background: transparent;
    border-color: var(--line);
    color: var(--ink)
}

.btn-outline:hover {
    border-color: #35507c
}

/* Tables */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--ink)
}

.table thead th {
    position: sticky;
    top: 0;
    background: #0b1320;
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: 10px 12px;
    font-weight: 700
}

.table tbody td {
    border-top: 1px solid var(--line);
    padding: 10px 12px
}

.tr-alt:nth-child(odd) {
    background: rgba(255, 255, 255, .02)
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 12px;
    background: #0a1220
}

.b-ok {
    background: rgba(34, 197, 94, .12);
    color: #c5f7d8;
    border-color: #29533a
}

.b-err {
    background: rgba(239, 68, 68, .12);
    color: #ffd6d6;
    border-color: #4d2126
}

.b-pend {
    background: rgba(245, 158, 11, .12);
    color: #ffe7bb;
    border-color: #53401e
}

.code {
    background: #0c1524;
    border: 1px solid var(--line);
    padding: 2px 6px;
    border-radius: 10px
}

/* Pagination */
.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px
}

.page {
    border: 1px solid var(--line);
    background: #0a1120;
    border-radius: 10px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center
}

.page.is-active {
    background: linear-gradient(90deg, var(--accent-2), #6aa6ff);
    color: #0a0f14;
    border: 0
}

/* Editor */
.editor-toolbar {
    position: sticky;
    top: 56px;
    z-index: 6;
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .04);
    margin-bottom: 10px
}

.editor-pane {
    position: relative;
    height: 72vh;
    min-height: 420px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--code)
}

#editor {
    position: absolute;
    inset: 0
}

/* Auth */
.nv-auth-center {
    width: 100%;
    max-width: 440px;
    padding: 20px
}

.nv-auth-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .00)), var(--panel);
    box-shadow: var(--shadow);
    padding: 28px
}

.auth-logo {
    font-size: 40px;
    text-align: center;
    margin-bottom: 8px
}

.auth-title {
    text-align: center;
    margin-bottom: 16px
}

.form {
    display: flex;
    flex-direction: column;
    gap: 12px
}

.f-label {
    font-size: 12px;
    color: var(--muted)
}

.f-input {
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--code);
    color: var(--ink);
    padding: 0 12px;
    width: 100%;
}

.btn-wide {
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(90deg, var(--accent), #8dbdff);
    color: #fff;
    border: 0;
    font-weight: 800
}

/* Empty */
.empty {
    padding: 28px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 16px
}

.code,
pre.code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}


/* ===== Layout utilities for server pages ===== */
.container { max-width: 1200px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.page-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-title { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: .2px; }
.subhead { margin: 0; font-size: 16px; font-weight: 700; }

.stack-12 > * + * { margin-top: 12px; }
.stack-16 > * + * { margin-top: 16px; }

.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.gap-16 { gap: 16px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.space-between { justify-content: space-between; }
.center { align-items: center; }
.actions { display: inline-flex; gap: 10px; flex-wrap: wrap; }

/* Key-Value table look */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px; align-items: center; }
.kv-k { color: var(--muted); font-size: 12px; }
.kv-v { min-width: 0; }

/* Code block behavior for long SSH keys */
.block-wrap { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.scroll-y { max-height: 320px; overflow-y: auto; }

/* Smaller text helpers */
.small { font-size: 12px; }
.text-dim { color: var(--muted); }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; }

/* Responsive */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
}


/* ===== Overlay toasts (fixed; не двигают вёрстку) ===== */
.toasts{
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
}
.toast{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: min(520px, 80vw);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: rgba(13, 20, 32, .96);
  color: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: toast-in .24s ease-out both;
}
.toast .toast-msg{ line-height: 1.35; }
.toast .toast-x{
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font-size: 16px; line-height: 1; padding: 0 4px; cursor: pointer;
}
.toast .toast-x:hover{ color: var(--ink); }

/* цветовые акценты по категориям Flask: success/info/warning/danger */
.toast.is-success{ border-left-color: var(--ok); }
.toast.is-info{ border-left-color: var(--accent); }
.toast.is-warning{ border-left-color: var(--warn); }
.toast.is-danger, .toast.is-error{ border-left-color: var(--err); }

@keyframes toast-in{
  from{ transform: translateY(-8px); opacity: 0; }
  to{ transform: translateY(0); opacity: 1; }
}
@keyframes toast-out{
  to{ transform: translateY(-8px); opacity: 0; }
}
.toast.is-hide{ animation: toast-out .18s ease-in both; }

/* ===== Multiselect (servers) ===== */
.ms{ position: relative; min-width: 260px; }
.ms-btn{
  display: inline-flex; align-items:center; gap:8px; height:38px; padding:0 12px;
  border-radius:12px; background:var(--code); border:1px solid var(--line); color:var(--ink);
  cursor:pointer; max-width:420px; overflow:hidden;
}
.ms-label{ color: var(--muted); }
.ms-chips{ display:flex; gap:6px; align-items:center; overflow:hidden; }
.ms-chip{
  display:inline-flex; align-items:center; padding:2px 8px; border-radius:999px;
  border:1px solid var(--line); background:#0a1220; font-size:12px; white-space:nowrap;
}
.ms-chip.ms-muted{ opacity:.7 }
.ms-chip.ms-more{ background:transparent }
.ms-count{ color:var(--muted); font-size:12px; }
.ms-caret{ margin-left:auto; opacity:.7 }

.ms-panel{
  position:absolute; top: 42px; left:0; min-width: 320px; max-width: 520px; width: max-content;
  background: var(--panel); border:1px solid var(--line); border-radius:12px; box-shadow: var(--shadow);
  padding:8px; display:none; z-index: 1000;
}
.ms.is-open .ms-panel{ display:block; }
.ms-search{ display:flex; gap:8px; align-items:center; margin-bottom:8px }
.ms-input{
  flex:1 1 auto; height:34px; border-radius:10px; border:1px solid var(--line); background:var(--bg-2);
  color:var(--ink); padding:0 10px;
}
.ms-actions{ display:flex; gap:6px }
.ms-act{
  height:34px; padding:0 10px; border-radius:10px; border:1px solid var(--line); background:transparent; color:var(--ink);
  cursor:pointer;
}
.ms-list{ max-height: 260px; overflow:auto; border-top:1px solid var(--line) }
.ms-row{
  display:grid; grid-template-columns: 22px 1fr auto; align-items:center; gap:10px;
  padding:6px 2px; border-bottom:1px solid var(--line);
}
.ms-row:last-child{ border-bottom:0 }
.ms-row input{ width:16px; height:16px; }
.ms-title{ font-weight:600 }
.ms-sub{ color: var(--muted); font-size:12px }

/* На узких экранах панель не уезжает за края */
@media (max-width: 720px){
  .ms-panel{ min-width: min(92vw, 520px); max-width: 92vw; }
}
