/* QUANTA app — screen-specific layout
   Reuses tokens.css + shell.css design language */

/* ============ shared bits ============ */
.scroll-y { overflow-y: auto; }
.row-flex { display: flex; align-items: center; gap: var(--pad-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--pad-3); }
.muted { color: var(--fg-2); }
.h1 { font-size: var(--t-3xl); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.h2 { font-size: var(--t-xl); font-weight: 600; margin: 0; }
.h3 { font-size: var(--t-md); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-2); margin: 0; }
.mono { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; }
.pill { display: inline-flex; align-items: center; padding: 1px 6px; font-size: var(--t-xs); border-radius: var(--r-1);
        background: var(--bg-3); color: var(--fg-1); font-family: var(--font-mono); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.pill-pos { background: var(--pos-bg); color: var(--pos); }
.pill-neg { background: var(--neg-bg); color: var(--neg); }
.pill-warn { background: rgba(255,184,77,0.12); color: var(--warn); }
.pill-info { background: rgba(90,200,250,0.12); color: var(--info); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }

.btn { font-family: var(--font-sans); font-size: var(--t-md); font-weight: 600; padding: 6px 12px;
       background: var(--bg-3); color: var(--fg-0); border: 1px solid var(--line-2); border-radius: var(--r-2); cursor: pointer;
       display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--bg-4); border-color: var(--line-3); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 3px 8px; font-size: var(--t-sm); }

.input { font-family: var(--font-sans); font-size: var(--t-md); padding: 6px 10px;
         background: var(--bg-3); color: var(--fg-0); border: 1px solid var(--line-2); border-radius: var(--r-2); width: 100%; outline: none; }
.input:focus { border-color: var(--accent); }
.textarea { min-height: 280px; resize: vertical; line-height: 1.55; padding: 10px 12px; font-family: var(--font-sans); }

/* page padding */
.page { padding: var(--pad-5) var(--pad-5); height: 100%; box-sizing: border-box; overflow: hidden; display: flex; flex-direction: column; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--pad-4); margin-bottom: var(--pad-4); }
.page-body { flex: 1; min-height: 0; }

/* ============ News screen ============ */
.news-layout { display: grid; grid-template-columns: 1fr 380px; gap: var(--pad-4); height: 100%; min-height: 0; }
.news-list { background: var(--bg-1); border: 1px solid var(--line-1); border-radius: var(--r-card); overflow: hidden; display: flex; flex-direction: column; }
.news-toolbar { display: flex; align-items: center; gap: var(--pad-2); padding: var(--pad-3); border-bottom: 1px solid var(--line-1); }
.news-tab-row { display: flex; gap: 0; padding: 0 var(--pad-3); border-bottom: 1px solid var(--line-1); }
.news-tab { padding: 8px 14px; font-size: var(--t-md); color: var(--fg-2); cursor: pointer; border-bottom: 2px solid transparent;
            font-weight: 500; }
.news-tab:hover { color: var(--fg-1); }
.news-tab.is-active { color: var(--fg-0); border-bottom-color: var(--accent); }
.news-tab-count { color: var(--fg-3); margin-left: 6px; font-size: var(--t-sm); }
.news-rows { flex: 1; overflow-y: auto; }
.news-row { padding: 12px 16px; border-bottom: 1px solid var(--line-1); cursor: pointer; }
.news-row:hover { background: var(--bg-3); }
.news-row.is-active { background: var(--bg-3); border-left: 3px solid var(--accent); padding-left: 13px; }
.news-row-time { font-size: var(--t-xs); color: var(--fg-3); font-family: var(--font-mono); margin-bottom: 4px; }
.news-row-title { font-size: var(--t-md); color: var(--fg-0); line-height: 1.45; margin-bottom: 6px; font-weight: 500; }
.news-row-meta { display: flex; align-items: center; gap: var(--pad-2); font-size: var(--t-sm); color: var(--fg-2); flex-wrap: wrap; }

.news-detail { background: var(--bg-1); border: 1px solid var(--line-1); border-radius: var(--r-card); padding: var(--pad-4); display: flex; flex-direction: column; gap: var(--pad-3); overflow-y: auto; }
.news-detail-empty { display: flex; align-items: center; justify-content: center; color: var(--fg-2); font-size: var(--t-md); height: 100%; }
.news-detail-title { font-size: var(--t-2xl); font-weight: 600; line-height: 1.35; }

/* ============ Workspaces ============ */
.ws-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--pad-3); padding-right: var(--pad-2); }
.ws-card { background: var(--bg-1); border: 1px solid var(--line-1); border-radius: var(--r-card); padding: var(--pad-4); cursor: pointer;
           display: flex; flex-direction: column; gap: 8px; min-height: 130px; }
.ws-card:hover { border-color: var(--line-3); background: var(--bg-2); }
.ws-card-ticker { font-family: var(--font-mono); font-weight: 700; font-size: var(--t-xl); color: var(--accent); }
.ws-card-name { font-size: var(--t-md); color: var(--fg-1); }
.ws-card-meta { display: flex; align-items: center; gap: var(--pad-2); font-size: var(--t-sm); color: var(--fg-2); margin-top: auto; }
.ws-card-empty { border-style: dashed; align-items: center; justify-content: center; color: var(--fg-2); }
.ws-card-empty:hover { color: var(--accent); border-color: var(--accent); }

.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; }
.dialog { background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--r-card); width: 480px; padding: var(--pad-5); display: flex; flex-direction: column; gap: var(--pad-3); box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.dialog h2 { margin: 0; font-size: var(--t-xl); font-weight: 600; }
.dialog-row { display: flex; flex-direction: column; gap: 4px; }
.dialog-label { font-size: var(--t-xs); color: var(--fg-2); text-transform: uppercase; letter-spacing: 0.08em; }
.suggest { background: var(--bg-2); border: 1px solid var(--line-1); border-radius: var(--r-2); max-height: 200px; overflow-y: auto; margin-top: 2px; }
.suggest-row { padding: 6px 10px; cursor: pointer; display: flex; gap: 10px; align-items: center; font-size: var(--t-md); }
.suggest-row:hover { background: var(--bg-3); }
.suggest-row .mono { color: var(--accent); min-width: 90px; }

/* ============ Workspace detail ============ */
.wd-layout { display: grid; grid-template-rows: auto 1fr; gap: var(--pad-3); height: 100%; min-height: 0; }
.wd-hero { background: var(--bg-1); border: 1px solid var(--line-1); border-radius: var(--r-card); padding: var(--pad-4); display: grid;
           grid-template-columns: minmax(220px, 1fr) auto; gap: var(--pad-4); align-items: center; }
.wd-hero-title { display: flex; align-items: baseline; gap: var(--pad-3); }
.wd-hero-ticker { font-family: var(--font-mono); font-weight: 700; font-size: var(--t-3xl); color: var(--accent); }
.wd-hero-name { font-size: var(--t-md); color: var(--fg-1); }
.wd-hero-price { font-family: var(--font-mono); font-size: var(--t-3xl); font-weight: 600; color: var(--fg-0); }
.wd-hero-change { font-family: var(--font-mono); font-size: var(--t-md); font-weight: 600; }
.wd-hero-stats { display: flex; gap: var(--pad-4); margin-top: 8px; }
.wd-hero-stats .stat-label { font-size: var(--t-xs); color: var(--fg-2); text-transform: uppercase; }
.wd-hero-stats .stat-value { font-family: var(--font-mono); font-size: var(--t-md); color: var(--fg-0); }

.wd-tabs { display: flex; gap: 0; padding: 0 var(--pad-3); border-bottom: 1px solid var(--line-1); margin-bottom: var(--pad-3); }
.wd-tab { padding: 8px 14px; font-size: var(--t-md); color: var(--fg-2); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 500; }
.wd-tab:hover { color: var(--fg-1); }
.wd-tab.is-active { color: var(--fg-0); border-bottom-color: var(--accent); }

.wd-grid { display: grid; grid-template-columns: 1fr 320px; gap: var(--pad-3); height: 100%; min-height: 0; }
.wd-grid-3 { display: grid; grid-template-columns: 1fr 1fr 320px; gap: var(--pad-3); height: 100%; min-height: 0; }
.wd-panel { background: var(--bg-1); border: 1px solid var(--line-1); border-radius: var(--r-card); padding: var(--pad-4); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.wd-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--pad-3); }
.wd-panel-body { flex: 1; min-height: 0; overflow-y: auto; }

.range-seg { display: inline-flex; gap: 0; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--r-2); }
.range-seg button { background: transparent; color: var(--fg-2); border: none; padding: 4px 10px; font-size: var(--t-sm); cursor: pointer; font-family: var(--font-mono); }
.range-seg button.is-active { background: var(--bg-4); color: var(--fg-0); }

.kv-list { display: flex; flex-direction: column; gap: 8px; font-size: var(--t-md); }
.kv-list .kv-row { display: flex; justify-content: space-between; gap: var(--pad-3); padding: 6px 0; border-bottom: 1px dashed var(--line-1); }
.kv-list .kv-row:last-child { border-bottom: 0; }
.kv-list .kv-key { color: var(--fg-2); }
.kv-list .kv-val { font-family: var(--font-mono); color: var(--fg-0); font-weight: 500; }

.saved-row { padding: 10px 0; border-bottom: 1px solid var(--line-1); display: flex; flex-direction: column; gap: 4px; }
.saved-row:last-child { border-bottom: 0; }
.saved-row-title { font-size: var(--t-md); color: var(--fg-0); font-weight: 500; line-height: 1.45; }
.saved-row-meta { font-size: var(--t-sm); color: var(--fg-2); display: flex; gap: var(--pad-2); align-items: center; }

/* ============ Skills ============ */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--pad-3); }
.skill-card { background: var(--bg-1); border: 1px solid var(--line-1); border-radius: var(--r-card); padding: var(--pad-4); display: flex; flex-direction: column; gap: var(--pad-2); cursor: pointer; }
.skill-card:hover { border-color: var(--accent); }
.skill-card-cat { font-family: var(--font-mono); color: var(--accent); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em; }
.skill-card-name { font-size: var(--t-lg); color: var(--fg-0); font-weight: 600; }
.skill-card-desc { font-size: var(--t-md); color: var(--fg-2); line-height: 1.5; }

/* report block */
.report { display: flex; flex-direction: column; gap: var(--pad-4); }
.report-section h3 { color: var(--fg-2); font-size: var(--t-xs); text-transform: uppercase; margin-bottom: 8px; letter-spacing: 0.1em; }
.report-section p { color: var(--fg-0); font-size: var(--t-md); line-height: 1.6; margin: 0; }
.report-section ul { padding-left: 16px; margin: 0; color: var(--fg-0); }
.report-section li { font-family: var(--font-mono); font-size: var(--t-sm); margin-bottom: 4px; }
.report-headlines li { font-family: var(--font-sans); font-size: var(--t-md); margin-bottom: 8px; line-height: 1.45; }

/* slide deck */
.deck { display: flex; flex-direction: column; gap: var(--pad-3); }
.slide { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-card); padding: var(--pad-5); min-height: 240px; display: flex; flex-direction: column; gap: var(--pad-3); }
.slide-title { font-size: var(--t-2xl); font-weight: 600; color: var(--fg-0); }
.slide-sub { font-size: var(--t-md); color: var(--fg-2); }
.slide-num { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--fg-3); align-self: flex-end; }
.slide-cover { background: linear-gradient(135deg, var(--bg-2), var(--bg-1)); border-color: var(--accent); }
.slide-cover .slide-title { font-size: var(--t-4xl); color: var(--accent); font-family: var(--font-mono); letter-spacing: 0.04em; }

/* chart */
.chart-host { width: 100%; height: 100%; min-height: 280px; position: relative; }
.chart-host canvas { display: block; width: 100%; height: 100%; }
.chart-tip { position: absolute; pointer-events: none; padding: 6px 10px; background: var(--bg-2); border: 1px solid var(--line-3); border-radius: var(--r-2); font-family: var(--font-mono); font-size: var(--t-sm); color: var(--fg-0); white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }

/* ============ Folder tree ============ */
.folder-tree { background: var(--bg-1); border: 1px solid var(--line-1); border-radius: var(--r-card); padding: var(--pad-2) 0; }
.folder-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line-1); transition: background 0.1s; }
.folder-row:last-child { border-bottom: 0; }
.folder-row:hover { background: var(--bg-2); }
.folder-row-disclosure { background: transparent; border: 0; color: var(--fg-2); cursor: pointer; padding: 2px; display: flex; align-items: center; }
.folder-row-icon { display: flex; align-items: center; justify-content: center; min-width: 56px; }
.folder-ticker { font-family: var(--font-mono); font-weight: 700; color: var(--accent); font-size: var(--t-md); }
.folder-row-main { flex: 1; display: flex; align-items: center; cursor: pointer; min-width: 0; }
.folder-row-name { font-size: var(--t-md); color: var(--fg-0); font-weight: 500; }
.folder-row-actions { display: flex; align-items: center; gap: 2px; opacity: 0.4; transition: opacity 0.1s; }
.folder-row:hover .folder-row-actions { opacity: 1; }

/* ============ Chat ============ */
.chat-host { display: flex; flex: 1; min-height: 0; gap: var(--pad-3); width: 100%; }
.chat-history { width: 240px; flex-shrink: 0; background: var(--bg-1); border: 1px solid var(--line-1); border-radius: var(--r-card); display: flex; flex-direction: column; min-height: 0; }
.chat-history-head { padding: var(--pad-3); border-bottom: 1px solid var(--line-1); display: flex; align-items: center; justify-content: space-between; }
.chat-history-body { flex: 1; overflow-y: auto; padding: 4px; }
.chat-history-row { padding: 8px 10px; cursor: pointer; border-radius: var(--r-2); display: flex; flex-direction: column; gap: 2px; position: relative; }
.chat-history-row:hover { background: var(--bg-3); }
.chat-history-row.is-active { background: var(--bg-3); border-left: 2px solid var(--accent); }
.chat-history-row .iconbtn { position: absolute; right: 6px; top: 6px; opacity: 0; }
.chat-history-row:hover .iconbtn { opacity: 1; }
.chat-history-title { font-size: var(--t-sm); color: var(--fg-0); font-weight: 500; line-height: 1.3; padding-right: 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-main { flex: 1; min-width: 0; background: var(--bg-1); border: 1px solid var(--line-1); border-radius: var(--r-card); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-toolbar { padding: var(--pad-2) var(--pad-3); border-bottom: 1px solid var(--line-1); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.chat-stream { flex: 1; overflow-y: auto; padding: var(--pad-4); display: flex; flex-direction: column; gap: var(--pad-3); }

.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; text-align: center; color: var(--fg-2); padding: 40px 20px; }
.chat-empty-title { font-size: var(--t-2xl); color: var(--fg-1); font-weight: 600; margin-bottom: 8px; }
.chat-empty-hint { font-size: var(--t-md); max-width: 460px; line-height: 1.55; margin-bottom: 24px; }
.chat-empty-suggestions { display: flex; flex-direction: column; gap: 8px; max-width: 480px; width: 100%; }
.chat-suggestion { background: var(--bg-2); border: 1px solid var(--line-1); color: var(--fg-1); padding: 10px 14px; border-radius: var(--r-2); cursor: pointer; text-align: left; font-size: var(--t-md); transition: all 0.1s; }
.chat-suggestion:hover { border-color: var(--accent); color: var(--fg-0); background: var(--bg-3); }

.chat-msg { display: flex; gap: var(--pad-3); align-items: flex-start; }
.chat-msg-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: var(--t-xs); font-weight: 700; flex-shrink: 0; }
.chat-msg-user .chat-msg-avatar { background: var(--bg-3); color: var(--fg-1); }
.chat-msg-assistant .chat-msg-avatar { background: var(--accent); color: var(--accent-fg); }
.chat-msg-body { flex: 1; min-width: 0; }
.chat-msg-text { color: var(--fg-0); font-size: var(--t-md); line-height: 1.6; word-wrap: break-word; }
.chat-msg-meta { color: var(--fg-3); font-family: var(--font-mono); font-size: var(--t-xs); margin-top: 4px; }
.chat-msg-user .chat-msg-text { color: var(--fg-1); }

.chat-thinking { display: inline-flex; align-items: center; padding: 6px 0; }
.chat-thinking .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-2); margin-right: 4px; animation: chat-bounce 1.2s infinite; }
.chat-thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.chat-composer { padding: var(--pad-3); border-top: 1px solid var(--line-1); display: flex; gap: var(--pad-2); flex-shrink: 0; align-items: flex-end; }
.chat-composer-input { flex: 1; min-height: 44px; max-height: 160px; resize: none; line-height: 1.5; padding: 10px 12px; }
.chat-composer-send { height: 44px; flex-shrink: 0; }

/* ============ Skill editor ============ */
.skill-inputs { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--bg-2); border: 1px solid var(--line-1); border-radius: var(--r-2); }
.skill-input-row { display: flex; gap: 6px; align-items: center; }
.skill-input-row .input { padding: 4px 8px; font-size: var(--t-sm); }
.skill-input-row select.input { padding: 4px 8px; }
code.mono { background: var(--bg-3); padding: 1px 5px; border-radius: 2px; color: var(--accent); font-size: var(--t-xs); }

/* ============ Login ============ */
.login-page {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,159,28,0.05), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(34,197,115,0.04), transparent 50%),
    var(--bg-0);
}
.login-card {
  width: 420px; padding: 32px; background: var(--bg-1);
  border: 1px solid var(--line-2); border-radius: var(--r-card);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; gap: 16px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-brand-name { font-family: var(--font-mono); font-weight: 700; font-size: var(--t-2xl); letter-spacing: 0.04em; color: var(--accent); }
.login-brand-tag { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--fg-2); letter-spacing: 0.08em; text-transform: uppercase; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-error { color: var(--neg); font-size: var(--t-sm); padding: 6px 8px; background: var(--neg-bg); border-radius: var(--r-2); }
.login-submit { width: 100%; justify-content: center; padding: 10px; font-size: var(--t-md); }
.login-hint {
  font-size: var(--t-xs); color: var(--fg-2); line-height: 1.6;
  padding: 10px 12px; background: var(--bg-2); border-radius: var(--r-2);
  border-left: 2px solid var(--warn);
}
.login-hint code { background: var(--bg-3); padding: 1px 5px; border-radius: 2px; color: var(--accent); }
.login-foot { font-size: var(--t-xs); text-align: center; margin-top: 4px; }

/* ============ User menu (top-right) ============ */
.user-menu { position: relative; }
.user-menu-trigger { border: none; cursor: pointer; }
.user-menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--r-2);
  min-width: 220px; padding: 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  z-index: 50;
}
.user-menu-head { padding: 10px 12px 8px; }
.user-menu-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; width: 100%;
  background: transparent; border: none; color: var(--fg-1);
  cursor: pointer; font-size: var(--t-sm); font-family: var(--font-sans);
  text-align: left; border-radius: var(--r-2);
}
.user-menu-row:hover { background: var(--bg-3); color: var(--fg-0); }
.user-menu-sep { height: 1px; background: var(--line-1); margin: 4px 0; }

/* ============ Admin user table ============ */
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-1);
  font-size: var(--t-sm);
}
.user-table th {
  font-weight: 600; color: var(--fg-2); text-transform: uppercase;
  letter-spacing: 0.06em; font-size: var(--t-xs);
  background: var(--bg-2);
}
.user-table tr.is-suspended { opacity: 0.5; }
.user-table tr:hover { background: var(--bg-2); }

/* ============ Settings warning banner ============ */
.settings-warn {
  background: rgba(255,184,77,0.1); border-left: 3px solid var(--warn);
  color: var(--warn); padding: 12px 16px; border-radius: var(--r-2);
  font-size: var(--t-md); margin-bottom: 16px;
}
