/* Commodity Intelligence — terminal design system.
   Faithful port of the Claude Design "Commodity Intelligence v2" component.
   Most component styling is inline (set by terminal.js to mirror the design);
   this file holds the global tokens, keyframes, responsive rules, form-control
   polish and the auth screens. The app theme tokens are also set inline on the
   terminal root by terminal.js so the Dark/Light toggle re-themes the subtree. */

:root {
  --bg:#0a0b0d; --bg2:#101216; --bg3:#16191f; --card:#101216; --bar:rgba(10,11,13,.82);
  --line:rgba(255,255,255,.07); --line2:rgba(255,255,255,.15);
  --text:#f2f4f7; --muted:#8b93a1; --faint:#5b6473;
  --gold:#e3b341; --goldWash:rgba(227,179,65,.12); --up:#5fd08a; --down:#f0666b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Hanken Grotesk', ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
button, select, input { font-family: inherit; }
[hidden] { display: none !important; }
::selection { background: rgba(227,179,65,.28); }

@keyframes ci-ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes ci-pulse  { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes ci-rise   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ci-spin   { to { transform: rotate(360deg); } }
@keyframes ci-blink  { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(140,150,165,.28); border-radius: 8px; }

/* Range slider polish (basket weights + scenario shocks) */
input[type=range] { accent-color: var(--gold); height: 4px; cursor: pointer; }

/* Edge-to-edge safe areas.
   Android 15+ (targetSdk 35+) draws the app behind the status and gesture
   bars. Capacitor's built-in SystemBars plugin only pads the native container
   when the page omits `viewport-fit=cover`; index.html sets it, so on a
   WebView >= 140 the real insets are handed to the web layer instead and the
   CSS below is what keeps content clear of the bars. On older WebViews and
   pre-Android-15 the insets resolve to 0 and these rules are inert. */
:root {
  --ci-safe-top: env(safe-area-inset-top, 0px);
  --ci-safe-right: env(safe-area-inset-right, 0px);
  --ci-safe-bottom: env(safe-area-inset-bottom, 0px);
  --ci-safe-left: env(safe-area-inset-left, 0px);
}

/* Responsive nav: hide top nav on phones, show bottom nav */
.ci-bottomnav { display: none; }
@media (max-width: 860px) {
  .ci-topnav { display: none !important; }
  .ci-bottomnav { display: flex !important; }
  /* The bottom nav grows by the gesture-bar inset, so the spacer must too. */
  .ci-main { padding-bottom: calc(88px + var(--ci-safe-bottom)) !important; }
  .ci-twocol, .ci-threecol { grid-template-columns: 1fr !important; }
}

/* Card hover (design used DC style-hover) */
.ci-card { transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.ci-card:hover { transform: translateY(-3px); border-color: var(--line2); box-shadow: 0 18px 40px rgba(0,0,0,.28); }

/* Chart value tooltip (hover on desktop, touch on mobile) */
.ci-tip {
  position: fixed; z-index: 9999; display: none; pointer-events: none;
  padding: 7px 11px; border-radius: 8px; border: 1px solid var(--line2);
  background: var(--bg2); color: var(--text);
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); max-width: 260px; white-space: nowrap;
}
.ci-tp { cursor: crosshair; }

/* ============ AUTH SCREENS ============ */
.ci-login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
@media (max-width: 820px) { .ci-login { grid-template-columns: 1fr; } .ci-login .ci-login-aside { display: none; } }

.ci-login-aside {
  position: relative; overflow: hidden;
  background: linear-gradient(155deg, #0c0e12, #0a0b0d 60%, #111319);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(48px + var(--ci-safe-top)) calc(clamp(32px, 5vw, 72px) + var(--ci-safe-right))
           calc(48px + var(--ci-safe-bottom)) calc(clamp(32px, 5vw, 72px) + var(--ci-safe-left));
}
.ci-login-aside::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 22% 30%, rgba(227,179,65,.12), transparent 38%),
              repeating-linear-gradient(118deg, rgba(227,179,65,.05) 0 1px, transparent 1px 26px);
}
.ci-login-form-wrap {
  display: flex; align-items: center; justify-content: center; background: var(--bg);
  padding: calc(40px + var(--ci-safe-top)) calc(40px + var(--ci-safe-right))
           calc(40px + var(--ci-safe-bottom)) calc(40px + var(--ci-safe-left));
}

.ci-auth-wrap {
  display: grid; place-items: center; min-height: 100vh; background: var(--bg);
  padding: calc(28px + var(--ci-safe-top)) calc(28px + var(--ci-safe-right))
           calc(28px + var(--ci-safe-bottom)) calc(28px + var(--ci-safe-left));
}
.ci-auth-card { width: 100%; max-width: 400px; }
.ci-auth-card h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; color: var(--text); }
.ci-auth-card p.sub { font-size: 14px; color: var(--muted); margin: 0 0 26px; line-height: 1.5; }
.ci-field { display: block; margin-bottom: 16px; }
.ci-field > span { display: block; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.ci-input {
  width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line2); border-radius: 10px;
  background: var(--bg2); color: var(--text); font-size: 15px;
}
.ci-input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.ci-btn-primary {
  width: 100%; height: 48px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #caa133); color: #1a1605;
  font-weight: 800; font-size: 15px; cursor: pointer; letter-spacing: .01em;
}
.ci-auth-links { display: flex; justify-content: space-between; margin-top: 18px; font-size: 13px; }
.ci-link { color: var(--muted); cursor: pointer; text-decoration: none; }
.ci-link.gold { color: var(--gold); font-weight: 600; }
.ci-auth-msg { margin-top: 16px; min-height: 1.2em; font-size: 13px; }
.ci-auth-msg.err { color: var(--down); }
.ci-auth-msg.ok { color: var(--up); }
.ci-strength { height: 6px; border-radius: 4px; background: var(--bg3); overflow: hidden; margin: -6px 0 16px; }
.ci-strength > i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.ci-fineprint { margin-top: 30px; font-size: 11px; color: var(--faint); line-height: 1.5; }

/* Admin screen */
.ci-admin { padding: 18px clamp(14px, 4vw, 40px); max-width: 1100px; margin: 0 auto; }
.ci-admin table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.ci-admin th, .ci-admin td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.ci-admin th { color: var(--faint); font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.ci-btn-sm, .ci-admin .secondary { height: 30px; padding: 0 10px; border: 1px solid var(--line2); border-radius: 8px; background: var(--bg2); color: var(--text); font-size: 12px; cursor: pointer; }
.ci-btn-sm.danger { border-color: rgba(240,102,107,.5); color: var(--down); }

/* ---- Continue with Google ---- */
.ci-btn-google{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;
  padding:12px 16px;border:1px solid var(--line);border-radius:10px;background:var(--card);
  color:var(--text);font-size:14px;font-weight:600;cursor:pointer;font-family:inherit}
.ci-btn-google:hover{background:var(--line)}
.ci-auth-or{display:flex;align-items:center;gap:12px;margin:16px 0;color:var(--muted);font-size:12px}
.ci-auth-or::before,.ci-auth-or::after{content:"";flex:1;height:1px;background:var(--line)}
/* display:flex above has equal specificity to a bare [hidden] rule and comes
   later in the sheet, so it would win and el.hidden = true would do nothing. */
.ci-btn-google[hidden],.ci-auth-or[hidden]{display:none}
