/* ============================================================
   Greeqs — live options trading UI
   Faithful implementation of Greeqs.dc.html design.
   Palette: light, #1D4ED8 accent. Fonts: Space Grotesk / Public Sans / IBM Plex Mono.
   ============================================================ */

:root {
  --q-bg:        #F7F8FA;
  --q-dot:       #E2E8F0;
  --q-card:      #ffffff;
  --q-border:    #E4E7EC;
  --q-border-2:  #F2F4F7;
  --q-soft:      #F4F3F1;
  --q-ink:       #101828;
  --q-ink-2:     #344054;
  --q-muted:     #475467;
  --q-muted-2:   #667085;
  --q-muted-3:   #98A2B3;
  --q-accent:    #1D4ED8;
  --q-accent-hi: #1741B0;
  --q-up:        #16A34A;
  --q-down:      #DC2626;
  --q-term-bg:   #0B0F14;
  --q-term-row:  #131A24;
  --q-font-ui:   'Inter', system-ui, -apple-system, sans-serif;
  --q-font-head: 'Inter', var(--q-font-ui);
  --q-font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; }
body {
  font-family: var(--q-font-ui);
  background-color: var(--q-bg);
  color: var(--q-ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
#q-root { position: relative; z-index: 1; }

/* Fixed grid-line backdrop */
.q-dotlayer {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--q-dot) 1px, transparent 1px),
    linear-gradient(to bottom, var(--q-dot) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.35;
}

/* Slim, smooth scrollbars */
body, .q-scroll, .q-terminal, .q-sidebar { scroll-behavior: smooth; }
.q-scroll::-webkit-scrollbar, body::-webkit-scrollbar, .q-sidebar::-webkit-scrollbar { width: 10px; height: 10px; }
.q-scroll::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb, .q-sidebar::-webkit-scrollbar-thumb {
  background: #D0D5DD; border-radius: 8px; border: 2px solid var(--q-bg); background-clip: padding-box;
}
.q-scroll::-webkit-scrollbar-thumb:hover, body::-webkit-scrollbar-thumb:hover { background: #B4BCC8; }
.q-terminal::-webkit-scrollbar { width: 10px; }
.q-terminal::-webkit-scrollbar-thumb { background: #2A3546; border-radius: 8px; }
::selection { background: #cfe0ff; }
input::placeholder { color: var(--q-muted-3); }
input:focus, select:focus { outline: none; }
a { color: var(--q-accent); text-decoration: none; }
button { font-family: inherit; }

@keyframes qspin { to { transform: rotate(360deg); } }
@keyframes qfade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes qblink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.q-hidden { display: none !important; }
.q-mono { font-family: var(--q-font-mono); font-variant-numeric: tabular-nums; }
.q-head { font-family: var(--q-font-head); letter-spacing: -0.01em; }
.q-up { color: var(--q-up); }
.q-down { color: var(--q-down); }

/* ---------- Brand mark ---------- */
.q-logo { display: flex; align-items: center; gap: 9px; }
.q-logo-badge {
  border-radius: 7px; background: var(--q-accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.q-logo-badge > i { border: 2px solid #fff; border-radius: 3px; display: block; }
.q-logo-name { font-family: var(--q-font-head); font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Auth screens (login / connect) ---------- */
.q-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.q-auth-inner { width: 100%; max-width: 400px; animation: qfade .4s ease; }
.q-auth-brand { justify-content: center; margin-bottom: 36px; }
.q-auth-brand .q-logo-badge { width: 30px; height: 30px; }
.q-auth-brand .q-logo-badge > i { width: 12px; height: 12px; }
.q-auth-brand .q-logo-name { font-size: 19px; }
.q-card-auth {
  background: var(--q-card); border: 1px solid var(--q-border);
  border-radius: 12px; padding: 32px; box-shadow: 0 1px 3px rgba(16,24,40,.05);
}
.q-card-auth h1 { font-family: var(--q-font-head); font-size: 22px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.q-card-auth .q-sub { font-size: 13.5px; color: var(--q-muted-2); margin: 0 0 26px; line-height: 1.5; }
.q-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--q-ink-2); margin-bottom: 6px; }
.q-input {
  width: 100%; padding: 10px 12px; border: 1px solid #D0D5DD; border-radius: 8px;
  font-size: 14px; font-family: inherit; color: var(--q-ink); background: #fff;
}
.q-input + .q-label { margin-top: 16px; }
.q-btn {
  width: 100%; padding: 11px; border: none; border-radius: 8px; background: var(--q-accent);
  color: #fff; font-size: 14.5px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.q-btn:hover { background: var(--q-accent-hi); }
.q-btn:disabled { background: #CBD2DD; cursor: not-allowed; }
.q-auth-foot { text-align: center; font-size: 12.5px; color: var(--q-muted-3); margin-top: 20px; }
.q-btn-google {
  width: 100%; padding: 10px; border: 1px solid #D0D5DD; border-radius: 8px; background: #fff;
  color: var(--q-ink-2); font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px; transition: background .15s;
}
.q-btn-google:hover { background: #F9FAFB; }
.q-btn-google:disabled { opacity: .6; cursor: not-allowed; }
.q-or { display: flex; align-items: center; gap: 12px; margin: 18px 0; }
.q-or::before, .q-or::after { content: ""; flex: 1; height: 1px; background: var(--q-border); }
.q-or span { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: var(--q-muted-3); }

/* ---------- App shell ---------- */
.q-app { display: flex; align-items: flex-start; min-height: 100vh; position: relative; z-index: 1; }
.q-sidebar {
  width: 210px; flex-shrink: 0; background: var(--q-card); border-right: 1px solid var(--q-border);
  display: flex; flex-direction: column; padding: 20px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.q-sb-brand { padding: 0 8px; margin-bottom: 28px; }
.q-sb-brand .q-logo-badge { width: 26px; height: 26px; }
.q-sb-brand .q-logo-badge > i { width: 10px; height: 10px; }
.q-sb-brand .q-logo-name { font-size: 16px; }
.q-nav { display: flex; flex-direction: column; gap: 2px; }
.q-nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; color: var(--q-muted-2); font-size: 13.5px; font-weight: 600;
}
.q-nav-item:hover { background: var(--q-border-2); }
.q-nav-item.active { background: #EEF3FF; color: var(--q-accent); }
.q-nav-item .q-nav-ico { width: 16px; height: 16px; flex-shrink: 0; color: currentColor; display: flex; }
.q-nav-item .q-nav-ico svg { width: 16px; height: 16px; }
.q-nav-spacer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--q-border-2); }

/* ---------- Main region ---------- */
.q-main { flex: 1; min-width: 0; }
.q-main-inner { max-width: 1560px; width: 100%; margin: 0 auto; padding: 20px 28px; }
.q-topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 0 0 18px;
  flex-wrap: wrap; gap: 12px;
}
.q-page-title { font-family: var(--q-font-head); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.q-topbar-right { display: flex; align-items: center; gap: 14px; }
.q-status { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 20px; }
.q-status .q-dot { width: 7px; height: 7px; border-radius: 50%; }
.q-status span { font-size: 12.5px; font-weight: 600; }
.q-status--live { background: #DCFCE7; }
.q-status--live .q-dot { background: var(--q-up); }
.q-status--live span { color: var(--q-up); }
.q-status--off { background: #F2F4F7; }
.q-status--off .q-dot { background: var(--q-muted-3); }
.q-status--off span { color: var(--q-muted-2); }
.q-topbar-sep { width: 1px; height: 20px; background: var(--q-border); }
.q-user { font-size: 13.5px; color: var(--q-muted); }

.q-page { display: block; animation: qfade .35s ease; }

/* ---------- Stat cards ---------- */
.q-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; flex-shrink: 0; }
.q-stat { background: var(--q-card); border: 1px solid var(--q-border); border-radius: 10px; padding: 18px 20px; }
.q-stat-label { font-size: 12px; color: var(--q-muted-2); font-weight: 600; margin-bottom: 8px; }
.q-stat-value { font-family: var(--q-font-mono); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Dashboard grid ---------- */
.q-dash-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
  align-items: start;
}
.q-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.q-col-left  {}
.q-col-right {}

/* ---------- Cards ---------- */
.q-card { background: var(--q-card); border: 1px solid var(--q-border); border-radius: 10px; padding: 20px; min-width: 0; }
.q-card--grow { display: flex; flex-direction: column; }
.q-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-shrink: 0; }
.q-card-title { font-family: var(--q-font-head); font-size: 14px; font-weight: 600; letter-spacing: .02em; }
.q-link { font-size: 12.5px; font-weight: 600; color: var(--q-accent); cursor: pointer; }
.q-scroll { overflow-x: auto; }
.q-scroll--cap  { max-height: 420px; overflow-y: auto; }
.q-scroll--page { max-height: calc(100vh - 168px); overflow-y: auto; }

/* ---------- Full trade log table ---------- */
.q-table--trades { min-width: 1100px; }
.q-table--trades thead { position: sticky; top: 0; z-index: 1; background: var(--q-card); }
.q-side-tag { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; }
.q-side-tag--buy  { background: #DCFCE7; color: var(--q-up); }
.q-side-tag--sell { background: #FEE2E2; color: var(--q-down); }
.q-type-tag { display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 600; background: var(--q-soft); color: var(--q-muted-2); }


/* ---------- Tables ---------- */
.q-table { width: 100%; border-collapse: collapse; }
.q-table thead tr { border-bottom: 1px solid var(--q-border); }
.q-table th { text-align: left; padding: 0 8px 10px 0; font-size: 11.5px; color: var(--q-muted-2); font-weight: 600; white-space: nowrap; }
.q-table th.r, .q-table td.r { text-align: right; }
.q-table tbody tr { border-bottom: 1px solid var(--q-border-2); }
.q-table td { padding: 11px 8px 11px 0; font-size: 13.5px; }
.q-table td.q-mono { font-size: 13px; }
.q-table .q-sym { font-weight: 600; }
.q-table .q-side { color: var(--q-muted-2); font-size: 13px; }
.q-empty { color: var(--q-muted-3); font-size: 13px; padding: 20px 4px; text-align: center; }

/* ---------- Configure / Auto-Pilot panel ---------- */
.q-cfg { border-radius: 12px; padding: 20px; }
.q-cfg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.q-badge { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 3px 8px; border-radius: 5px; }
.q-badge--saved { color: var(--q-up); background: #DCFCE7; }
.q-badge--dirty { color: #B54708; background: #FEF0C7; }
.q-cfg-status { display: flex; align-items: center; gap: 6px; }
.q-cfg-status .q-dot { width: 6px; height: 6px; border-radius: 50%; }
.q-cfg-status span { font-size: 12px; color: var(--q-muted-2); white-space: nowrap; }
.q-pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--q-border-2); scrollbar-width: thin; }
.q-pill { display: flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 20px; background: #fff; border: 1px solid var(--q-border); cursor: pointer; flex-shrink: 0; white-space: nowrap; }
.q-pill .q-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--q-muted-3); flex-shrink: 0; }
.q-pill span { font-size: 12px; font-weight: 600; color: var(--q-muted-2); }
.q-pill.active { background: #EEF3FF; border-color: var(--q-accent); }
.q-pill.active .q-dot { background: var(--q-accent); }
.q-pill.active span { color: var(--q-accent); }
.q-autopilot { background: var(--q-soft); border-radius: 10px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.q-autopilot .t { font-size: 13.5px; font-weight: 700; color: var(--q-ink); margin-bottom: 3px; }
.q-autopilot .s { font-size: 12px; color: var(--q-muted-2); }
.q-toggle { width: 42px; height: 24px; border-radius: 12px; background: #D0D5DD; position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.q-toggle .thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; position: absolute; top: 3px; left: 3px; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.q-toggle.on { background: var(--q-accent); }
.q-toggle.on .thumb { left: 21px; }
.q-cfg-lbl { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--q-muted-3); margin-bottom: 9px; }
.q-seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); gap: 6px; margin-bottom: 20px; }
.q-seg-item { text-align: center; padding: 10px 4px; border-radius: 8px; background: #fff; border: 1px solid var(--q-border); cursor: pointer; }
.q-seg-item span { font-size: 12.5px; font-weight: 700; color: var(--q-muted-2); white-space: nowrap; }
.q-seg-item.active { border-color: var(--q-accent); background: #EEF3FF; }
.q-seg-item.active span { color: var(--q-accent); }
.q-risk { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 6px; margin-bottom: 12px; }
.q-risk-item { padding: 11px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--q-border); cursor: pointer; }
.q-risk-item.active { border-color: var(--q-accent); background: #EEF3FF; }
.q-risk-item .h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.q-risk-item .h span { font-size: 13px; font-weight: 700; color: var(--q-ink); }
.q-risk-item .radio { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #D0D5DD; }
.q-risk-item.active .radio { border-color: var(--q-accent); background: var(--q-accent); box-shadow: inset 0 0 0 2.5px #fff; }
.q-risk-item .sz { font-size: 11.5px; color: var(--q-muted-2); }
.q-risk-desc { background: var(--q-soft); border-radius: 8px; padding: 11px 13px; font-size: 12px; color: var(--q-muted); line-height: 1.5; margin-bottom: 20px; }
.q-alloc-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.q-alloc-head .l { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--q-muted-3); }
.q-alloc-head .r { font-size: 11.5px; color: var(--q-muted-3); }
.q-alloc-row { display: grid; grid-template-columns: 1fr 84px; gap: 8px; margin-bottom: 14px; }
.q-alloc-box { background: var(--q-soft); border-radius: 8px; padding: 10px 13px; display: flex; align-items: center; gap: 6px; }
.q-alloc-box .cur { font-size: 14px; color: var(--q-muted-3); }
.q-alloc-box .val { font-family: var(--q-font-mono); font-size: 17px; font-weight: 700; color: var(--q-ink); }
.q-alloc-box.pct { justify-content: center; gap: 4px; }
.q-range { width: 100%; margin-bottom: 20px; accent-color: var(--q-accent); }
.q-cfg-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.q-btn-ghost { padding: 12px 18px; border: none; border-radius: 8px; background: var(--q-soft); color: var(--q-ink-2); font-size: 13.5px; font-weight: 700; cursor: pointer; }
.q-btn-primary { padding: 12px 18px; border: none; border-radius: 8px; background: var(--q-accent); color: #fff; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.q-btn-primary:hover { background: var(--q-accent-hi); }

/* ---------- Portfolio strip (full-width, above main grid) ---------- */
.q-portfolio-strip {
  background: var(--q-card);
  border: 1px solid var(--q-border);
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 14px;
  animation: qfade .35s ease;
}
.q-port-inner  { display: flex; align-items: center; gap: 0; }
.q-port-label  {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  color: var(--q-muted-3); flex-shrink: 0; padding-right: 18px;
  border-right: 1px solid var(--q-border-2);
  margin-right: 0;
}
.q-port-metrics {
  display: flex; align-items: center; flex: 1; overflow-x: auto;
  scrollbar-width: thin; gap: 0;
}
.q-port-divider {
  width: 1px; height: 32px; background: var(--q-border-2);
  flex-shrink: 0; margin: 0 18px;
}
.q-port-metric { flex-shrink: 0; }
.q-port-metric-lbl {
  font-size: 10.5px; color: var(--q-muted-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px;
}
.q-port-metric-val {
  font-family: var(--q-font-mono); font-size: 15px; font-weight: 700;
  color: var(--q-ink); font-variant-numeric: tabular-nums;
}
.q-port-metric--total .q-port-metric-val { color: var(--q-accent); }
.q-port-kite  {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  margin-left: auto; padding-left: 18px;
}
.q-port-kite-name { font-size: 13px; color: var(--q-muted); white-space: nowrap; }
.q-port-kite-btn  { padding: 7px 13px; font-size: 12px; }

/* ---------- Portfolio / Kite card ---------- */
.q-kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--q-border-2); }
.q-kv:last-child { border-bottom: none; }
.q-kv .k { font-size: 13px; color: var(--q-muted-2); }
.q-kv.total .k { color: var(--q-ink); font-weight: 600; }
.q-kv .v { font-family: var(--q-font-mono); font-size: 13px; font-weight: 600; }
.q-kv.total .v { font-weight: 700; }
.q-kite-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }

/* ---------- AI Terminal ---------- */
.q-term-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-shrink: 0; flex-wrap: wrap; }
.q-search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--q-border); border-radius: 8px; padding: 9px 12px; flex: 1; min-width: 180px; max-width: 300px; }
.q-search input { border: none; outline: none; font-family: inherit; font-size: 13px; flex: 1; min-width: 0; color: var(--q-ink); background: transparent; }
.q-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.q-chip { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 20px; background: #fff; border: 1px solid var(--q-border); cursor: pointer; white-space: nowrap; }
.q-chip .q-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.q-chip .lbl { font-size: 12px; font-weight: 600; color: var(--q-muted-2); }
.q-chip .cnt { font-size: 11px; font-weight: 600; color: var(--q-muted-3); }
.q-chip.active { background: #EEF3FF; border-color: var(--q-accent); }
.q-chip.active .lbl { color: var(--q-accent); }
.q-terminal { background: var(--q-term-bg); border-radius: 10px; padding: 20px 22px; height: calc(100vh - 250px); min-height: 340px; overflow-y: auto; font-family: var(--q-font-mono); font-size: 13.5px; line-height: 1.6; }
.q-term-group { margin-bottom: 16px; }
.q-term-ghead { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer; background: var(--q-term-row); margin-bottom: 4px; }
.q-term-ghead .chev { color: #7A8699; font-size: 11px; transition: transform .15s; display: inline-block; }
.q-term-ghead.collapsed .chev { transform: rotate(-90deg); }
.q-term-ghead .g-label { color: #E6EAF0; font-weight: 600; font-size: 12.5px; }
.q-term-ghead .g-time { color: #546276; font-size: 12px; }
.q-term-ghead .g-count { margin-left: auto; color: #546276; font-size: 11.5px; }
.q-term-line { display: flex; align-items: baseline; gap: 12px; padding: 6px 8px; border-radius: 5px; white-space: pre-wrap; }
.q-term-badge { flex-shrink: 0; width: 64px; text-align: center; padding: 2px 0; border-radius: 10px; font-size: 10px; font-weight: 700; letter-spacing: .03em; }
.q-term-time { flex-shrink: 0; width: 66px; color: #66748A; font-size: 12px; }
.q-cursor { color: #7CE38B; display: inline-block; width: 8px; height: 14px; background: #7CE38B; animation: qblink 1s step-end infinite; vertical-align: text-bottom; margin-left: 8px; }

/* ---------- Back link ---------- */
.q-back { font-size: 13px; font-weight: 600; color: var(--q-accent); cursor: pointer; margin-bottom: 14px; flex-shrink: 0; display: inline-block; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .q-dash-grid { grid-template-columns: 1fr; }
  .q-col-left  { min-height: unset; }
  .q-card--half  { flex: unset; min-height: 240px; }
  .q-card--fill  { flex: unset; }
  .q-port-metrics { flex-wrap: wrap; gap: 10px; }
  .q-port-divider { display: none; }
  .q-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .q-sidebar { width: 60px; padding: 20px 8px; }
  .q-sb-brand .q-logo-name, .q-nav-item span, .q-nav-spacer span { display: none; }
  .q-main-inner { padding: 16px; }
  .q-stats { grid-template-columns: 1fr 1fr; }
  .q-port-inner { flex-wrap: wrap; gap: 10px; }
  .q-port-label { border-right: none; padding-right: 0; }
}
