:root {
  --bg: #0b1220;
  --panel: #111a2e;
  --panel-2: #16213a;
  --text: #f3f7ff;
  --muted: #a9b7d3;
  --line: rgba(255, 255, 255, 0.12);
  --brand: #6bb6ff;
  --brand-strong: #4d9cff;
  --success: #39c27f;
  --warning: #f3b544;
  --danger: #ef6b6b;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --radius-sm: 12px;
  --font-main: "Lama Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #09101d 0%, #0b1220 100%);
  color: var(--text);
  font-family: var(--font-main);
  min-height: 100%;
}

body {
  line-height: 1.5;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

.container {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(9, 16, 29, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 78px;
  padding: 12px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px;
}

.brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.nav button {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid transparent;
  transition: 0.18s ease;
}

.nav button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav button.active {
  background: rgba(107, 182, 255, 0.16);
  border-color: rgba(107, 182, 255, 0.34);
  color: #dff0ff;
}

.page {
  padding: 22px 0 40px;
}

.hero {
  display: grid;
  gap: 18px;
}

.notice {
  background: linear-gradient(180deg, rgba(107, 182, 255, 0.12), rgba(107, 182, 255, 0.05));
  border: 1px solid rgba(107, 182, 255, 0.2);
  color: #dceeff;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-body {
  padding: 18px;
}

.card-block {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
}

.card-block h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.card-block p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 800;
}

.section-subtitle {
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.agent-detail {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.kv-list {
  display: grid;
  gap: 10px;
}

.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.kv span:first-child {
  color: var(--muted);
  font-size: 14px;
}

.kv span:last-child {
  font-size: 14px;
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-ready {
  background: rgba(57, 194, 127, 0.16);
  color: #bff3d6;
  border: 1px solid rgba(57, 194, 127, 0.28);
}

.status-limited {
  background: rgba(243, 181, 68, 0.16);
  color: #ffe4ab;
  border: 1px solid rgba(243, 181, 68, 0.28);
}

.status-restricted {
  background: rgba(239, 107, 107, 0.16);
  color: #ffd0d0;
  border: 1px solid rgba(239, 107, 107, 0.28);
}

.status-setup {
  background: rgba(255, 255, 255, 0.08);
  color: #dfe7f8;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: 0.18s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: rgba(107, 182, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(107, 182, 255, 0.12);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #dce7fb;
  font-size: 13px;
  font-weight: 700;
}

.login-form-block select,
select {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.login-form-block select option,
select option {
  background: #ffffff;
  color: #000000;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: #eaf2ff;
  font-size: 13px;
}

.open-btn,
.primary-btn,
.secondary-btn {
  border-radius: 12px;
  padding: 11px 16px;
  transition: 0.18s ease;
}

.open-btn,
.primary-btn {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #07111f;
  font-weight: 700;
}

.open-btn:hover,
.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.chat-shell {
  min-height: 760px;
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.chat-header h2 {
  margin: 0;
  font-size: 21px;
}

.chat-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.chat-messages {
  padding: 18px;
  display: grid;
  gap: 12px;
  max-height: 420px;
  overflow: auto;
  border-bottom: 1px solid var(--line);
}

.msg {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  justify-self: end;
  background: rgba(107, 182, 255, 0.16);
  border: 1px solid rgba(107, 182, 255, 0.28);
}

.msg.agent {
  justify-self: start;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.chat-input {
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.chat-input textarea {
  min-height: 64px;
}

.chat-input button {
  align-self: stretch;
  min-width: 120px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #07111f;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.list-stack {
  display: grid;
  gap: 12px;
}

.log-item {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px;
}

.log-item h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.log-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  background: rgba(255, 255, 255, 0.03);
}

thead {
  background: rgba(255, 255, 255, 0.06);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  color: #eaf3ff;
  font-weight: 800;
}

td {
  color: var(--muted);
}

.legend-list {
  display: grid;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(540px, 100%);
  background: linear-gradient(180deg, rgba(17, 26, 46, 0.98), rgba(22, 33, 58, 0.98));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 30px 24px;
}

.premium-login-card {
  display: grid;
  gap: 18px;
}

.login-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-logo {
  width: 400px;
  height: 500px;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px;
}

.login-brand-block {
  text-align: center;
}

.login-brand-block h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
}

.login-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form-block {
  display: grid;
  gap: 12px;
}

.login-form-block button {
  padding: 12px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #07111f;
  font-weight: 800;
}

.login-footnote {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.small {
  font-size: 12px;
}

.hierarchy-stack {
  display: grid;
  gap: 18px;
}

.hierarchy-card .card-body {
  padding: 0;
}

.hierarchy-header {
  width: 100%;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hierarchy-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.hierarchy-header-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.hierarchy-chevron {
  font-size: 20px;
  line-height: 1;
  color: var(--brand);
  margin-top: 2px;
}

.hierarchy-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.hierarchy-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.hierarchy-body {
  padding: 0 18px 18px;
  display: grid;
  gap: 10px;
}

.hierarchy-agent-row {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px;
  transition: 0.18s ease;
}

.hierarchy-agent-row:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(107, 182, 255, 0.26);
  transform: translateY(-1px);
}

.hierarchy-agent-main {
  display: grid;
  gap: 6px;
}

.hierarchy-agent-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hierarchy-agent-name {
  font-size: 16px;
  font-weight: 800;
}

.hierarchy-agent-role {
  color: #d9e7ff;
  font-size: 14px;
}

.hierarchy-agent-meta {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .agent-detail {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .grid-2,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .nav {
    justify-content: flex-start;
  }

  .chat-input {
    grid-template-columns: 1fr;
  }

  .container {
    width: min(100% - 20px, 1320px);
  }
}

@media (max-width: 560px) {
  .brand-text h1 {
    font-size: 18px;
  }

  .section-title {
    font-size: 18px;
  }

  .login-card {
    padding: 24px 18px;
  }
}