/* StructureFlowCharts — Dark Theme */

/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f1218;
  --bg-secondary: #1a1f2e;
  --bg-card: #1e2435;
  --bg-hover: #252b3d;
  --bg-active: #2d3548;

  --border: #2a3040;
  --border-light: #343b50;

  --text-primary: #e8eaed;
  --text-secondary: #9aa0b0;
  --text-muted: #6b7280;

  --accent-blue: #4f8cff;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --accent-yellow: #fbbf24;
  --accent-purple: #a78bfa;
  --accent-cyan: #22d3ee;

  --squeeze-1: #ef4444;
  --squeeze-2: #f97316;
  --squeeze-3: #eab308;
  --squeeze-4: #a78bfa;
  --squeeze-5: #6b7280;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;

  --max-width: 1280px;
  --header-height: 64px;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ---- Header ---- */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo:hover {
  color: var(--accent-blue);
  text-decoration: none;
}

.main-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-link.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot--loading { background: var(--text-muted); }
.status-dot--open { background: var(--accent-green); }
.status-dot--closed { background: var(--accent-red); }
.status-dot--running { background: var(--accent-yellow); animation: pulse-dot 1.5s infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Main Content ---- */
.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
  flex: 1;
}

/* ---- Summary Cards ---- */
.summary-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.summary-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.summary-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.filter-group select,
.filter-group input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  min-width: 120px;
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.15);
}

.filter-group select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.filter-group--search {
  flex: 1;
  min-width: 200px;
}

.filter-group--search input {
  width: 100%;
}

/* ---- Tables ---- */
.results-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

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

.results-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.results-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.table-wrapper {
  overflow-x: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.results-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.results-table th.sortable:hover {
  color: var(--text-primary);
}
.results-table th.sortable::after {
  content: " \2195";
  opacity: 0.3;
  font-size: 0.7rem;
}
.results-table th.sortable.asc::after {
  content: " \2191";
  opacity: 0.7;
}
.results-table th.sortable.desc::after {
  content: " \2193";
  opacity: 0.7;
}

.results-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.results-table tbody tr {
  transition: background 0.1s;
}
.results-table tbody tr:hover {
  background: var(--bg-hover);
}
.results-table tbody tr:last-child td {
  border-bottom: none;
}

/* ---- Table Cell Styles ---- */
.symbol-link {
  font-weight: 600;
  color: var(--accent-blue);
  cursor: pointer;
}
.symbol-link:hover {
  text-decoration: underline;
}

.direction-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}
.direction-badge--long {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
}
.direction-badge--short {
  background: rgba(248, 113, 113, 0.15);
  color: var(--accent-red);
}

.squeeze-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.85rem;
}
.squeeze-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.m50ma {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.m50ma--above {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
}
.m50ma--below {
  background: rgba(248, 113, 113, 0.15);
  color: var(--accent-red);
}

.timeframe-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(79, 140, 255, 0.15);
  color: var(--accent-blue);
}

.price {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.box-range {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.targets {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ---- Status Badges ---- */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}
.status-badge--completed {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
}
.status-badge--running {
  background: rgba(251, 191, 36, 0.15);
  color: var(--accent-yellow);
}
.status-badge--failed {
  background: rgba(248, 113, 113, 0.15);
  color: var(--accent-red);
}

/* ---- View Header ---- */
.view-header {
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
}

.view-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.back-link {
  font-size: 0.85rem;
  font-weight: 500;
}
.back-link::before {
  content: "\2190 ";
}

.scan-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 20px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

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

.btn--sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* ---- Loading Skeleton ---- */
.loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton--title {
  height: 28px;
  width: 40%;
}

.skeleton--card {
  height: 100px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Error Banner ---- */
.error-banner {
  text-align: center;
  padding: 60px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.error-banner h2 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.error-banner p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

/* ---- State Views ---- */
.state-view {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Footer ---- */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 24px;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.footer-inner p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footer-note {
  margin-top: 4px;
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .header-inner {
    padding: 0 16px;
  }

  .logo {
    font-size: 1rem;
  }

  .main-nav {
    gap: 2px;
  }

  .nav-link {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .main-content {
    padding: 20px 16px;
  }

  .summary-section {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .summary-card {
    padding: 14px;
  }

  .summary-value {
    font-size: 1.3rem;
  }

  .filter-bar {
    padding: 12px;
    gap: 8px;
  }

  .filter-group select,
  .filter-group input {
    min-width: 100px;
    padding: 6px 8px;
    font-size: 0.85rem;
  }

  .filter-group--search {
    min-width: 100%;
  }

  .results-table {
    font-size: 0.8rem;
  }

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

@media (max-width: 480px) {
  .summary-section {
    grid-template-columns: 1fr;
  }

  .header-status {
    display: none;
  }
}
