/* Data console: an internal tool for the Floorview team — calm, dense, clearly not the customer-facing app. */
:root {
  /* the same warm palette as Floorview (public/styles.css): ivory canvas, charcoal text, clay accent */
  --bg: #faf9f5; --panel: #ffffff; --surface-2: #f3f1ea; --ink: #1f1e1d; --muted: #73716b; --line: #e7e4da;
  --accent: #c6613f; --accent-soft: #f6e9e2; --ok: #2f8f6b; --warn: #c9850f; --err: #c2453a; --err-soft: #fbeceb;
  --shadow: 0 1px 2px rgba(31, 30, 29, 0.04), 0 2px 8px rgba(31, 30, 29, 0.03);
  --radius: 14px;
  --serif: 'Iowan Old Style', Charter, 'Source Serif Pro', 'Palatino Linotype', Georgia, serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}
/* dark is the default, as in Floorview; the choice is kept in this browser (see index.html) */
:root[data-theme="dark"] {
  --bg: #000000; --panel: #111111; --surface-2: #1b1b1a; --ink: #f2f0e9; --muted: #a3a09a; --line: #2c2b29;
  --accent: #d97757; --accent-soft: #4a3229; --ok: #4fbf94; --warn: #e6a640; --err: #ec6b5e; --err-soft: #4a2622;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pad { padding: 24px; }
.grow { flex: 1; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.bar[hidden] { display: none; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); text-decoration: none; }
.logo { width: 24px; height: 24px; border-radius: 7px; background: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22kg%22%20gradientUnits%3D%22userSpaceOnUse%22%20x1%3D%2213%22%20y1%3D%2219%22%20x2%3D%2225%22%20y2%3D%227%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22%23e5582b%22%2F%3E%3Cstop%20offset%3D%22.5%22%20stop-color%3D%22%23ff9a5c%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23ffe3c0%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%2232%22%20height%3D%2232%22%20rx%3D%229%22%20fill%3D%22%23111112%22%2F%3E%3Crect%20x%3D%22.5%22%20y%3D%22.5%22%20width%3D%2231%22%20height%3D%2231%22%20rx%3D%228.5%22%20fill%3D%22none%22%20stroke%3D%22%233a3a3c%22%2F%3E%3Cg%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-linecap%3D%22round%22%3E%3Cpath%20d%3D%22M8.6%206.6v18.8%22%20stroke-width%3D%224.8%22%2F%3E%3Cpath%20d%3D%22M15.4%2017.4l8.2%208%22%20stroke-width%3D%224.6%22%2F%3E%3C%2Fg%3E%3Cg%20fill%3D%22none%22%20stroke%3D%22url(%23kg)%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M13.6%2018.4L24.2%207.8%22%20stroke-width%3D%224.4%22%2F%3E%3Cpath%20d%3D%22M15.6%207.2h9.2v9.2%22%20stroke-width%3D%224.2%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E") center / cover no-repeat; }
.bar nav { display: flex; gap: 4px; }
.bar nav a { text-decoration: none; color: var(--muted); padding: 5px 10px; border-radius: 6px; font-weight: 500; }
.bar nav a.on { color: var(--accent); background: var(--accent-soft); }
.who { color: var(--muted); font-size: 13px; }
main { max-width: 1240px; margin: 0 auto; padding: 14px 18px; }
h1 { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 0 0 2px; letter-spacing: -0.01em; }
h2 { font-size: 14.5px; margin: 0; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 3px 9px; border-radius: 6px; cursor: pointer; font: 500 12.5px system-ui, sans-serif; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin: 10px 0 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 5px 10px; line-height: 1.25; }
.stat span { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; }
.stat.bad b { color: var(--err); }
.co { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 0 10px; overflow: hidden; }
.co-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 12px; border-bottom: 1px solid var(--line); }
.co-head .meta { color: var(--muted); font-size: 12.5px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); background: var(--err-soft); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.blue { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.acts { text-align: right; white-space: nowrap; }
td .err-text { color: var(--err); font-size: 12px; display: block; max-width: 340px; overflow-wrap: anywhere; }
.empty { padding: 10px 12px; color: var(--muted); font-size: 12.5px; }
.signin { min-height: 90vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
input, select, textarea { font: 13.5px system-ui, sans-serif; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; }
label.check input { width: auto; }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 90px; }
.help { font-weight: 400; font-size: 12px; }
.err { color: var(--err); font-size: 13px; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--panel); color: var(--ink); width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(10, 14, 22, .45); }
.form { padding: 20px 22px; display: flex; flex-direction: column; gap: 11px; max-height: calc(100vh - 42px); overflow: auto; }
.form h2 { font-size: 17px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } .bar { flex-wrap: wrap; } }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; position: sticky; bottom: -20px; background: var(--panel); padding: 10px 0 0; }
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.types button { text-align: left; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 9px 11px; cursor: pointer; font: 600 13px system-ui, sans-serif; }
.types button:hover { border-color: var(--accent); }
.types button span { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.group-title { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 6px 0 0; }
.note { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 8px 12px; border-radius: 0 8px 8px 0; font-size: 13px; }
.box { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
code, .mono { font-family: var(--mono); font-size: 12px; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; white-space: pre-wrap; font: 12px var(--mono); user-select: all; margin: 0; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input { width: auto; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
#toast.error { background: var(--err); color: #fff; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
.log div { display: grid; grid-template-columns: 150px 140px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }

/* left menu (hamburger) */
.burger { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 36px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
.burger span { display: block; height: 2px; border-radius: 2px; background: var(--ink); }
.burger:hover { border-color: var(--accent); }
.burger:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.side { position: fixed; top: 54px; bottom: 0; left: 0; width: 250px; z-index: 4; overflow-y: auto; padding: 12px 10px 24px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.side[hidden] { display: none; }
.side a, .side button.item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: 500 13.5px system-ui, sans-serif; text-decoration: none; cursor: pointer; }
.side a:hover, .side button.item:hover { background: var(--bg); }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.side .sec { margin: 14px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.side .sub a { padding-left: 24px; font-weight: 400; }
.side .new { color: var(--accent); font-weight: 600; }
.side .off { opacity: .55; }
.scrim { position: fixed; inset: 54px 0 0 0; z-index: 3; background: rgba(10, 14, 22, .4); }
.scrim[hidden] { display: none; }
@media (min-width: 900px) {
  body.side-open #main { margin: 0 0 0 250px; max-width: none; }
  .scrim { display: none; }
}
@media (max-width: 899px) { .side { box-shadow: 0 10px 30px rgba(0, 0, 0, .3); } }
.co-link { color: inherit; text-decoration: none; }
.co-link:hover { color: var(--accent); }

/* compact: row actions sit tight, pills and sub-text stay small */
td.acts .btn { padding: 2px 8px; font-size: 12px; }
.co-head a.small { font-size: 12px; }
.pill { font-size: 10.5px; padding: 1px 7px; }

.side button.group { font-weight: 600; margin-top: 4px; }
.side .chev { display: inline-block; width: 12px; font-size: 11px; color: var(--muted); transition: transform .12s; }
.side .chev.open { transform: rotate(90deg); }
.side .sub button.new { padding-left: 24px; }
@media (prefers-reduced-motion: reduce) { .side .chev { transition: none; } }

/* SQL helper: [[ and @ pick-lists, the "did you mean" check, and the clickable tables panel */
textarea.mono { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; min-height: 180px; resize: vertical; }
.assist { position: absolute; left: 0; right: 0; top: 100%; z-index: 60; max-height: 220px; overflow: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(0, 0, 0, .35); margin-top: 2px; font-weight: 400; }
.assist[hidden], .assist-warn[hidden] { display: none; }
.as-item { display: flex; justify-content: space-between; gap: 10px; padding: 5px 10px; cursor: pointer; font: 12.5px/1.3 var(--mono); }
.as-item i { font: 11px system-ui, sans-serif; color: var(--muted); font-style: normal; white-space: nowrap; }
.as-item.on, .as-item:hover { background: var(--accent-soft); }
.assist-warn { font-size: 12px; color: var(--warn); display: flex; flex-direction: column; gap: 3px; margin: -2px 0 2px; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.sql-tables { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--bg); }
.sql-tables summary { cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.sql-table { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 8px 0 0; }
.sql-fields { display: flex; flex-wrap: wrap; gap: 4px; }
.chip, .field-chip { font: 500 11.5px system-ui, sans-serif; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; background: var(--panel); color: var(--ink); cursor: pointer; }
.chip { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--accent); font-weight: 700; }
.field-chip { font-family: var(--mono); font-size: 11px; }
.chip:hover, .field-chip:hover { border-color: var(--accent); }

label[hidden] { display: none; }
.sql-table-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }

#exform .full[hidden], #exform label[hidden] { display: none; }

/* every dialog can be resized (drag its bottom-right corner); content follows the size */
dialog { resize: both; overflow: auto; min-width: min(380px, 96vw); max-width: 96vw; max-height: 94vh; }
dialog > .form { max-height: none; }
dialog > .form .actions { bottom: 0; }
dialog > .form.fill { display: flex; flex-direction: column; min-height: 100%; box-sizing: border-box; }
.form.fill .grow-box { flex: 1 1 auto; min-height: 140px; overflow: auto; }
.form.fill #tdout { overflow: auto; max-height: 40%; }
table.fit { table-layout: fixed; }
table.fit td, table.fit th { overflow-wrap: anywhere; word-break: break-word; }

.theme-btn { min-width: 30px; }

a.btn { text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
a.btn.primary { color: #fff; }

/* ---------- menu polish ---------- */
.side .ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.side a.on .ico, .side button.new .ico { color: var(--accent); }
.side a, .side button.item { padding: 7px 10px; }
.side a.on { box-shadow: inset 2px 0 0 var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--ink); }
.side a:hover, .side button.item:hover { background: var(--surface-2); }
.side .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .count { background: var(--surface-2); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.side .sec { margin: 16px 10px 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.side .sub { margin-left: 15px; padding-left: 4px; border-left: 1px solid var(--line); }
.side .sub a, .side .sub button.new { padding-left: 10px; }
.side .chev { order: 2; margin-left: 4px; }
.side button.group .count { margin-left: auto; }

/* ---------- menu gradient (same as Floorview) ---------- */
.side {
  background:
    radial-gradient(130% 50% at 0% 0%, color-mix(in srgb, var(--accent) 26%, transparent) 0%, transparent 62%),
    radial-gradient(120% 40% at 100% 100%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 9%, var(--panel)) 0%, var(--panel) 48%, color-mix(in srgb, var(--accent) 5%, var(--panel)) 100%);
}
.side .sec { border-top-color: color-mix(in srgb, var(--accent) 16%, var(--line)); }

/* connection form: optional sections, row editors, actions, history */
[data-showkey][hidden] { display: none !important; }
.sect { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-top: 10px; }
.sect > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.sect[open] > summary { margin-bottom: 8px; }
.re { margin: 4px 0 8px; }
.re-head { display: flex; gap: 8px; font-size: 11.5px; color: var(--muted); padding: 0 2px 2px; }
.re-head span { min-width: 0; }
.re-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.re-row > div { min-width: 0; }
.re-row input, .re-row select, .re-row textarea { width: 100%; box-sizing: border-box; }
.re-x { width: 28px; flex: none; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 6px 0; }
.re-x:hover { color: var(--err, #d92d4b); }
.act-block { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: color-mix(in srgb, var(--surface, #fff) 60%, transparent); }
.act-block label { display: block; }
.act-foot { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.act-result { flex: 1; min-width: 0; }
.ok-text { color: var(--ok, #12a189); }
.try { margin-top: 12px; }
#ctest { margin-top: 8px; max-height: 260px; overflow: auto; }
.ai-pick { display: block; width: 100%; text-align: left; border: 1px dashed var(--accent, #d97757); background: color-mix(in srgb, var(--accent, #d97757) 8%, transparent); border-radius: 10px; padding: 10px 12px; margin: 8px 0 4px; cursor: pointer; color: inherit; font: inherit; }
.ai-pick b { display: block; }
.ai-pick span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* an action shows only the settings that fit what it does */
.act-block:not([data-on="new_rows"]) .only-rows { display: none !important; }
.act-block:not([data-on="schedule"]) .only-sched { display: none !important; }

/* how-to lessons */
.howto { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.howto-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 8px; }
.howto-nav a { padding: 7px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 13.5px; }
.howto-nav a:hover { color: var(--text); background: var(--surface-2, rgba(127,127,127,.1)); }
.howto-nav a.on { color: var(--text); background: var(--accent-soft); font-weight: 600; }
.howto-body { max-width: 760px; line-height: 1.55; }
.howto-body h2 { margin-top: 0; }
.howto-body li { margin: 5px 0; }
.howto-body code { font-size: 12.5px; }
@media (max-width: 760px) { .howto { grid-template-columns: 1fr; } .howto-nav { position: static; flex-direction: row; flex-wrap: wrap; } }

.errtxt { color: var(--err); }
.hrow { cursor: pointer; }
.hrow:hover { background: color-mix(in srgb, currentColor 6%, transparent); }
.hmsg { max-width: 320px; overflow-wrap: anywhere; }
.hsum { display: flex; gap: 8px; margin: 0 0 12px; }
