:root {
  --bg0: #070b0a;
  --bg1: #0a1411;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.09);
  --stroke: rgba(255, 255, 255, 0.14);
  --stroke2: rgba(170, 255, 210, 0.28);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);
  --muted2: rgba(255, 255, 255, 0.5);
  --shadow: 0 16px 50px rgba(0, 0, 0, 0.45);

  --green0: #00ff83;
  --green1: #00c96d;
  --green2: #2bffb0;

  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-w: 290px;
  --sidebar-w-collapsed: 78px;

  --focus: 0 0 0 4px rgba(0, 255, 131, 0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 650px at 18% 0%, rgba(0, 255, 131, 0.15), transparent 55%),
    radial-gradient(1000px 600px at 100% 20%, rgba(0, 201, 109, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.app {
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  padding: 18px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: width 260ms cubic-bezier(.2,.9,.2,1);
  position: relative;
  overflow: hidden; /* фикс фантомного свечения от box-shadow при collapse */
}

.sidebar--collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar__top {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__mark {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(0,255,131,0.9), rgba(0,201,109,0.35));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 18px 40px rgba(0,255,131,0.14);
  position: relative;
  overflow: hidden;
}

.brand__mark::after {
  content: "";
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.55), transparent 40%);
  transform: translateX(-15%);
  opacity: 0.55;
}

.brand__title {
  font-weight: 920;
  letter-spacing: 0.2px;
  line-height: 1.05;
  font-size: 18px;
}

.brand__subtitle {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
  margin-top: 2px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  color: var(--text);
  display: grid;
  place-items: center;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(0,255,131,0.38);
  background: rgba(0,255,131,0.08);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100vh - 140px);
}

.nav__spacer {
  flex: 1;
}

.nav__item {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  padding: 12px 12px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.nav__item:hover {
  transform: translateY(-1px);
  border-color: rgba(0,255,131,0.28);
  background: rgba(0,255,131,0.06);
}

.nav__item--active {
  border-color: rgba(0,255,131,0.55);
  background:
    linear-gradient(180deg, rgba(0,255,131,0.12), rgba(0,255,131,0.03));
  box-shadow: 0 14px 50px rgba(0,255,131,0.08);
}

.nav__icon {
  width: 34px;
  height: 34px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

.nav__img {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
  /* SVG-иконки из ui/ в большинстве случаев чёрные — делаем их зелёными через фильтр */
  filter: invert(66%) sepia(92%) saturate(600%) hue-rotate(95deg) brightness(1.05) contrast(1.05);
  transition: transform 140ms ease, filter 140ms ease;
}

.nav__item--active .nav__img {
  filter: invert(68%) sepia(98%) saturate(750%) hue-rotate(95deg) brightness(1.15) contrast(1.1);
  transform: scale(1.06);
}

.nav__label {
  font-weight: 780;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 200ms ease, transform 200ms ease;
}

.sidebar--collapsed .nav__label,
.sidebar--collapsed .brand__text {
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
  width: 0;
}

/* В свернутом состоянии кнопка toggle должна быть доступна */
.sidebar--collapsed #sidebarToggle {
  opacity: 1 !important;
  transform: translateX(0) !important;
  pointer-events: all !important;
  width: auto;
}

.sidebar:not(.sidebar--collapsed) #sidebarToggle {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
}

.main {
  flex: 1;
  overflow: auto;
  padding: 18px 18px 26px;
}

.view {
  animation: fadeInUp 280ms ease both;
  min-height: calc(100vh - 44px);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0px); }
}

.glass {
  background: var(--card);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

/* Liquid glass (subtle): включается, когда в DOM есть svg#displacementFilter */
@supports not (hanging-punctuation:first) {
  .glass,
  .btn,
  .nav__item,
  .listItem,
  .alert,
  .stat,
  .topbar {
    backdrop-filter: url(#displacementFilter) blur(7px);
    -webkit-backdrop-filter: url(#displacementFilter) blur(7px);
  }
}

.card {
  border-radius: var(--radius);
  padding: 16px;
}

.card--login {
  max-width: 520px;
  margin: 64px auto 0;
}

.topbar {
  padding: 14px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.topbar__left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.greeting {
  font-weight: 930;
  letter-spacing: 0.2px;
  font-size: 18px;
  line-height: 1.1;
}

.subtle {
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
}

.h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 950;
  letter-spacing: -0.3px;
}

.muted {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
  font-weight: 620;
}

.grid--cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 980px) {
  .grid--cards { grid-template-columns: 1fr; }
  .sidebar { width: 250px; }
  .sidebar--collapsed { width: 74px; }
}

.stat {
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at 30% 20%, rgba(0,255,131,0.25), transparent 45%);
  transform: translateX(-8%);
  opacity: 0.9;
  pointer-events: none;
}

.stat__title {
  color: var(--muted);
  font-weight: 750;
  font-size: 13px;
  margin-bottom: 8px;
}

.stat__value {
  font-size: 34px;
  font-weight: 980;
  letter-spacing: -0.6px;
  margin-bottom: 6px;
}

.stat__hint {
  color: var(--muted2);
  font-weight: 650;
  font-size: 12px;
}

.section {
  margin-bottom: 14px;
  padding: 16px;
}

.section__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section__title {
  font-weight: 940;
  letter-spacing: 0.1px;
  font-size: 16px;
}

.section__meta {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.listItem {
  border-radius: 16px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.035);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.listItem:hover {
  transform: translateY(-1px);
  border-color: rgba(0,255,131,0.25);
  background: rgba(0,255,131,0.05);
}

.listItem__title {
  font-weight: 900;
  margin-bottom: 6px;
}

.listItem__meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 650;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 10px;
  border: 1px solid rgba(0,255,131,0.28);
  background: rgba(0,255,131,0.08);
  color: rgba(255,255,255,0.92);
  font-weight: 820;
}

.btn {
  border-radius: 14px;
  padding: 11px 14px;
  border: 1px solid rgba(255,255,255,0.11);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-weight: 820;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(0,255,131,0.35);
}

.btn:focus {
  outline: none;
  box-shadow: var(--focus);
}

.btn--primary {
  border-color: rgba(0,255,131,0.55);
  background:
    linear-gradient(135deg, rgba(0,255,131,0.20), rgba(0,201,109,0.06));
}

.btn--ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.14);
}

.row {
  display: flex;
  align-items: center;
}

.row--gap { gap: 10px; }
.row--center { justify-content: center; }

.form { display: flex; flex-direction: column; gap: 12px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  color: var(--muted);
  font-weight: 780;
  font-size: 13px;
}

.input, .input--textarea, select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.20);
  color: var(--text);
  padding: 11px 12px;
  font-weight: 750;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

textarea.input--textarea {
  resize: vertical;
  min-height: 88px;
}

.input:focus, .input--textarea:focus, select:focus {
  outline: none;
  box-shadow: var(--focus);
  border-color: rgba(0,255,131,0.45);
  background: rgba(0,0,0,0.28);
}

.alert {
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-weight: 720;
}

.alert--error {
  border-color: rgba(255, 80, 80, 0.35);
  background: rgba(255, 80, 80, 0.08);
  color: rgba(255,255,255,0.92);
}

.keygen {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.keygen__formWrap {
  animation: panelPop 220ms ease both;
}

@keyframes panelPop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.keyResult__frame {
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid rgba(0,255,131,0.25);
  background:
    radial-gradient(500px 200px at 20% 0%, rgba(0,255,131,0.10), transparent 55%),
    rgba(255,255,255,0.035);
  animation: shineIn 260ms ease both;
}

@keyframes shineIn {
  from { filter: saturate(0.8); transform: translateY(8px); opacity: 0; }
  to { filter: saturate(1); transform: translateY(0); opacity: 1; }
}

.keyResult__label {
  color: var(--muted);
  font-weight: 820;
  margin-bottom: 10px;
}

.keyResult__code {
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.26);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 15px;
  line-height: 1.45;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.wip {
  display: grid;
  place-items: center;
  padding: 34px 18px;
  text-align: center;
  gap: 8px;
}
.wip__icon { font-size: 34px; }
.wip__title { font-weight: 950; font-size: 18px; }
.wip__text { color: var(--muted); font-weight: 700; line-height: 1.5; margin-top: 4px; }

/* Sidebar animation handle */
.sidebar {
  transform-origin: left center;
}

.sidebar.sidebar--collapsed {
  transform: translateX(0);
}

/* Hide view properly */
.view[hidden] { display: none; }
