/* StockHub — Zed × Bloomberg Design System */

:root {
  --bg-base: #09090b;
  --bg-surface: #18181b;
  --bg-elevated: #27272a;
  --border: #3f3f46;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --up: #10b981;
  --down: #ef4444;
  --warning: #f59e0b;
  --font-mono: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  height: 100%;
  overflow-x: hidden;
}

/* Header */
.sh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 40px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.sh-logo {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.sh-logo span { color: var(--accent); }

.sh-market-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.sh-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 4px var(--up);
}

.sh-status-dot.closed { background: var(--text-muted); box-shadow: none; }

.sh-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sh-nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
}

.sh-nav-link:hover { color: var(--text-primary); }

/* Layout */
.sh-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 40px);
}

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

.sh-search {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.sh-search input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 28px 6px 10px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}

.sh-search input:focus { border-color: var(--accent); }

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

.sh-search-clear {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  display: none;
}

.sh-search-clear:hover { color: var(--text-primary); }

.sh-search:has(input:not(:placeholder-shown)) .sh-search-clear {
  display: block;
}

.sh-section-title {
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.sh-stock-list {
  flex: 1;
  overflow-y: auto;
}

.sh-stock-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.sh-stock-item:hover { background: var(--bg-elevated); }

.sh-stock-item.active { background: rgba(79, 70, 229, 0.1); border-left: 2px solid var(--accent); }

.sh-stock-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

.sh-stock-name small {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.sh-stock-price {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  text-align: right;
}

.sh-stock-change {
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
  min-width: 56px;
}

.sh-stock-change.up { color: var(--up); }
.sh-stock-change.down { color: var(--down); }

/* Main content */
.sh-main {
  padding: 16px;
  overflow-y: auto;
  background: var(--bg-base);
}

.sh-hero {
  margin-bottom: 20px;
}

.sh-hero h1 {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.sh-hero p {
  color: var(--text-secondary);
  font-size: 12px;
}

/* Cards */
.sh-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}

.sh-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.sh-card-body { padding: 12px; }

/* Detail panel (fint-style) */
.sh-detail-price-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 12px 4px;
}

.sh-detail-price {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.sh-detail-change {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.sh-detail-meta {
  padding: 0 12px 12px;
  font-size: 11px;
  color: var(--text-muted);
  min-height: 16px;
}

.sh-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px 16px;
  padding: 0 12px 12px;
}

#kline-chart {
  min-height: 320px;
}

.sh-detail-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(63, 63, 70, 0.5);
}

.sh-detail-cell .sh-quote-label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}

.sh-detail-cell .sh-quote-value {
  font-size: 13px;
  font-weight: 500;
}

/* Quote grid */
.sh-quote-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.sh-quote-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sh-quote-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sh-quote-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.sh-quote-value.up { color: var(--up); }
.sh-quote-value.down { color: var(--down); }

.sh-quote-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

/* Table */
.sh-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11px;
}

.sh-table th {
  text-align: left;
  padding: 6px 8px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
}

.sh-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

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

.sh-table td.up { color: var(--up); }
.sh-table td.down { color: var(--down); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

.sh-status-dot.open { animation: pulse-dot 2s infinite; }

/* Home page */
.sh-home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.sh-index-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sh-index-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(63, 63, 70, 0.5);
  font-family: var(--font-mono);
  font-size: 13px;
}

.sh-index-item:last-child {
  border-bottom: none;
}

.sh-index-name {
  color: var(--text-secondary);
  flex: 1;
}

.sh-index-price {
  font-weight: 600;
  min-width: 80px;
  text-align: right;
}

.sh-index-change {
  min-width: 140px;
  text-align: right;
}

.sh-stats-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sh-stat-row {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.sh-stat-label {
  color: var(--text-secondary);
}

.sh-stat-label.up { color: var(--up); }
.sh-stat-label.down { color: var(--down); }
.sh-stat-label.flat { color: var(--text-muted); }

.sh-global-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}

.sh-global-grid .sh-index-item {
  padding: 4px 0;
  font-size: 12px;
}

.sh-sector-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sh-sector-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  border-bottom: 1px solid rgba(63, 63, 70, 0.5);
}

.sh-sector-item:last-child {
  border-bottom: none;
}

.sh-sector-rank {
  color: var(--text-muted);
  min-width: 20px;
}

.sh-sector-name {
  color: var(--text-secondary);
  flex: 1;
}

.sh-sector-change {
  font-weight: 600;
  min-width: 60px;
  text-align: right;
}

.sh-sector-count {
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

@media (max-width: 768px) {
  .sh-home-grid {
    grid-template-columns: 1fr;
  }
  .sh-global-grid {
    grid-template-columns: 1fr;
  }
}
