/* Modern Terminal Dark Theme for Personal Stock AI */

:root {
  --bg: #0b0f17;
  --bg-subtle: #111827;
  --panel: #151d2c;
  --panel-hover: #1c273a;
  --border: #232f42;
  --border-hover: #334460;
  --border-focus: #3b82f6;

  --text: #f3f4f6;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent: #3b82f6;
  --accent-hover: #2563eb;

  /* Action Colors */
  --action-buy: #10b981;
  --action-buy-bg: rgba(16, 185, 129, 0.12);
  --action-buy-border: rgba(16, 185, 129, 0.35);

  --action-sell: #f43f5e;
  --action-sell-bg: rgba(244, 63, 94, 0.12);
  --action-sell-border: rgba(244, 63, 94, 0.35);

  --action-hold: #f59e0b;
  --action-hold-bg: rgba(245, 158, 11, 0.12);
  --action-hold-border: rgba(245, 158, 11, 0.35);

  /* Market Badges */
  --mkt-asx: #06b6d4;
  --mkt-crypto: #f59e0b;

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

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px -4px rgba(0, 0, 0, 0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-icon {
  font-size: 1.5rem;
}

.site-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

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

/* Buttons */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--panel-hover);
  border-color: var(--border-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--panel-hover);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-icon {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  color: #fff;
  background: var(--panel-hover);
}

.badge-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Main Container */
.main-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
  width: 100%;
}

/* Status Bar */
.status-bar {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-bar.info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.status-bar.error {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fca5a5;
}

/* Overview Summary Cards */
.overview-section {
  margin-bottom: 24px;
}

.summary-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.summary-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.summary-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: #fff;
}

.summary-card.stat-buy .summary-value {
  color: var(--action-buy);
}

.summary-card.stat-hold .summary-value {
  color: var(--action-hold);
}

.summary-card.stat-sell .summary-value {
  color: var(--action-sell);
}

/* Toolbar & Filters */
.toolbar-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  margin-bottom: 24px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Segmented View Mode */
.segmented-control {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.segment-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.segment-btn.active {
  background: var(--panel-hover);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Market Pills */
.market-pills {
  display: inline-flex;
  gap: 6px;
}

.pill-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn:hover {
  border-color: var(--border-hover);
  color: #fff;
}

.pill-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
  color: #93c5fd;
}

/* Select Dropdown */
.select-control {
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 7px 28px 7px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}

.select-control:focus {
  border-color: var(--accent);
}

/* Search Box */
.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 7px 12px 7px 32px;
  border-radius: var(--radius-md);
  outline: none;
  width: 220px;
  transition: all 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent);
  width: 260px;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 20px;
}

/* Signal Card */
.signal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}

.signal-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.card-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ticker-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.ticker-symbol {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff;
}

.badge-market {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.badge-market.mkt-asx {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.35);
  color: var(--mkt-asx);
}


.badge-market.mkt-crypto {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--mkt-crypto);
}

.ticker-name {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Action Badges */
.badge-action {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-action.action-buy {
  background: var(--action-buy-bg);
  border: 1px solid var(--action-buy-border);
  color: var(--action-buy);
}

.badge-action.action-sell {
  background: var(--action-sell-bg);
  border: 1px solid var(--action-sell-border);
  color: var(--action-sell);
}

.badge-action.action-hold {
  background: var(--action-hold-bg);
  border: 1px solid var(--action-hold-border);
  color: var(--action-hold);
}

/* Price & Indicators Metrics Bar */
.card-metrics-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.price-box {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.price-val {
  font-size: 1.18rem;
  font-weight: 700;
  color: #fff;
}

.price-currency {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 600;
}

.pill-change {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
}

.pill-change.positive {
  color: var(--action-buy);
  background: rgba(16, 185, 129, 0.12);
}

.pill-change.negative {
  color: var(--action-sell);
  background: rgba(244, 63, 94, 0.12);
}

.indicators-box {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip-rsi,
.chip-indicator {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--panel-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chip-rsi.oversold {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--action-buy);
}

.chip-rsi.overbought {
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--action-sell);
}

.chip-macd.bullish {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--action-buy);
  background: rgba(16, 185, 129, 0.08);
}

.chip-macd.bearish {
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--action-sell);
  background: rgba(244, 63, 94, 0.08);
}

.chip-boll.overbought {
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--action-sell);
}

.chip-boll.oversold {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--action-buy);
}

.chip-target {
  border-color: rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.chip-target .positive {
  color: var(--action-buy);
  font-weight: 700;
}

.chip-target .negative {
  color: var(--action-sell);
  font-weight: 700;
}

.chip-fng.greed {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--action-buy);
}

.chip-fng.fear {
  border-color: rgba(244, 63, 94, 0.4);
  color: #f97316;
}

.chip-fng.neutral {
  border-color: var(--border);
  color: var(--text-muted);
}

.tech-summary-box {
  font-size: 0.76rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  line-height: 1.4;
}

/* AI Analysis Section */
.ai-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confidence-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.confidence-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 600;
}

.confidence-meter-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meter-track {
  width: 80px;
  height: 6px;
  background: var(--bg);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border);
}

.meter-fill {
  height: 100%;
  border-radius: var(--radius-full);
}

.meter-fill.buy {
  background: var(--action-buy);
}

.meter-fill.hold {
  background: var(--action-hold);
}

.meter-fill.sell {
  background: var(--action-sell);
}

.confidence-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.rationale-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #e2e8f0;
}

/* Key Drivers */
.drivers-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.driver-pill {
  font-size: 0.72rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

/* News Box */
.news-box {
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.45;
}

.news-box strong {
  color: var(--text-muted);
}

/* Watchlist Drawer */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: none;
}

.modal-backdrop.active {
  display: block;
}

.watchlist-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.watchlist-drawer.active {
  transform: translateX(0);
}

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

.drawer-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.drawer-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.form-row {
  display: flex;
  gap: 8px;
}

.text-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 12px;
  outline: none;
}

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

.form-help {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 5px;
  display: block;
}

/* Market Dropdowns Section */
.market-dropdowns-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.watchlist-dropdown-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.watchlist-dropdown-group[open] {
  border-color: var(--border-hover);
}

.dropdown-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--panel);
  list-style: none;
  transition: background 0.2s ease;
}

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

.dropdown-summary:hover {
  background: var(--panel-hover);
}

.dropdown-summary-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
}

.dropdown-icon {
  font-size: 1rem;
}

.dropdown-summary-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-link-action {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.btn-link-action:hover {
  color: #fff;
  background: rgba(59, 130, 246, 0.15);
}

.sep {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.chevron-icon {
  transition: transform 0.2s ease;
  color: var(--text-muted);
  margin-left: 2px;
}

.watchlist-dropdown-group[open] .chevron-icon {
  transform: rotate(180deg);
}

.dropdown-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
  padding: 10px 12px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.checkbox-item:hover {
  background: var(--panel-hover);
  border-color: var(--border-hover);
}

.checkbox-item.checked {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.4);
}

.checkbox-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.checkbox-text-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.checkbox-ticker {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.checkbox-name {
  font-size: 0.68rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 85px;
  line-height: 1.2;
}

.drawer-tools-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.active-tickers-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.active-tickers-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ticker-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 2px;
}

.ticker-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.btn-remove-tag {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  line-height: 1;
  font-size: 1rem;
  padding: 0 2px;
}

.btn-remove-tag:hover {
  color: var(--action-sell);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  grid-column: 1 / -1;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.empty-state h3 {
  color: #fff;
  font-size: 1.1rem;
  margin-bottom: 8px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  background: var(--bg);
  margin-top: auto;
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: #fff;
}

.footer-meta {
  margin-top: 4px;
  font-size: 0.72rem;
}

/* Responsive Styling */
@media (max-width: 768px) {
  .site-header {
    padding-top: env(safe-area-inset-top);
  }

  .header-inner {
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .brand-title-row {
    gap: 8px;
    justify-content: flex-start;
  }

  .brand-logo-icon {
    font-size: 1.35rem;
  }

  .site-header h1 {
    font-size: clamp(1.02rem, 4vw, 1.18rem);
    line-height: 1.25;
  }

  .header-actions {
    width: 100%;
    display: flex;
    gap: 8px;
  }

  .header-actions .btn {
    flex: 1;
    min-height: 42px;
    justify-content: center;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .main-container {
    padding: 14px 12px;
  }

  .overview-section {
    margin-bottom: 16px;
  }

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

  .summary-card {
    padding: 10px 12px;
    border-radius: var(--radius-md);
  }

  .summary-card:first-child {
    grid-column: 1 / -1;
  }

  .summary-label {
    font-size: 0.68rem;
    letter-spacing: 0.03em;
  }

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

  .toolbar-section {
    padding: 12px;
    gap: 10px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .segmented-control {
    width: 100%;
    display: flex;
  }

  .segment-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.76rem;
    text-align: center;
    justify-content: center;
    display: flex;
  }

  .market-pills {
    width: 100%;
    display: flex;
    gap: 6px;
  }

  .pill-btn {
    flex: 1;
    padding: 7px 4px;
    font-size: 0.74rem;
    text-align: center;
    justify-content: center;
  }

  .toolbar-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .select-control {
    width: 100%;
    min-height: 40px;
    font-size: 0.8rem;
    padding: 6px 24px 6px 10px;
  }

  .search-wrap {
    grid-column: 1 / -1;
    width: 100%;
  }

  .search-input {
    width: 100% !important;
    min-height: 40px;
    font-size: 16px;
    /* Prevents auto-zoom on iOS */
  }

  .search-input:focus {
    width: 100% !important;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .signal-card {
    padding: 14px 12px;
    gap: 12px;
    border-radius: var(--radius-md);
  }

  .card-top-row {
    gap: 8px;
  }

  .ticker-symbol {
    font-size: 1.15rem;
  }

  .badge-market {
    font-size: 0.65rem;
    padding: 2px 6px;
  }

  .ticker-name {
    font-size: 0.76rem;
  }

  .badge-action {
    font-size: 0.8rem;
    padding: 4px 10px;
    flex-shrink: 0;
  }

  .card-metrics-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
  }

  .price-box {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    width: 100%;
  }

  .price-val {
    font-size: 1.1rem;
  }

  .indicators-box {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
  }

  .chip-rsi,
  .chip-indicator {
    font-size: 0.7rem;
    padding: 2px 6px;
  }

  .tech-summary-box {
    font-size: 0.74rem;
    padding: 6px 8px;
  }

  .confidence-row {
    flex-wrap: wrap;
    gap: 6px;
  }

  .meter-track {
    width: 60px;
  }

  .rationale-text {
    font-size: 0.82rem;
    line-height: 1.45;
  }

  .driver-pill {
    font-size: 0.7rem;
    padding: 2px 6px;
  }

  .news-box {
    font-size: 0.75rem;
  }

  /* Drawer on Mobile */
  .watchlist-drawer {
    width: 100vw;
    max-width: 100vw;
    border-left: none;
  }

  .drawer-header {
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .drawer-title {
    font-size: 1.05rem;
  }

  .drawer-subtitle {
    font-size: 0.72rem;
  }

  .drawer-body {
    padding: 14px 12px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    gap: 14px;
  }

  .form-row {
    display: flex;
    gap: 6px;
  }

  .form-row .text-input {
    min-height: 42px;
    font-size: 16px;
  }

  .form-row .btn {
    min-height: 42px;
    padding: 0 16px;
  }

  .market-dropdowns-section {
    gap: 10px;
  }

  .dropdown-summary {
    padding: 10px 12px;
  }

  .dropdown-summary-left {
    font-size: 0.82rem;
    gap: 6px;
  }

  .dropdown-checkbox-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 8px 10px;
    max-height: 240px;
  }

  .checkbox-item {
    padding: 8px 6px;
    min-height: 42px;
    gap: 6px;
  }

  .checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
  }

  .checkbox-ticker {
    font-size: 0.75rem;
  }

  .checkbox-name {
    font-size: 0.65rem;
    max-width: 75px;
  }

  .drawer-tools-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .drawer-tools-row .btn {
    min-height: 38px;
    justify-content: center;
    font-size: 0.74rem;
    padding: 6px 4px;
    text-align: center;
  }

  .ticker-tags-list {
    max-height: 200px;
    gap: 6px;
  }

  .ticker-tag {
    padding: 5px 10px;
    font-size: 0.76rem;
  }

  .btn-remove-tag {
    padding: 2px 4px;
    font-size: 1.1rem;
  }

  .site-footer {
    padding: 18px 16px max(18px, env(safe-area-inset-bottom));
    font-size: 0.75rem;
  }
}

@media (max-width: 360px) {
  .header-actions .btn {
    font-size: 0.75rem;
    padding: 8px 6px;
  }

  .dropdown-checkbox-grid {
    grid-template-columns: 1fr;
  }

  .drawer-tools-row {
    grid-template-columns: 1fr;
  }
}
