@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600;700;800;900&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --dark: #2e1a47;
  --mid: #7c3aed;
  --purple: #b06af0;
  --muted: #6b5299;
  --soft: #d8d0f0;
  --terrain: #2db66b;
  --page: #f3edff;
  --border: #c4b8e8;
  --footer: #4a3370;
  --font: "Geist Mono", "Courier New", monospace;
}
body { background: var(--page); font-family: var(--font); min-height: 100vh; color: var(--dark); }

/* HEADER */
.header { background: var(--dark); padding: 14px 28px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 200; border-bottom: 2px solid var(--mid); }
.logo { background: var(--purple); border-radius: 6px; padding: 5px 12px; font-weight: 900; font-size: 20px; color: var(--dark); letter-spacing: -1px; }
.header-right .title { color: var(--purple); font-size: 14px; font-weight: 700; text-align: right; }
.header-right .sub { color: var(--muted); font-size: 10px; margin-top: 2px; text-align: right; }
.header-right .user { color: var(--soft); font-size: 9px; margin-top: 2px; text-align: right; }
.header-right .signout { background: none; border: 1px solid var(--muted); color: var(--soft); font-family: var(--font); font-size: 9px; font-weight: 700; padding: 3px 8px; border-radius: 4px; cursor: pointer; margin-top: 4px; }
.header-right .signout:hover { border-color: var(--purple); color: var(--purple); }

/* NAV */
.nav { background: white; border-bottom: 2px solid var(--mid); display: flex; overflow-x: auto; }
.nav-tab { padding: 12px 24px; font-family: var(--font); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; border: none; cursor: pointer; background: transparent; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; transition: color 0.15s; }
.nav-tab:hover { color: var(--mid); }
.nav-tab.active { background: var(--soft); color: var(--mid); border-bottom-color: var(--mid); }
.nav-tab.locked { opacity: 0.5; cursor: not-allowed; }

/* FILTER BAR */
.filter-bar { background: white; border-bottom: 1px solid var(--border); padding: 10px 28px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.filter-btn { padding: 3px 12px; font-size: 10px; font-family: var(--font); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; background: white; color: var(--dark); font-weight: 500; transition: all 0.12s; }
.filter-btn:hover { border-color: var(--mid); color: var(--mid); }
.filter-btn.active { background: var(--mid); color: white; border-color: var(--mid); font-weight: 700; }

/* LIVE BAR */
.live-bar { background: var(--dark); padding: 5px 28px; display: flex; align-items: center; justify-content: space-between; font-size: 9px; border-bottom: 1px solid var(--footer); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--terrain); display: inline-block; margin-right: 5px; }
.live-label { color: var(--terrain); font-weight: 700; }
.live-right { color: var(--muted); }

/* MAIN */
.main { padding: 24px 28px; }

/* TEAM SECTION */
.team-section { margin-bottom: 32px; }
.team-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: white; padding: 4px 10px; border-radius: 3px; display: inline-block; margin-bottom: 12px; }

/* CARD GRID */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; gap: 10px; position: relative; }
.card:hover { border-color: var(--mid); box-shadow: 0 4px 16px rgba(124, 58, 237, 0.1); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-title { font-size: 12px; font-weight: 700; color: var(--dark); line-height: 1.35; }
.card-badge { font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 3px; color: white; white-space: nowrap; flex-shrink: 0; }
.card-desc { font-size: 10px; color: var(--muted); line-height: 1.55; flex: 1; }
.card-footer-row { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; border-top: 1px solid var(--soft); }
.card-meta { font-size: 9px; color: var(--muted); }
.card-cta { font-size: 9px; font-weight: 700; color: var(--mid); display: flex; align-items: center; gap: 3px; }
.card-cta-placeholder { font-size: 9px; color: var(--soft); font-weight: 600; }
.card.placeholder { opacity: 0.6; cursor: default; }
.card.placeholder:hover { border-color: var(--border); box-shadow: none; }

/* STATUS PILL */
.status-live { display: inline-flex; align-items: center; gap: 4px; font-size: 9px; font-weight: 700; color: var(--terrain); }
.status-live::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--terrain); flex-shrink: 0; }
.status-placeholder { font-size: 9px; color: var(--soft); font-weight: 600; }

/* FULLSCREEN VIEWER */
.viewer { display: none; position: fixed; inset: 0; z-index: 1000; background: var(--page); flex-direction: column; }
.viewer.open { display: flex; }
.viewer-header { background: var(--dark); padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--mid); flex-shrink: 0; }
.viewer-title { color: var(--purple); font-size: 13px; font-weight: 700; }
.viewer-meta { color: var(--muted); font-size: 10px; margin-top: 2px; }
.viewer-close { background: none; border: 1px solid var(--muted); color: var(--soft); font-family: var(--font); font-size: 11px; font-weight: 700; padding: 5px 14px; border-radius: 4px; cursor: pointer; transition: all 0.15s; }
.viewer-close:hover { border-color: var(--purple); color: var(--purple); }
.viewer-body { flex: 1; overflow: hidden; position: relative; }
.viewer-iframe { width: 100%; height: 100%; border: none; display: block; }
.viewer-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--page); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--soft); border-top-color: var(--mid); border-radius: 50%; animation: spin 0.8s linear infinite; }
.loading-text { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* RESTRICTED ACCESS DENIED */
.gate { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; }
.gate-box { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 36px 40px; max-width: 420px; width: 100%; text-align: center; }
.gate-icon { font-size: 28px; margin-bottom: 12px; }
.gate-title { font-size: 14px; font-weight: 800; color: var(--dark); margin-bottom: 6px; }
.gate-sub { font-size: 10px; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }
.gate-detail { font-size: 9px; color: var(--soft); font-family: var(--font); }

.hidden { display: none !important; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--soft); border-radius: 3px; }

/* CHATBOT */
.chat-bubble { position: fixed; bottom: 24px; right: 24px; z-index: 500; width: 48px; height: 48px; border-radius: 50%; background: var(--mid); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4); transition: transform 0.2s, box-shadow 0.2s; }
.chat-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(124, 58, 237, 0.5); }
.chat-bubble svg { width: 22px; height: 22px; fill: white; }
.chat-panel { position: fixed; bottom: 84px; right: 24px; z-index: 500; width: 380px; height: 560px; background: white; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 40px rgba(46, 26, 71, 0.2); display: none; flex-direction: column; overflow: hidden; transform: translateY(12px); opacity: 0; transition: transform 0.2s, opacity 0.2s; }
.chat-panel.open { display: flex; transform: translateY(0); opacity: 1; }
.chat-panel-header { background: var(--dark); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; border-bottom: 2px solid var(--mid); }
.chat-panel-title { color: var(--purple); font-size: 12px; font-weight: 700; }
.chat-panel-sub { color: var(--muted); font-size: 9px; margin-top: 1px; }
.chat-panel-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; font-family: var(--font); }
.chat-panel-close:hover { color: var(--purple); }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; flex-direction: column; gap: 3px; max-width: 88%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; align-items: flex-start; }
.chat-bubble-msg { padding: 8px 12px; border-radius: 10px; font-size: 11px; line-height: 1.55; font-family: var(--font); word-break: break-word; }
.chat-msg.user .chat-bubble-msg { background: var(--mid); color: white; border-bottom-right-radius: 3px; }
.chat-msg.assistant .chat-bubble-msg { background: var(--page); color: var(--dark); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat-msg-time { font-size: 8px; color: var(--muted); padding: 0 4px; }
.chat-typing { display: flex; gap: 4px; align-items: center; padding: 8px 12px; background: var(--page); border: 1px solid var(--border); border-radius: 10px; border-bottom-left-radius: 3px; width: fit-content; }
.chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: chatdot 1.2s ease-in-out infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatdot { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }
.chat-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0; background: white; }
.chat-input { flex: 1; padding: 8px 10px; font-family: var(--font); font-size: 11px; border: 1px solid var(--border); border-radius: 6px; outline: none; color: var(--dark); resize: none; height: 36px; line-height: 1.4; transition: border-color 0.15s; }
.chat-input:focus { border-color: var(--mid); }
.chat-send { padding: 0 14px; background: var(--mid); color: white; border: none; border-radius: 6px; cursor: pointer; font-family: var(--font); font-size: 11px; font-weight: 700; height: 36px; transition: background 0.15s; flex-shrink: 0; }
.chat-send:hover { background: var(--dark); }
.chat-send:disabled { opacity: 0.4; cursor: default; }
.chat-table-wrap { overflow-x: auto; margin-top: 6px; border-radius: 6px; border: 1px solid var(--border); }
.chat-table { border-collapse: collapse; font-size: 10px; font-family: var(--font); width: 100%; }
.chat-table th { background: var(--dark); color: var(--purple); padding: 5px 8px; text-align: left; font-weight: 700; font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.chat-table td { padding: 4px 8px; border-bottom: 1px solid var(--soft); color: var(--dark); white-space: nowrap; }
.chat-table tr:last-child td { border-bottom: none; }
.chat-table tr:nth-child(even) td { background: #faf8ff; }
.chat-chart { margin-top: 8px; padding: 8px; background: var(--page); border-radius: 6px; border: 1px solid var(--border); }
.chat-chart-title { font-size: 9px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.chart-bar-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.chart-bar-label { font-size: 9px; color: var(--dark); width: 80px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track { flex: 1; height: 12px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--mid); border-radius: 3px; transition: width 0.4s; }
.chart-bar-val { font-size: 9px; color: var(--muted); width: 52px; text-align: right; flex-shrink: 0; }
.chat-suggestions { display: flex; flex-direction: column; gap: 5px; padding: 0 14px 10px; }
.chat-suggestion { font-size: 10px; color: var(--mid); background: var(--page); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer; font-family: var(--font); text-align: left; transition: border-color 0.15s; }
.chat-suggestion:hover { border-color: var(--mid); background: var(--soft); }

/* Tool-call footer — collapsed "queries ran" disclosure under assistant bubbles */
.tool-calls { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--soft); }
.tool-calls summary { font-size: 9px; color: var(--muted); cursor: pointer; text-transform: uppercase; letter-spacing: 0.05em; user-select: none; font-weight: 600; padding: 2px 0; }
.tool-calls summary:hover { color: var(--mid); }
.tool-calls[open] summary { color: var(--mid); margin-bottom: 4px; }
.tool-call { margin-top: 6px; }
.tool-call-head { font-size: 9px; color: var(--mid); font-weight: 700; margin-bottom: 3px; font-family: var(--font); }
.tool-call-server { color: var(--muted); font-weight: 400; }
.tool-call-sql, .tool-call-args { font-family: var(--font); font-size: 9px; background: var(--page); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; color: var(--dark); margin: 0; line-height: 1.45; }
