:root {
  --bg-root: #141414;
  --bg-shell: #181818;
  --bg-panel: #1e1e1e;
  --bg-raised: #232323;
  --bg-control: #303030;
  --bg-hover: #424351;
  --border: #3d3d3d;
  --border-strong: #424242;
  --text: #ffffffd9;
  --text-strong: #ffffff;
  --text-muted: #a8a8a8;
  --text-dim: #80868b;
  --blue: #1677ff;
  --blue-hover: #4096ff;
  --teal: #27d0bd;
  --amber: #dca642;
  --green: #50c878;
  --warning: #faad14;
  --error: #ff4d4f;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg-root);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5714;
}

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

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 0%, #046264 0%, #0e4f5d 22%, #1d3d4e 46%, #212c3a 70%, #1d1d25 100%);
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: rgba(24, 24, 24, 0.94);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.login-mark,
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #275282;
  border-radius: var(--radius);
  background: #1f1f1f;
  color: var(--text-strong);
  font-family: var(--mono);
  font-weight: 700;
}

.login-title {
  margin: 18px 0 4px;
  color: var(--text-strong);
  font-size: 24px;
  font-weight: 600;
}

.login-subtitle,
.muted {
  color: var(--text-muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  background: var(--bg-root);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-shell);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-title {
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 600;
}

.brand-subtitle {
  color: var(--text-dim);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 12px 8px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-button:hover {
  background: var(--bg-hover);
  color: var(--text-strong);
}

.nav-button.active {
  background: #275282;
  color: var(--text-strong);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid var(--border);
}

.main {
  min-width: 0;
  background: var(--bg-root);
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-shell);
}

.page-title {
  margin: 0;
  color: var(--text-strong);
  font-size: 20px;
  font-weight: 600;
}

.page-description {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.content {
  padding: 24px;
}

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

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

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

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.wide-panel {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  margin: 0;
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 600;
}

.panel-note {
  margin: 3px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}

.panel-body {
  padding: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.metric {
  min-height: 92px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.metric-label {
  color: var(--text-dim);
  font-size: 12px;
}

.metric-value {
  margin-top: 10px;
  color: var(--text-strong);
  font-family: var(--mono);
  font-size: 28px;
  line-height: 1;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

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

.field label {
  color: var(--text-muted);
  font-size: 12px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-control);
  color: var(--text);
  padding: 6px 10px;
  outline: none;
}

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

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.16);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  align-items: center;
  gap: 10px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn-row.compact {
  flex-wrap: nowrap;
  gap: 6px;
}

.btn {
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-control);
  color: var(--text);
  padding: 6px 13px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  border-color: var(--blue-hover);
  color: var(--text-strong);
}

.btn.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.btn.primary:hover {
  border-color: var(--blue-hover);
  background: var(--blue-hover);
}

.btn.ghost {
  background: transparent;
}

.btn.danger:hover {
  border-color: var(--error);
  color: var(--error);
}

.table-wrap {
  overflow: auto;
}

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

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

.table th {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}

.table td {
  color: var(--text);
}

.mono {
  font-family: var(--mono);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 8px;
  color: var(--text-muted);
  background: var(--bg-raised);
  font-size: 12px;
}

.tag.blue {
  color: #91caff;
  border-color: #275282;
  background: rgba(22, 119, 255, 0.16);
}

.tag.green {
  color: #8fe3ad;
  border-color: rgba(80, 200, 120, 0.5);
  background: rgba(80, 200, 120, 0.14);
}

.tag.warning {
  color: #ffd666;
  border-color: rgba(250, 173, 20, 0.5);
  background: rgba(250, 173, 20, 0.12);
}

.tag.error {
  color: #ffccc7;
  border-color: rgba(255, 77, 79, 0.5);
  background: rgba(255, 77, 79, 0.12);
}

.notice {
  border: 1px solid #275282;
  border-radius: var(--radius);
  background: rgba(22, 119, 255, 0.12);
  padding: 12px;
}

.notice.error {
  border-color: rgba(255, 77, 79, 0.5);
  background: rgba(255, 77, 79, 0.1);
  color: #ffccc7;
}

.secret-box {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid #275282;
  border-radius: var(--radius);
  background: #181f2a;
  padding: 12px;
}

.secret-value {
  overflow-wrap: anywhere;
  color: #91caff;
  font-family: var(--mono);
  font-size: 12px;
}

.search-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 16px;
}

.smart-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
  border: 1px solid #305f5a;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(39, 208, 189, 0.14), rgba(220, 166, 66, 0.08)),
    var(--bg-panel);
  padding: 22px;
}

.smart-hero h2 {
  margin: 4px 0 6px;
  color: var(--text-strong);
  font-size: 26px;
  line-height: 1.15;
}

.smart-hero p {
  max-width: 780px;
  margin: 0;
  color: var(--text-muted);
}

.eyebrow {
  color: var(--teal);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
}

.smart-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.smart-steps span {
  border: 1px solid rgba(39, 208, 189, 0.38);
  border-radius: 999px;
  background: rgba(39, 208, 189, 0.1);
  color: #9ff4ea;
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 12px;
}

.smart-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(360px, 1.2fr);
  gap: 16px;
}

.smart-query-panel,
.smart-answer-panel,
.smart-records-panel {
  grid-column: 1 / -1;
}

.answer-block {
  min-height: 104px;
  border: 1px solid #305f5a;
  border-radius: var(--radius);
  background: #172320;
  color: var(--text);
  white-space: pre-wrap;
  padding: 14px;
}

.check-row {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.check-row.wide {
  grid-column: 1 / -1;
}

.record-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 540px;
}

.record-fields span {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-muted);
  padding: 2px 8px;
  font-size: 12px;
}

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

.result-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  overflow: hidden;
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.result-title {
  color: var(--text-strong);
  font-weight: 600;
}

.result-text {
  margin: 0;
  padding: 12px;
  color: var(--text);
  white-space: pre-wrap;
}

.debug {
  border-top: 1px solid var(--border);
  background: #181818;
  padding: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  overflow: auto;
}

.api-doc {
  max-width: 1120px;
}

.api-doc-body {
  display: grid;
  gap: 18px;
}

.doc-section {
  display: grid;
  gap: 10px;
}

.doc-section h3 {
  margin: 0;
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 600;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.doc-card {
  display: grid;
  gap: 6px;
  min-height: 78px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 12px;
}

.doc-card code,
.doc-section code {
  color: #91caff;
  font-family: var(--mono);
  font-size: 12px;
}

.doc-label {
  color: var(--text-dim);
  font-size: 12px;
}

.doc-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

.doc-list li + li {
  margin-top: 6px;
}

.table.compact th,
.table.compact td {
  padding: 8px 10px;
}

.empty {
  padding: 20px;
  color: var(--text-dim);
  text-align: center;
}

@media (max-width: 1100px) {
  .app-shell,
  .search-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .metrics,
  .grid.cols-2,
  .grid.cols-3,
  .smart-hero,
  .smart-layout,
  .doc-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
