/* public/app.css */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  /* allow header to grow on small viewports so nav buttons stay visually inside */
  padding-block: clamp(6px, 2.5vh, 22px);
  border-bottom: 1px solid #eee;
  box-shadow:0 2px 10px rgba(0,0,0,.06);
  gap: 0px;
}

/* Header: stack logo + nav vertically without touching global app.css */
.site-header-inner{display:flex;flex-direction:column;align-items:center;gap:0px;padding-block:clamp(6px,2vh,18px)}
.site-subnav{display:flex;gap:16px;align-items:center;justify-content:center;flex-wrap:wrap}
.site-subnav a{
  display:inline-block;padding:8px 14px;border:1px solid #e6e6e6;border-radius:999px;
  text-decoration:none;font-weight:600;font-size:14px;line-height:1;color:#0d6efd;background:#fafafa
}
.site-subnav a:hover{background:#f0f6ff;border-color:#d7e3ff;text-decoration:none}

.footer {
  top: 0;
  z-index: 1000;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 2%;
  padding-bottom: 2%;
  padding-right: 3%;
  padding-left: 3%;
  border-top: 1px solid #eee;
  box-shadow:0 2px 10px rgba(0,0,0,.06);
  margin-top: 3%;
  margin-bottom: 2%;
}

/* faster load times */
.shimmer{ position:relative; background:#eee; border-radius:4px; }
.shimmer::after{
  content:""; position:absolute; inset:0;
  background:linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
  transform:translateX(-100%); animation:sh 1.2s infinite;
}

/* Logo scales with viewport */
.logo {
  display: block;
  height: auto;
  max-height: clamp(56px, 12vw, 150px);
  max-width: min(70vw, 620px);
  width: auto;
  object-fit: contain;
  cursor: pointer;
}

/* Typography + layout */
body {
  font-family: system-ui, "Plus Jakarta Sans", sans-serif;
  padding-top: 0;
  padding-left: 10%;
  padding-right: 10%;
  /* Make the page fill the viewport so footer stays at the bottom */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Ensure main grows to fill available space between header and footer */
main { flex: 1 1 auto; }

/* ---- Status cards layout ---- */
.critical-container{
  display:flex;
  flex-wrap:wrap;
  gap:16px;
  align-items:stretch;
}
.critical-card{
  border:1px solid #eee;
  border-radius:12px;
  padding:16px;
  margin-top: 2%;
  margin-bottom: 2%;
  width: 50px;
  max-width:560px;
  box-shadow:0 2px 10px rgba(0,0,0,.06);
  flex: 1 1 150px;
}

/* Make the first two status cards narrower so the realtime/ticker card can take more space */
.critical-container .critical-card:nth-child(1),
.critical-container .critical-card:nth-child(2) {
  /* prefer a compact, fixed-ish size but still shrink on small viewports */
  flex: 0 1 160px;
  max-width: 260px;
}

/* Allow the realtime ticker card to expand more prominently */
#rtCard {
  flex: 2 1 480px;
}

/* Make the realtime/ticker card stretch vertically and allow the grid to scroll */
#rtCard{
  display: flex;
  flex-direction: column;
  /* ensure it can grow taller than content when space allows */
  min-height: 220px;
}
.rt{ /* inner container */
  display:flex;
  flex-direction:column;
  flex: 1 1 auto;
  min-height: 0; /* allow children to shrink/scroll inside flex */
}
.rt-grid{
  /* make the grid take remaining vertical space and scroll if content overflows */
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.normal-container{
  border:1px solid #eee;
  border-radius:12px;
  padding:16px;
  margin-top: 2%;
  margin-bottom: 3%;
  box-shadow:0 2px 10px rgba(0,0,0,.06);
}

.std-button {
  padding:6px 10px; width: 100px; border-radius: 5px;
}

/* ensure pseudo-element spinner positions correctly */
.std-button { position: relative; }

/* small visual for the latch button */
.std-button.on { background: #0a8f2d; color: #fff; border-color: #0a8f2d; }

.latch-toast-container { position: fixed; top: 16px; right: 16px; z-index: 99999 !important; display:flex; flex-direction:column; gap:8px; align-items:flex-end; pointer-events: none; }
.latch-toast { min-width: 160px; max-width:320px; padding:10px 12px; border-radius:8px; color:#fff; background:rgba(0,0,0,0.92) !important; transform:translateY(-8px); opacity:0; transition:opacity .25s ease, transform .25s ease; box-shadow:0 12px 30px rgba(0,0,0,0.28) !important; font-size:14px; pointer-events: auto; }
.latch-toast.visible{ transform:translateY(0); opacity:1; }
.latch-toast.success{ background:#198754 !important; }
.latch-toast.error{ background:#d6333c !important; }

/* small spinner on button when loading */
.std-button.loading{ opacity:0.9; cursor:progress; }
.std-button.loading::after{
  content: '';
  box-sizing: border-box;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: rgba(255,255,255,0.95);
  border-radius: 50%;
  animation: latch-spin .8s linear infinite;
}
@keyframes latch-spin{ to { transform: translateY(-50%) rotate(360deg); } }

.dropdown {
  padding:6px 10px; width: 100px; border-radius: 5px;
}

.row { display:flex; gap:12px; align-items:center; margin:8px 0; }
.dot { width:14px; height:14px; border-radius:80%; background:#bbb; }
.on { background:#090; box-shadow:0 0 10px rgba(0,160,0,.7); }
.on-red { background:#d00; box-shadow:0 0 10px rgba(220,0,0,.7); }
.ts { color:hsl(225, 8%, 72%); font-size:14px; }

/* Keep RT meta elements on one line inside the realtime card */
#rtCard .ts, #rtCard .pill, #rtCard #rtTs, #rtCard #rtMeta{
  display: inline-block;
  vertical-align: middle;
  margin-left: 10px;
}

#rtCard #rtPhase.pill{ margin-left: 0px; }

/* inline container that prevents the RT meta from wrapping/stacking */
.rt-meta-line{ display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-meta-line .ts{ margin:0; }

/* Make the phase render inline with other muted metadata words (no pill visuals) */
#rtCard .pill{
  color: hsl(225, 8%, 72%);
  background: transparent;
  border: none;
  padding: 0;
}

/* Ensure open/closed variants do not render as pills so the phase reads inline */
#rtCard .pill.open,
#rtCard .pill.closed {
  background: transparent;
  color: hsl(225, 8%, 72%);
  border: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}
.group { margin-top:0px; }

.blue-text { color:#2962FF; text-decoration:none !important; }
.brand { color:#B2B5BE !important; text-decoration:none; }
.reserved { color:#B2B5BE; text-decoration:none !important; }

.copyright {
  font-size: 13px !important;
  margin-top: 7px;
  margin-bottom: 1%;
  line-height: 3px !important;
  text-align: center !important;
  vertical-align: middle !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif !important;
  cursor: pointer;
}

/* Header Logo */
.logo-link { display: inline-flex; align-items: center; }
.logo-link:focus { outline: 2px solid #4c9ffe; outline-offset: 4px; }

/* TradingView Widget */
.tradingview-widget-container {
  width: 100%;
  max-width: 1200px;
  margin: 40px auto 0 auto;
}
.tradingview-widget-container__widget {
  width: 100%;
  height: 600px;
}

/* Chart.js */
#dual { width:100%; height:360px; border:1px solid lab(88.47% 0 -0.01 / 0.14); background:#fff; position:relative; }
#chart { width:100%; height:100%; display:block; }
.xhover { margin:6px 0 0 0; color:#444; text-align:center; }
#symForm { display:flex; flex-wrap:wrap; margin-bottom: 2%; gap:8px; align-items:center; }
#symForm label { display:flex; align-items:center; gap:6px; }
#symForm input { padding: 4px 6px; }
/* #applyBtn { padding:6px 10px; } */
#xLabel { display: block; width: 100%; text-align: center; margin-top: 1%; }
.err { color:hsl(349, 98%, 49%); font:14px/1.4 system-ui, sans-serif; padding:8px; white-space:pre-wrap; }

/* zChart.js */
.wrap { max-width: 980px; margin-inline: auto; }
.controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin: 12px 0 8px;
  align-items: end;
}
.controls label { font-size: 12px; color: #444; display:block; margin-bottom: 4px; }
input[type="text"], input[type="number"], select, textarea {
   padding: 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}
textarea { height: 140px; resize: vertical;}

.empty-field{
  /* width: 20%; */
  border:1px solid hwb(0 93% 7% / 0.863);
  border-radius:3px;
  margin-top: 2%;
  margin-bottom: 3%;
  box-shadow:0 2px 10px #00000005;

}

button { padding: 9px 14px; border: 1px solid #ccc; border-radius: 6px; background:#f6f6f6; cursor:pointer; }
button:disabled { opacity:.6; cursor:not-allowed; }
#sub { color:#666; margin: 6px 0 14px 0; }
canvas { background:#fff; border-radius: 8px; display:block; width:100%; height:440px; }
:root { --gold:#d19a00; --grid:#d9d9d9; }

/* Password visibility toggle styling (small eye button) */
.pwd-toggle {
  padding: 6px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 8px;
  cursor: pointer;
  color: #334155; /* svg stroke color */
}
.pwd-toggle svg { display:block; width:18px; height:18px; }
.pwd-toggle:hover { background:#f8fafc; border-color:#c7defa; }
.pwd-toggle:focus { outline:2px solid rgba(79, 70, 229, 0.18); outline-offset:2px; }
.pwd-toggle[aria-pressed="true"] { background:#eef2ff; border-color:#c7defa; }

/* Center the login box and give it a subtle card look so it's visually centered on the page */
#loginBox {
  max-width: 560px;
  /* responsive vertical spacing: smaller min so heading sits closer to card, still scales with viewport */
  margin-block: clamp(16px, 8vh, 120px);
  margin-inline: auto;
  padding: 18px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  border: 1px solid #f0f0f0;
}

/* Centered, polished login form inside the login card */
#loginBox .login-form{
  display:flex;
  flex-direction:column;
  gap:12px;
  align-items:center; /* center the whole form block inside the card */
  max-width:420px; /* control form width so it looks neat inside the card */
  margin: 0 auto; /* horizontally center */
  padding: 6px 0;
}

#loginBox .login-form .form-row{ display:flex; flex-direction:column; width:100%; gap:6px; }

#loginBox .login-form label{ font-weight:600; color:#344054; font-size:14px; }

/* inputs inside the centered form get a cleaner look */
#loginBox .login-form input[type="text"],
#loginBox .login-form input[type="password"]{
  width:100%;
  padding: 10px 12px;
  border: 1px solid #e6edf3;
  border-radius: 8px;
  background: #fbfdff;
  box-shadow: 0 1px 2px rgba(16,24,40,0.03);
  transition: box-shadow .12s ease, border-color .12s ease;
}
#loginBox .login-form input:focus{ outline: none; border-color: #9ec5ff; box-shadow: 0 6px 18px rgba(13,110,253,0.08); }

/* ensure username input uses full width inside the centered form */
#loginBox .login-form input#username{ width:100%; max-width:100%; }

#loginBox .login-form .form-actions{ display:flex; gap:10px; width:100%; align-items:center; }

/* primary button style */
.btn-primary{ padding:8px 14px; background:#0d6efd; color:#fff; border:none; border-radius:8px; box-shadow:0 8px 20px rgba(13,110,253,0.12); cursor:pointer; font-weight:700; }
.btn-primary:hover{ background:#0b5ed7; }

/* if there are secondary actions they should be subtle */
.btn-ghost{ padding:8px 12px; background:transparent; border:1px solid #e6eefb; color:#334155; border-radius:8px; }

/* center the primary action if desired */
#loginBox .login-form .form-actions.center{ justify-content:center; }

/* Center the page-level heading above the login card on the /me page */
main > h1 { text-align: center; margin-top: 0.25rem; margin-bottom: 0.25rem; }

/* Make inputs full-width inside the login card for a cleaner layout */
#loginBox input[type="text"],
#loginBox input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #dfe3ea;
  border-radius: 6px;
}

/* Make the username input narrower to match the visual width of the password field */
#loginBox input#username {
  width: 190px;
  max-width: 100%;
  display: inline-block;
}

@media (max-width: 520px) {
  #loginBox input#username { width: 100%; }
}

/* Reuse the same card styling for account and positions boxes so layout is consistent */
#accountBox, #positionsBox {
  max-width: 900px;
  /* use the same responsive vertical spacing as #loginBox so cards align visually */
  margin-block: clamp(16px, 8vh, 120px);
  margin-inline: auto;
  padding: 18px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  border: 1px solid #f0f0f0;
}

/* When account/positions are visible, align their inner elements */
#accountBox pre#accountJson {
  background: #f6f8fa;
  border: 1px solid #e6e9ee;
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
}

#positionsBox table {
  width: 100%;
  border-collapse: collapse;
}

#positionsBox th, #positionsBox td {
  padding: 8px;
  vertical-align: middle;
  border-bottom: 1px solid #f0f0f0;
}

/* Card header layout: title on the left, actions (buttons) aligned right */
.card-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.card-header h2{margin:0;font-size:20px}
.card-actions{display:flex;gap:8px;align-items:center}
.card-actions .std-button{padding:6px 10px;border-radius:6px}

/* Responsive tweaks */
@media (max-width: 480px) {
  /* keep some header padding on small screens so wrapped nav sits inside header */
  .site-header { padding-block: clamp(8px, 4vh, 16px); }
  .critical-card { padding: 14px; }
}
@media (max-width:480px){.site-subnav{gap:10px}.site-subnav a{padding:7px 12px;font-size:13px}}
@media (min-width: 1280px) {
  .site-header { padding-block: 0px; }
  .critical-card { max-width: 1280px; }
}
@media (max-width: 520px) {
  .chartwrap { gap: 12px; }
}

/* Faster load times */
@keyframes sh{ 100% { transform:translateX(100%); } }
.news-grid{ display:grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap:12px; }
.news-item{ border:1px solid #eee; border-radius:10px; padding:10px; box-shadow:0 2px 10px rgba(0,0,0,.04); }
.sym-head{ font-weight:700; margin-bottom:6px; }

/* realtime price percent change styling: refined */
.rt .price-cell{ font-variant-numeric: tabular-nums; }

/* Re-styled realtime header */
.rt-headers{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;padding-bottom:1px}
.rt-headers h3{margin:0;font-size:18px;font-weight:700;color:#0f1724;letter-spacing:0.2px}
.rt-headers .meta{font-size:13px;color:#6b7280}

/* RT grid: 3 columns of ticker items */
.rt-grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px 18px;
  margin-top: 8px;
}
.rt-col{ display:flex; flex-direction:column; gap:8px; }

/* polished item card */
.rt-item{ display:flex; justify-content:space-between; align-items:center; padding:1px 6px; border-radius:8px; background: linear-gradient(180deg, #ffffff, #fbfbfb); border: 1px solid rgba(15,23,42,0.04); box-shadow: 0 4px 14px hsla(229, 84%, 5%, 0); transition: transform .06s ease, box-shadow .06s ease; }
.rt-item:hover{ transform: translateY(-2px); box-shadow: 0 10px 30px rgba(2,6,23,0.06); }
.rt-item .symbol{ font-weight:700; color:#0f1724; margin-right:8px; font-size:15px }
.rt-item .price{ color:#0b1723; font-variant-numeric: tabular-nums; min-width:110px; text-align:right; font-weight:500 }
.rt-item .price .rt-pct{ margin-left:10px; font-weight:500 }

/* percent pill styling */
.rt-pct-pill{ display:inline-block; min-width:56px; padding:4px 8px; border-radius:7px; font-size:13px; font-weight:500; text-align:center; box-shadow: inset 0 -1px 0 rgba(255,255,255,0.02); }
.pct-up { color: #0a8f2d; background: rgba(10,143,45,0.06); border:1px solid rgba(10,143,45,0.12); }
.pct-down { color: #d6333c; background: rgba(214,51,60,0.06); border:1px solid rgba(214,51,60,0.10); }

/* subtle update highlight when percent changes */
.rt-updated{ animation: rt-pulse 760ms cubic-bezier(.2,.9,.3,1); }
.pct-up.rt-updated{ box-shadow: 0 10px 24px rgba(10,143,45,0.10); }
.pct-down.rt-updated{ box-shadow: 0 10px 24px rgba(214,51,60,0.10); }

@keyframes rt-pulse{
  0% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-3px) scale(1.04); }
  60% { transform: translateY(0) scale(1.01); }
 100% { transform: translateY(0) scale(1); }
}


@media (max-width: 820px){
  .rt-grid{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  /* Center the left-stack (critical/momentum) cards so they sit centered on narrow viewports */
  .critical-container{ justify-content: center; }
  .critical-container .critical-card{
    flex: 0 1 92%;
    max-width: 520px;
    width: 92%;
    margin-left: 0;
    margin-right: 0;
  }
}
@media (max-width: 520px){
  .rt-grid{ grid-template-columns: 1fr; }
  .rt-item .price{ min-width:70px; }
  /* keep the critical cards centered on even smaller viewports */
  .critical-container{ justify-content: center; }
  .critical-container .critical-card{
    flex: 0 1 94%;
    max-width: 480px;
    width: 94%;
  }
}

/* Positions table numeric columns */
#positionsTable th, #positionsTable td {
  padding: 8px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
#positionsTable th { font-weight:700; }
.col-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.col-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', 'Courier New', monospace; }

/* Comparison summary fallback message */
.empty-summary{ color:#666; padding:8px 12px; border-radius:8px; background:transparent; font-weight:600 }

/* ------------------------------------------------------------------
   UI visibility tweaks: hide controls/panels while preserving DOM
   - Keep elements in the DOM (so JS still reads/writes values) but
     visually remove them from the layout. This preserves functionality
     while making the UI cleaner per user request.
------------------------------------------------------------------ */
/* Hide the Mode label + select visually but keep them available to scripts */
label[for="rtMode"], #rtMode { display: none !important; }

/* Hide the close / prev text only inside the realtime card so other
  components (like the comparison summary) can still use the same
  classes for consistent styling. */
#rtCard .rt-close, #rtCard .rt-prev { display: none !important; }
.rt-close, .rt-prev { display: none !important; }