@import url('https://fonts.googleapis.com/css2?family=Jura:wght@500;600;700&family=Unbounded:wght@400;500&display=swap');

/* =========================================================
   AYDA портал — новый стиль.
   Старые названия переменных и классов сохранены,
   чтобы все существующие страницы продолжили работать.
   ========================================================= */
:root {
  --bg: #06150F;
  --surface: #0B2218;
  --surface-2: #0F2B1F;
  --hover: #123324;
  --border: #1B4433;
  --border-glow: #54F0B0;
  --text: #E6F6EE;
  --text-muted: #8DB3A2;
  --faint: #5E8574;
  --accent: #54F0B0;
  --accent-dim: rgba(84, 240, 176, 0.12);
  --accent-glow: rgba(84, 240, 176, 0.3);
  --success: #54F0B0;
  --danger: #F0726A;
  --danger-dim: rgba(240, 114, 106, 0.13);
  --warning: #E8C06A;
  --warning-dim: rgba(232, 192, 106, 0.14);
  --radius: 14px;
  --side: 268px;
  --font-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --font-body: "Jura", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 600 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--bg); }

/* ---------- заголовки и текст ---------- */
h1, h2, h3, h4 { color: var(--text); margin: 0 0 16px; }
h1 { font: 400 28px/1.2 var(--font-display); letter-spacing: -0.01em; }
h2 { font: 400 22px/1.25 var(--font-display); letter-spacing: -0.01em; margin-top: 4px; }
h3 { font: 700 17px/1.3 var(--font-body); margin-top: 28px; }
h4 { font: 700 15px/1.3 var(--font-body); }
p { margin: 0 0 12px; }
.lead { color: var(--text-muted); margin-top: -8px; margin-bottom: 20px; }
.mono { font-family: var(--font-mono); font-weight: 500; font-size: 0.95em; }

/* ============ КАРКАС С БОКОВЫМ МЕНЮ ============ */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #081B13, #06150F);
}
.side-logo { display: block; padding: 22px 22px 14px; }
.side-logo img { display: block; height: 26px; width: auto; }

.nav { flex: 1; overflow-y: auto; padding: 4px 12px 20px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.nav-group { margin-top: 16px; }
.nav-group:first-child { margin-top: 4px; }
.nav-title { padding: 0 12px 6px; font-size: 12.5px; color: var(--faint); }

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 10px;
  color: var(--text-muted); text-decoration: none; line-height: 1.3;
  transition: background .2s, color .2s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--text); }
.nav-item.active svg { color: var(--accent); }
.nav-item.active::before { content: ""; position: absolute; left: -5px; top: 50%; width: 5px; height: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.nav-item.active::after { content: ""; position: absolute; left: -10px; top: 50%; width: 7px; height: 7px; margin-top: -2.5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.nav-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--danger-dim); color: var(--danger); font-size: 12px; text-align: center; }

.me { display: flex; align-items: center; gap: 12px; margin: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
.avatar { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--accent); color: var(--bg); font: 500 13px var(--font-display); }
.me-text { min-width: 0; }
.me-text b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text span { display: block; font-size: 13px; color: var(--text-muted); }
.me-out { margin-left: auto; padding: 7px; border-radius: 8px; color: var(--text-muted); display: grid; }
.me-out svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.me-out:hover { color: var(--text); background: var(--hover); }

.main { min-width: 0; }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 32px;
  background: rgba(6, 21, 15, 0.8);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.top .burger {
  display: none; padding: 8px; border-radius: 10px;
  background: transparent; color: var(--text); border: 0; box-shadow: none; filter: none;
}
.top .burger svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.top .burger:hover { background: var(--hover); box-shadow: none; filter: none; }
.top .search {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 380px; padding: 9px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--faint);
  font: 600 14px var(--font-body); text-align: left; box-shadow: none; filter: none;
}
.top .search:hover { border-color: #27604a; color: var(--text-muted); box-shadow: none; filter: none; }
.top .search svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.search-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd { padding: 1px 7px; border: 1px solid var(--border); border-radius: 6px; font: 600 12px var(--font-body); color: var(--faint); background: transparent; }

.side-backdrop { display: none; }

/* основное содержимое */
.container { width: 100%; max-width: 1240px; margin: 0; padding: 28px 32px 64px; }
body.guest .container { max-width: 980px; margin: 0 auto; }
.has-side a.back-link[href="/"] { display: none; }

/* гостевые страницы (регистрация, сброс пароля) */
.guest-top { display: flex; justify-content: center; padding: 28px 16px 8px; }
.guest-logo { height: 28px; width: auto; display: block; }

/* старая шапка — для шаблонов, которые ещё не переведены */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: rgba(6, 21, 15, 0.8); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.brand-logo { height: 26px; width: auto; display: block; }
.topbar-right { display: flex; align-items: center; gap: 16px; color: var(--text-muted); font-size: 14px; }
.topbar-right a { color: var(--text-muted); text-decoration: none; }
.topbar-right a:hover { color: var(--accent); }

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 18px; color: var(--text-muted); text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--accent); }

/* ============ КАРТОЧКИ ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.card > :last-child { margin-bottom: 0; }
.card-glow {
  background: var(--surface);
  border: 1px solid rgba(84, 240, 176, 0.45);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: 0 0 30px -12px var(--accent-glow);
}

/* цифры на главной */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin: 4px 0 8px; }
.kpi {
  display: block; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
  transition: border-color .2s, transform .2s var(--ease);
}
.kpi:hover { border-color: #2d6b53; transform: translateY(-2px); }
.kpi span { display: block; color: var(--text-muted); font-size: 14px; }
.kpi b { display: block; margin-top: 10px; font: 400 34px/1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-warn b { color: var(--warning); }

/* плитки разделов на главной */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-weight: 700;
  transition: border-color .2s, transform .2s var(--ease), background .2s;
}
.menu-item svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-item .icon { font-size: 20px; }
.menu-item:hover { border-color: #2d6b53; background: var(--surface-2); transform: translateY(-2px); }

/* ============ ТАБЛИЦЫ ============ */
.table-wrap { overflow-x: auto; margin-bottom: 18px; border-radius: var(--radius); }
.table-wrap > table { margin-bottom: 0; }
table {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14.5px;
  margin-bottom: 18px;
}
th {
  padding: 11px 14px;
  text-align: left; white-space: nowrap;
  font-size: 13px; font-weight: 600; color: var(--faint);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
td { padding: 11px 14px; border-bottom: 1px solid rgba(27, 68, 51, 0.6); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(18, 51, 36, 0.5); }
td form { margin: 0; }
td button, td .btn { white-space: nowrap; }

/* ============ ФОРМЫ ============ */
input[type="text"], input[type="password"], input[type="number"], input[type="email"],
input[type="tel"], input[type="date"], input[type="month"], input[type="search"], input[type="url"],
select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 12px;
  font: 600 14.5px var(--font-body);
  transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #27604a; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(84, 240, 176, 0.18); }
select { cursor: pointer; }
input[type="date"], input[type="month"] { color-scheme: dark; }
input[type="file"] { color: var(--text-muted); font: 600 14px var(--font-body); }
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: 700 13.5px var(--font-body); cursor: pointer;
}
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }

label { color: var(--text-muted); font-size: 13.5px; margin-right: 6px; }
.field-row { margin-bottom: 14px; }
.field-row label { display: inline-block; margin-bottom: 5px; }
.field-row input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field-row select, .field-row textarea { width: 100%; max-width: 380px; }

.checkbox-list label { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14.5px; margin-bottom: 8px; cursor: pointer; }

.link-box {
  width: 100%; padding: 11px 13px;
  background: var(--surface-2); border: 1px dashed rgba(84, 240, 176, 0.45); border-radius: 10px;
  color: var(--accent); font-family: var(--font-mono); font-size: 13.5px;
}

/* ============ КНОПКИ ============ */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px;
  background: var(--accent); color: #04140D;
  border: 1px solid transparent; border-radius: 10px;
  font: 700 14px/1.2 var(--font-body);
  text-decoration: none; cursor: pointer;
  transition: filter .15s, box-shadow .2s, transform .1s, border-color .2s, background .2s;
}
button:hover, .btn:hover { filter: brightness(1.08); box-shadow: 0 8px 24px -10px var(--accent-glow); }
button:active, .btn:active { transform: scale(0.97); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; box-shadow: none; }

button.secondary, .btn.secondary {
  background: transparent; color: var(--text); border-color: var(--border);
}
button.secondary:hover, .btn.secondary:hover { border-color: var(--accent); box-shadow: none; filter: none; }

button.danger, .btn.danger { background: var(--danger-dim); color: var(--danger); border-color: rgba(240, 114, 106, 0.35); }
button.danger:hover, .btn.danger:hover { background: rgba(240, 114, 106, 0.22); box-shadow: none; filter: none; }

button.warn, .btn.warn { background: var(--warning-dim); color: var(--warning); border-color: rgba(232, 192, 106, 0.35); }
button.warn:hover, .btn.warn:hover { background: rgba(232, 192, 106, 0.22); box-shadow: none; filter: none; }

/* ============ МЕТКИ И СООБЩЕНИЯ ============ */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--accent-dim); color: var(--success); }
.badge-danger { background: var(--danger-dim); color: var(--danger); }
.badge-warning { background: var(--warning-dim); color: var(--warning); }

.message-success, .message-error {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 16px;
  border-radius: 12px; font-size: 14.5px;
  animation: msg-in .4s var(--ease);
}
.message-success { background: var(--accent-dim); border: 1px solid rgba(84, 240, 176, 0.4); color: var(--accent); }
.message-error { background: var(--danger-dim); border: 1px solid rgba(240, 114, 106, 0.4); color: var(--danger); }
@keyframes msg-in { from { opacity: 0; transform: translateY(-6px); } }

/* ============ ВХОД ============ */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; padding: 36px 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6), 0 0 60px -30px var(--accent-glow);
}
.login-card h2 { text-align: center; }
.login-card form > div { margin-bottom: 14px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 6px; padding: 11px; }

/* ============ ПОИСК CTRL+K ============ */
.palette-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px;
  background: rgba(3, 10, 7, 0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: fade-in .15s;
}
.palette-overlay[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }
.palette {
  width: min(560px, 100%); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: pal-in .3s var(--ease);
}
@keyframes pal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.palette .palette-input {
  width: 100%; padding: 17px 20px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  background: transparent; font-size: 16px; box-shadow: none;
}
.palette .palette-input:focus { box-shadow: none; }
.palette-list { list-style: none; margin: 0; padding: 8px; max-height: 360px; overflow-y: auto; }
.palette-list a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-muted); text-decoration: none; }
.palette-list a svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.palette-list a small { margin-left: auto; font-size: 12.5px; color: var(--faint); white-space: nowrap; }
.palette-list a[aria-selected="true"], .palette-list a:hover { background: var(--accent-dim); color: var(--text); }
.palette-list a[aria-selected="true"] svg { color: var(--accent); }
.palette-empty { padding: 16px 12px; color: var(--faint); }
.palette-hint { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--faint); }


/* ============ ЭЛЕМЕНТЫ СТРАНИЦ (шаг 2) ============ */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-bottom: 18px; }
.page-head h1 { margin-bottom: 6px; }
.page-head .lead { margin: 0; }
.page-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.muted { color: var(--text-muted); }
.small { font-size: 13.5px; }
.accent-text { color: var(--accent); }
.td-right { text-align: right; }
.card-title { margin: 0 0 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.field-grid .field-row input, .field-grid .field-row select { max-width: none; }
.form-card { max-width: 560px; }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row .link-box { flex: 1; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 8px 0 12px; }
.search-field { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 360px; margin: 0; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(84, 240, 176, 0.18); }
.search-field svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; }
.search-field input[type="search"] { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 0; box-shadow: none; }
.search-field input[type="search"]:focus { box-shadow: none; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.row-actions form { margin: 0; }
.row-actions.compact { flex-wrap: wrap; }
.row-actions.compact button { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.cell-sub { padding: 2px 10px 0; }
.muted.small { white-space: normal; }
.cell-input { padding: 7px 10px; font-size: 14px; background: transparent; border-color: transparent; }
tr:hover .cell-input, .cell-input:focus { background: var(--surface-2); border-color: var(--border); }

/* страницы входа */
.login-logo { display: block; height: 30px; width: auto; margin: 0 auto 8px; }
.login-sub { text-align: center; color: var(--text-muted); margin: 0 0 24px; }
.login-card h2 { margin: 18px 0 16px; }
.login-card label { display: block; margin-bottom: 5px; }
.login-foot { margin: 16px 0 0; text-align: center; font-size: 14px; }
.login-foot a { text-decoration: none; }
.login-foot a:hover { text-decoration: underline; }
.hint { display: block; margin-top: 5px; font-size: 12.5px; color: var(--faint); }
.info-list { margin: 0 0 20px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.info-list div { display: flex; gap: 12px; padding: 3px 0; }
.info-list dt { width: 72px; flex: none; color: var(--faint); font-size: 13.5px; }
.info-list dd { margin: 0; }
body.auth { background: radial-gradient(900px 500px at 50% -10%, #0E2C1F, transparent 60%), var(--bg); }

@media (max-width: 560px) {
  .field-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .copy-row { flex-direction: column; }
  .page-actions { margin-left: 0; }
}

/* ============ АДАПТИВ ============ */
@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; left: 0; top: 0; z-index: 60;
    width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform .35s var(--ease);
  }
  .side-open .side { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, 0.5); }
  .side-backdrop { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(3, 10, 7, 0.55); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .side-open .side-backdrop { opacity: 1; pointer-events: auto; }
  .top { padding: 10px 16px; }
  .top .burger { display: inline-flex; }
  .top .search kbd { display: none; }
  .container { padding: 22px 16px 48px; }
  .has-side a.back-link[href="/"] { display: none; }
}
@media (max-width: 560px) {
  h1 { font-size: 23px; }
  h2 { font-size: 19px; }
  .card, .card-glow { padding: 18px 16px; }
  .kpi b { font-size: 28px; }
  .field-row input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field-row select, .field-row textarea { max-width: none; }
  .palette-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
