/* ==========================================================================
   HARP Platform - application styles

   The design language is inherited from the Freethinking Group system already
   used by Budget Planning and the potent.ai portal: Montserrat, the TFG
   secondary palette, teal accent, generous card radii, soft shadows on a light
   dot-gridded working surface.

   Two deliberate departures, both because this is a reporting workspace rather
   than a linear tool:

   1. Navigation is a persistent left rail, not a top bar. There are nine
      destinations here against Budget Planning's two, and a rail also leaves
      the full width of the header free for the context bar.
   2. Density is higher. Type steps down a notch and table rows are tighter,
      because the job is reading hundreds of rows of booking data rather than
      filling in a short form.
   ========================================================================== */

:root {
    --ink: #17181c;
    --ink-soft: #3f4450;
    --ink-muted: #6b7280;
    --line: #e7e7ec;
    --line-soft: #f0f0f4;
    --surface: #ffffff;
    --accent: #2c757c;
    --accent-soft: rgba(44, 117, 124, 0.12);
    --danger: #d92d5a;
    --danger-soft: rgba(217, 45, 90, 0.08);
    --success: #1a7f4f;
    --warning: #f28e1b;
    --warning-soft: rgba(242, 142, 27, 0.10);

    /* The Freethinking Group secondary palette, 2023 brand guidelines. */
    --tfg-black: #1d1d1b;
    --tfg-red: #e5291c;
    --tfg-orange: #f28e1b;
    --tfg-yellow: #f0bb32;
    --tfg-blue: #78bdc4;
    --tfg-teal: #2c757c;
    --tfg-purple: #712b70;

    --surface-page: #f7f8fa;
    --surface-rail: #ffffff;
    --dot-grid: radial-gradient(rgba(23, 24, 28, 0.06) 1px, transparent 1px);

    --rail-width: 252px;
    --radius-card: 20px;
    --radius-panel: 14px;
    --radius-input: 10px;
    --radius-pill: 999px;

    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 28px -10px rgba(16, 24, 40, 0.10);
    --shadow-pill: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px -2px rgba(16, 24, 40, 0.08);
    --shadow-rail: 1px 0 0 rgba(231, 231, 236, 0.9);

    --font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Generated SQL, column names and result cells all want a monospace face
       with unambiguous zeroes - HARP codes are full of them. */
    --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--surface-page);
    background-image: var(--dot-grid);
    background-size: 22px 22px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.012em; color: var(--ink); }
h1 { font-size: 25px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0; }

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

.muted { color: var(--ink-muted); }
.small { font-size: 12.5px; line-height: 1.5; }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Shell -------------------------------------------------------------- */
/* Structure follows the Interval (MMM) tool: a permanent white appbar, a
   collapsible mesh-gradient sidebar beneath it, an optional contextual panel
   (the FreethinkingHub pattern) and the working column. */

.app { display: flex; flex-direction: column; min-height: 100vh; }

.appbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 58px;
    padding: 0 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.appbar-toggle {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    color: var(--ink-muted);
    background: transparent;
    border: 1px solid var(--line);
    cursor: pointer;
    flex-shrink: 0;
}

.appbar-toggle:hover { background: var(--surface-page); color: var(--ink); }
.appbar-toggle svg { width: 15px; height: 15px; }

.appbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.appbar-brand:hover { text-decoration: none; }

.rail-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--tfg-teal);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.rail-title { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.rail-sub { font-size: 11px; font-weight: 600; color: var(--ink-muted); letter-spacing: 0.02em; }

.appbar-page { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--ink-soft); }

.appbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--ink-muted);
    padding-left: 14px;
    border-left: 1px solid var(--line);
    max-width: 280px;
}

.body-row { display: flex; flex: 1; min-height: 0; }

/* The brand mesh lives on the sidebar, not behind the content. Same device as
   the MMM tool but in this product's own colours - the TFG teal/blue/yellow
   sweep instead of Interval's greens. */
.sidebar {
    width: var(--rail-width);
    flex: 0 0 var(--rail-width);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 12px;
    position: sticky;
    top: 58px;
    height: calc(100vh - 58px);
    border-right: 1px solid var(--line);
    overflow: hidden;
    background:
        radial-gradient(ellipse 130% 46% at 6% 0%,   rgba(120, 189, 196, 0.55) 0%, transparent 62%),
        radial-gradient(ellipse 120% 42% at 96% 52%, rgba(240, 187, 50, 0.34) 0%, transparent 64%),
        radial-gradient(ellipse 140% 50% at 30% 104%, rgba(44, 117, 124, 0.30) 0%, transparent 66%),
        #f2f5f4;
    transition: width 0.18s ease, flex-basis 0.18s ease, padding 0.18s ease;
}

/* Fine vertical grain over the mesh only. */
.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.34) 0 1px, transparent 1px 5px);
    mix-blend-mode: overlay;
}

.sidebar > * { position: relative; z-index: 1; }

.sidebar nav { flex: 1; overflow-y: auto; overflow-x: hidden; }

.rail-group { padding: 7px 0; border-top: 1px solid rgba(255, 255, 255, 0.5); }
.rail-group:first-child { border-top: none; padding-top: 0; }

.rail-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-soft);
    opacity: 0.72;
    padding: 4px 9px 6px;
    white-space: nowrap;
}

.rail-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 9px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    color: #2c3138;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.12s ease;
}

.rail-link:hover { background: rgba(255, 255, 255, 0.62); text-decoration: none; }

.rail-link.is-current {
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
    box-shadow: inset 2px 0 0 var(--accent), 0 1px 3px rgba(17, 20, 24, 0.10);
}

.rail-link .rail-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.rail-link.is-current .rail-icon { opacity: 1; color: var(--accent); }

.rail-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, 0.75);
    border-radius: var(--radius-pill);
    padding: 1px 7px;
    font-variant-numeric: tabular-nums;
}

.rail-foot {
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 13px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

/* Collapsed: icons only. Driven by a class on .app, remembered in localStorage. */
.app.nav-collapsed .sidebar { width: 60px; flex-basis: 60px; padding: 16px 8px; }
.app.nav-collapsed .rail-label,
.app.nav-collapsed .rail-count,
.app.nav-collapsed .rail-foot,
.app.nav-collapsed .rail-link span { display: none; }
.app.nav-collapsed .rail-link { justify-content: center; padding: 9px 0; }

/* --- Contextual secondary panel (FreethinkingHub pattern) ---------------- */

.subpanel {
    width: 250px;
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
    position: sticky;
    top: 58px;
    height: calc(100vh - 58px);
}

.subpanel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 14px;
    background: var(--tfg-black);
    color: #fff;
    font-size: 12.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.subpanel-head .rail-icon { width: 14px; height: 14px; opacity: 0.7; }

.subpanel-body { flex: 1; overflow-y: auto; padding: 14px 8px; }

.subpanel-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9aa0ac;
    padding: 10px 12px 5px;
}

.subpanel-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-muted);
    text-decoration: none;
    border-radius: 7px;
}

.subpanel-link:hover { color: var(--ink); background: #f7f8fa; text-decoration: none; }

.subpanel-link.is-current { color: var(--ink); background: #f7f8fa; }

.subpanel-link.is-current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2.5px;
    height: 18px;
    border-radius: 2px;
    background: var(--accent);
}

.subpanel-empty { padding: 10px 12px; font-size: 12.5px; color: var(--ink-muted); }

/* --- Footer (attribution shared across the group's tools) ---------------- */

.app-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 28px 22px;
    padding: 15px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.footer-product { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.footer-product .footer-copyright { font-weight: 500; color: var(--ink-muted); margin-left: 6px; }

.attribution {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 13px;
    font-size: 11.5px;
    color: var(--ink-soft);
}

.attr-item { display: inline-flex; align-items: center; gap: 7px; }
.attr-tfg { height: 24px; width: auto; display: block; }
.attr-potent { height: 16px; width: 16px; display: block; }
.attr-potent-word { font-weight: 800; color: var(--tfg-purple); }
.attr-rule { width: 1px; height: 12px; background: currentColor; opacity: 0.3; }

/* --- Context bar -------------------------------------------------------- */
/* Persistent across every screen. Shows what the app is currently pointed at,
   so a number on screen can never be read without its context. */

.context-bar {
    position: sticky;
    top: 58px; /* sits directly beneath the appbar */
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 28px;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.context-title { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.context-spacer { margin-left: auto; }

.context-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    white-space: nowrap;
}

.context-chip .label { color: var(--ink-muted); font-weight: 600; }
.context-chip.is-empty { color: var(--ink-muted); border-style: dashed; }

/* Connection state. Deliberately readable without relying on colour alone -
   each state carries a text label as well as a dot. */
.conn-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.conn-live .conn-dot { background: var(--success); }
.conn-down .conn-dot { background: var(--danger); }
.conn-unknown .conn-dot { background: #c4c8d0; }
.conn-live { color: var(--success); border-color: rgba(26, 127, 79, 0.3); }
.conn-down { color: var(--danger); border-color: rgba(217, 45, 90, 0.3); }

/* --- Page --------------------------------------------------------------- */

.workspace { display: flex; flex-direction: column; min-width: 0; }

.page {
    padding: 26px 28px 72px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1560px;
    width: 100%;
}

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-head p { color: var(--ink-muted); font-size: 14px; margin-top: 5px; max-width: 68ch; }

/* --- Cards and panels --------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid rgba(231, 231, 236, 0.9);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 22px 24px;
}

.card-flush { padding: 0; overflow: hidden; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.card-header h2, .card-header h3 { letter-spacing: -0.012em; }
.card-header .sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

.card-flush .card-header { padding: 20px 24px 0; margin-bottom: 14px; }

.panel {
    background: #fbfbfd;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-panel);
    padding: 16px 18px;
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-tight { display: flex; flex-direction: column; gap: 8px; }
.cluster { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.divider { border: none; border-top: 1px solid var(--line-soft); margin: 16px 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* --- KPI tiles ---------------------------------------------------------- */
/* Used only for query metadata the app actually knows - row counts, durations,
   date bounds. Never for invented business metrics. */

.kpi {
    background: var(--surface);
    border: 1px solid rgba(231, 231, 236, 0.9);
    border-radius: var(--radius-panel);
    box-shadow: var(--shadow-card);
    padding: 15px 17px;
}

.kpi-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
}

.kpi-value {
    margin-top: 7px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.kpi-value.is-empty { color: #b8bcc6; font-weight: 600; font-size: 19px; }
.kpi-foot { margin-top: 3px; font-size: 12px; color: var(--ink-muted); }

/* --- Buttons ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.005em;
    border-radius: var(--radius-pill);
    padding: 9px 18px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 2px 6px rgba(16, 24, 40, 0.16), 0 8px 20px -6px rgba(16, 24, 40, 0.22); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); background: #26282f; }

.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(44, 117, 124, 0.22), 0 8px 20px -6px rgba(44, 117, 124, 0.32); }
.btn-accent:hover:not(:disabled) { transform: translateY(-1px); background: #25646a; }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-pill); }
.btn-secondary:hover:not(:disabled) { transform: translateY(-1px); border-color: #d5d5dd; }

.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: #f2f3f7; color: var(--ink); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { transform: translateY(-1px); background: #c02450; }

.btn-sm { padding: 6px 13px; font-size: 12.5px; }

/* --- Forms -------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink-soft);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.field-hint { font-size: 11.5px; font-weight: 500; color: var(--ink-muted); }

.control {
    font-family: var(--font);
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-input);
    padding: 9px 12px;
    width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.control::placeholder { color: #a8adb8; }
.control:disabled { background: #f5f6f9; color: var(--ink-muted); cursor: not-allowed; }

select.control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.search-control { position: relative; }
.search-control .control { padding-left: 34px; }
.search-control svg {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; color: var(--ink-muted); pointer-events: none;
}

/* --- Tags and chips ----------------------------------------------------- */

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: var(--radius-pill);
    padding: 3px 9px;
    white-space: nowrap;
}

.tag-key      { color: #8a5a00; background: rgba(240, 187, 50, 0.20); }
.tag-accent   { color: var(--accent); background: var(--accent-soft); }
.tag-muted    { color: var(--ink-muted); background: #f0f1f5; }
.tag-warning  { color: #9a5a06; background: var(--warning-soft); }
.tag-danger   { color: #ab1e44; background: var(--danger-soft); }
.tag-nullable { color: var(--ink-muted); background: transparent; border: 1px dashed var(--line); }

/* Field group colours. Distinct hues, all drawn from the TFG palette so the
   selector reads as one system rather than a rainbow. */
.tag-group-identifier { color: var(--tfg-teal);   background: rgba(44, 117, 124, 0.12); }
.tag-group-dimension  { color: #4a5568;           background: #eef0f4; }
.tag-group-date       { color: var(--tfg-purple); background: rgba(113, 43, 112, 0.11); }
.tag-group-numeric    { color: #9a5a06;           background: rgba(242, 142, 27, 0.13); }
.tag-group-rate       { color: #a33116;           background: rgba(229, 41, 28, 0.10); }
.tag-group-status     { color: #2a6b8f;           background: rgba(120, 189, 196, 0.22); }
.tag-group-technical  { color: #7c828e;           background: #f2f3f6; }

.type-chip {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-muted);
    background: #f5f6f9;
    border-radius: 6px;
    padding: 2px 7px;
    white-space: nowrap;
}

/* --- Tables ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
}

.data-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    background: #fafafc;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table td {
    padding: 11px 18px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-soft);
    vertical-align: top;
}

.data-table th.num, .data-table td.num { text-align: right; }
.data-table td.num { font-weight: 600; color: var(--ink); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background-color 0.12s ease; }
.data-table tbody tr:hover { background: #fafbfd; }
.data-table td.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* A null in a result set is not an empty string, and the difference matters
   when reading booking data. Render it explicitly. */
.null-cell { color: #b8bcc6; font-style: italic; font-size: 12px; }

/* --- States ------------------------------------------------------------- */

.alert {
    border-radius: var(--radius-panel);
    padding: 13px 16px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.55;
}

.alert-danger  { background: var(--danger-soft); border: 1px solid rgba(217, 45, 90, 0.25); color: #ab1e44; }
.alert-success { background: rgba(26, 127, 79, 0.08); border: 1px solid rgba(26, 127, 79, 0.25); color: var(--success); }
.alert-warning { background: var(--warning-soft); border: 1px solid rgba(242, 142, 27, 0.30); color: #9a5a06; }
.alert-info    { background: var(--accent-soft); border: 1px solid rgba(44, 117, 124, 0.22); color: #1f5c62; }
.alert strong { font-weight: 700; }
.alert ul { margin: 5px 0 0; padding-left: 18px; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 48px 24px;
    color: var(--ink-muted);
}

.empty-state h3 { color: var(--ink-soft); }
.empty-state p { font-size: 13.5px; max-width: 46ch; }
.empty-state .empty-icon { width: 34px; height: 34px; color: #c4c8d0; margin-bottom: 2px; }

/* Skeleton loading. Used wherever a query is in flight, so the layout does not
   jump when results land. */
.skeleton {
    background: linear-gradient(90deg, #f0f1f4 25%, #f7f8fa 37%, #f0f1f4 63%);
    background-size: 400% 100%;
    animation: skeleton 1.4s ease infinite;
    border-radius: 6px;
}

.skeleton-row { height: 13px; margin: 9px 0; }

@keyframes skeleton {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
    .btn:hover { transform: none; }
    * { transition-duration: 0.01ms !important; }
}

/* --- SQL preview -------------------------------------------------------- */

.sql-block {
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.7;
    background: #1d1f26;
    color: #e6e8ee;
    border-radius: var(--radius-panel);
    padding: 16px 18px;
    overflow-x: auto;
    white-space: pre;
    tab-size: 2;
}

.sql-block .kw  { color: #78bdc4; font-weight: 600; }
.sql-block .fn  { color: #f0bb32; }
.sql-block .str { color: #9ede9e; }
.sql-block .par { color: #f28e1b; font-weight: 600; }
.sql-block .cmt { color: #6f7684; font-style: italic; }

/* --- Responsive --------------------------------------------------------- */
/* Desktop-first, as specified. Below 1100px the sidebar folds to a top strip
   (keeping its mesh) and the contextual panel hides, so the tool stays usable
   on a laptop in a meeting without pretending this is a phone-first product. */

@media (max-width: 1100px) {
    .body-row { flex-direction: column; }

    .sidebar {
        position: static;
        width: auto;
        flex: none;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        overflow-x: auto;
        padding: 8px 14px;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .sidebar nav { display: flex; align-items: center; gap: 4px; overflow: visible; }
    .rail-group { display: flex; align-items: center; gap: 4px; padding: 0; border-top: none; }
    .rail-label, .rail-count, .rail-foot { display: none; }
    .rail-link { padding: 7px 11px; white-space: nowrap; }
    .appbar-toggle { display: none; }
    .subpanel { display: none; }
    .context-bar { position: static; padding: 10px 16px; }
    .page { padding: 20px 16px 56px; }
    .app-footer { margin: 0 16px 16px; }
}
