/* ==========================================================================
   Keseimbangan · Japanese Editorial Studio Palette & Layout
   Harmonized with Richardo Sinulingga Portfolio Aesthetic
   ========================================================================== */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg-ground: #0e0f11;
  --bg-surface: #151619;
  --bg-elevated: #1d1f24;
  --bg-header: rgba(14, 15, 17, 0.94);
  --bg-chart: #151619;

  --text-primary: #f2f2ee;
  --text-secondary: #b0b0a9;
  --text-muted: #888882;

  --border: #282a30;
  --border-strong: #3d4049;
  --border-subtle: #22242a;
  --border-control: #4a4e59;

  --accent: #7ba4f0;
  --accent-hover: #9bc0ff;
  --accent-subtle: #192338;
  --accent-subtle-text: #93b6f5;

  --cta-bg: #f2f2ee;
  --cta-bg-hover: #dcdcd5;
  --cta-text: #111214;

  --up-text: #34d399;
  --up-tint: rgba(52, 211, 153, 0.12);
  --down-text: #f87171;
  --down-tint: rgba(248, 113, 113, 0.14);

  --gold-tape-bg: rgba(224, 168, 46, 0.12);
  --gold-tape-text: #e8b74b;
  --focus-ring: #7ba4f0;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-ground: #f6f6f3;
  --bg-surface: #ffffff;
  --bg-elevated: #eeede8;
  --bg-header: rgba(246, 246, 243, 0.94);
  --bg-chart: #ffffff;

  --text-primary: #141414;
  --text-secondary: #4a4a46;
  --text-muted: #5c5c57;

  --border: #dcdcd6;
  --border-strong: #bfbfb7;
  --border-subtle: #e5e5df;
  --border-control: #8f9298;

  --accent: #22438c;
  --accent-hover: #1a3470;
  --accent-subtle: #eaeff9;
  --accent-subtle-text: #1d3a7a;

  --cta-bg: #141414;
  --cta-bg-hover: #2c2c2a;
  --cta-text: #ffffff;

  --up-text: #059669;
  --up-tint: rgba(5, 150, 105, 0.08);
  --down-text: #dc2626;
  --down-tint: rgba(220, 38, 38, 0.08);

  --gold-tape-bg: rgba(143, 99, 10, 0.09);
  --gold-tape-text: #8f630a;
  --focus-ring: #22438c;
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-ground);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.mono, .font-code {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.font-mincho {
  font-family: "Shippori Mincho", Georgia, serif;
}

/* Accessibility skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--cta-bg);
  color: var(--cta-text);
  padding: 0.5rem 1rem;
  z-index: 100;
  border-radius: 2px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 1rem;
}

/* ==========================================================================
   Header: Japanese Editorial Topbar
   ========================================================================== */
.top-tape {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-header);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1.25rem;
}

.top-tape-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-title {
  font-family: "Shippori Mincho", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  border-radius: 2px;
  background: var(--accent-subtle);
  color: var(--accent-subtle-text);
  border: 1px solid var(--border);
}

.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
}
.conn-badge[data-mode="online"] {
  color: var(--up-text);
  border-color: var(--up-text);
  background: var(--up-tint);
}
.conn-badge[data-mode="online"] .conn-dot {
  background-color: var(--up-text);
}
.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-muted);
  display: inline-block;
}

.tape-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.tape-chip {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
}
.tape-chip.is-gold {
  background: var(--gold-tape-bg);
  color: var(--gold-tape-text);
  border-color: var(--gold-tape-text);
  font-weight: 600;
}

/* ==========================================================================
   Buttons & Controls
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  min-height: 32px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}
.btn-primary {
  background: var(--cta-bg);
  color: var(--cta-text);
  border-color: var(--cta-bg);
}
.btn-primary:hover {
  background: var(--cta-bg-hover);
  border-color: var(--cta-bg-hover);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--bg-elevated);
}
.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  min-height: 26px;
}

/* ==========================================================================
   Main Desk Grid (2-Column Responsive Layout)
   ========================================================================== */
.desk-grid {
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1080px) {
  .desk-grid {
    grid-template-columns: 1fr;
  }
}

/* Chart Column */
.chart-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.desk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.bar-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.mode-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  background: var(--bg-elevated);
}
.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode-btn.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.select-broker {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.select-broker:focus {
  border-color: var(--focus-ring);
}

.symbol-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  border-radius: 2px;
}

/* Timeframe buttons */
.tf-btn {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tf-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.tf-btn.is-active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* Chart Cards */
.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  min-height: 580px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cfd-stage {
  width: 100%;
  height: 580px;
  background: var(--bg-chart);
}

.lite-toolbar {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ind-btn {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  cursor: pointer;
}
.ind-btn.is-active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.lite-metrics {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
}

.ohlcv-bar {
  padding: 0.35rem 0.75rem;
  font-size: 0.7rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.lite-stage {
  position: relative;
  height: 520px;
}
.chart-canvas {
  width: 100%;
  height: 100%;
}
.chart-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  padding: 1rem;
}

/* ==========================================================================
   Aside Rail: Tabs & Panels (Pasar CFD, Kalkulator, Alarm)
   ========================================================================== */
.desk-rail {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.rail-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.rail-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.65rem 0.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}
.rail-tab-btn:hover {
  color: var(--text-primary);
}
.rail-tab-btn.is-active {
  background: var(--bg-surface);
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

.tab-count {
  font-size: 0.65rem;
  background: var(--accent-subtle);
  color: var(--accent-subtle-text);
  padding: 0.1rem 0.35rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.rail-panel {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* Pair Watchlist */
.watchlist-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pair-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  background: var(--bg-ground);
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pair-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}
.pair-card.is-active {
  border-color: var(--accent);
  background: var(--accent-subtle);
}
.pair-name {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-primary);
}
.pair-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.pair-price {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* Forms (Calc & Alert) */
.panel-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.field-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.field-input {
  width: 100%;
  background: var(--bg-ground);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 0.45rem 0.6rem;
  border-radius: 2px;
  outline: none;
}
.field-input:focus {
  border-color: var(--focus-ring);
}
.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.form-actions .btn {
  flex: 1;
}

/* Calc Results Grid */
.calc-results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  background: var(--bg-ground);
  padding: 0.65rem;
  border-radius: 2px;
  border: 1px solid var(--border-subtle);
}
.metric-box {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.metric-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.metric-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.65rem;
}

/* Alerts list */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 240px;
  overflow-y: auto;
}
.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  background: var(--bg-ground);
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  font-size: 0.72rem;
}
.alert-item button {
  background: transparent;
  border: none;
  color: var(--down-text);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 0.25rem;
}

/* ==========================================================================
   Footer: Google Standard / Portfolio Link
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 1.25rem 1.25rem;
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  sm-flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
@media (min-width: 768px) {
  .footer-inner {
    flex-direction: row;
    align-items: center;
  }
}
.footer-left {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.footer-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}
.footer-links a:hover {
  color: var(--accent);
}

/* Toast */
.app-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 0.65rem 1rem;
  border-radius: 3px;
  font-size: 0.8rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 99;
}


/* Watchlist Rows (Daftar Instrumen) */
.watchlist-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.watch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.watch-row:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.watch-row.is-active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.watch-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.watch-name {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.watch-row.is-active .watch-name {
  color: var(--accent);
}

.watch-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.watch-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
}

.watch-symbol-pill {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-secondary);
}

.watch-row.is-active .watch-symbol-pill {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
