/* LS MCP Gateway — админ-панель в духе Apple Design Awards:
   чёрный фон, светящиеся орбы, стекло, крупная типографика, градиентные акценты. */

:root {
  --bg: #050507;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.085);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --text-2: rgba(245, 245, 247, 0.6);
  --text-3: rgba(245, 245, 247, 0.36);
  --accent: #5e8eff;
  --grad: linear-gradient(135deg, #ff5fa2 0%, #b36bff 34%, #5e8eff 66%, #3fd2ff 100%);
  --good: #32d74b;
  --warn: #ffd60a;
  --serious: #ff9f0a;
  --crit: #ff453a;
  --radius: 22px;
  --radius-s: 13px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ---------- светящиеся орбы фона ---------- */

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}
.orb-a { width: 560px; height: 560px; left: -180px; top: -160px;
         background: radial-gradient(circle, #b36bff 0%, #ff5fa2 70%, transparent 100%); }
.orb-b { width: 640px; height: 640px; right: -220px; bottom: -240px;
         background: radial-gradient(circle, #1d5fff 0%, #3fd2ff 75%, transparent 100%); }
.orb-c { width: 380px; height: 380px; right: 18%; top: -200px;
         background: radial-gradient(circle, #5e3bff 0%, transparent 75%); opacity: .3; }

/* ---------- стекло ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
}

/* ---------- каркас ---------- */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 22px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 22px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px;
  height: calc(100vh - 44px);
}

.brand { display: flex; gap: 12px; align-items: center; padding: 2px 8px; }
.brand-mark, .login-mark {
  width: 40px; height: 40px; flex: none;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 7px, #000 7px 10px, transparent 10px),
    var(--grad);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; line-height: 1.15; }

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--text); color: #0b0b0f; font-weight: 600; }

.sidebar-foot { display: flex; flex-direction: column; gap: 10px; padding: 0 8px; }
.me-chip { font-size: 12.5px; color: var(--text-2); word-break: break-all; }

.main { min-width: 0; padding-bottom: 60px; }

/* ---------- типографика страниц ---------- */

.view { animation: rise .35s cubic-bezier(.2,.7,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.page-head { margin: 26px 6px 24px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title {
  margin: 0;
  font-size: clamp(34px, 4.5vw, 52px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.02;
}
.page-sub { margin: 10px 0 0; color: var(--text-2); font-size: 15px; max-width: 640px; }

/* ---------- кнопки ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
  color: var(--text);
  background: var(--surface-2);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); opacity: .85; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.btn-primary { background: var(--text); color: #0b0b0f; }
.btn-accent { background: var(--grad); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border-strong); }
.btn-danger { background: rgba(255, 69, 58, 0.16); color: #ff8d85; }
.btn-danger:hover { background: rgba(255, 69, 58, 0.26); }
.btn-small { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- формы ---------- */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--text-2); font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="number"], select, textarea {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 11px 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 142, 255, 0.25);
}
select { appearance: none; }
option { background: #16161d; color: var(--text); }

.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.form-error { color: #ff8d85; font-size: 13.5px; margin-bottom: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---------- логин ---------- */

.login-screen {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card { width: 400px; max-width: 94vw; padding: 36px 34px 26px; text-align: center; }
.login-card .login-mark { margin: 0 auto 18px; width: 52px; height: 52px; border-radius: 15px; }
.login-title { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; margin: 0 0 6px; }
.login-sub { color: var(--text-2); margin: 0 0 26px; font-size: 14.5px; }
.login-card form { text-align: left; }
.login-foot { color: var(--text-3); font-size: 12.5px; margin: 22px 0 0; }

/* ---------- плитки статистики ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.tile { padding: 20px 22px 18px; transition: transform .2s ease; }
.tile:hover { transform: translateY(-2px); }
.tile-value {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.tile-value.is-warn { color: var(--serious); }
.tile-value.is-crit { color: var(--crit); }
.tile-label { color: var(--text-2); font-size: 13px; margin-top: 7px; font-weight: 500; }

/* ---------- секции и списки ---------- */

.section { padding: 24px; margin-bottom: 20px; }
.section-title { margin: 0 0 4px; font-size: 19px; font-weight: 650; letter-spacing: -0.015em; }
.section-sub { color: var(--text-2); font-size: 13.5px; margin: 0 0 18px; }

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}
.list-row:first-child { border-top: none; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 14.5px; }
.list-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.list-actions { display: flex; gap: 8px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}
.entity-card { padding: 22px; display: flex; flex-direction: column; gap: 12px; transition: transform .2s ease; }
.entity-card:hover { transform: translateY(-2px); }
.entity-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.entity-name { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.entity-desc { color: var(--text-2); font-size: 13.5px; }
.entity-meta { color: var(--text-3); font-size: 12.5px; font-family: var(--mono); overflow-wrap: anywhere; }
.entity-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* ---------- чипы и статусы ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok      { background: rgba(50, 215, 75, 0.14);  color: #7ee89b; }
.chip.err     { background: rgba(255, 69, 58, 0.14);  color: #ff9d96; }
.chip.denied  { background: rgba(255, 159, 10, 0.14); color: #ffc46e; }
.chip.info    { background: rgba(94, 142, 255, 0.16); color: #a4c0ff; }
.chip.neutral { background: var(--surface-2); color: var(--text-2); }
.chip.admin   { background: rgba(179, 107, 255, 0.18); color: #d2b3ff; }

.tool-chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 7px;
  background: rgba(94, 142, 255, 0.12);
  color: #a4c0ff;
  margin: 2px 4px 2px 0;
}
.tool-chip.all { background: rgba(50, 215, 75, 0.12); color: #7ee89b; }

/* ---------- график ---------- */

.chart-wrap { position: relative; }
.chart-svg { display: block; width: 100%; height: 180px; }
.chart-bar { fill: #5e8eff; }
.chart-bar-hit { fill: transparent; cursor: default; }
.chart-bar-hit:hover + .chart-bar, .chart-bar.hot { fill: #8fb0ff; }
.chart-grid-line { stroke: rgba(255, 255, 255, 0.07); stroke-width: 1; }
.chart-axis-label { fill: rgba(245, 245, 247, 0.4); font-size: 11px; font-family: var(--font); }

.chart-tooltip {
  position: fixed;
  z-index: 60;
  background: rgba(22, 22, 29, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 12.5px;
  pointer-events: none;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
.chart-tooltip b { font-variant-numeric: tabular-nums; }

/* ---------- аудит ---------- */

.audit-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.audit-filters select, .audit-filters input { width: auto; min-width: 150px; }

.audit-row { display: flex; gap: 12px; align-items: baseline; padding: 11px 6px;
             border-top: 1px solid rgba(255,255,255,.055); font-size: 13.5px; }
.audit-row:first-child { border-top: none; }
.audit-time { color: var(--text-3); font-family: var(--mono); font-size: 12px; flex: none; width: 118px; }
.audit-body { flex: 1; min-width: 0; }
.audit-line { overflow-wrap: anywhere; }
.audit-line .who { font-weight: 600; }
.audit-line .what { color: var(--text-2); }
.audit-meta { color: var(--text-3); font-size: 12px; font-family: var(--mono); margin-top: 2px; }

/* ---------- модалки ---------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(14px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 560px; max-width: 96vw;
  max-height: 88vh; overflow: auto;
  padding: 28px;
  animation: pop .25s cubic-bezier(.2,.8,.25,1);
  background: rgba(24, 24, 31, 0.92);
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal-title { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.modal-sub { color: var(--text-2); font-size: 13.5px; margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.secret-reveal {
  font-family: var(--mono);
  font-size: 16px;
  background: rgba(50, 215, 75, 0.1);
  border: 1px solid rgba(50, 215, 75, 0.3);
  border-radius: var(--radius-s);
  padding: 14px;
  text-align: center;
  user-select: all;
  overflow-wrap: anywhere;
}

/* ---------- гранты в модалке роли ---------- */

.grant-block { border: 1px solid var(--border); border-radius: var(--radius-s); padding: 14px 16px; margin-bottom: 12px; }
.grant-head { display: flex; align-items: center; gap: 10px; }
.grant-head .check { margin: 0; flex: 1; }
.grant-tools { margin-top: 12px; padding-left: 27px; display: none; }
.grant-block.open .grant-tools { display: block; }
.grant-mode { display: flex; gap: 14px; margin-bottom: 10px; font-size: 13.5px; }
.grant-mode label { display: flex; gap: 6px; align-items: center; cursor: pointer; color: var(--text-2); }
.grant-mode input { accent-color: var(--accent); }
.tools-box { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tools-box label { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono);
                   font-size: 12px; background: var(--surface); padding: 5px 10px;
                   border-radius: 8px; cursor: pointer; }
.tools-box input { accent-color: var(--accent); }
.tools-manual { margin-top: 10px; }

/* ---------- тосты ---------- */

.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 70; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: rgba(24, 24, 31, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 14px;
  animation: rise .3s ease;
  max-width: 380px;
  backdrop-filter: blur(10px);
}
.toast.err { border-color: rgba(255, 69, 58, 0.5); }

.empty { color: var(--text-3); text-align: center; padding: 34px 0; font-size: 14px; }

.copy-line { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.copy-line code { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--text-2);
                  background: rgba(255,255,255,.05); padding: 7px 10px; border-radius: 8px;
                  overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .form-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
