:root {
  color-scheme: dark;
  --bg: #000000;
  --panel: #171821;
  --panel-2: #202033;
  --line: #303048;
  --text: #ffffff;
  --muted: #c7c8d9;
  --accent: #ffffff;
  --button: #202033;
  --button-line: #383852;
  --danger: #e55d5d;
  --success: #72e0a6;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  min-height: 86px;
  padding: 14px clamp(18px, 6vw, 160px);
  color: #07070b;
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.16);
}

.nav,
.nav-actions {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 34px);
  font-size: 15px;
  font-weight: 700;
  text-transform: none;
}

.nav a,
.more-button {
  border-bottom: 2px solid transparent;
}

.nav a.is-active {
  border-bottom-color: #07070b;
}

.more-menu {
  position: relative;
}

.more-button {
  min-height: auto;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  color: #07070b;
  background: transparent;
  text-transform: none;
  font-weight: 700;
  box-shadow: none;
}

.more-button:hover {
  transform: none;
}

.more-button span {
  display: inline-block;
  margin-left: 4px;
  font-size: 18px;
  line-height: 1;
}

.more-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 12px);
  min-width: 140px;
  display: grid;
  padding: 10px 0;
  border-radius: 0 0 10px 10px;
  background: #ffffff;
  color: #07070b;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.more-menu:hover .more-dropdown,
.more-menu:focus-within .more-dropdown,
.more-menu.is-open .more-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.more-dropdown a {
  padding: 10px 20px;
  border: 0;
  text-transform: none;
  font-size: 14px;
  font-weight: 400;
}

.more-dropdown a:hover {
  background: #f0f2f7;
}

.nav-actions {
  justify-content: flex-end;
}

.brand {
  width: 96px;
  height: 58px;
  display: grid;
  place-items: center;
}

.brand img {
  width: 66px;
  height: 66px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 9px 10px rgba(0, 0, 0, 0.28));
}

.nav-button {
  min-width: 190px;
  padding: 15px 22px;
  border-radius: 5px;
  color: #fff;
  background: #181a20;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.28);
}

.hero {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 62px 20px 44px;
  text-align: center;
  background: #000;
}

.credit,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  max-width: 900px;
  font-size: clamp(32px, 4vw, 42px);
  font-weight: 700;
  line-height: 1.05;
  text-shadow: none;
}

.hero p:not(.credit) {
  margin: 0;
  font-size: 16px;
}

.hero-button,
button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--button-line);
  border-radius: 8px;
  padding: 12px 24px;
  color: #fff;
  background: var(--button);
  font-weight: 900;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.hero-button {
  margin-top: 16px;
  min-width: 176px;
  border-color: #fff;
  color: #111;
  background: #fff;
  text-transform: uppercase;
}

button:hover,
.hero-button:hover,
.join-button:hover {
  transform: translateY(-1px);
  border-color: #8a8fb5;
}

.directory-section {
  max-width: 1010px;
  margin: 0 auto;
  padding: 28px 16px 34px;
}

.directory-section h2 {
  margin: 0 0 34px;
  text-align: center;
  font-size: clamp(30px, 4.2vw, 40px);
  font-weight: 700;
  line-height: 1.08;
  text-shadow: none;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 56px 64px;
  align-items: stretch;
}

.card {
  min-height: 492px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0 26px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  overflow: hidden;
}

.avatar-wrap {
  width: min(100%, 270px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 0 auto 25px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #050507;
  overflow: hidden;
}

.avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fallback-logo {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 34px;
  color: #fff;
  background: radial-gradient(circle at 30% 20%, #303748, #060609 72%);
  font-size: 72px;
  font-weight: 900;
  text-transform: uppercase;
}

.card h3 {
  margin: 0 22px 12px;
  min-height: 54px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.08;
  text-shadow: none;
}

.card p {
  margin: 0 26px 24px;
  min-height: 100px;
  color: #fff;
  text-align: center;
  font-size: 16px;
  line-height: 1.45;
}

.card p::before {
  content: "Описание:\A";
  white-space: pre;
}

.join-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 138px;
  min-height: 44px;
  margin-top: auto;
  padding: 10px 18px;
  border: 1px solid var(--button-line);
  border-radius: 8px;
  background: var(--button);
  color: #fff;
  font-weight: 900;
}

footer {
  display: grid;
  place-items: center;
  min-height: 90px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}

.control-body {
  background:
    radial-gradient(circle at 14% 10%, rgba(64, 83, 140, 0.25), transparent 26%),
    radial-gradient(circle at 82% 0%, rgba(118, 88, 64, 0.18), transparent 22%),
    #07080d;
}

.control-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

.login-panel,
.dashboard,
.editor-panel,
.import-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(23, 24, 33, 0.94);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
}

.login-panel {
  width: min(470px, 100%);
  margin: 12vh auto 0;
  padding: 30px;
}

.login-panel h1,
.control-header h1,
.table-panel h2,
.import-panel h2 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: #fff;
  background: #0d0e15;
  outline: none;
}

textarea {
  min-height: 116px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #8a8fb5;
}

.is-hidden {
  display: none;
}

.dashboard {
  padding: 26px;
}

.control-header,
.table-toolbar,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.75fr);
  gap: 18px;
  margin-top: 22px;
}

.editor-panel,
.import-panel,
.table-panel {
  padding: 20px;
}

.editor-panel {
  display: grid;
  gap: 14px;
}

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

.check-row {
  min-height: 44px;
  display: flex;
  align-items: end;
  gap: 10px;
  padding-bottom: 9px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.ghost-button {
  background: transparent;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--success);
  font-weight: 800;
}

.form-message.error {
  color: var(--danger);
}

.import-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

#importJson {
  min-height: 292px;
  font-family: Consolas, monospace;
  font-size: 13px;
}

.table-panel {
  margin-top: 18px;
}

.table-toolbar {
  margin-bottom: 16px;
}

.table-toolbar input {
  max-width: 280px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-top: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.table-actions button {
  min-height: 36px;
  padding: 8px 12px;
}

.danger-button {
  border-color: rgba(229, 93, 93, 0.5);
  color: #ffd8d8;
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 10px;
    padding: 14px;
  }

  .nav,
  .nav-actions {
    flex-wrap: wrap;
    justify-content: center;
    font-size: 13px;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
  }

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

@media (max-width: 620px) {
  .nav-button,
  .nav-link {
    display: none;
  }

  .directory-section {
    padding-inline: 12px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .card {
    min-height: 450px;
  }

  .avatar-wrap {
    width: min(100%, 244px);
  }

  .form-row,
  .control-header,
  .header-actions,
  .table-toolbar,
  .button-row {
    grid-template-columns: 1fr;
    display: grid;
  }
}

/* Control panel polish */
.card p::before {
  content: "Описание:\A";
}

.control-body {
  background: #090a0f;
}

.control-shell {
  width: min(1280px, calc(100% - 32px));
  padding: 34px 0;
}

.login-panel,
.dashboard,
.editor-panel,
.table-panel {
  border: 1px solid #2b2e3f;
  border-radius: 12px;
  background: #151722;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

.dashboard {
  padding: 24px;
}

.login-panel h1,
.control-header h1,
.table-panel h2,
.editor-panel h2 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
}

input,
select,
textarea {
  border-color: #303449;
  background: #0c0e16;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.stat-card {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  border: 1px solid #2b2e3f;
  border-radius: 12px;
  background: #10121b;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-card strong {
  font-size: 34px;
  line-height: 1;
}

.editor-layout {
  grid-template-columns: minmax(360px, 0.85fr) minmax(0, 1.35fr);
  align-items: start;
}

.editor-panel,
.table-panel {
  padding: 22px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.compact-button {
  min-height: 36px;
  padding: 8px 12px;
}

.table-panel {
  margin-top: 0;
}

.table-toolbar input {
  max-width: 320px;
}

td,
th {
  padding: 13px 10px;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

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

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

@media (max-width: 620px) {
  .stats-grid,
  .panel-title-row {
    grid-template-columns: 1fr;
    display: grid;
  }
}
