:root {
  --bg: #0f1115;
  --bg-deep: #080a0e;
  --panel: rgba(28, 32, 40, 0.72);
  --panel-strong: rgba(35, 40, 50, 0.86);
  --panel-soft: rgba(255, 255, 255, 0.055);
  --field: rgba(11, 14, 20, 0.66);
  --field-focus: rgba(16, 22, 31, 0.92);
  --ink: #f4f7fb;
  --muted: #a7b0c0;
  --muted-2: #788394;
  --line: rgba(255, 255, 255, 0.105);
  --line-strong: rgba(255, 255, 255, 0.18);
  --accent: #4dd4ff;
  --accent-strong: #1ea7d6;
  --accent-soft: rgba(77, 212, 255, 0.14);
  --mint: #7cffb2;
  --mint-soft: rgba(124, 255, 178, 0.13);
  --warn: #ffcf70;
  --warn-soft: rgba(255, 207, 112, 0.14);
  --bad: #ff6b6b;
  --bad-soft: rgba(255, 107, 107, 0.14);
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.24);
  --glass-blur: blur(18px) saturate(128%);
  --radius: 14px;
  --radius-sm: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(145deg, rgba(15, 17, 21, 1) 0%, rgba(14, 17, 23, 1) 48%, rgba(8, 10, 14, 1) 100%);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(77, 212, 255, 0.055), transparent 34%, rgba(124, 255, 178, 0.045) 68%, transparent),
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: auto, 44px 44px, 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.22));
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.01) 38%, rgba(0, 0, 0, 0.2));
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.045)),
    rgba(255, 255, 255, 0.06);
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 10px 22px rgba(0, 0, 0, 0.18);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(77, 212, 255, 0.55);
  background:
    linear-gradient(180deg, rgba(77, 212, 255, 0.2), rgba(77, 212, 255, 0.07)),
    rgba(255, 255, 255, 0.075);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 16px 32px rgba(0, 0, 0, 0.26),
    0 0 0 3px rgba(77, 212, 255, 0.08);
}

button:active {
  transform: translateY(0);
}

button.primary {
  border-color: rgba(77, 212, 255, 0.72);
  background:
    linear-gradient(180deg, rgba(77, 212, 255, 0.95), rgba(30, 167, 214, 0.72)),
    var(--accent-strong);
  color: #061018;
  font-weight: 760;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 16px 34px rgba(77, 212, 255, 0.18);
}

button.primary:hover {
  border-color: rgba(124, 255, 178, 0.8);
  background:
    linear-gradient(180deg, rgba(124, 255, 178, 0.95), rgba(77, 212, 255, 0.78)),
    var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 18px 38px rgba(77, 212, 255, 0.25),
    0 0 0 4px rgba(124, 255, 178, 0.09);
}

button.danger {
  border-color: rgba(255, 107, 107, 0.34);
  color: #ffdada;
  background:
    linear-gradient(180deg, rgba(255, 107, 107, 0.17), rgba(255, 107, 107, 0.055)),
    rgba(255, 255, 255, 0.05);
}

button.danger:hover {
  border-color: rgba(255, 107, 107, 0.7);
  background:
    linear-gradient(180deg, rgba(255, 107, 107, 0.28), rgba(255, 107, 107, 0.09)),
    rgba(255, 255, 255, 0.06);
}

button.ghost {
  background: rgba(255, 255, 255, 0.04);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(167, 176, 192, 0.58);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(77, 212, 255, 0.7);
  background: var(--field-focus);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 0 0 4px rgba(77, 212, 255, 0.09);
}

select option {
  background: #151922;
  color: var(--ink);
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--mint);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.label-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

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

.checks label {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.052);
  padding: 10px 11px;
  color: var(--ink);
  font-size: 13px;
}

.checks input {
  width: auto;
  accent-color: var(--accent);
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(460px, 100%);
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 30px;
  backdrop-filter: var(--glass-blur);
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(77, 212, 255, 0.12), transparent 42%, rgba(124, 255, 178, 0.08));
}

.login-panel > * {
  position: relative;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 6vw, 36px);
  letter-spacing: 0;
}

.login-panel p {
  margin: 0 0 22px;
  color: var(--muted);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 278px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    rgba(15, 18, 25, 0.78);
  color: var(--ink);
  border-right: 1px solid var(--line);
  box-shadow: 20px 0 60px rgba(0, 0, 0, 0.22);
  backdrop-filter: var(--glass-blur);
  padding: 18px 14px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
}

.brand {
  position: relative;
  padding: 8px 10px 18px;
  border-bottom: 1px solid var(--line);
}

.brand::before {
  content: "";
  display: inline-block;
  width: 38px;
  height: 38px;
  margin-right: 10px;
  vertical-align: middle;
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(77, 212, 255, 0.9), rgba(124, 255, 178, 0.75)),
    var(--accent);
  box-shadow: 0 0 26px rgba(77, 212, 255, 0.28);
}

.brand strong {
  display: inline-block;
  vertical-align: middle;
  font-size: 18px;
  letter-spacing: 0;
}

.brand span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 7px;
  align-content: start;
}

.nav button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  background: rgba(255, 255, 255, 0.038);
  color: var(--muted);
  border-color: transparent;
  border-radius: 12px;
  padding: 11px 12px;
  box-shadow: none;
}

.nav button.active,
.nav button:hover {
  color: var(--ink);
  border-color: rgba(77, 212, 255, 0.34);
  background:
    linear-gradient(180deg, rgba(77, 212, 255, 0.16), rgba(77, 212, 255, 0.045)),
    rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 12px 24px rgba(0, 0, 0, 0.2);
}

.nav button.active {
  border-color: rgba(124, 255, 178, 0.42);
}

.userbox {
  border-top: 1px solid var(--line);
  padding: 14px 8px 0;
  display: grid;
  gap: 10px;
}

.userbox strong {
  color: var(--ink);
}

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

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  max-width: 780px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.metric,
.item,
.messages,
.table,
.empty,
.notice,
.error {
  backdrop-filter: var(--glass-blur);
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.065), transparent 46%, rgba(77, 212, 255, 0.035));
}

.panel > * {
  position: relative;
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
  font-size: 17px;
  letter-spacing: 0;
}

.metric {
  background:
    linear-gradient(145deg, rgba(77, 212, 255, 0.09), rgba(255, 255, 255, 0.045)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  min-height: 104px;
}

.metric strong {
  display: block;
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1;
  color: var(--ink);
}

.metric span {
  display: block;
  margin-top: 9px;
  color: var(--muted);
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.032)),
    rgba(255, 255, 255, 0.045);
  padding: 13px;
  display: grid;
  gap: 9px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.item-title {
  font-weight: 780;
  color: var(--ink);
}

.item-meta {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.item-meta span {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.035);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(124, 255, 178, 0.22);
  background: var(--mint-soft);
  color: #c7ffdc;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.pill.warn {
  border-color: rgba(255, 207, 112, 0.28);
  background: var(--warn-soft);
  color: #ffe2a3;
}

.pill.bad {
  border-color: rgba(255, 107, 107, 0.28);
  background: var(--bad-soft);
  color: #ffd0d0;
}

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

.form-grid {
  display: grid;
  gap: 13px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chat {
  height: calc(100vh - 214px);
  min-height: 460px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 13px;
}

.messages {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)),
    rgba(9, 12, 18, 0.62);
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 11px;
  box-shadow: var(--shadow-soft);
}

.message {
  max-width: 78%;
  padding: 11px 13px;
  border-radius: 14px;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
}

.message.user {
  justify-self: end;
  border-color: rgba(77, 212, 255, 0.35);
  background:
    linear-gradient(180deg, rgba(77, 212, 255, 0.36), rgba(30, 167, 214, 0.18)),
    rgba(77, 212, 255, 0.11);
  color: var(--ink);
}

.message.assistant {
  justify-self: start;
  border-color: rgba(124, 255, 178, 0.2);
  background:
    linear-gradient(180deg, rgba(124, 255, 178, 0.13), rgba(255, 255, 255, 0.045)),
    rgba(255, 255, 255, 0.045);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.chat-form button {
  min-width: 132px;
}

.empty {
  color: var(--muted);
  padding: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.table th,
.table td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: top;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.notice {
  background: var(--warn-soft);
  border: 1px solid rgba(255, 207, 112, 0.2);
  color: #ffe7b4;
  border-radius: var(--radius-sm);
  padding: 12px;
}

.error {
  background: var(--bad-soft);
  border: 1px solid rgba(255, 107, 107, 0.24);
  color: #ffd6d6;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}

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

.split > * {
  flex: 1;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (min-width: 981px) and (max-width: 1280px) {
  .shell {
    grid-template-columns: 236px 1fr;
  }

  .main {
    padding: 22px;
  }

  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    max-height: 44vh;
    overflow: auto;
    grid-template-rows: auto auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 4px 8px 12px;
  }

  .brand::before {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  .brand span {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(128px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }

  .nav button {
    min-width: 128px;
    scroll-snap-align: start;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
  }

  .userbox {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.cols-2,
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .chat {
    height: auto;
    min-height: calc(100vh - 240px);
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-form button {
    width: 100%;
  }

  .message {
    max-width: 92%;
  }

  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  button {
    width: 100%;
  }

  .login {
    padding: 14px;
  }

  .login-panel {
    padding: 22px;
    border-radius: 16px;
  }

  .sidebar {
    max-height: 48vh;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(132px, 1fr));
  }

  .main {
    padding: 14px;
  }

  .topbar {
    margin-bottom: 14px;
  }

  .grid,
  .list,
  .form-grid {
    gap: 11px;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: 1fr;
  }

  .panel,
  .metric,
  .item {
    padding: 14px;
  }

  .item-head {
    display: grid;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .message {
    max-width: 100%;
  }

  .messages {
    min-height: 360px;
  }
}

@media (max-width: 420px) {
  .nav {
    grid-template-columns: 1fr;
  }

  .metric strong {
    font-size: 28px;
  }

  .topbar h1 {
    font-size: 25px;
  }
}

