/* ===========================================================================
   aiquery.dev — site.css  (Phase 7 frontend modernization)
   ---------------------------------------------------------------------------
   The single site-wide design system. No frameworks, no external fonts.

   CONTRACTS HONOURED BY THIS FILE
   1. Chrome class names consumed by the S3/TT templates:
        .container .site-header .site-header-inner .brand .brand-mark
        .brand-name .brand-tld .site-nav .nav-link .auth-area
        .site-main .card .engine-card .engine-content
        .site-footer .site-footer-inner .footer-copy .footer-note
        .breadcrumb .breadcrumb-sep .breadcrumb-here
        .page-header .page-heading .page-title .page-title-suffix .page-lede
        .page-tabs .tab .is-active
        .hero .home-card .about-card .section-title .section-note .empty-note
        .link-grid / .home-links (home page raw <a> link lists)
        .login-wrap .login-card .login-sub .form-field .form-message
        .btn .btn-primary .btn-block (.login-form is a marker, no rules)
   2. ENGINE-RENDERED markup is golden/untouchable and is styled purely from
      the outside, by selector only:
        - input_form():  <div style="background-color: #F0F0F8;"><form>
                           <input type=text name=sdql|pyql ...> <BR>
                           <input type=submit name=submit ...>
        - result tables: <table id='pyql_id' class='pyql_class'> (query pages,
          one PER GROUP — ids repeat, so ONLY class selectors are used) and
          <table id='sdql' class='sdql'> (trends/bar queries), each with
          <thead>/<tbody>.  ResultDict.html() emits a <b>group-key</b> label
          immediately before each group table.
        - right_header(): table-based mini login form (form action="/login")
          injected raw into .auth-area by sdb.tt.
   3. Custom properties read by Admin/admin.css (bare names first, then the
      --color-* spelling) — both spellings are defined below:
        --bg --surface --border --border-soft --text --text-soft --accent
        --accent-dark --danger --danger-bg --success --success-bg --warning
        --warning-bg --muted-bg --font-sans --font-mono
   4. Hooks used by JS/tablesort.js (th[aria-sort], table[data-sort-enhanced])
      and JS/export.js (.export-actions, .export-btn).
   ======================================================================== */

/* ---------------------------------------------------------------- tokens */

:root {
  /* palette — light, professional */
  --bg:           #f6f7f9;
  --surface:      #ffffff;
  --border:       #d9dee5;
  --border-soft:  #e7eaee;
  --text:         #1a2330;
  --text-soft:    #5b6675;
  --accent:       #2a5bd7;
  --accent-dark:  #1e44a8;
  --accent-soft:  #e8eefb;
  --danger:       #b3372f;
  --danger-bg:    #fae8e6;
  --success:      #1d7f4c;
  --success-bg:   #e3f3ea;
  --warning:      #9a6b15;
  --warning-bg:   #fdf3df;
  --muted-bg:     #e8eaee;
  --thead-bg:     #f0f3f7;
  --stripe-bg:    #f7f9fb;

  /* aliases (admin.css fallback spelling + template convenience) */
  --color-bg: var(--bg);
  --color-surface: var(--surface);
  --color-border: var(--border);
  --color-border-soft: var(--border-soft);
  --color-text: var(--text);
  --color-text-muted: var(--text-soft);
  --color-accent: var(--accent);
  --color-accent-dark: var(--accent-dark);
  --color-danger: var(--danger);
  --color-danger-bg: var(--danger-bg);
  --color-success: var(--success);
  --color-success-bg: var(--success-bg);
  --color-warning: var(--warning);
  --color-warning-bg: var(--warning-bg);
  --color-muted-bg: var(--muted-bg);

  /* typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans",
               sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono",
               Menlo, monospace;

  /* shape + depth */
  --radius:    10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.10);

  /* layout */
  --container-w: 1180px;
  --header-h:    56px;
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 8px);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

main { display: block; }

h1, h2, h3, h4 {
  margin: 1.2em 0 0.5em;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 650;
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }

p { margin: 0.6em 0; }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; border: 0; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

code, kbd, pre { font-family: var(--font-mono); }

pre {
  background: var(--muted-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.85rem;
  line-height: 1.5;
  overflow: auto;
}

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---------------------------------------------------------------- layout */

.container {
  width: 100%;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 20px;
}

.site-main {
  flex: 1 0 auto;
  padding: 22px 0 48px;
}

/* ------------------------------------------------------------ site header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: var(--header-h);
  padding-top: 6px;
  padding-bottom: 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  color: var(--accent);
  flex: none;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-tld { color: var(--accent); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 550;
  text-decoration: none;
  transition: color 0.12s ease, background-color 0.12s ease;
}
.nav-link:hover {
  color: var(--text);
  background: var(--muted-bg);
  text-decoration: none;
}

/* --- right_header() auth area (engine-injected markup, styled from outside).
   Logged out: a table-based mini form (form action="/login", rows:
   message | user+input | token+input | submit).  display:contents flattens
   the layout table into one compact flex row; inherited props (font, color)
   still cascade through the flattened cells. Logged in: <b>user</b><BR>
   <a href=/logout>. */

.auth-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.auth-area b { color: var(--text); font-weight: 650; }

.auth-area br { display: none; }

.auth-area a[href="/logout"] {
  margin-left: 10px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-weight: 550;
}
.auth-area a[href="/logout"]:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

.auth-area form[action="/login"] {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.auth-area form[action="/login"] table,
.auth-area form[action="/login"] tbody,
.auth-area form[action="/login"] tr,
.auth-area form[action="/login"] th,
.auth-area form[action="/login"] td {
  display: contents;
  /* fallback styling when display:contents is honoured these are inert: */
  padding: 0;
  border: 0;
  text-align: left;
}

.auth-area form[action="/login"] table { border-spacing: 0; }

.auth-area form[action="/login"] th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.auth-area form[action="/login"] input[type="text"],
.auth-area form[action="/login"] input[type="password"] {
  width: 8.5rem;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.auth-area form[action="/login"] input[type="text"]:focus,
.auth-area form[action="/login"] input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* the header token field is a real <input type=password> (right_header);
   the old -webkit-text-security hack is gone — it left the credential in
   PLAINTEXT on Firefox */

.auth-area form[action="/login"] input[type="submit"] {
  padding: 5px 12px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.auth-area form[action="/login"] input[type="submit"]:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* ------------------------------------------------------------ site footer */

.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.85rem;
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 22px;
  padding-bottom: 26px;
}

.footer-copy { font-weight: 600; color: var(--text); }
.footer-note { color: var(--text-soft); }
.site-footer a { color: var(--accent); }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin: 0 0 24px;
}

.card > h1:first-child,
.card > h2:first-child,
.card > h3:first-child { margin-top: 0; }

.card-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.card-grid .card { margin: 0; }

/* --------------------------------------------------- breadcrumb + heading */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
  font-size: 0.82rem;
  color: var(--text-soft);
}
.breadcrumb a { color: var(--text-soft); }
.breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.breadcrumb-sep { color: var(--border); }
.breadcrumb-here { font-weight: 600; color: var(--text); }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}

.page-heading { min-width: 0; }

.page-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.page-title-suffix {
  color: var(--text-soft);
  font-weight: 500;
}

.page-lede {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.92rem;
}

/* segmented Query | Trends tabs */
.page-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--muted-bg);
  border-radius: calc(var(--radius-sm) + 3px);
}

.tab {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 550;
  text-decoration: none;
  transition: color 0.12s ease, background-color 0.12s ease;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ------------------------------------------------- home page link grids
   home_query_links / home_trends_links are raw comma-separated <a> strings.
   font-size:0 on the wrapper hides the ", " text nodes between the anchors;
   the anchors restore their own font-size and become tiles. */

.link-grid,
.home-links {
  font-size: 0;
  margin: 6px -5px 14px;
}

.link-grid a,
.home-links a {
  display: inline-block;
  margin: 5px;
  padding: 11px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: border-color 0.12s ease, color 0.12s ease,
              box-shadow 0.12s ease, transform 0.12s ease;
}

.link-grid a:hover,
.home-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}

/* ------------------------------------------------------------- home page */

.hero { margin: 8px 0 26px; }

.hero .page-title {
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}

.hero .page-lede {
  max-width: 60ch;
  font-size: 1rem;
}

.home-card { min-width: 0; }

.about-card p { color: var(--text-soft); }
.about-card p:last-child { margin-bottom: 0; }
.about-card strong { color: var(--text); }

.section-title {
  margin: 0 0 2px;
  font-size: 1.05rem;
}

.section-note {
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.empty-note {
  margin: 8px 0 4px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--text-soft);
  background: var(--muted-bg);
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  padding: 9px 18px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease,
              color 0.12s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover {
  color: #ffffff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-block {
  display: block;
  width: 100%;
}

/* CSV / Parquet download buttons appended by JS/export.js */
.export-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0 10px;
  vertical-align: middle;
}

.export-btn {
  display: inline-block;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.export-btn:hover { background: var(--accent-soft); }
.export-btn:active { background: var(--accent); color: #ffffff; }

/* ------------------------------------------------------- forms (generic) */

.form-field {
  display: block;
  margin: 0 0 14px;
}

.form-field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-soft);
}

.form-field input {
  display: block;
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.form-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-message {
  margin: 0 0 16px;
  padding: 9px 12px;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--warning-bg);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------- login page */

.login-wrap {
  display: grid;
  place-items: center;
  padding: 36px 0;
  min-height: calc(100vh - var(--header-h) - 220px);
}

.login-card {
  width: 100%;
  max-width: 384px;
  padding: 30px 28px;
  box-shadow: var(--shadow-md);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.3rem;
}

.login-sub {
  margin: 0 0 20px;
  font-size: 0.9rem;
  color: var(--text-soft);
}

/* ===================================================================== */
/* ENGINE-RENDERED CONTENT — selector-only styling of golden markup      */
/* ===================================================================== */

/* the .card that wraps {% raw content %} */
.engine-card { overflow: hidden; }

.engine-content { min-width: 0; }

/* --- engine query form: <div style="background-color: #F0F0F8;"><form>…
   The inline background needs !important to be beaten. */

.engine-content div[style*="F0F0F8" i] {
  background: transparent !important;
  margin: 0 0 18px;
}

.engine-content div[style*="F0F0F8" i] form { margin: 0; }

/* the query text input (size=180 in markup — width is taken over here) */
input[name="sdql"],
input[name="pyql"] {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 0 4px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
input[name="sdql"]:focus,
input[name="pyql"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* the engine submit ("  S D Q L !  " / "  P Y Q L !  ") */
.engine-content input[type="submit"] {
  margin-top: 8px;
  padding: 8px 18px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.engine-content input[type="submit"]:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* --- engine result tables ---------------------------------------------
   <table id='pyql_id' class='pyql_class'> (query pages, repeated per group)
   <table id='sdql'    class='sdql'>       (trends / bar queries)
   display:block + max-height turns each table into its own scrollport, so
   the sticky thead AND the horizontal scroll both work with CSS only.
   border-spacing (inherited) reaches the anonymous inner table; borders are
   per-cell bottom borders so nothing depends on border-collapse. */

table.sdql,
table.pyql_class,
table.pyql {
  display: block;
  overflow: auto;
  width: max-content;
  max-width: 100%;
  max-height: 75vh;
  margin: 12px 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-spacing: 0;
  background: var(--surface);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

table.sdql thead th,
table.pyql_class thead th,
table.pyql thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 14px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-align: center;
  white-space: nowrap;
  color: var(--text-soft);
  background: var(--thead-bg);
  border-bottom: 1px solid var(--border);
  -webkit-user-select: none;
  user-select: none;
}

table.sdql td,
table.pyql_class td,
table.pyql td {
  padding: 7px 14px;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}

table.sdql tbody tr:nth-child(odd) td,
table.pyql_class tbody tr:nth-child(odd) td,
table.pyql tbody tr:nth-child(odd) td {
  background: var(--stripe-bg);
}

table.sdql tbody tr:hover td,
table.pyql_class tbody tr:hover td,
table.pyql tbody tr:hover td {
  background: var(--accent-soft);
}

table.sdql tbody tr:last-child td,
table.pyql_class tbody tr:last-child td,
table.pyql tbody tr:last-child td {
  border-bottom: 0;
}

/* sort affordance — JS/tablesort.js sets data-sort-enhanced + aria-sort */
table[data-sort-enhanced="1"] thead th { cursor: pointer; }
table[data-sort-enhanced="1"] thead th:hover { color: var(--accent); }

table[data-sort-enhanced="1"] thead th::after {
  content: "";
  display: inline-block;
  margin-left: 5px;
  font-size: 0.62rem;
  vertical-align: middle;
}
table[data-sort-enhanced="1"] thead th[aria-sort="ascending"]::after {
  content: "\25B2";  /* ▲ */
  color: var(--accent);
}
table[data-sort-enhanced="1"] thead th[aria-sort="descending"]::after {
  content: "\25BC";  /* ▼ */
  color: var(--accent);
}

/* ResultDict group-key label: <b>(('team=BTC', …),)</b> right before each
   group table — render it as a small mono caption (progressive: browsers
   without :has() simply keep it bold inline). */
.engine-content b:has(+ table.pyql_class),
.engine-content b:has(+ table.sdql),
.engine-content b:has(+ table.pyql) {
  display: block;
  margin: 18px 0 2px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

/* "Parameters:" blob and other engine paragraphs — on a real database the
   parameter dictionary is thousands of characters: render it as a scrollable
   secondary footnote, not the biggest block on the page */
.engine-content > p {
  overflow-wrap: anywhere;
  margin: 14px 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
  max-height: 16rem;
  overflow: auto;
}

/* manage-page dashboard table (<table border=4> layout table) */
.engine-content table[border] {
  width: 100%;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.engine-content table[border] > tbody > tr > th,
.engine-content table[border] > tr > th {
  padding: 9px 14px;
  text-align: left;
  background: var(--thead-bg);
  border-bottom: 1px solid var(--border);
}
.engine-content table[border] > tbody > tr > td,
.engine-content table[border] > tr > td {
  padding: 10px 14px;
  vertical-align: top;
  border-right: 1px solid var(--border-soft);
}
.engine-content table[border] td:last-child { border-right: 0; }

/* nested dashboard tables (file/server info on the manage page) carry no
   class and no border attribute — give them a quiet baseline so they don't
   render as bare default-HTML tables inside the polished card */
.engine-content table:not([border]):not(.sdql):not(.pyql_class):not(.pyql) {
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 0.85rem;
}
.engine-content table:not([border]):not(.sdql):not(.pyql_class):not(.pyql) th,
.engine-content table:not([border]):not(.sdql):not(.pyql_class):not(.pyql) td {
  padding: 4px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
.engine-content table:not([border]):not(.sdql):not(.pyql_class):not(.pyql) th {
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 760px) {
  .container { padding: 0 14px; }

  .site-header { position: static; }   /* free the small viewport */
  .site-header-inner {
    flex-wrap: wrap;
    gap: 10px 16px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .auth-area {
    flex-basis: 100%;
    justify-content: flex-start;
  }
  .auth-area form[action="/login"] input[type="text"],
  .auth-area form[action="/login"] input[type="password"] { width: 6.5rem; }

  .site-main { padding-top: 14px; }

  .card { padding: 16px 14px; }
  .login-card { padding: 24px 18px; }

  .page-header { align-items: flex-start; }

  .hero .page-title { font-size: 1.5rem; }

  table.sdql,
  table.pyql_class,
  table.pyql { max-height: 65vh; font-size: 0.85rem; }

  /* the manage dashboard frame (<table border=4>) has no scrollport of its
     own and .engine-card clips overflow — let it scroll instead of clipping */
  .engine-content table[border] {
    display: block;
    overflow-x: auto;
  }

  .link-grid a,
  .home-links a {
    display: block;
    margin: 6px 5px;
  }

  .export-actions { margin: 10px 0 0; }
}

/* ----------------------------------------------------------------- print */

@media print {
  .site-header,
  .site-footer,
  .export-actions { display: none; }

  .card { border: 0; box-shadow: none; padding: 0; }

  table.sdql,
  table.pyql_class,
  table.pyql {
    display: table;
    width: auto;
    max-height: none;
    overflow: visible;
  }
}
