:root {
  --bg-primary: #07030f;
  --bg-secondary: #120821;
  --bg-terminal: #05020a;
  --bg-input: #1b1030;
  --text-primary: #f2f6ff;
  --text-secondary: #a9bad4;
  --text-muted: #65708a;
  --accent-green: #35ff8a;
  --accent-cyan: #00e5ff;
  --accent-yellow: #ffd166;
  --accent-red: #ff3d81;
  --accent-purple: #bd4cff;
  --border: #35204d;
  --overlay-opacity: 0.16;
  --glass-strong: 0.28;
  --glass-medium: 0.22;
  --glass-soft: 0.16;
  --glass-terminal: 0.18;
  --font-mono: Consolas, "SFMono-Regular", "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

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

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

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(0, 229, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(189, 76, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 80% 10%, rgba(255, 61, 129, 0.08), transparent 30%),
    radial-gradient(circle at 8% 90%, rgba(0, 229, 255, 0.07), transparent 34%),
    rgba(7, 3, 15, var(--overlay-opacity));
  background-size: 40px 40px, 40px 40px, auto, auto, auto;
  pointer-events: none;
}

.video-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-primary);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden],
.hidden {
  display: none !important;
}

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

.login-console {
  width: min(100%, 720px);
  padding: 22px;
  border: 1px solid rgba(0, 229, 255, 0.45);
  background: rgba(18, 8, 33, var(--glass-strong));
  backdrop-filter: blur(5px) saturate(1.05);
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.1), inset 0 0 18px rgba(189, 76, 255, 0.04);
}

.login-logo,
.logo {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 700;
}

.login-logo span,
.logo-bracket {
  color: var(--accent-cyan);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.8);
}

.login-logo em,
.logo-version {
  margin-left: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: normal;
}

.ascii {
  margin: 18px 0;
  color: var(--accent-cyan);
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.55);
  font-size: 12px;
  line-height: 1.18;
  overflow-x: auto;
}

.ascii.small {
  margin: 0 0 8px;
  font-size: 10px;
}

.key-panel {
  display: grid;
  gap: 12px;
}

label {
  color: var(--accent-purple);
  font-size: 12px;
}

.terminal-input-row,
.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.terminal-input-row span,
.prompt-symbol,
.command-preview span,
.prompt-green {
  color: var(--accent-green);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 39px;
  padding: 9px 12px;
  border: 1px solid rgba(189, 76, 255, 0.38);
  border-radius: 4px;
  background: rgba(27, 16, 48, 0.3);
  color: var(--text-primary);
  outline: none;
}

input:focus {
  border-color: var(--accent-cyan);
}

input::placeholder {
  color: var(--text-muted);
}

input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-execute,
.btn-help,
.btn-ghost,
.btn-secondary,
.btn-clear,
.btn-action,
.mode-tab,
.btn-close-guide {
  border-radius: 4px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-execute {
  min-height: 39px;
  padding: 9px 22px;
  border: 1px solid var(--accent-green);
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  color: #030710;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.btn-execute:hover {
  background: linear-gradient(135deg, #7dffb1, #65f1ff);
  box-shadow: 0 0 18px rgba(53, 255, 138, 0.22);
}

.btn-execute.full {
  width: 100%;
}

.btn-help,
.btn-ghost,
.btn-secondary,
.btn-clear,
.btn-action,
.mode-tab,
.btn-close-guide {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
}

.btn-help,
.btn-ghost {
  min-height: 32px;
  padding: 6px 11px;
  font-size: 12px;
}

.btn-help:hover,
.btn-ghost:hover,
.mode-tab:hover,
.btn-action:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-help.danger:hover,
.btn-clear:hover,
.btn-close-guide:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.btn-secondary {
  width: 100%;
  padding: 10px;
  font-size: 12px;
}

.btn-clear {
  padding: 4px 10px;
  font-size: 10px;
}

.btn-action {
  min-height: 32px;
  padding: 6px 12px;
  background: rgba(27, 16, 48, 0.32);
  font-size: 11px;
  font-weight: 700;
}

.message {
  min-height: 22px;
  margin: 0;
  color: var(--accent-red);
  font-size: 12px;
}

.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  min-height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(0, 229, 255, 0.32);
  background: rgba(18, 8, 33, var(--glass-medium));
  backdrop-filter: blur(4px) saturate(1.05);
  box-shadow: 0 1px 12px rgba(0, 229, 255, 0.06);
}

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

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-yellow);
  animation: pulse 1.6s infinite;
}

.status-dot.connected {
  background: var(--accent-green);
  animation: none;
}

.status-dot.error {
  background: var(--accent-red);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.main-layout {
  flex: 1;
  min-height: 0;
  display: flex;
}

.sidebar {
  width: 290px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid rgba(189, 76, 255, 0.28);
  background: rgba(7, 3, 15, var(--glass-medium));
  backdrop-filter: blur(4px) saturate(1.05);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--accent-cyan);
  font-size: 12px;
  font-weight: 800;
}

.sidebar-header span {
  color: var(--accent-green);
}

.module-group {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.group-title {
  padding: 0 16px 8px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.module-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 31px;
  padding: 5px 16px;
  color: var(--text-secondary);
  cursor: pointer;
}

.module-option:hover {
  background: rgba(27, 16, 48, 0.25);
}

.module-option input {
  display: none;
}

.module-option span {
  width: 14px;
  height: 14px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 3px;
  flex: 0 0 auto;
}

.module-option input[type="radio"] + span {
  border-radius: 50%;
}

.module-option input:checked + span {
  border-color: var(--accent-cyan);
  background: var(--accent-cyan);
}

.module-option input:checked + span::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: #05020a;
}

.module-option input[type="radio"]:checked + span::after {
  border-radius: 50%;
}

.module-option strong {
  min-width: 86px;
  color: var(--accent-green);
  font-size: 13px;
  font-weight: 600;
}

.module-option small {
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
}

.container.quick-mode .sidebar {
  display: none;
}

.main-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.top-bar {
  border-bottom: 1px solid rgba(0, 229, 255, 0.26);
  background: rgba(18, 8, 33, var(--glass-soft));
  backdrop-filter: blur(4px) saturate(1.05);
}

.mode-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
}

.mode-tab {
  min-height: 30px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
}

.mode-tab.active {
  border-color: var(--accent-green);
  background: rgba(53, 255, 138, 0.12);
  color: var(--accent-green);
  box-shadow: 0 0 14px rgba(53, 255, 138, 0.12);
}

.input-area {
  padding: 14px 16px;
}

.input-row {
  margin-bottom: 12px;
}

.input-row input {
  flex: 1;
}

.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.container.quick-mode .options-row {
  display: none;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.option-group label {
  color: var(--accent-purple);
}

.option-group input {
  width: 110px;
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.option-group input[type="date"] {
  width: 140px;
}

.command-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  background: rgba(5, 2, 10, var(--glass-terminal));
  backdrop-filter: blur(3px);
}

.command-preview code {
  min-width: 0;
  overflow-x: auto;
  color: var(--accent-yellow);
  font-size: 13px;
  white-space: nowrap;
}

.panels-container {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.35fr);
  gap: 1px;
  overflow: hidden;
  background: rgba(0, 229, 255, 0.12);
}

.panel-box {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(7, 3, 15, var(--glass-soft));
  backdrop-filter: blur(3px) saturate(1.05);
}

.panel-header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(189, 76, 255, 0.28);
  background: rgba(18, 8, 33, var(--glass-medium));
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.terminal {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  background:
    linear-gradient(rgba(0, 229, 255, 0.025) 1px, transparent 1px),
    rgba(5, 2, 10, var(--glass-terminal));
  background-size: 100% 24px;
}

.terminal-content {
  color: var(--text-secondary);
  font-size: 12px;
  word-break: break-word;
}

.terminal-line {
  margin: 0 0 8px;
}

.cmd-input {
  color: var(--text-primary);
}

.cmd-info {
  color: var(--accent-cyan);
}

.cmd-success {
  color: var(--accent-green);
}

.cmd-error {
  color: var(--accent-red);
}

.cmd-warning {
  color: var(--accent-yellow);
}

.results-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 8, 33, var(--glass-medium));
  backdrop-filter: blur(3px);
}

.results-filter {
  flex: 1;
  min-width: 160px;
  min-height: 33px;
  font-size: 12px;
}

.results-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.results-size select {
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(27, 16, 48, 0.28);
  color: var(--text-secondary);
  font: inherit;
  outline: none;
}

.results-count,
.results-info {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.results-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 2, 10, var(--glass-terminal));
}

.results-pages {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding: 1px 0;
}

.page-button {
  min-width: 31px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(27, 16, 48, 0.24);
  color: var(--text-secondary);
  font: inherit;
  font-size: 11px;
}

.page-button.active {
  border-color: var(--accent-green);
  color: var(--accent-green);
  box-shadow: 0 0 12px rgba(53, 255, 138, 0.12);
}

.page-button:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.page-ellipsis {
  color: var(--text-muted);
  font-size: 11px;
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.results-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 34px;
  color: var(--text-muted);
  text-align: center;
}

.empty-icon {
  color: var(--accent-cyan);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
}

.empty-state p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 16px;
}

.empty-state span {
  font-size: 12px;
}

.result-card {
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(189, 76, 255, 0.3);
  border-radius: 4px;
  background: rgba(18, 8, 33, var(--glass-medium));
  backdrop-filter: blur(3px);
}

.result-card:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.1);
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.result-title {
  color: var(--accent-cyan);
  font-weight: 700;
  word-break: break-word;
}

.result-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(27, 16, 48, 0.24);
  color: var(--text-muted);
  font-size: 11px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 7px 12px;
}

.result-field {
  min-width: 0;
  font-size: 12px;
  word-break: break-word;
}

.result-field span {
  color: var(--accent-purple);
}

.result-preview {
  margin-top: 10px;
  padding: 9px;
  overflow: auto;
  border-radius: 3px;
  background: rgba(5, 2, 10, 0.22);
  color: var(--text-secondary);
  font-size: 12px;
  white-space: pre-wrap;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  visibility: hidden;
  background: rgba(0, 0, 0, 0.18);
  opacity: 0;
  transition: opacity 0.2s, visibility 0.2s;
}

.guide-overlay.active {
  visibility: visible;
  opacity: 1;
}

.guide-panel {
  position: fixed;
  top: 0;
  right: -430px;
  z-index: 21;
  width: min(420px, 94vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: rgba(18, 8, 33, 0.3);
  backdrop-filter: blur(5px) saturate(1.05);
  transition: right 0.22s ease;
}

.guide-panel.active {
  right: 0;
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

.guide-header h2 {
  margin: 0;
  font-size: 16px;
}

.btn-close-guide {
  width: 32px;
  height: 32px;
  font-size: 18px;
}

.guide-content {
  overflow-y: auto;
  padding: 18px;
}

.guide-section {
  margin-bottom: 23px;
}

.guide-section h3 {
  margin: 0 0 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  color: var(--accent-cyan);
  font-size: 12px;
  text-transform: uppercase;
}

.guide-section p,
.guide-list {
  margin: 0 0 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.guide-list {
  padding-left: 17px;
}

.guide-list code {
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(5, 2, 10, 0.24);
  color: var(--accent-yellow);
}

.guide-item {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(7, 3, 15, 0.18);
}

.guide-item span {
  color: var(--accent-green);
  font-weight: 800;
}

.guide-item p {
  margin: 3px 0 0;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: rgba(7, 3, 15, 0.26);
  backdrop-filter: blur(4px);
  color: var(--text-secondary);
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(7, 3, 15, 0.2);
}

::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: var(--border);
}

@media (max-width: 1100px) {
  .panels-container {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(190px, 0.45fr) minmax(360px, 1fr);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .container {
    min-height: 100vh;
  }

  .header,
  .header-actions,
  .main-layout {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .input-row,
  .results-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .results-pager {
    justify-content: flex-start;
  }

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

  .option-group input {
    flex: 1;
  }

  .panels-container {
    min-height: 680px;
  }
}
