:root {
  --bg: #0a0c11;
  --bg-2: #0f1218;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #7c5cff;
  --accent-2: #22d3a6;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, rgba(34, 211, 166, 0.09), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- каркас ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 248px; flex: none; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 24px rgba(124, 92, 255, 0.35);
}
.brand-logo svg { stroke: #fff; width: 20px; height: 20px; }
.brand b { display: block; font-size: 15px; letter-spacing: 0.2px; }
.brand span { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 11px;
  color: var(--muted); text-decoration: none; font-weight: 500; transition: .15s;
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, rgba(124, 92, 255, 0.22), rgba(124, 92, 255, 0.05)); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.status-pill {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 500;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.warn { background: var(--warn); box-shadow: 0 0 10px var(--warn); animation: pulse 1.2s infinite; }
.dot.err { background: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.banner {
  display: none; align-items: center; gap: 12px; padding: 10px 28px;
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.16), rgba(251, 191, 36, 0.05));
  border-bottom: 1px solid rgba(251, 191, 36, 0.25); color: #fde68a;
}
.banner.show { display: flex; }
.banner .grow { flex: 1; }
.view { flex: 1; min-height: 0; padding: 26px 28px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
/* блоки не сжимаются под высоту окна — страница скроллится целиком (консоль растягивается сама) */
.view > :not(.console) { flex-shrink: 0; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: .2px; }
.page-head .sub { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- компоненты ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(10px);
}
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 600;
  transition: .15s; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.11); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b8cff); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(124, 92, 255, .3); }
.btn.success { background: linear-gradient(135deg, #10b981, var(--accent-2)); border-color: transparent; color: #04140e; }
.btn.danger { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, .3); color: #fca5a5; }
.btn.warning { background: rgba(251, 191, 36, 0.14); border-color: rgba(251, 191, 36, .3); color: #fde68a; }
.btn.icon { padding: 8px; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { padding: 15px 17px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.stat .value { font-size: 21px; font-weight: 700; margin-top: 6px; display: flex; align-items: center; gap: 9px; }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 3px; min-height: 16px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- консоль ---------- */
.console { display: flex; flex-direction: column; flex: 1; min-height: 320px; overflow: hidden; position: relative; }
.console-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.console-head .title { font-weight: 600; display: flex; align-items: center; gap: 9px; }
.live { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: rgba(52, 211, 153, .14); color: var(--ok); font-weight: 700; }
.live.off { background: rgba(248, 113, 113, .14); color: var(--err); }
.console-body {
  flex: 1; overflow-y: auto; padding: 12px 16px; background: rgba(0, 0, 0, .35);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
}
.ln { white-space: pre-wrap; word-break: break-word; color: #c9cedb; }
.ln.warn { color: var(--warn); }
.ln.error { color: var(--err); }
.ln.cmd { color: var(--accent-2); }
.ln.resp { color: #93c5fd; }
.ln .ts { color: #5d667a; }
.jump {
  position: absolute; right: 18px; bottom: 74px; display: none;
  background: var(--accent); color: #fff; border: 0; padding: 7px 13px; border-radius: 99px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4); font-weight: 600;
}
.jump.show { display: block; }
.cmd-row { display: flex; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--border); align-items: center; }
.cmd-row .prompt { color: var(--accent-2); font-family: var(--mono); font-weight: 700; }
.cmd-row input {
  flex: 1; background: transparent; border: 0; outline: 0; font-family: var(--mono); font-size: 13px;
}

/* ---------- списки файлов ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.input {
  width: 100%; padding: 10px 13px; border-radius: 10px; background: rgba(0, 0, 0, .3);
  border: 1px solid var(--border); outline: 0; transition: .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .2); }
.search .input { padding-left: 38px; }

.drop {
  border: 1.5px dashed rgba(255, 255, 255, .16); border-radius: var(--radius); padding: 20px;
  text-align: center; color: var(--muted); transition: .15s; cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(124, 92, 255, .08); color: var(--text); }

.table { overflow: hidden; }
.row { display: grid; grid-template-columns: 1fr 110px 150px 44px; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row.head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; padding-top: 11px; padding-bottom: 11px; background: rgba(255, 255, 255, .025); }
.row:not(.head):hover { background: rgba(255, 255, 255, .03); }
.row .name { font-family: var(--mono); font-size: 13px; word-break: break-all; display: flex; align-items: center; gap: 10px; }
.row .muted { color: var(--muted); }
.row.backup { grid-template-columns: 1fr 110px 150px 100px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.progress { height: 8px; background: rgba(255, 255, 255, .08); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }

/* ---------- модалки / тосты / трей ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4, 6, 10, .65); backdrop-filter: blur(5px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 480px; padding: 22px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: pop .18s; }
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal .body { color: #c3c9d8; line-height: 1.55; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.pick { max-height: 260px; overflow-y: auto; margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; }
.pick label { display: flex; gap: 10px; align-items: center; padding: 9px 12px; cursor: pointer; font-family: var(--mono); font-size: 12.5px; border-bottom: 1px solid var(--border); word-break: break-all; }
.pick label:last-child { border-bottom: 0; }
.pick label:hover { background: var(--surface); }
.pick input { accent-color: var(--accent); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }

.toasts { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); box-shadow: 0 12px 40px rgba(0, 0, 0, .5); max-width: 360px; animation: pop .2s; border-left: 3px solid var(--ok); }
.toast.error { border-left-color: var(--err); }

.tray { position: fixed; right: 18px; bottom: 18px; width: 320px; display: flex; flex-direction: column; gap: 10px; z-index: 70; }
.tray-item { padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.tray-item .t { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.tray-item .t span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- логин ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; padding: 32px 28px; }
.login .brand { padding-bottom: 8px; justify-content: center; flex-direction: column; text-align: center; }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.login .err { color: var(--err); min-height: 18px; font-size: 13px; text-align: center; }

.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }

/* ---------- мобильная версия ---------- */
@media (max-width: 820px) {
  .app { flex-direction: column-reverse; }
  .sidebar { width: 100%; flex-direction: row; padding: 8px; border-right: 0; border-top: 1px solid var(--border); gap: 4px; }
  .brand, .status-pill span, .side-foot .btn span { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 4px; font-size: 11px; padding: 8px 10px; }
  .nav a.active { box-shadow: none; }
  .side-foot { margin: 0; flex-direction: row; align-items: center; }
  .status-pill { padding: 10px; }
  .view { padding: 16px; }
  .banner { padding: 10px 16px; }
  .row { grid-template-columns: 1fr 80px 40px; }
  .row .date { display: none; }
  .row.backup { grid-template-columns: 1fr 80px 96px; }
  .tray { width: calc(100% - 36px); bottom: 84px; }
}
