:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: #f3f6fc;
  --line: #dde3ef;
  --line-strong: #c6d0e2;
  --ink: #1d2636;
  --muted: #6d7789;
  --brand: #285ff4;
  --brand-soft: #e8efff;
  --success: #0f9d58;
  --warn: #f29900;
  --danger: #d93025;
  --shadow: 0 18px 48px rgba(44, 73, 131, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --font: "Avenir Next", "Segoe UI", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(40, 95, 244, 0.12), transparent 20rem),
    linear-gradient(180deg, #f9fbff 0%, #f4f6fb 100%);
  color: var(--ink);
  font-family: var(--font);
}

body {
  min-height: 100vh;
}

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

.admin-shell {
  min-height: 100vh;
}

.admin-shell.is-hidden {
  display: none;
}

.hidden {
  display: none !important;
}

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

.auth-gate.is-hidden {
  display: none;
}

.auth-stage {
  width: min(560px, calc(100vw - 24px));
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.auth-copy {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

.auth-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 64px rgba(24, 46, 94, 0.14);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(221, 227, 239, 0.8);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), #5f83ff);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-kicker,
.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}

.brand h1,
.hero-card h2,
.card-head h3 {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  font-weight: 700;
}

.topbar-search {
  min-width: 0;
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
}

.search-shell input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
}

.search-icon {
  color: var(--muted);
  font-size: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 24px;
  width: min(1560px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.sidebar {
  position: sticky;
  top: 94px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-block,
.panel-card,
.hero-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.tool-card {
  padding: 24px;
}

.tool-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 12px;
}

.tool-file-drop {
  display: grid;
  gap: 8px;
  padding: 22px;
  border: 1.5px dashed rgba(40, 95, 244, 0.28);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(232, 239, 255, 0.72), rgba(255, 255, 255, 0.88));
  cursor: pointer;
}

.tool-file-title {
  font-size: 18px;
  font-weight: 700;
}

.tool-file-hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.tool-actions {
  margin-top: 18px;
}

.tool-current-file {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(243, 246, 252, 0.72);
}

.tool-current-file img {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  display: block;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.tool-task-list {
  display: grid;
  gap: 14px;
}

.tool-task-list .task-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(243, 246, 252, 0.78);
  padding: 18px;
}

.tool-task-list .task-card.running {
  border-color: rgba(40, 95, 244, 0.28);
}

.tool-task-list .task-card.failed {
  border-color: rgba(217, 48, 37, 0.28);
}

.tool-task-list .task-head,
.tool-task-list .task-meta,
.tool-task-list .task-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.tool-task-list .task-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tool-task-list .task-state {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(29, 38, 54, 0.08);
}

.tool-task-list .task-card.running .task-state {
  background: rgba(40, 95, 244, 0.12);
}

.tool-task-list .task-card.failed .task-state {
  background: rgba(217, 48, 37, 0.12);
}

.tool-task-list .task-meta,
.tool-task-list .task-message {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.tool-task-list .task-links a {
  color: var(--brand);
  text-decoration: none;
}

.ai-profiles-layout {
  align-items: start;
}

.ai-profiles-list {
  display: grid;
  gap: 12px;
}

.ai-profile-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(243, 246, 252, 0.78);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.ai-profile-card:hover {
  transform: translateY(-1px);
  border-color: rgba(40, 95, 244, 0.24);
}

.ai-profile-card.is-active {
  border-color: rgba(40, 95, 244, 0.4);
  box-shadow: 0 16px 32px rgba(40, 95, 244, 0.08);
}

.ai-profile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.ai-profile-card .mono {
  display: block;
  margin-top: 4px;
}

.ai-profile-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ai-profile-card-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.ai-reference-list {
  display: grid;
  gap: 12px;
}

.ai-reference-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(251, 252, 255, 0.9);
}

.ai-reference-preview {
  width: min(240px, 100%);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #eef3ff;
}

.ai-reference-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  background: rgba(243, 246, 252, 0.48);
}

.ai-test-card {
  margin-top: 18px;
}

.ai-test-grid {
  margin-bottom: 12px;
}

.ai-test-results {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.ai-test-result-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(251, 252, 255, 0.9);
}

.ai-test-result-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-test-result-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.ai-test-result-preview {
  display: grid;
  gap: 10px;
}

.ai-test-result-preview img {
  width: min(320px, 100%);
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #eef3ff;
}

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

.ai-test-result-actions a {
  color: var(--brand);
  text-decoration: none;
}

.sidebar-block,
.panel-card {
  border-radius: var(--radius-xl);
}

.hero-card {
  border-radius: 28px;
}

.compose-button,
.nav-item,
.primary-button,
.ghost-button,
.icon-button,
.small-button,
.text-link {
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.compose-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 18px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(54, 83, 150, 0.12);
  color: var(--ink);
  font-weight: 700;
}

.compose-plus {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fbbc04, #ea4335, #34a853, #4285f4);
  color: #fff;
  font-weight: 700;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  background: transparent;
  color: #4e596d;
  font-weight: 600;
  text-align: left;
}

.nav-item:hover {
  background: #eef3ff;
}

.nav-item.is-active {
  background: #dce7ff;
  color: #163278;
}

.credentials-card {
  padding: 20px;
}

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

.card-head.compact {
  margin-bottom: 16px;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 18px;
}

.hero-card h2 {
  margin-top: 6px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.02;
}

.hero-copy,
.section-note,
.hint,
.table-summary {
  color: var(--muted);
}

.hero-copy {
  max-width: 680px;
  margin-top: 12px;
  line-height: 1.65;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
  min-width: 260px;
}

.hero-meta-item {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #f6f8fd);
}

.hero-meta-item span {
  color: var(--muted);
  font-size: 12px;
}

.hero-meta-item strong {
  font-size: 20px;
}

.content {
  min-width: 0;
}

.section-block {
  margin-bottom: 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 255, 0.92));
}

.metric-card.clickable {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.metric-card.clickable:hover {
  transform: translateY(-2px);
  border-color: rgba(40, 95, 244, 0.28);
  box-shadow: 0 18px 40px rgba(44, 73, 131, 0.12);
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -10% -30% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(40, 95, 244, 0.14), transparent 70%);
}

.metric-label {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  font-size: 30px;
  font-weight: 800;
}

.metric-helper {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

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

.panel-card {
  padding: 22px;
}

.section-inline-note {
  margin: -4px 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(40, 95, 244, 0.14);
  border-radius: 14px;
  background: rgba(40, 95, 244, 0.05);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.advanced-fieldset {
  margin: 4px 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #fafcff);
}

.advanced-fieldset summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 700;
  color: #2a3655;
  user-select: none;
}

.advanced-fieldset-body {
  padding: 0 16px 16px;
}

.advanced-fieldset .section-inline-note {
  margin-bottom: 0;
}

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

.token-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: #1f4bd8;
  font-size: 13px;
  font-weight: 600;
}

.token-pill.warn {
  background: rgba(242, 153, 0, 0.16);
  color: #8b5c02;
}

.table-helper {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.table-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: #fbfcff;
}

.field textarea {
  min-height: 140px;
  padding: 14px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-shell:focus-within {
  border-color: rgba(40, 95, 244, 0.35);
  box-shadow: 0 0 0 4px rgba(40, 95, 244, 0.08);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.toggle-field input {
  width: 18px;
  height: 18px;
}

.announcement-current-banner {
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(15, 157, 88, 0.18);
  border-radius: 16px;
  background: rgba(15, 157, 88, 0.08);
  color: #116f41;
  line-height: 1.7;
}

.announcement-list {
  display: grid;
  gap: 12px;
}

.announcement-item {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 249, 255, 0.92));
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.announcement-item:hover {
  transform: translateY(-1px);
  border-color: rgba(40, 95, 244, 0.28);
  box-shadow: 0 12px 28px rgba(40, 95, 244, 0.08);
}

.announcement-item.is-active {
  border-color: rgba(40, 95, 244, 0.42);
  box-shadow: 0 12px 28px rgba(40, 95, 244, 0.14);
}

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

.announcement-item-head strong {
  font-size: 16px;
}

.announcement-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.announcement-content-preview {
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.primary-button,
.ghost-button,
.small-button,
.text-link,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), #3c71ff);
  color: #fff;
  box-shadow: 0 10px 24px rgba(40, 95, 244, 0.22);
}

.primary-button:hover,
.ghost-button:hover,
.small-button:hover,
.text-link:hover {
  transform: translateY(-1px);
}

.ghost-button,
.small-button,
.text-link {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary-button.small,
.ghost-button.small,
.small-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13px;
}

.hint {
  margin-top: 12px;
  line-height: 1.6;
}

.hint.error {
  color: var(--danger);
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfcff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  background: #f3f6fc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #edf1f8;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

tbody tr:hover {
  background: rgba(40, 95, 244, 0.04);
}

tbody tr:last-child td {
  border-bottom: none;
}

.empty-cell {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.mono {
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.ok {
  background: rgba(15, 157, 88, 0.12);
  color: #0d7a47;
}

.status-badge.warn {
  background: rgba(242, 153, 0, 0.14);
  color: #935f00;
}

.status-badge.danger {
  background: rgba(217, 48, 37, 0.12);
  color: #af261d;
}

.detail-preview-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.detail-preview-thumb,
.detail-avatar-thumb {
  display: block;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #eef3ff;
  object-fit: cover;
}

.detail-avatar-thumb {
  width: 42px;
  height: 42px;
  border-radius: 999px;
}

.detail-stack {
  display: grid;
  gap: 4px;
}

.detail-inline-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.pager-meta {
  color: var(--muted);
  font-size: 13px;
}

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

.pager button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.blocks-layout {
  align-items: start;
}

.text-link {
  min-height: 42px;
  color: var(--ink);
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  background: #fff;
  border: 1px solid var(--line);
  color: #51607b;
}

.icon-button span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 2px 0;
  background: #51607b;
}

.mobile-only {
  display: none;
}

.hidden-section {
  display: none;
}

.auth-required {
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(217, 48, 37, 0.16);
  border-radius: 18px;
  background: rgba(217, 48, 37, 0.06);
  color: #8f241c;
}

.data-source-warning {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px dashed rgba(242, 153, 0, 0.42);
  border-radius: 16px;
  background: rgba(242, 153, 0, 0.08);
  color: #8f6200;
  line-height: 1.6;
}

@media (max-width: 1220px) {
  .topbar {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

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

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
    width: min(100vw - 24px, 1560px);
  }

  .sidebar {
    position: static;
    display: none;
  }

  .sidebar.is-open {
    display: flex;
  }

  .mobile-only {
    display: inline-flex;
  }

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

  .topbar-actions {
    justify-content: flex-start;
  }

  .hero-card {
    flex-direction: column;
  }

  .hero-meta,
  .stat-grid,
  .split-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
