/* ---------------------------------------------------------------- theme tokens (pale, light + dark) */
:root {
  --bg: #f4f6fa; --card: #ffffff; --card-2: #f8f9fc; --border: #e4e8ef; --text: #333b4a; --muted: #7a8396;
  --hdr-bg: #ffffff; --hdr-fg: #333b4a; --track: #edf0f5; --hover: rgba(91, 141, 239, .07); --sel: rgba(91, 141, 239, .14);
  --good: #7CC4A4; --warn: #F2C46D; --bad: #EE9B8F; --info: #7EA6E0; --link: #4a7bd8;
  --shadow: 0 1px 2px rgba(30, 40, 60, .04), 0 2px 8px rgba(30, 40, 60, .04);
}
body.body--dark {
  --bg: #12151b; --card: #1a1e26; --card-2: #1f242d; --border: #2a303b; --text: #dde2ea; --muted: #98a1b0;
  --hdr-bg: #161a21; --hdr-fg: #dde2ea; --track: #2a303b; --hover: rgba(138, 180, 248, .07); --sel: rgba(138, 180, 248, .16);
  --good: #81C995; --warn: #FDD663; --bad: #F6AEA9; --info: #8AB4F8; --link: #8AB4F8;
  --shadow: none;
}

html, body { height: 100%; }
body { font-family: Roboto, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
body.body--dark { background: var(--bg); }

/* surfaces */
.q-card, .q-table__card, .q-menu, .q-dialog .q-card { background: var(--card); color: var(--text); }
body.body--dark .q-card, body.body--dark .q-table__card, body.body--dark .q-menu, body.body--dark .q-table__container { background: var(--card); }
.q-card--bordered, .q-table--bordered, .q-table--bordered .q-table__container { border-color: var(--border) !important; }
.q-table--flat.q-table--bordered { border-radius: 10px; }
.q-table th { color: var(--muted); font-weight: 600; }
.q-table tbody td, .q-table thead th, .q-table tr { border-color: var(--border) !important; }
.q-table tbody tr:hover > td { background: var(--hover); }
.q-field--outlined .q-field__control:before { border-color: var(--border); }

/* header */
.css-header { background: var(--hdr-bg) !important; color: var(--hdr-fg) !important; border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.css-header .q-btn, .css-header .q-tab { color: var(--hdr-fg); }
.css-header .q-tab { opacity: .75; }
.css-header .q-tab--active { opacity: 1; color: var(--link); }
.brand-icon { color: var(--link); }

/* agents page (TRMM-style) */
.tree-pane { font-size: 13px; border-right: 1px solid var(--border) !important; }
.tree-pane .q-tree__node-header { padding: 2px 4px; border-radius: 6px; }
.tree-pane .q-tree__node--selected .q-tree__node-header-content { font-weight: 600; }
.agent-table .q-table th { font-weight: 600; }
.agent-table .q-table tbody td { height: 30px; padding-top: 2px; padding-bottom: 2px; }
.agent-table tr.selected td { background: var(--sel) !important; }
.agent-table tbody tr { cursor: pointer; }
.offline-row td { font-style: italic; color: var(--muted); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; }

/* overview */
.kpi { min-width: 150px; }
.kpi .val { font-size: 28px; font-weight: 500; line-height: 1.1; }
.kpi .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chart-box { position: relative; height: 260px; }
.clickable { cursor: pointer; }
.clickable:hover { text-decoration: underline; }
.page { padding: 12px; }
.sticky-table { max-height: calc(100vh - 230px); }
.sticky-table thead tr th { position: sticky; z-index: 1; top: 0; background: var(--card); }
.q-tab-panel { padding: 8px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.kv td:first-child { color: var(--muted); padding-right: 12px; white-space: nowrap; vertical-align: top; }
.kv td { padding: 2px 0; font-size: 13px; }

/* ---------------------------------------------------------------- dashboards page */
.dash-page { padding: 14px 16px 24px; max-width: 1680px; margin: 0 auto; }
.dash-tabs { min-width: 0; }
.dash-tabs .q-tab { border-radius: 999px; margin-right: 6px; min-height: 34px; padding: 0 14px; color: var(--muted); background: transparent; }
.dash-tabs .q-tab:hover { background: var(--hover); }
.dash-tabs .dash-tab-active { background: var(--card); color: var(--link); box-shadow: var(--shadow); border: 1px solid var(--border); }
.dash-client { width: 230px; }
.dash-desc { color: var(--muted); font-size: 13px; padding: 0 4px; }
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: 104px; gap: 14px; grid-auto-flow: row dense; transition: opacity .2s; }
.dash-grid.reloading { opacity: .55; }
.tile { grid-column: span var(--span); grid-row: span var(--rows); background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.tile .skel { border-radius: 12px; background: var(--card-2); }
.tile-head { display: flex; align-items: center; padding: 10px 12px 4px 14px; min-height: 38px; }
.tile-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.tile-muted { color: var(--muted); }
.tile-body { flex: 1; min-height: 0; padding: 4px 12px 12px; display: flex; flex-direction: column; }
.tile-chart { position: relative; flex: 1; min-height: 0; height: 100%; }
.tile-empty { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 13px; }
.tile-error { color: var(--bad); font-size: 12px; padding: 8px; }
.tile-filter { width: 130px; font-size: 12px; }
.tile-filter .q-field__control { height: 28px; min-height: 28px; }
.tile-filter .q-field__marginal { height: 28px; }

/* kpi tile */
.tile-kpi .tile-body { padding: 0; }
.kpi-tile { position: relative; display: flex; align-items: center; gap: 12px; height: 100%; padding: 0 16px 0 18px; }
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.kpi-val { font-size: 28px; font-weight: 500; line-height: 1.1; letter-spacing: -.01em; }
.kpi-val small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.kpi-lbl { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi-bar { position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; }

/* gauge tile */
.gauge-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.gauge-chart { position: relative; flex: 1; min-height: 0; }
.gauge-val { position: absolute; left: 0; right: 0; bottom: 18%; text-align: center; font-size: 34px; font-weight: 500; }
.gauge-val small { font-size: 16px; color: var(--muted); }
.gauge-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; padding: 0 12%; }

/* progress tile */
.progress-list { display: flex; flex-direction: column; justify-content: space-around; flex: 1; gap: 4px; font-size: 13px; }
.progress-track { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 3px; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .4s; }

/* table tile */
.tile-table { flex: 1; min-height: 0; background: transparent !important; }
.tile-table .q-table__middle { max-height: 100%; }
.tile-table thead tr th { position: sticky; top: 0; z-index: 1; background: var(--card); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.tile-table tbody td { font-size: 12.5px; height: 28px; }
.tile-table td.wrap-cell { white-space: normal; min-width: 220px; max-width: 520px; line-height: 1.35; padding-top: 4px; padding-bottom: 4px; }
.link-cell { color: var(--link); cursor: pointer; font-weight: 500; }
.link-cell:hover { text-decoration: underline; }

@media (max-width: 1100px) {
  .tile { grid-column: span var(--span-md); }
}
@media (max-width: 640px) {
  .dash-page, .page { padding: 8px; }
  .dash-grid { gap: 10px; }
  .tile { grid-column: span 12; }
  .tile-kpi { grid-column: span 6; }
  .tile-table, .tile-bar, .tile-hbar { grid-row: span 4; }
  .dash-client { width: 150px; }
  .dash-bar { flex-wrap: wrap; }
}

/* ---------------------------------------------------------------- Ask IT */
.ask-page { display: flex; flex-direction: column; height: calc(100vh - 50px); }
.ask-head { padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--card); }
.ask-avatar { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(126, 166, 224, .2); color: var(--link); }
.ask-title { font-weight: 600; font-size: 15px; }
.ask-sub { font-size: 12.5px; color: var(--muted); }
.ask-scroll { flex: 1; overflow-y: auto; padding: 18px 16px 8px; }
.ask-inner { max-width: 1100px; margin: 0 auto; }
.ask-warn { background: rgba(242, 196, 109, .18); color: var(--text); border: 1px solid var(--border); }
.ask-empty { text-align: center; padding: 40px 10px 10px; }
.ask-empty-icon { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; display: flex; align-items: center; justify-content: center; background: rgba(126, 166, 224, .18); color: var(--link); }
.ask-empty-title { font-size: 20px; font-weight: 500; }
.ask-empty-sub { color: var(--muted); font-size: 13.5px; max-width: 560px; margin: 6px auto 20px; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 860px; margin: 0 auto; }
.ask-chip { cursor: pointer; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-size: 13px; color: var(--text); transition: background .15s, border-color .15s; }
.ask-chip:hover { background: var(--hover); border-color: var(--link); }
.ask-msg { display: flex; margin: 10px 0; }
.ask-msg.user { justify-content: flex-end; }
.bubble { border-radius: 16px; padding: 10px 14px; font-size: 14px; line-height: 1.5; max-width: 100%; }
.bubble.user { background: rgba(126, 166, 224, .22); border: 1px solid rgba(126, 166, 224, .35); max-width: 75%; white-space: pre-wrap; border-bottom-right-radius: 4px; }
.bubble.bot { background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); width: 100%; border-bottom-left-radius: 4px; }
.bubble.bot.error { border-color: var(--bad); background: rgba(238, 155, 143, .12); }
.bubble.thinking { width: auto; display: flex; align-items: center; color: var(--muted); }
.md p { margin: 0 0 6px; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 22px; }
.md code, .ask-sql { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; background: var(--card-2); border-radius: 4px; padding: 1px 4px; }
.md-h { font-weight: 600; margin: 6px 0 4px; }
.ask-table-wrap { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.ask-table { max-height: 420px; background: transparent !important; }
.ask-table thead tr th { position: sticky; top: 0; z-index: 1; background: var(--card); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.ask-table tbody td { font-size: 12.5px; }
.ask-table td.wrap-cell { white-space: normal; min-width: 240px; max-width: 520px; }
.ask-steps { margin-top: 8px; font-size: 12.5px; }
.ask-steps-toggle { cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 2px; }
.ask-steps-toggle:hover { color: var(--link); }
.ask-step { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card-2); }
.ask-sql { display: block; white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; padding: 8px; background: var(--bg); max-height: 240px; overflow: auto; }
.ask-input-bar { border-top: 1px solid var(--border); background: var(--card); padding: 10px 16px 8px; }
.ask-input { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--border); border-radius: 16px; padding: 8px 8px 8px 14px; background: var(--bg); }
.ask-input:focus-within { border-color: var(--link); }
.ask-input textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font: inherit; font-size: 14px; max-height: 140px; min-height: 24px; field-sizing: content; }
.ask-foot { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 6px; }
@media (max-width: 640px) { .bubble.user { max-width: 90%; } .ask-head { padding: 10px; } .ask-sub { display: none; } }
.ask-understood { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: -2px 0 6px; }
.ask-fchip { background: rgba(126, 166, 224, .16) !important; color: var(--text) !important; font-size: 12px; }
