/* Phone / app layout (Android app + "Install app" from Chrome).
   Loaded last; only applies on narrow screens. */

@media (max-width: 780px) {
  html, body { overflow-x: hidden; }
  body { -webkit-tap-highlight-color: transparent; }

  /* ---------- compact header ---------- */
  .terminal-header {
    position: sticky; top: 0; z-index: 50;
    min-height: 54px; height: auto;
    padding: 4px 10px; padding-top: max(4px, env(safe-area-inset-top));
    gap: 8px;
  }
  .brand-area { min-width: 0; flex: 0 0 auto; }
  .biatrader-logo { width: 92px !important; height: 44px !important; flex-basis: 92px !important; object-fit: contain; }
  .header-actions { gap: 6px; flex: 1 1 auto; justify-content: flex-end; min-width: 0; }
  .market-clock, .header-status-dot, .client-chip { display: none !important; }
  .view-switch > span { display: none; }
  .view-switch select { max-width: 112px; font-size: 13px !important; padding: 5px 6px; }
  .theme-toggle { width: 32px; height: 32px; font-size: 15px; }
  .logout-button { min-width: 0 !important; padding: 6px 10px !important; font-size: 11px !important; }

  /* ---------- bottom tab bar (the sidebar becomes app tabs) ---------- */
  .terminal-sidebar {
    display: block !important;
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    z-index: 60; width: 100% !important; height: auto; min-height: 0;
    padding: 0 0 env(safe-area-inset-bottom); margin: 0;
    background: rgba(4, 18, 29, .97);
    border-top: 1px solid rgba(242, 189, 89, .35); border-right: 0;
    box-shadow: 0 -6px 18px rgba(0, 0, 0, .35);
    backdrop-filter: blur(8px);
  }
  .sidebar-session { display: none !important; }
  .terminal-nav {
    display: flex !important; flex-direction: row; gap: 0;
    overflow-x: auto; scrollbar-width: none; padding: 0; margin: 0;
  }
  .terminal-nav::-webkit-scrollbar { display: none; }
  .terminal-nav .nav-item {
    flex: 1 1 0; min-width: 52px; overflow: hidden; text-overflow: ellipsis;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 7px 2px 6px !important; margin: 0;
    font-size: 9px !important; letter-spacing: 0; line-height: 1.1;
    border: 0 !important; border-radius: 0 !important; background: transparent !important;
    color: #9fb6c8; text-align: center; white-space: nowrap;
  }
  .terminal-nav .nav-item .nav-icon { font-size: 18px; width: auto; height: auto; margin: 0; background: none; border: 0; }
  .terminal-nav .nav-item.active { color: #f2bd59 !important; box-shadow: inset 0 2px 0 #f2bd59; }

  .terminal-layout { grid-template-columns: 1fr !important; }
  .terminal-main { padding-bottom: calc(70px + env(safe-area-inset-bottom)); min-width: 0; }

  /* ---------- pages ---------- */
  body .pro-page, body .strategy-page { padding: 14px 12px !important; }
  body .pro-head h1, body .strategy-page-head h1 { font-size: 26px; }

  /* strategy card header: title on top, badges below */
  body .strategy-runtime-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  body .strategy-title-wrap { align-items: flex-start; }
  body .strategy-status-wrap { display: flex; flex-wrap: wrap; gap: 6px; }

  /* runtime tiles: let numbers wrap instead of "₹ 1,839…" */
  body .rt-tile strong { white-space: normal; overflow: visible; font-size: 17px; word-break: break-word; }
  body .rt-tile small { white-space: normal; }

  /* wide tables scroll sideways inside their card */
  body .rt-body table, body .pro-panel table, body .table-scroll table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  body .table-scroll { overflow-x: auto; }

  /* run mode + action buttons stack neatly */
  body .mode-switch { flex-wrap: wrap; gap: 8px; }
  body .mode-switch .mode-option { flex: 1 1 140px; }
  body .strategy-actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; }
  body .strategy-actions > * { width: 100%; text-align: center; justify-content: center; }

  /* bigger touch targets for form controls */
  input, select, textarea { font-size: 16px !important; } /* stops Android/iOS zooming into fields */
}

@media (max-width: 400px) {
  .biatrader-logo { width: 80px !important; flex-basis: 80px !important; }
  .view-switch select { max-width: 92px; }
}

/* Light theme for the tab bar */
@media (max-width: 780px) {
  html[data-theme="light"] .terminal-sidebar { background: rgba(255, 255, 255, .97); border-top-color: #e3c37a; box-shadow: 0 -4px 14px rgba(20, 40, 60, .12); }
  html[data-theme="light"] .terminal-nav .nav-item { color: #5b6f80; }
  html[data-theme="light"] .terminal-nav .nav-item.active { color: #b7791f !important; box-shadow: inset 0 2px 0 #c88329; }
}

/* ---------- sign-in page (all screen sizes) ---------- */
body.signed-out .terminal-sidebar, body.signed-out .header-actions > :not(.theme-toggle) { display: none !important; }
body.signed-out .terminal-layout { grid-template-columns: 1fr !important; }
.login-wrapper { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; box-sizing: border-box; padding: 28px 24px;
  background: linear-gradient(180deg, #0b2a40, #071d2d); border: 1px solid #29465c; border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; color: #fff; }
.login-card .muted { margin: 0 0 20px; color: #8fa8bb; }
.login-card form { display: grid; gap: 8px; }
.login-card label { color: #9fb6c8; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; margin-top: 6px; }
.login-card input { width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 10px; border: 1px solid #315069; background: #041624; color: #fff; font-size: 16px; }
.login-card input:focus { outline: none; border-color: #f2bd59; box-shadow: 0 0 0 3px rgba(242, 189, 89, .18); }
.login-card button { margin-top: 14px; padding: 13px; border-radius: 10px; font-size: 15px; font-weight: 800; letter-spacing: 1px; }
html[data-theme="light"] .login-card { background: #fff; border-color: #d9e2ea; box-shadow: 0 14px 30px rgba(20, 40, 60, .12); }
html[data-theme="light"] .login-card h1 { color: #0b2a40; }
html[data-theme="light"] .login-card input { background: #f6f9fb; border-color: #cfdbe5; color: #0b2a40; }
.login-error { margin: 0 0 12px; padding: 10px 12px; border-radius: 9px; background: rgba(229, 72, 77, .14); border: 1px solid rgba(229, 72, 77, .45); color: #ff9b9e; font-size: 13px; font-weight: 600; }

/* ---------- daily Zebu login banner ---------- */
.zebu-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 12px 18px 0; padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  background: rgba(242, 189, 89, .12); border: 1px solid rgba(242, 189, 89, .45); color: #f6dca4; }
.zebu-banner b { color: #ffd67b; }
.zebu-banner-btn { flex: 0 0 auto; padding: 7px 14px; border-radius: 8px; font-weight: 800; font-size: 12.5px; text-decoration: none;
  color: #061722 !important; background: linear-gradient(180deg, #f2bd59, #c88329); border: 1px solid #ffd67b; }
html[data-theme="light"] .zebu-banner { background: #fff7e6; border-color: #e8c272; color: #6b4a0f; }
html[data-theme="light"] .zebu-banner b { color: #8a5a00; }
@media (max-width: 780px) { .zebu-banner { margin: 10px 12px 0; } }
