/* Same structure/conventions as admin/static/style.css -- deliberately a
   different --accent hue (emerald, not sky blue) so the two apps are
   visually distinguishable at a glance, since it's easy to have both
   open in adjacent tabs. */

:root {
    --bg: #0a0e17;
    --bg-alt: #0e1420;
    --card: #121a2b;
    --card-alt: #16203380;
    --border: #232d42;
    --border-soft: #1a2336;
    --text: #e6edf5;
    --muted: #7d8ba3;
    --muted-dim: #545f78;

    --accent: #34d399;
    --accent-dim: #34d39933;
    --success: #34d399;
    --danger: #fb7185;
    --warning: #fbbf24;
    --purple: #a78bfa;

    --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-ui);
    background:
        radial-gradient(ellipse 1200px 600px at 20% -10%, #10231a55, transparent),
        radial-gradient(ellipse 1000px 500px at 100% 0%, #1a2f2344, transparent),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Global "something is loading" hint -- one fixed bar, driven entirely
   by wrapping window.fetch in base.html, so every page's existing fetch
   calls light it up automatically with zero per-page changes. Indeterminate
   (we don't track real progress, just "a request is in flight"), so it's
   a sliding gradient rather than a width tied to any actual percentage. */
#globalLoadingBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 10001;
    background: transparent;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}
#globalLoadingBar.active { opacity: 1; }
#globalLoadingBar::after {
    content: "";
    position: absolute;
    top: 0; bottom: 0; left: -30%;
    width: 30%;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: global-loading-slide 1.1s ease-in-out infinite;
}
@keyframes global-loading-slide {
    0% { left: -30%; }
    100% { left: 100%; }
}

nav {
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-soft);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

nav .brand {
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
    margin-right: 12px;
    letter-spacing: 0.02em;
}
nav .brand::before {
    content: "◆ ";
    color: var(--accent);
}

nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
nav a:hover { color: var(--text); border-color: var(--muted-dim); }

/* Sub-tabs within a detail view (e.g. Agent Lookup's per-agent panel) --
   filled pill style, not just an underline, so it reads as clickable
   navigation rather than plain section headers at a glance. */
.tab-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.tab-btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-bottom: 2px solid transparent;
    border-radius: 8px 8px 0 0;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    padding: 9px 16px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--text); background: #0f1626; }
.tab-btn.active { color: var(--accent); border-color: var(--accent); background: #0f1626; }

main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-top: 40px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.card {
    background: linear-gradient(180deg, var(--card) 0%, #0f1626 100%);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 20px;
    overflow-x: auto;
    box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px -12px rgba(0,0,0,0.5);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

th {
    color: var(--muted-dim);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td { font-family: var(--font-mono); font-size: 12.5px; color: var(--text); }
td:first-child { font-family: var(--font-ui); font-size: 13px; }

tr:hover td { background: rgba(52, 211, 153, 0.05); }

a { color: var(--accent); }

.btn {
    display: inline-block;
    background: linear-gradient(180deg, #4ee0ab, var(--accent));
    color: #04120c;
    border: none;
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 0 0 1px #34d39955, 0 4px 14px -4px #34d39977;
    transition: transform 0.1s, box-shadow 0.15s;
}
.btn:hover { box-shadow: 0 0 0 1px #34d399aa, 0 6px 18px -4px #34d399aa; }
.btn:active { transform: translateY(1px); }

.message {
    background: #1a2336;
    border: 1px solid var(--accent-dim);
    border-left: 3px solid var(--accent);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text);
}

.message-error {
    background: #1a2336;
    border: 1px solid #fb718555;
    border-left: 3px solid var(--danger);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text);
}

.summary-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.summary-box {
    flex: 1;
    min-width: 150px;
    background: linear-gradient(160deg, var(--card), #0f1626);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 10px;
    padding: 18px;
    text-align: left;
    overflow: hidden;
    /* .n below shrinks via cqw (container query width) against THIS
       box's own rendered width, not the viewport -- a box's actual
       width depends on how many siblings share the row (flex: 1). */
    container-type: inline-size;
}

.summary-box .n {
    font-family: var(--font-mono);
    /* cqw (container query width) is relative to the nearest ancestor
       with container-type set -- .summary-box itself, above -- so this
       shrinks to fit THIS box's own rendered width, not the viewport. */
    font-size: clamp(20px, 5cqw, 32px);
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    /* A long formatted number ("$1,385,000") has no natural break point,
       so the browser's default overflow-wrap (only breaks at
       whitespace) just lets it spill past the box edge instead of
       wrapping -- break-word forces a break if (and only if) it still
       doesn't fit even after shrinking, as a last resort rather than
       visually overflowing into neighboring boxes. */
    overflow-wrap: break-word;
}
.summary-box .label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 6px;
}

/* Inline "this section is (re)computing" placeholder -- dropped directly
   into whatever container is about to be replaced, at the START of an
   async render function (before its await), not just the thin top-of-page
   #globalLoadingBar. That bar is easy to miss since it's peripheral and
   easy to glance past; this sits exactly where the user is already
   looking (the stale content it's about to replace), so switching
   selections/filters is never silently unresponsive while a query runs. */
.loading-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    padding: 22px 4px;
}
.loading-inline .spinner {
    width: 15px;
    height: 15px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: loading-spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes loading-spin {
    to { transform: rotate(360deg); }
}

code {
    background: var(--bg-alt);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--border);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: none;
    letter-spacing: 0;
}
.info-icon:hover { background: var(--accent); color: #04120c; }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 12, 0.88);
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.modal-overlay.open { display: flex; }

.modal-box {
    background: #16203a;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 560px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px -20px rgba(0,0,0,0.9);
    isolation: isolate;
}
.modal-box h3 { margin-top: 0; color: var(--text); font-family: var(--font-ui); }
.modal-box h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.modal-box p, .modal-box li { font-size: 13px; line-height: 1.5; }
.modal-box ul { padding-left: 18px; margin: 4px 0; }
.modal-box .close-btn { margin-top: 16px; }
.modal-box.wide { max-width: 920px; }
.modal-box table { font-size: 12.5px; }

/* Inline footnote-style citation marker -- e.g. "...effect [Case & Quigley]..."
   right in a sentence, not a bare "see references" link. Click shows a
   small floating card near the marker (.cite-popover), not the big
   centered modal -- this is a footnote, not a document. */
.cite {
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85em;
    white-space: nowrap;
    border-bottom: 1px dotted var(--accent);
}
.cite:hover { color: var(--text); }

.cite-popover {
    display: none;
    position: absolute;
    z-index: 10000; /* above .modal-overlay's 9999 -- a citation is always clicked from inside a methodology popup, so it must render on top of it, not behind it */
    max-width: 360px;
    background: #16203a;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 12px 32px -12px rgba(0,0,0,0.8);
    font-size: 12.5px;
    line-height: 1.5;
}
.cite-popover.open { display: block; }
.cite-popover .source { color: var(--text); font-weight: 600; margin-bottom: 6px; }
.cite-popover .excerpt { color: var(--muted); }
.cite-popover .excerpt em { color: var(--text); font-style: italic; }

/* Fakes a dark basemap over plain OpenStreetMap tiles (free, no API key
   -- see market_overview.html's comment on why not a paid dark-tile
   provider) when the alternate "street map" view is toggled on. Scoped
   to a class on the map container, not applied globally, so the default
   plain (no-tile) view is unaffected. */
.map-with-tiles .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 5px;
    padding: 5px 8px;
    font-family: var(--font-mono);
    font-size: 12.5px;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}
textarea { font-family: var(--font-ui); resize: vertical; }
label { color: var(--muted); font-size: 13px; }
