:root {
  --bg-app: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-block: rgba(255, 255, 255, 0.05);
  --bg-input: #0f172a;
  --text-main: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --table-hover: rgba(255, 255, 255, 0.03);
}

body.light-theme {
  --bg-app: #ffffff;
  --bg-sidebar: #f8fafc;
  --bg-block: #ffffff;
  --bg-input: #ffffff;
  --text-main: #0f172a;
  --text-dim: #475569;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #059669;
  --danger: #dc2626;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --table-hover: #f1f5f9;
}

body.light-theme .brand-title {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.light-theme .table-wrap {
  background: #ffffff;
}

body.light-theme .table th {
  background: #f8fafc;
}

body.light-theme .sidebar {
  background: #f8fafc;
}

body.light-theme .social-link {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.12);
}

body.light-theme .social-link:hover {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(59, 130, 246, 0.35);
}

body.light-theme .content {
  background: #ffffff;
}

body.light-theme .btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

body.light-theme .btn-secondary:hover {
  background: #cbd5e1;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background: var(--bg-app);
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-main);
  cursor: pointer;
  margin-left: auto;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.theme-toggle:hover {
  background: var(--bg-block);
  border-color: var(--accent);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  position: relative;
}

.hidden {
  display: none !important;
}

.boot-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  padding: 10px 12px;
  background: rgba(2, 6, 23, 0.9);
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  backdrop-filter: blur(10px);
}

body.light-theme .boot-overlay {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
}

.boot-card {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.boot-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.boot-bar-fill {
  width: 35%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.3), rgba(56, 189, 248, 0.95), rgba(56, 189, 248, 0.3));
  animation: bootbar 1.05s ease-in-out infinite;
}

@keyframes bootbar {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.avatar-btn:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.10);
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.3px;
}

.profile-menu {
  position: absolute;
  top: 44px;
  left: 0;
  width: 260px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  padding: 8px;
  z-index: 1000;
}

.profile-submenu {
  margin-top: 6px;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-menu-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  padding: 10px 10px;
  border-radius: 10px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.profile-menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(59, 130, 246, 0.25);
}

.profile-menu-item.danger {
  color: #fca5a5;
}

.profile-menu-label {
  cursor: default;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.03);
}

.profile-menu-label:hover {
  border-color: transparent;
}

.profile-menu-k {
  font-size: 12px;
  color: var(--text-dim);
}

.profile-menu-v {
  font-size: 12px;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu-chev {
  color: var(--text-dim);
}

.profile-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 16px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.md-pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

/* Progress Overlay */
.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.progress-card {
  width: min(400px, calc(100vw - 32px));
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.progress-text {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
  text-align: center;
}

.progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
}

.auth-wrap {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 800px at 30% -10%, rgba(59, 130, 246, 0.25), transparent 60%),
    radial-gradient(900px 600px at 120% 20%, rgba(16, 185, 129, 0.16), transparent 55%),
    var(--bg-app);
}

.auth-card {
  width: min(420px, calc(100vw - 32px));
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  padding: 18px;
}

.auth-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.auth-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.auth-tab {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.45);
}

.auth-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-code-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  align-items: end;
}

.auth-code-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-code-btn {
  height: 40px;
  padding: 0 10px;
}

.auth-msg {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: var(--text-main);
  font-size: 12px;
  line-height: 1.4;
}

.auth-foot {
  margin-top: 12px;
}

.auth2-wrap {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 800px at 30% -10%, rgba(59, 130, 246, 0.25), transparent 60%),
    radial-gradient(900px 600px at 120% 20%, rgba(16, 185, 129, 0.16), transparent 55%),
    var(--bg-app);
}

.auth2-card {
  width: min(520px, calc(100vw - 32px));
  background: var(--bg-sidebar);
  border-radius: 16px;
  padding: 24px 22px;
  border: 1px solid var(--border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
}

.auth2-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.auth2-logo {
  width: 84px;
  height: 84px;
  border-radius: 18px;
  object-fit: cover;
  background: transparent;
}

.auth2-title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--text-main);
}

.auth2-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth2-field {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 0 10px;
  height: 54px;
}

.auth2-ic {
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.auth2-ic svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.auth2-input {
  width: 100%;
  box-sizing: border-box;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  padding: 0 6px;
  height: 100%;
  color: var(--text-main);
}

.auth2-input::placeholder {
  color: rgba(148, 163, 184, 0.9);
}

.auth2-eye {
  border: none;
  background: transparent;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.auth2-eye svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.auth2-row {
  display: flex;
  justify-content: flex-end;
}

.auth2-btn {
  width: 100%;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  height: 54px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2em;
  background: var(--accent);
  color: #ffffff;
}

.auth2-btn:active {
  transform: translateY(0.5px);
}

.auth2-code-btn {
  border: none;
  cursor: pointer;
  border-radius: 10px;
  height: 44px;
  width: 44px;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 700;
  font-size: 12px;
}

.auth2-code-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth2-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.auth2-bottom {
  margin-top: 4px;
}

.auth2-link,
.auth2-link:visited {
  color: var(--text-dim);
  text-decoration: none;
}

.auth2-link:hover {
  text-decoration: underline;
}

.auth2-link-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 700;
}

.auth2-link-btn:hover {
  text-decoration: underline;
}

.auth2-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  user-select: none;
}

.auth2-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.auth2-muted {
  color: var(--text-dim);
}

.auth2-msg {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.auth2-hint {
  margin-top: 6px;
  margin-left: 0;
  padding-left: 12px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
  min-height: 16px;
}

.auth2-hint.ok {
  color: var(--success);
}

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

.legal-wrap {
  min-height: 100vh;
  padding: 22px;
  background: var(--bg-app);
}

.legal-card {
  width: min(920px, 94vw);
  margin: 0 auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 22px;
  box-shadow: var(--shadow);
}

.legal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 10px;
}

.legal-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.legal-body {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.8;
  white-space: pre-wrap;
}

/* Sidebar */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  flex: 1; /* Allow title to take available space */
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.brand-sub {
  font-size: 12px;
  margin-top: 8px;
  color: var(--text-dim);
  line-height: 1.5;
}

#status {
  color: var(--accent);
  font-weight: 500;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}



.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
}

.sidebar-social {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.social-link {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.35);
  color: var(--accent);
  text-decoration: none;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.social-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.social-link:hover {
  transform: translateY(-1px);
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(15, 23, 42, 0.55);
  color: var(--accent);
}

.social-link:active {
  transform: translateY(0px);
}

.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* Blocks */
.block {
  background: var(--bg-block);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  transition: all 0.2s ease;
}

.block:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.block-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.block-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* Form Elements */
.label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.select, .input, .textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select:focus, .input:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.textarea {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  line-height: 1.6;
}

/* Buttons */
.btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Custom Controls */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  cursor: pointer;
}

.cond {
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.cond-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Details & Folding */
.details {
  margin-top: 4px;
}

.details summary {
  list-style: none;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.details summary:hover {
  background: rgba(59, 130, 246, 0.1);
}

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

.param-list {
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.param-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.param-item .input {
  width: 80px;
  padding: 6px 8px;
  text-align: center;
}

/* Folder List */
.folder-conds {
  margin-top: 8px;
}

.enrich-progress {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.enrich-progress-text {
  font-size: 12px;
  opacity: 0.9;
}

.enrich-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.enrich-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #22c55e);
  transition: width 120ms linear;
}

.cond-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
}

.cond-line .mini {
  width: 60px;
  padding: 4px 6px;
}

.cond-line .btn.mini {
  width: 40px;
  background: var(--danger);
  padding: 4px;
}

/* Main Content & Table */
.content {
  background: #0f172a;
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.table-wrap {
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
  flex: 1;
  box-shadow: var(--shadow);
}

.watermark {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  opacity: 0.075;
  transform: translateZ(0);
}

.watermark-logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  filter: grayscale(1);
  opacity: 0.85;
}

.watermark-text {
  margin-top: 10px;
  font-size: 44px;
  letter-spacing: 6px;
  font-weight: 800;
  color: var(--text-main);
  opacity: 0.8;
  text-transform: none;
}

body.light-theme .watermark {
  opacity: 0.06;
}

.watermark-kline {
  inset: 42px 0 0 0;
  opacity: 0.07;
}

.table-wrap {
  position: relative;
  z-index: 2;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table th {
  position: sticky;
  top: 0;
  background: #1e293b;
  color: var(--text-dim);
  font-weight: 600;
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  z-index: 10;
  white-space: nowrap;
}

.th-symbol {
  display: flex;
  align-items: center;
  gap: 8px;
}

.th-icon-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.th-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

body.light-theme .th-icon-btn {
  background: rgba(0, 0, 0, 0.03);
}

body.light-theme .th-icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.th-filter {
  width: 132px;
  padding: 6px 8px;
  font-size: 12px;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  white-space: nowrap;
}

.table tr:hover td {
  background: var(--table-hover);
}

.num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

.column-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}

.column-selector label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.column-selector label:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

body.light-theme .column-selector label:hover {
  background: rgba(0, 0, 0, 0.05);
}

.column-selector input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.kline-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
  line-height: 1.4;
}

.kline-canvas {
  width: 100%;
  height: 220px;
  display: block;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
}

body.light-theme .kline-canvas {
  background: #ffffff;
}

body.light-theme .kline-chip {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(15, 23, 42, 0.18);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

body.light-theme .kline-chip:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(15, 23, 42, 0.28);
}

.kline-page {
  height: 100svh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  overflow: hidden;
}

.kline-topbar {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}

.kline-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kline-binance-link {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
}

.kline-binance-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.light-theme .kline-binance-link {
  background: rgba(0, 0, 0, 0.03);
}

body.light-theme .kline-binance-link:hover {
  background: rgba(0, 0, 0, 0.06);
}

.kline-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.kline-tail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}

.kline-tail-hint {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.2;
  text-align: right;
}

.kline-tail-select {
  width: 100%;
}

.kline-back, .kline-reload, .kline-action {
  width: 100%;
}

.kline-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.kline-title-main {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kline-title-sub {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kline-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.kline-charts {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.kline-panels {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  min-height: 0;
  overflow: auto;
}

.kline-picks {
  width: clamp(240px, 20vw, 360px);
  flex: 0 0 auto;
  border-left: 1px solid var(--border);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kline-picks-head {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kline-picks-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.kline-pick-search {
  width: 100%;
}

.kline-picks-meta {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kline-pick-list {
  padding: 10px 10px 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kline-pick-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 10px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 4px 10px;
}

.kline-pick-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.kline-pick-item.active {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.12);
}

.kline-pick-rank {
  font-size: 12px;
  color: var(--text-dim);
}

.kline-pick-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kline-pick-sub {
  grid-column: 2 / 3;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.kline-pick-sub .up {
  color: var(--success);
}

.kline-pick-sub .down {
  color: var(--danger);
}

.kline-candle-panel {
  flex: 6 1 0;
  min-height: 0;
  position: relative;
}

.kline-indicator-panel {
  flex: 4 1 0;
  min-height: 0;
}

.kline-panel {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-sidebar);
  padding: 8px;
}

.kline-chipbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 6;
  pointer-events: auto;
}

.kline-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text-main);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.18);
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.kline-chip:hover {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.55);
}

.kline-chip:active {
  transform: translateY(0.5px);
}

.kline-chip.off {
  opacity: 0.5;
}

.kline-chip-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.kline-panel .kline-canvas {
  height: 100%;
}

.kline-indicator-stack {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr;
  gap: 8px;
}

.kline-indicator-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  padding: 6px;
  position: relative;
}

.kline-indicator-item .kline-canvas {
  height: 100%;
  border: none;
  border-radius: 8px;
}

.kline-alert {
  margin: 10px 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.12);
  color: var(--text-main);
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.kline-tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.78);
  color: #ffffff;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
  max-width: 420px;
  backdrop-filter: blur(10px);
}

body.light-theme .kline-tooltip {
  background: rgba(15, 23, 42, 0.9);
}

.kline-settings {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 24px;
}

.kline-settings-card {
  width: min(720px, 92vw);
  max-height: 88vh;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.kline-settings-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kline-settings-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.kline-settings-body {
  padding: 14px 18px;
  overflow: auto;
}

.kline-settings-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.kline-settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kline-settings-row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 10px;
  align-items: center;
}

.kline-settings-name {
  font-size: 12px;
  color: var(--text-main);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.coin-link {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.coin-link:hover {
  color: var(--accent-hover);
}

.table tr.selected td {
  background: rgba(59, 130, 246, 0.12);
}

body.light-theme .table tr.selected td {
  background: rgba(37, 99, 235, 0.08);
}

.table tr.new-on-list td:first-child {
  position: relative;
  padding-left: 18px;
}

.table tr.new-on-list td:first-child::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.95);
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.factor-lib {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.factor-lib-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.factor-lib-item {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 10px 10px;
}

body.light-theme .factor-lib-item {
  background: rgba(15, 23, 42, 0.04);
}

.factor-lib-expr {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.factor-lib-desc {
  font-size: 12px;
  line-height: 1.35;
  opacity: 0.9;
  white-space: pre-wrap;
}

/* Modal */
.modal-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(600px, 90vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.basecfg {
  display: flex;
  gap: 14px;
  min-height: 520px;
}

.basecfg-nav {
  width: 140px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 14px;
  border-right: 1px solid var(--border);
}

.basecfg-tab {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  cursor: pointer;
  font: inherit;
}

.basecfg-tab:hover {
  background: rgba(255, 255, 255, 0.06);
}

.basecfg-tab.active {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.12);
}

.basecfg-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  display: flex;
}

.basecfg-pane {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-line {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
}

.strategy-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.strategy-editor .cond {
  margin-bottom: 0;
}

.strategy-editor .param-list {
  margin-top: 10px;
}

.modal-body textarea.textarea {
  min-height: 96px;
  font-family: inherit;
}

/* Scrollbar styling for general app */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
