:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --text: #17201b;
  --muted: #5d6a63;
  --border: #dde3de;
  --brand: #0b5d3b;
  --brand-2: #128a58;
  --brand-ink: #ffffff;
  --accent: #e8a317;
  --danger: #b42318;
  --error: #b42318;
  --error-bg: #fdecea;
  --code-bg: #f1f4f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 16px rgba(16, 24, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #161d19;
    --surface-2: #1d2621;
    --text: #e7ece9;
    --muted: #9aa8a0;
    --border: #2a352f;
    --brand: #2fb67a;
    --brand-2: #48cf92;
    --brand-ink: #06140d;
    --danger: #ff8a80;
    --error: #ff8a80;
    --error-bg: #3a1714;
    --code-bg: #111815;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Sarabun", sans-serif;
}
[hidden] { display: none !important; }
h1, h2, h3, h4, h5 { line-height: 1.25; margin: 0 0 .5rem; }
p { margin: 0 0 .6rem; }
a { color: var(--brand-2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.error { color: var(--error); background: var(--error-bg); padding: .6rem .8rem; border-radius: 8px; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: .5rem .9rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--brand-2); }
button.secondary { background: var(--surface-2); }
button.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); font-weight: 600; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--surface-2); }
button.small { padding: .25rem .5rem; font-size: 13px; }
button.icon { padding: .3rem .55rem; }
button.wide { width: 100%; }
.ghost-link { color: var(--muted); text-decoration: none; padding: .25rem .5rem; }
.ghost-link:hover { color: var(--text); }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem;
}
input, textarea { width: 100%; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }

/* Brand */
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 800; font-size: 13px;
}
.brand-name { font-weight: 750; font-size: 16px; letter-spacing: -.01em; }
.brand-tag { font-size: 11px; color: var(--muted); }
.brand-lg .brand-mark { width: 44px; height: 44px; font-size: 17px; border-radius: 11px; }
.brand-lg .brand-name { font-size: 22px; }
.brand-lg .brand-tag { font-size: 12px; }

/* Sign-in */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px;
}
.login-card label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.row-buttons { display: flex; gap: 8px; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #241a00;
         font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.status-pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); }
.status-pill.pending { background: var(--accent); color: #241a00; }
.status-pill.active { background: var(--brand-2); color: var(--brand-ink); }
.status-pill.disabled { background: var(--error-bg); color: var(--error); }
.admin td input, .admin td select { padding: .25rem .4rem; font-size: 13px; }
.admin td input[type=number] { width: 130px; }
.admin td.actions { display: flex; gap: 4px; }

/* Layout */
.app {
  --sidebar-w: 272px;
  height: 100%; height: 100dvh;          /* dvh: the visible height on phones, without the browser bars */
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}
.app.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.app.sidebar-collapsed .sidebar { visibility: hidden; overflow: hidden; padding: 0; border: 0; }
.app.resizing { cursor: col-resize; user-select: none; }
.sidebar {
  position: relative; min-width: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px; padding: 14px 12px; min-height: 0;
}
.sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.conv-list { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.conv-group { font-size: 12px; color: var(--muted); font-weight: 600; margin: 12px 8px 4px; }
.conv-item {
  display: flex; align-items: center; gap: 4px; border-radius: 8px; padding: 2px 2px 2px 8px;
}
.conv-item:hover, .conv-item.active { background: var(--surface-2); }
.conv-item a {
  flex: 1; min-width: 0; color: var(--text); text-decoration: none; padding: 6px 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px;
}
.conv-item .conv-actions { display: none; }
.conv-item:hover .conv-actions, .conv-item.active .conv-actions, .conv-item:focus-within .conv-actions { display: flex; }
.conv-item input { padding: .25rem .4rem; font-size: 14px; }
.conv-empty { color: var(--muted); font-size: 13px; padding: 8px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 10px; display: grid; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 4px; }
.user-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
#quota-bar { height: 100%; width: 0; background: var(--brand-2); transition: width .3s; }
#quota-bar.warn { background: var(--accent); }
.quota p { margin: 4px 0 0; }

.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg); flex-wrap: wrap;
}
.picker select { padding: .35rem .5rem; font-size: 14px; max-width: 220px; }
.chat-title { font-size: 15px; font-weight: 600; margin: 0 0 0 6px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messages { flex: 1; overflow-y: auto; padding: 24px 16px; }
.messages > * { max-width: 860px; margin-left: auto; margin-right: auto; }

/* Landing */
.welcome { padding: 48px 0 12px; text-align: center; }
.welcome h1 { font-size: 28px; }
.welcome .lead { color: var(--muted); max-width: 560px; margin: 0 auto 18px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.example { text-align: left; background: var(--surface); font-size: 14px; }
.example:hover { border-color: var(--brand-2); }

/* Messages */
.msg { margin-bottom: 20px; }
.msg.user .bubble {
  margin-left: auto; width: fit-content; max-width: 85%; background: var(--brand); color: var(--brand-ink);
  padding: .6rem .9rem; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.assistant .bubble { padding: 2px 2px; overflow-wrap: anywhere; }
.msg.assistant.partial .bubble { opacity: .85; }
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 4px; color: var(--muted); flex-wrap: wrap; }
.msg-actions button { padding: .2rem .45rem; font-size: 13px; }
.msg-actions button.on { color: var(--brand-2); background: var(--surface-2); }
.msg-actions .model-tag { font-size: 12px; margin-left: 6px; }
.siblings { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; }
.feedback-form { display: flex; gap: 6px; margin-top: 6px; }
.feedback-form input { font-size: 13px; padding: .3rem .5rem; }
.notice { font-size: 13px; color: var(--muted); border-left: 3px solid var(--accent); padding: 2px 10px; margin: 6px 0; }
.status { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: 14px; margin: .3rem 0 .6rem; }
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--brand-2);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Tool activity (SQL cards) */
details.run { border: 1px solid var(--border); border-radius: 10px; margin: 0 0 10px; background: var(--surface-2); }
details.run > summary {
  cursor: pointer; padding: .5rem .8rem; font-size: 14px; list-style: none; display: flex; gap: .5rem; align-items: baseline;
}
details.run > summary::before { content: "▸"; color: var(--muted); }
details.run[open] > summary::before { content: "▾"; }
details.run .meta { color: var(--muted); font-size: 13px; margin-left: auto; white-space: nowrap; }
details.run.rejected > summary { color: var(--error); }
.run-body { padding: 0 .8rem .8rem; display: grid; gap: 8px; min-width: 0; }
.run-actions { display: flex; gap: 8px; align-items: center; }
.run-actions button { padding: .3rem .7rem; font-size: 13px; }

/* Code */
details.code { border: 1px solid var(--border); border-radius: 10px; margin: .4rem 0 .8rem; background: var(--surface-2); }
details.code > summary { cursor: pointer; padding: .45rem .8rem; font-size: 14px; color: var(--muted); list-style: none; }
details.code > summary::before { content: "▸ "; }
details.code[open] > summary::before { content: "▾ "; }
details.code > summary:hover { color: var(--text); }
details.code > pre { margin: 0 .8rem .8rem; }
.codeblock { position: relative; margin: 0 0 .8rem; }
.codeblock .copy { position: absolute; top: 6px; right: 6px; padding: .15rem .5rem; font-size: 12px; }
.codeblock .lang { position: absolute; top: 8px; left: 12px; font-size: 11px; color: var(--muted); }
.codeblock pre { padding-top: 1.8rem; }
pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: .7rem .8rem; overflow-x: auto; margin: 0 0 .6rem; }
:not(pre) > code { background: var(--code-bg); padding: .1rem .35rem; border-radius: 5px; }
blockquote { margin: 0 0 .6rem; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }

.table-wrap { overflow: auto; max-height: 380px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin: .4rem 0 .8rem; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: .4rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bubble .table-wrap { max-height: none; }
.bubble ul, .bubble ol { margin: 0 0 .6rem; padding-left: 1.4rem; }

/* Composer */
.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px 4px;
  max-width: 892px; width: 100%; margin: 0 auto;
}
.composer textarea { resize: none; max-height: 220px; min-height: 46px; border-radius: 12px; }
.composer button { height: 46px; }
.disclaimer { text-align: center; margin: 2px 0 10px; }

dialog {
  width: min(900px, calc(100vw - 32px)); max-height: 80vh; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#schema-text { max-height: 65vh; white-space: pre-wrap; }

/* Admin page */
.admin { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.admin header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.admin header .spacer { flex: 1; }
.admin .filters { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.admin .filters label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.admin .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 18px; }
.admin .card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.admin .card .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.admin .card .k { font-size: 13px; color: var(--muted); }
.admin section { margin-bottom: 26px; }
.admin .tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.admin .tabs button.on { background: var(--surface-2); border-color: var(--border); color: var(--text); }

/* Drag handle on the sidebar's right edge (mouse, touch, pen; arrow keys when focused) */
.sidebar-resizer {
  position: absolute; top: 0; right: -5px; width: 10px; height: 100%; z-index: 5;
  cursor: col-resize; touch-action: none; outline: none;
}
.sidebar-resizer::after {
  content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .15s;
}
.sidebar-resizer:hover::after, .sidebar-resizer:focus-visible::after, .app.resizing .sidebar-resizer::after { background: var(--brand-2); }
.drawer-backdrop { display: none; }

.only-mobile { display: none; }
@media (max-width: 820px) {
  .app, .app.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar, .app.sidebar-collapsed .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 20;
    visibility: visible; overflow: visible; padding: 14px 12px; border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .35); }
  .sidebar-resizer { display: none; }
  .only-mobile { display: inline-block; }
  .chat-title { display: none; }
  .picker select { max-width: 150px; }
  .msg.user .bubble { max-width: 92%; }
  .welcome { padding-top: 24px; }
}
@media (max-width: 520px) {
  .topbar { padding: 8px 10px; gap: 6px; }
  .picker { flex: 1 1 40%; min-width: 0; }
  .picker select { max-width: none; width: 100%; }
  .messages { padding: 16px 10px; }
  .composer { padding: 8px 10px calc(4px + env(safe-area-inset-bottom)); gap: 6px; }
  .composer button { height: 44px; padding-left: .7rem; padding-right: .7rem; }
  .composer textarea, .picker select, .conv-item input { font-size: 16px; }   /* 16px stops iOS zooming into inputs */
  dialog { width: calc(100vw - 16px); padding: 12px; }
  .admin { padding: 14px 10px 30px; }
  .admin .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin .filters label { flex: 1 1 140px; }
  .admin .filters input, .admin .filters select { width: 100%; }
}
@media (max-width: 820px) and (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* Data catalog lookups (search_catalog / describe_table) */
details.run.catalog pre { max-height: 22rem; overflow: auto; white-space: pre-wrap; }

/* Cost of an answer */
.cost-line { margin: .5rem 0 0; }
.cost-line .cost-total { font-weight: 600; }

/* Logo */
.brand-logo, .logo-full { display: inline-flex; flex: none; }
.brand-logo img { width: 34px; height: auto; display: block; }
.logo-full img { width: min(260px, 100%); height: auto; display: block; }
.login-card .logo-full { margin: 0 auto 6px; }

/* About */
dialog.about { width: min(520px, calc(100vw - 32px)); }
.about-logo { display: flex; justify-content: center; margin: 4px 0 10px; }
.about-logo img { width: min(300px, 100%); }
.about-version { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0 0 10px; }
.about-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 12px 0 0; font-size: 14px; }
.about-facts dt { color: var(--muted); }
.about-facts dd { margin: 0; overflow-wrap: anywhere; }
.link-button { background: none; border: 0; text-align: left; cursor: pointer; font: inherit; justify-self: start; }
@media (max-width: 520px) { .about-facts { grid-template-columns: 1fr; gap: 2px; } .about-facts dd { margin-bottom: 8px; } }

/* Admin: system prompt editor */
.prompt-field { margin: 0 0 16px; }
.prompt-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prompt-head .spacer { flex: 1; }
.prompt-field textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px;
  line-height: 1.45; resize: vertical; min-height: 6rem; }
.prompt-preview { max-height: 60vh; overflow: auto; white-space: pre-wrap; }
.admin .row-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; }
@media (max-width: 520px) { .prompt-field textarea { font-size: 16px; } }

/* Admin: add people in advance */
.add-users { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.add-users summary { cursor: pointer; }
.add-users .add-emails { display: grid; gap: 4px; margin: 10px 0 8px; font-size: 13px; color: var(--muted); }
.add-users textarea { width: 100%; resize: vertical; }
@media (max-width: 520px) { .add-users textarea { font-size: 16px; } }

/* Export menu and progress notice */
.export-menu { position: relative; display: inline-block; }
.export-menu > summary { list-style: none; cursor: pointer; padding: .25rem .5rem; border-radius: 6px; color: var(--muted); font-size: 13px; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu > summary:hover, .export-menu[open] > summary { background: var(--surface-2); color: var(--text); }
.export-list {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 190px; display: grid; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.topbar .export-list { left: auto; right: 0; }
.export-head { padding: 4px 8px 6px; }
.export-list button { text-align: left; background: transparent; border: 0; padding: .45rem .6rem; border-radius: 6px; color: var(--text); }
.export-list button:hover, .export-list button:focus-visible { background: var(--surface-2); }
.export-toast {
  position: fixed; z-index: 50; right: 16px; bottom: 16px; max-width: min(420px, calc(100vw - 32px)); display: flex; gap: 10px;
  align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--brand-2); box-shadow: var(--shadow); font-size: 14px;
}
.export-toast.error { border-left-color: var(--danger); }
.export-toast .small { color: var(--muted); margin-top: 2px; }
@media (max-width: 520px) { .export-toast { left: 16px; right: 16px; bottom: calc(12px + env(safe-area-inset-bottom)); } }
.msg-actions .export-list { top: auto; bottom: calc(100% + 4px); }   /* open upward, clear of the message box */

/* Business definitions used by an answer */
.defs-line { margin: 6px 0 2px; color: var(--muted); }
.defs-line > summary { cursor: pointer; list-style: none; }
.defs-line > summary::-webkit-details-marker { display: none; }
.defs-line[open] > summary { color: var(--text); }
.defs-list { margin: 6px 0 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.defs-list dt { font-weight: 600; color: var(--text); margin-top: 6px; }
.defs-list dt:first-child { margin-top: 0; }
.defs-list dd { margin: 2px 0 0; color: var(--text); }

/* Verified queries */
.verified-badge { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; }
.verified-mark { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--brand-2); color: var(--brand-ink);
                 font-size: 12px; font-weight: 700; }
.verify-form { display: grid; gap: 6px; margin: 6px 0 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); max-width: 640px; }
.verify-form input { font-size: 13px; padding: .35rem .5rem; }

/* Charts under data answers (web/charts.js) */
.chart-panel { margin: 8px 0 10px; padding: 10px 12px 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.chart-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.chart-title { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; }
.chart-controls { display: flex; gap: 4px; align-items: center; }
.chart-controls button.on { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.chart-controls select { padding: .2rem .4rem; font-size: 13px; }
.chart-box { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-zero { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.chart-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-label { fill: var(--text); font-size: 12px; }
.chart-value { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-bar { fill: var(--brand-2); }
.chart-line { fill: none; stroke: var(--brand-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--brand-2); stroke: var(--surface); stroke-width: 2; }
.chart-marker { fill: var(--brand-2); stroke: var(--surface); stroke-width: 2; }
.chart-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-hit { fill: transparent; cursor: default; }
.chart-hit.on { fill: var(--surface-2); fill-opacity: .6; }
.chart-hit-area { fill: transparent; }
.chart-tip { position: absolute; pointer-events: none; z-index: 3; background: var(--surface); color: var(--text); border: 1px solid var(--border);
             border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; }
.chart-tip-title { color: var(--muted); }
.chart-tip-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-note { font-size: 12px; color: var(--muted); margin: 4px 0 2px; }
@media (forced-colors: active) { .chart-bar, .chart-dot, .chart-marker { fill: CanvasText; } .chart-line { stroke: CanvasText; } }

/* Map of GPS points (OpenStreetMap tiles) */
.map-box { position: relative; height: 380px; overflow: hidden; border-radius: 8px; background: var(--surface-2); touch-action: none; cursor: grab; user-select: none; }
.map-box.dragging { cursor: grabbing; }
.map-tiles img { position: absolute; width: 256px; height: 256px; max-width: none; pointer-events: none; }
.map-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-dot { fill: var(--brand-2); stroke: #fff; stroke-width: 2; cursor: pointer; }
.map-controls { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.map-controls button { min-width: 32px; padding: .2rem .4rem; background: var(--surface); }
.map-credit { position: absolute; right: 0; bottom: 0; font-size: 11px; background: rgba(255,255,255,.85); color: #333; padding: 1px 6px; border-top-left-radius: 6px; z-index: 2; }
.map-credit a { color: #333; }
@media (prefers-color-scheme: dark) { .map-tiles img { filter: brightness(.8) contrast(1.1); } }
.map-area { fill: var(--brand-2); fill-opacity: .22; stroke: var(--brand-2); stroke-width: 2; stroke-linejoin: round; pointer-events: none; }

/* Alerts */
.alerts-button { justify-content: flex-start; text-align: left; }
.alerts-dialog { width: min(860px, calc(100vw - 32px)); }
#alerts-list { max-height: 65vh; overflow: auto; }
.alert-event.unread > summary { font-weight: 600; }
.alert-form select { padding: .25rem .4rem; font-size: 13px; }

/* Chart/map toolbar and full-screen view */
.chart-tools { display: flex; gap: 4px; margin-left: auto; }
.chart-tools .button { display: inline-flex; align-items: center; text-decoration: none; color: var(--muted); border-radius: 8px;
                       padding: .25rem .5rem; font-size: 13px; border: 1px solid transparent; }
.chart-tools .button:hover { color: var(--text); background: var(--surface-2); }
.chart-panel.expanded { position: fixed; inset: 16px; z-index: 60; margin: 0; display: flex; flex-direction: column;
                        box-shadow: 0 10px 40px rgba(0,0,0,.25); overflow: auto; }
.chart-panel.expanded .map-box { flex: 1; height: auto; min-height: 300px; }
.chart-panel.expanded .chart-box { flex: 1; }
body.chart-expanded { overflow: hidden; }
body.chart-expanded::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }

/* Team workspaces */
.teams { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 4px; }
.teams-head { display: flex; align-items: center; justify-content: space-between; }
.teams-head button { padding: 0 6px; }
.team summary { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 4px 4px 8px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.team summary:hover { background: var(--surface-2); }
.team .team-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team summary button { padding: 0 6px; }
.team-chat { padding-left: 16px; }
.team-chat a { display: flex; flex-direction: column; padding: 4px 0; }
.team-chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-chat-owner { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-chat-owner:empty { display: none; }
dialog.team-dialog { width: min(560px, calc(100vw - 32px)); }
.team-dialog h3 { font-size: 14px; margin: 16px 0 6px; }
.team-form { display: grid; gap: 8px; }
.team-form.inline { grid-template-columns: 1fr auto; margin-top: 8px; }
.team-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.team-members li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); font-size: 14px; }
.team-members li > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
.share-picker select { max-width: 200px; }
.shared-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px;
}
.team-members .pill { font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }

/* Web lookup card and the admin Web search page */
.run.web .web-body p { margin: 0 0 8px; }
.run.web .web-body ul { margin: 0; padding-left: 18px; }
.switch-row { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.switch-row input { width: 18px; height: 18px; }
#ws-prompt { width: 100%; font-family: var(--mono, ui-monospace, monospace); font-size: 13px; }
#ws-test input { flex: 1; min-width: 200px; }
