/* ===== Websuite AI Trading · mobile-first dark theme ===== */
:root {
  --bg: #0b1220;
  --panel: #11192c;
  --panel-2: #161f37;
  --ink: #e6edf6;
  --muted: #8493ad;
  --line: #1f2a44;
  --brand: #0F766E;
  --brand-2: #34D399;
  --brand-ink: #0b1220;
  --up: #22c55e;
  --down: #ef4444;
  --bubble-user: linear-gradient(135deg, #0F766E, #34D399);
  --bubble-user-ink: #06140f;
  --bubble-agent: #1a2342;
  --bubble-agent-ink: #e6edf6;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code, .mono { font-family: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace; }

/* ----- LOGIN ----- */
.login-body {
  display: grid; place-items: center; min-height: 100dvh;
  background:
    radial-gradient(60% 50% at 50% 10%, rgba(15, 118, 110, .35), transparent 60%),
    radial-gradient(50% 40% at 90% 90%, rgba(52, 211, 153, .18), transparent 60%),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
  text-align: center;
}
.brand { margin-bottom: 24px; }
.brand-logo {
  width: 80px; height: 80px;
  border-radius: 22px;
  display: block; margin: 0 auto 14px;
  object-fit: cover;
  box-shadow: 0 6px 22px rgba(15, 118, 110, .35);
}
.brand h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.3px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 0;
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-google { background: #fff; color: #111; }

/* ----- APP SHELL ----- */
.app { display: grid; grid-template-rows: auto auto 1fr auto; height: 100dvh; }
.topbar {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center;
  padding: env(safe-area-inset-top, 0) 6px 0;
  background: var(--panel); border-bottom: 1px solid var(--line);
  height: calc(56px + env(safe-area-inset-top, 0));
  overflow: hidden;
}
.topbar .title { min-width: 0; }    /* allow truncation */
.topbar .title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700;
}
.topbar .title img { width: 24px; height: 24px; border-radius: 7px; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: transparent; color: var(--ink); border: 0; cursor: pointer;
}
.iconbtn:active { background: var(--panel-2); }

/* ----- TABS ----- */
.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 8px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.tab {
  padding: 10px 8px; border-radius: 10px; text-align: center;
  background: var(--panel-2); border: 1px solid transparent;
  font-weight: 600; color: var(--muted); cursor: pointer; user-select: none;
}
.tab.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-ink); border-color: transparent; }

/* ----- CHAT ----- */
.chat {
  overflow-y: auto; padding: 14px 12px 80px;
  display: flex; flex-direction: column; gap: 10px;
}
.bubble {
  max-width: 86%; padding: 10px 14px; border-radius: 16px;
  line-height: 1.45; word-wrap: break-word; white-space: pre-wrap;
  font-size: 15px;
}
.bubble.user { align-self: flex-end; background: var(--bubble-user); color: var(--bubble-user-ink); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--bubble-agent); color: var(--bubble-agent-ink); border-bottom-left-radius: 4px; }
.bubble.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; max-width: 100%; text-align: center; }
.bubble code { background: rgba(255,255,255,0.08); padding: 0 4px; border-radius: 4px; }

/* ----- COMPOSER ----- */
.composer {
  position: sticky; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: 1fr 44px;
  gap: 8px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0));
  background: var(--panel); border-top: 1px solid var(--line);
}
.composer textarea {
  resize: none; max-height: 140px; padding: 12px 14px;
  border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink);
}
.send-btn { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-ink); border-radius: 12px; }

/* ----- ADMIN ----- */
.admin { padding: 16px; max-width: 560px; margin: 0 auto; }
.admin h2 { margin: 0 0 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 12px 0; }
.card h3 { margin: 0 0 8px; font-size: 15px; color: var(--brand-2); }
.field { display: grid; gap: 6px; margin: 10px 0; }
.field input, .field textarea {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); width: 100%;
}
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-ink); }
.btn-secondary { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.status-pill.ok { background: rgba(34,197,94,.15); border-color: rgba(34,197,94,.4); color: var(--up); }
.status-pill.warn { background: rgba(241,196,15,.15); border-color: rgba(241,196,15,.4); color: #f1c715; }
.status-pill.err { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.4); color: var(--down); }

.term {
  background: #07101e; color: #b5d3ff; padding: 10px;
  font-family: ui-monospace, monospace; font-size: 11.5px;
  border-radius: 10px; max-height: 240px; overflow: auto; white-space: pre-wrap;
}

/* Quota pill in topbar */
.quota-pill {
  width: auto; padding: 0 10px; height: 30px; min-width: 0;
  border: 1px solid var(--line); background: var(--panel-2);
  align-self: center; margin-right: 6px; border-radius: 999px;
  flex-shrink: 0;
}
.quota-pill .small { font-weight: 700; font-size: 11px; }
.quota-pill.ok { border-color: rgba(34,197,94,.45); color: var(--up); }
.quota-pill.warn { border-color: rgba(241,196,15,.45); color: #f1c715; }
.quota-pill.err { border-color: rgba(239,68,68,.45); color: var(--down); }

/* ----- BOTTOM-SHEET DRAWER (menu) ----- */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 99; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-bottom {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--panel);
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  transform: translateY(100%); transition: transform .26s ease-out;
  z-index: 100; padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0));
  max-height: 86vh; overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(0,0,0,.4);
}
.drawer-bottom.open { transform: translateY(0); }
.drawer-handle {
  width: 44px; height: 4px; border-radius: 2px;
  background: var(--line); margin: 6px auto 18px;
}
.menu-card {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 14px; margin-bottom: 14px;
}
.menu-card.spotlight { border-color: var(--brand-2); }
.menu-card .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; font-weight: 700; }
.menu-card p { margin: 0 0 12px; }
.menu-link {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line);
  margin-bottom: 8px; color: var(--ink); text-decoration: none;
  width: 100%; text-align: left; font: inherit; cursor: pointer;
}
.menu-link:active { background: #1f2a44; }
.menu-link .ico { font-size: 20px; width: 24px; text-align: center; }
.menu-link.danger { color: var(--down); }
.menu-section-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 12px 4px 6px; }
