:root {
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e8edf3;
  --sidebar: #101827;
  --accent: #4f6ef7;
}

body {
  color: var(--ink);
  background: #f6f8fb;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #e5ebff, transparent 44%), #f6f8fb;
}

.login-card {
  width: min(100%, 440px);
  border-radius: 18px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--accent);
  font-size: 18px;
  font-weight: 800;
}

.login-brand-mark {
  width: auto;
  min-height: 56px;
  padding: 0 16px;
  font-size: 22px;
  letter-spacing: -.04em;
  white-space: nowrap;
}

.admin-page {
  min-height: 100vh;
  padding-left: 250px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  display: flex;
  flex-direction: column;
  padding: 25px 17px;
  color: #d7dfed;
  background: var(--sidebar);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 4px 42px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-label {
  padding: 0 10px 10px;
  color: #7e8ba1;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.sidebar .nav-link {
  margin: 2px 0;
  padding: 11px 12px;
  border-radius: 8px;
  color: #acb8ca;
  font-size: 14px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  color: #fff;
  background: #26344a;
}

.sidebar-group {
  margin-top: 5px;
}

.sidebar-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2px 0;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  color: #acb8ca;
  background: transparent;
  font: inherit;
  font-size: 13px;
  text-align: left;
}

.sidebar-group-toggle:hover,
.sidebar-group-toggle.active {
  color: #fff;
  background: #1b2739;
}

.sidebar-chevron {
  width: 7px;
  height: 7px;
  margin: -4px 2px 0 10px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform .15s ease;
}

.sidebar-group-toggle[aria-expanded="true"] .sidebar-chevron {
  margin-top: 4px;
  transform: rotate(225deg);
}

.sidebar-subnav {
  padding-left: 10px;
}

.sidebar-subnav .nav-link {
  padding: 9px 12px;
  font-size: 13px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px 0;
  border-top: 1px solid #293448;
  color: #7e8ba1;
  font-size: 12px;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.content-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 34px;
}

.analysis-content {
  min-height: 120px;
  overflow-wrap: anywhere;
}

.analysis-content > :last-child {
  margin-bottom: 0;
}

.analysis-content .analysis-heading {
  margin: 1.25rem 0 .75rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.analysis-content .analysis-heading:first-child {
  margin-top: 0;
}

.analysis-content .analysis-table {
  margin-bottom: 1rem;
}

.analysis-content .analysis-quote {
  margin: 0 0 1rem;
  padding: .5rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  background: #f8faff;
}

.analysis-content .analysis-quote p:last-child {
  margin-bottom: 0;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  min-height: 145px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px #1e293b08;
}

.stat-card span {
  color: var(--muted);
  font-size: 14px;
}

.stat-card strong {
  font-size: 34px;
  line-height: 1;
}

.table > :not(caption) > * > * {
  padding: 15px 17px;
  border-color: var(--line);
}

.table thead th {
  color: var(--muted);
  background: #fbfcfe;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.table td {
  font-size: 13px;
}

.permission-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  max-height: 290px;
  overflow-y: auto;
}

.permission-option {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.company-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.company-profile-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.company-profile-item dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.company-profile-item dd {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 13px;
}

.internet-results {
  display: grid;
  gap: 12px;
}

.internet-result-card {
  min-width: 0;
}

.internet-result-card a {
  overflow-wrap: anywhere;
}

.internet-history-card > summary {
  cursor: pointer;
  overflow-wrap: anywhere;
}

.agent-conversation {
  min-height: 320px;
  max-height: 540px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fbfd;
}

.agent-turn {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.agent-turn:last-child {
  margin-bottom: 0;
}

.agent-turn-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fbfcfe;
  cursor: pointer;
  font-size: 12px;
  list-style: none;
}

.agent-turn-summary::-webkit-details-marker {
  display: none;
}

.agent-turn-summary::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s ease;
}

.agent-turn[open] .agent-turn-summary::before {
  transform: rotate(45deg);
}

.agent-turn-index,
.agent-turn-time {
  flex: 0 0 auto;
  color: var(--muted);
}

.agent-turn-index {
  font-weight: 600;
}

.agent-turn-preview {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-turn-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.agent-message {
  max-width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.agent-message-user {
  max-width: 88%;
  margin-left: auto;
  background: #eef2ff;
}

.agent-message-assistant {
  border: 1px solid var(--line);
  background: #f7f9fc;
}

.agent-message-role {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}

.agent-message-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.agent-tool-steps > summary {
  cursor: pointer;
}

.agent-tool-result {
  max-height: 220px;
  margin: 0;
  padding: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.agent-empty {
  font-size: 13px;
}

@media (max-width: 760px) {
  .admin-page {
    padding-left: 0;
    padding-top: 62px;
  }

  .sidebar {
    inset: 0 0 auto;
    width: auto;
    height: 62px;
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    overflow-x: auto;
  }

  .sidebar-brand {
    flex: 0 0 auto;
    margin: 0 12px 0 0;
  }

  .sidebar-label,
  .sidebar-footer {
    display: none;
  }

  .sidebar .nav {
    flex-direction: row !important;
    white-space: nowrap;
  }

  .sidebar .nav-link {
    padding: 9px 10px;
    font-size: 12px;
  }

  .sidebar-group {
    position: relative;
    flex: 0 0 auto;
    margin: 0 2px;
  }

  .sidebar-group-toggle {
    width: auto;
    min-height: 42px;
    padding: 8px 10px;
    white-space: nowrap;
    font-size: 12px;
  }

  .sidebar-subnav.show {
    position: fixed;
    z-index: 1050;
    inset: 62px 0 auto;
    display: flex;
    flex-direction: column;
    padding: 8px 12px 12px;
    border-top: 1px solid #293448;
    background: var(--sidebar);
    box-shadow: 0 8px 16px #10182733;
  }

  .sidebar-subnav .nav-link {
    padding: 9px 12px;
  }

  .topbar {
    height: 66px;
    padding: 0 16px;
  }

  .content-wrap {
    padding: 24px 16px;
  }
}
