/* ═══════════ Bentley Command Deck ═══════════ */
:root {
  --bg: #040812;
  --panel: rgba(11, 18, 40, .72);
  --panel-solid: #0b1228;
  --line: #1b2848;
  --line-hi: #2a3a66;
  --blue: #4f7df9;
  --violet: #8b5cf6;
  --cyan: #38bdf8;
  --teal: #5eead4;
  --text: #e6ecfa;
  --dim: #8b97b9;
  --danger: #f87171;
  --grad: linear-gradient(92deg, #4f7df9, #8b5cf6);
  --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, system-ui, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
}
h1, h2, h3, .wordmark, .tab { font-family: "Space Grotesk", Inter, sans-serif; }

/* ── ambient layers ── */
.bg-glow, .bg-diamonds { position: fixed; inset: 0; pointer-events: none; }
.bg-glow {
  background:
    radial-gradient(60% 38% at 50% -6%, rgba(79, 125, 249, .28), transparent 70%),
    radial-gradient(45% 30% at 85% 110%, rgba(139, 92, 246, .14), transparent 70%),
    radial-gradient(35% 25% at 8% 90%, rgba(56, 189, 248, .08), transparent 70%);
  z-index: 0;
}
.bg-diamonds {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='88'%3E%3Cg fill='none' stroke='%232a3a66' stroke-opacity='.33'%3E%3Cpath d='M22 6 L38 22 L22 38 L6 22 Z'/%3E%3Cpath d='M66 50 L82 66 L66 82 L50 66 Z'/%3E%3C/g%3E%3C/svg%3E");
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), rgba(0,0,0,.25) 40%, rgba(0,0,0,.55));
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), rgba(0,0,0,.25) 40%, rgba(0,0,0,.55));
  z-index: 0;
}

.hidden { display: none !important; }
.dim { color: var(--dim); }

/* ── brand ── */
.brand { display: flex; align-items: center; gap: 12px; }
.wordmark { font-size: 22px; font-weight: 700; letter-spacing: .3px; }
.brand.big .wordmark { font-size: 34px; }
.grad {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.orb-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #9db4ff, #4f7df9 55%, #2b1e8f);
  box-shadow: 0 0 14px rgba(79, 125, 249, .8);
}
.brand.big .orb-dot { width: 26px; height: 26px; }

/* ── login ── */
.login {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login::before { content: ""; position: absolute; inset: 0;
  background: radial-gradient(55% 40% at 50% 0%, rgba(79,125,249,.25), transparent 70%); }
.login-card {
  position: relative; width: min(400px, 100%);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 24px; padding: 40px 32px 32px;
  backdrop-filter: blur(14px); text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
}
.login-card .brand { justify-content: center; margin-bottom: 10px; }
.login-sub { color: var(--dim); font-size: 14px; margin-bottom: 26px; }
.login-card input {
  width: 100%; padding: 14px 18px; margin-bottom: 14px;
  background: #060b1c; border: 1px solid var(--line-hi);
  border-radius: 999px; color: var(--text); font-size: 16px; outline: none;
  text-align: center;
}
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79,125,249,.2); }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ── buttons ── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 22px; border: none; cursor: pointer;
  border-radius: 999px; background: var(--grad);
  color: #fff; font-size: 16px; font-weight: 600; font-family: inherit;
  box-shadow: 0 6px 24px rgba(79, 125, 249, .35), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .15s, box-shadow .15s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(79,125,249,.45), inset 0 1px 0 rgba(255,255,255,.25); }
.btn-primary.small { width: auto; padding: 11px 20px; font-size: 14px; }
.link-btn { background: none; border: none; color: var(--dim); cursor: pointer; font: inherit; font-size: 12px; }
.link-btn:hover { color: var(--text); }
.reset-chat { font-size: 13px; align-self: center; }
.reset-chat:hover { color: var(--cyan); }

/* ── app shell ── */
.app { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto;
  padding: 18px clamp(14px, 4vw, 32px) 40px; min-height: 100dvh;
  display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; color: #b9c6e8;
  background: rgba(37, 55, 110, .35); border: 1px solid var(--line-hi);
  backdrop-filter: blur(8px);
}
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal);
  box-shadow: 0 0 8px var(--teal); animation: pulse 2.4s infinite; }
.pulse-dot.down { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
@keyframes pulse { 50% { opacity: .45; } }

/* ── tabs ── */
.tabs { display: flex; gap: 8px; padding: 5px; border-radius: 16px;
  background: rgba(10, 16, 36, .7); border: 1px solid var(--line);
  backdrop-filter: blur(10px); position: sticky; top: 10px; z-index: 20; }
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 8px; border: none; border-radius: 12px; cursor: pointer;
  background: transparent; color: var(--dim); font-size: 14.5px; font-weight: 600;
  transition: color .2s, background .2s;
}
.tab.active { background: linear-gradient(180deg, rgba(79,125,249,.22), rgba(79,125,249,.08));
  color: #fff; box-shadow: inset 0 0 0 1px rgba(79,125,249,.35); }

/* ── views ── */
.view { display: none; padding-top: 26px; flex: 1; }
.view.active { display: block; }

/* ── voice / orb ── */
.orb-stage { display: flex; flex-direction: column; align-items: center; }
#orb { width: min(300px, 62vw); height: auto; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.orb-state { margin-top: 2px; color: var(--dim); font-size: 14px; min-height: 20px;
  letter-spacing: .04em; text-align: center; transition: color .3s; }
.orb-state.hot { color: var(--cyan); }
.stop-btn {
  margin-top: 12px; padding: 10px 22px; cursor: pointer;
  border-radius: 999px; font: 600 13.5px Inter, sans-serif; letter-spacing: .04em;
  color: #ffb4b4; background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .45);
  box-shadow: 0 0 18px rgba(248, 113, 113, .18);
  transition: background .15s, transform .15s;
}
.stop-btn:hover { background: rgba(248, 113, 113, .22); transform: translateY(-1px); }

.convo-controls { display: flex; justify-content: center; gap: 26px; margin: 18px 0 8px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--dim); cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .track { width: 36px; height: 20px; border-radius: 999px; background: #131d3d;
  border: 1px solid var(--line-hi); position: relative; transition: background .2s; }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--dim); transition: transform .2s, background .2s; }
.toggle input:checked + .track { background: rgba(79,125,249,.45); }
.toggle input:checked + .track .knob { transform: translateX(16px); background: #fff; }

.voice-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); }
.voice-pick select {
  background: #131d3d; color: var(--text); border: 1px solid var(--line-hi);
  border-radius: 10px; padding: 5px 10px; font-size: 13px; max-width: 190px;
  outline: none; cursor: pointer;
}
.voice-pick select:focus { border-color: var(--blue); }

/* chat */
.chat-log { display: flex; flex-direction: column; gap: 10px; margin: 16px auto 0; max-width: 640px; }
.bubble { padding: 12px 16px; border-radius: 16px; font-size: 14.5px; line-height: 1.55;
  max-width: 86%; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: linear-gradient(120deg, rgba(79,125,249,.32), rgba(139,92,246,.28));
  border: 1px solid rgba(79,125,249,.4); border-bottom-right-radius: 6px; }
.bubble.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line);
  border-bottom-left-radius: 6px; }
.bubble.err { align-self: center; color: var(--danger); background: rgba(248,113,113,.08);
  border: 1px solid rgba(248,113,113,.3); font-size: 13px; }

.chat-input { display: flex; gap: 10px; max-width: 640px; margin: 14px auto 0; width: 100%; }
.chat-input input {
  flex: 1; min-width: 0; padding: 13px 18px; background: rgba(6, 11, 28, .92);
  border: 1px solid var(--line-hi); border-radius: 999px;
  color: var(--text); font-size: 16px; outline: none;
}
.chat-input input:focus { border-color: var(--blue); }
.mic-btn {
  width: 46px; height: 46px; flex: none; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line-hi); background: rgba(13, 20, 42, .9); color: var(--cyan);
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.mic-btn:hover { border-color: var(--cyan); }
.mic-btn.live { background: var(--grad); color: #fff; border-color: transparent;
  box-shadow: 0 0 18px rgba(79,125,249,.6); }

/* ── files ── */
.files-head h2 { font-size: 24px; margin-bottom: 3px; }
.files-head p { font-size: 13.5px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 16px 0; font-size: 13.5px; }
.crumb { color: var(--cyan); cursor: pointer; background: none; border: none; font: inherit; padding: 2px 4px; }
.crumb:hover { text-decoration: underline; }
.crumb.here { color: var(--text); cursor: default; text-decoration: none; }
.crumb-sep { color: var(--dim); }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card {
  position: relative; border-radius: var(--radius); overflow: hidden; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-hi); box-shadow: 0 12px 34px rgba(0,0,0,.45); }
.card.folder {
  padding: 18px 14px 14px; min-height: 118px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56'%3E%3Cpath d='M14 4 L24 14 L14 24 L4 14 Z' fill='none' stroke='%232a3a66' stroke-opacity='.5'/%3E%3Cpath d='M42 32 L52 42 L42 52 L32 42 Z' fill='none' stroke='%232a3a66' stroke-opacity='.5'/%3E%3C/svg%3E");
}
.card.folder .f-ico { font-size: 20px; color: var(--cyan); }
.card.folder .f-name { font-size: 13px; font-weight: 600; line-height: 1.35; word-break: break-word; }
.card.folder .f-meta { font-size: 11.5px; color: var(--dim); }
.card.thumb img, .card.thumb video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #060b1c; }
.card.thumb .f-name { position: absolute; inset: auto 0 0 0; padding: 20px 10px 8px; font-size: 11px;
  background: linear-gradient(transparent, rgba(4,8,18,.92)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.plain { padding: 16px 14px; display: flex; flex-direction: column; gap: 6px; min-height: 96px; justify-content: center; }
.card.plain .f-ico { font-size: 18px; }
.card.plain .f-name { font-size: 12.5px; word-break: break-all; }
.card.plain .f-meta { font-size: 11px; color: var(--dim); }
.empty { color: var(--dim); font-size: 14px; padding: 30px 0; text-align: center; grid-column: 1/-1; }

/* ── status ── */
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat-card h3 { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin-bottom: 10px; }
.stat-big { font-size: 20px; font-weight: 700; font-family: "Space Grotesk", sans-serif; }
.stat-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 4px 0; }
.ok-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.ok-dot.bad { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

/* ── footer ── */
.foot { display: flex; justify-content: space-between; align-items: center; margin-top: 40px;
  padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 11px; letter-spacing: .18em; color: #4a5878; }

/* ── lightbox ── */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(2, 4, 10, .92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(10px); }
.lightbox img { max-width: 94vw; max-height: 82vh; border-radius: 12px; box-shadow: 0 30px 90px rgba(0,0,0,.7); }
.lb-cap { margin-top: 12px; color: var(--dim); font-size: 13px; }
.lb-close { position: absolute; top: 18px; right: 20px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(13,20,42,.8); border: 1px solid var(--line-hi); color: var(--text); font-size: 16px; cursor: pointer; }

@media (max-width: 560px) {
  .wordmark { font-size: 19px; }
  .tab { font-size: 13px; gap: 5px; }
  .bubble { max-width: 94%; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 9px; }
}

/* ── market report panel (Status tab) ── */
.report-panel { margin-top: 14px; }
.report-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.report-head h3 { margin-bottom: 10px; }
.report-link { color: var(--cyan); font-size: 13px; text-decoration: none; }
.report-link:hover { text-decoration: underline; }
.report-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.report-actions button:disabled { opacity: .5; cursor: progress; transform: none; }
.btn-ghost {
  padding: 11px 20px; border-radius: 999px; border: 1px solid var(--line-hi); background: transparent;
  color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--blue); }
.report-note { font-size: 12px; margin-top: 12px; line-height: 1.5; max-width: 62ch; }
.spin {
  display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--line-hi); border-top-color: var(--cyan); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
