/* Alpha Blueprint client portal — dark modern SaaS */
:root {
  --bg: #0b0f17;
  --bg-soft: #101622;
  --panel: #141c2b;
  --panel-2: #182136;
  --line: #223049;
  --text: #e8eef8;
  --muted: #93a1b8;
  --accent: #4f7cff;
  --accent-2: #38d9c0;
  --danger: #ff6b6b;
  --radius: 14px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(79,124,255,.14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(56,217,192,.10), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

/* ------------------------------- brand ------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; letter-spacing: .5px; color: #fff;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  box-shadow: 0 6px 18px rgba(79,124,255,.35);
}
.brand.small .brand-mark { width: 30px; height: 30px; border-radius: 8px; font-size: .8rem; }
.brand-name { font-weight: 700; letter-spacing: .2px; }
.brand-name span { color: var(--accent); }

/* ------------------------------- login ------------------------------- */
#login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 34px 32px; box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.login-card h1 { margin: 22px 0 6px; font-size: 1.55rem; }
.login-card .sub { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
#login-form { display: grid; gap: 12px; }
#access-code {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 13px 14px; font-size: 1rem; letter-spacing: 2px;
}
#access-code:focus { outline: none; border-color: var(--accent); }
#login-btn {
  background: linear-gradient(135deg, var(--accent), #7c5cff); color: #fff; border: 0;
  padding: 13px; border-radius: 10px; font-weight: 700; font-size: 1rem; cursor: pointer;
}
#login-btn:disabled { opacity: .6; cursor: wait; }
.login-error { color: var(--danger); font-size: .9rem; }
.fineprint { color: var(--muted); font-size: .8rem; margin-top: 20px; }

/* ------------------------------- topbar ------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 14px 22px;
  border-bottom: 1px solid var(--line); background: rgba(11,15,23,.8);
  position: sticky; top: 0; backdrop-filter: blur(10px); z-index: 5;
}
.client-chip {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-weight: 600; font-size: .9rem;
}
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
#range-select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
button.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; cursor: pointer;
}
button.ghost:hover { color: var(--text); border-color: var(--accent); }

/* ------------------------------- layout ------------------------------- */
.layout { display: grid; grid-template-columns: 1fr 370px; gap: 0; min-height: calc(100vh - 63px); }
.content { padding: 24px; overflow-x: hidden; }
.loading { color: var(--muted); padding: 60px; text-align: center; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; }
.kpi .value { font-size: 1.65rem; font-weight: 800; margin-top: 6px; }
.kpi .hint { color: var(--muted); font-size: .78rem; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: .95rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }

.rows { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .bar { height: 6px; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: .85; }
.row .num { color: var(--muted); min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.asof { color: var(--muted); font-size: .8rem; margin-top: 10px; }

/* ------------------------------- chat ------------------------------- */
.chat {
  border-left: 1px solid var(--line); background: var(--bg-soft);
  display: flex; flex-direction: column; height: calc(100vh - 63px); position: sticky; top: 63px;
}
.chat-head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.chat-title { font-weight: 700; }
.chat-sub { color: var(--muted); font-size: .8rem; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 12px; line-height: 1.45; font-size: .92rem; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), #7c5cff); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot.thinking { color: var(--muted); font-style: italic; }
.msg.bot pre, .msg.bot code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.msg.bot pre { background: #0d1320; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }
.chat-input { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--line); }
#chat-text {
  flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px;
}
#chat-text:focus { outline: none; border-color: var(--accent); }
#chat-send {
  background: linear-gradient(135deg, var(--accent), #7c5cff); color: #fff; border: 0;
  border-radius: 10px; padding: 0 18px; font-weight: 700; cursor: pointer;
}
#chat-send:disabled { opacity: .6; }

/* ------------------------------- responsive ------------------------------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .chat { position: fixed; inset: 63px 0 0 auto; width: min(400px, 100%); z-index: 9; transform: translateX(100%); transition: transform .25s ease; height: calc(100vh - 63px); }
  .chat.open { transform: translateX(0); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
