/* EDGAR Media — theme mirrors hxuanheng.github.io */
:root {
    --primary-color: #3e54ac;
    --secondary-color: #655dbb;
    --accent-color: #bface2;
    --bg: #f7f7fb;
    --card-bg: #ffffff;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --green: #15803d;
    --green-bg: #dcfce7;
    --red: #b91c1c;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.05);
    --radius: 10px;
    --transition: 0.25s;
}

body.dark-mode {
    --bg: #121212;
    --card-bg: #1f2937;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #374151;
    --green: #4ade80;
    --green-bg: #14321f;
    --red: #f87171;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    transition: background var(--transition), color var(--transition);
}

.container { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--primary-color); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--secondary-color); }

/* header */
.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
    transition: background var(--transition), border-color var(--transition);
}
.header-row { display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1.25rem; }
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.15rem; color: inherit; text-decoration: none; }
.brand:hover { opacity: 0.75; }
.brand-mark { font-size: 1.3rem; }
.header-nav { display: flex; align-items: center; gap: 1.25rem; font-size: 0.9rem; }
#theme-toggle {
    background: none; border: 1px solid var(--border); border-radius: 8px;
    cursor: pointer; font-size: 1rem; padding: 0.25rem 0.5rem; line-height: 1;
    transition: border-color var(--transition);
}
#theme-toggle:hover { border-color: var(--secondary-color); }

/* intro */
.content { padding: 2.5rem 0 1rem; }
.intro { margin-bottom: 2rem; }
h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }
.lede { color: var(--text-muted); max-width: 60ch; }
.lede strong { color: var(--text); }
.fresh-pill {
    background: var(--green-bg); color: var(--green);
    padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
    white-space: nowrap;
}
.updated { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.75rem; }

.controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.9rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.controls select {
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    transition: border-color var(--transition);
}
.controls select:hover { border-color: var(--secondary-color); }
#search {
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.7rem;
    min-width: 14rem;
    flex: 1 1 12rem;
    transition: border-color var(--transition);
}
#search::placeholder { color: var(--text-muted); }
#search:focus { outline: none; border-color: var(--secondary-color); }
.empty-search {
    padding: 1.5rem 0;
    text-align: center;
    font-style: italic;
    color: var(--text-muted);
}

/* cards */
.cards { display: flex; flex-direction: column; gap: 0.75rem; }
.loading { color: var(--text-muted); padding: 2rem 0; text-align: center; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color var(--transition), transform var(--transition);
}
.card:hover { transform: translateY(-1px); }
.card.hot { border-left-color: var(--green); }

.card-main {
    padding: 1rem 1.1rem;
    display: grid;
    grid-template-columns: 2.2rem 1fr;
    gap: 0.5rem 1rem;
    align-items: center;
}

/* expandable per-firm filing list */
/* "Latest filings" header — label left, show-more/less toggle far right (aligns with the
   age column). The toggle sits in this fixed top header, so collapse never needs a scroll. */
.filing-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 0.7rem;
    padding: 0.5rem 1.1rem 0.1rem; font-size: 0.78rem;
}
.filing-head-label { color: var(--text-muted); font-weight: 600; letter-spacing: 0.02em; }
.more-open, .more-close {
    cursor: pointer; user-select: none; white-space: nowrap;
    color: var(--text-muted); transition: color var(--transition);
}
.more-open:hover, .more-close:hover { color: var(--primary-color); }
.more-open::after  { content: " ▾"; }
.more-close::after { content: " ▴"; }
.more-close { display: none; }
.more-rows  { display: none; }
.more-toggle:checked ~ .filing-head .more-open  { display: none; }
.more-toggle:checked ~ .filing-head .more-close { display: inline; }
.more-toggle:checked ~ .more-rows { display: block; }
.filing-list { list-style: none; margin: 0; padding: 0 1.1rem; }
.flrow { padding: 0.5rem 0; border-top: 1px dashed var(--border); font-size: 0.85rem; }
/* header line: form code link (left scan-anchor) · date · summary ... age */
.fl-head { display: flex; align-items: baseline; gap: 0.7rem; }
.flform { flex: 0 0 auto; min-width: 4.5rem; font-weight: 600; color: var(--primary-color); white-space: nowrap; }
.flform:hover { color: var(--secondary-color); }
.fl-date { flex: 0 1 auto; color: var(--text-muted); }
.flwhen { flex: 0 0 auto; margin-left: auto; color: var(--text-muted); font-size: 0.8rem; }

/* summarized rows collapse to a one-liner; a "Summary" tag cues the reveal,
   click the header to open the summary inline. */
.flrow-ai > .fl-head { cursor: pointer; }
.fl-tag {
    flex: 0 0 auto;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    background: var(--border);
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
}
.fl-tag:hover { color: var(--primary-color); background: var(--accent-color); }
.fl-expand:checked ~ .fl-head .fl-tag { display: none; }   /* body's "Summary:" label takes over when open */

.fl-summary { display: none; margin: 0.35rem 0 0.1rem; color: var(--text); line-height: 1.5; font-size: 0.9rem; }
.fl-expand:checked ~ .fl-summary { display: block; }
.fl-label { font-style: italic; color: var(--text-muted); font-weight: 600; }

.rank { font-weight: 700; color: var(--text-muted); font-size: 1.05rem; text-align: center; }

.tick { min-width: 0; }
.tick-row { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.ticker { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.02em; }
.ticker-sep { color: var(--text-muted); font-weight: 400; margin: 0 0.3rem; }
.coname { color: var(--text-muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; }
.attention { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.15rem; }
.chg-up { color: var(--green); font-weight: 600; }
.chg-down { color: var(--red); font-weight: 600; }

/* filing area: the latest filing shows directly as the first row; the rest live
   behind the "N more filings" menu below it. */
.card-filings { padding-bottom: 0.35rem; }
.filing-warn { padding: 0.5rem 1.1rem 0; margin: 0; }
.filing-lead .flrow { border-top: none; }   /* lead is first -> no divider above it */
.filing-none { padding: 0.6rem 1.1rem; margin: 0; color: var(--text-muted); font-size: 0.8rem; font-style: italic; }
.warn { color: #b45309; font-weight: 600; font-size: 0.8rem; }
body.dark-mode .warn { color: #fbbf24; }

@media (max-width: 620px) {
    .card-main { grid-template-columns: 1.8rem 1fr; }
    /* Phone: each row becomes two tidy lines — form code + age aligned at the
       edges on top, date/desc (and Summary tag) below — so the form and "days
       ago" line up cleanly instead of the age wrapping to a ragged second line. */
    .fl-head {
        display: grid;
        grid-template-columns: 1fr auto;
        column-gap: 0.7rem; row-gap: 0.15rem;
        align-items: baseline;
    }
    .flform { grid-column: 1; grid-row: 1; }
    .flwhen { grid-column: 2; grid-row: 1; margin-left: 0; justify-self: end; }
    .fl-date { grid-column: 1 / -1; grid-row: 2; }   /* date + filing label get the whole row */
    .fl-tag  { grid-column: 1 / -1; grid-row: 3; justify-self: start; }   /* Summary pill below */
}

/* footer */
.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 3rem; padding: 1.75rem 0;
    color: var(--text-muted); font-size: 0.85rem;
}
.site-footer p { margin-bottom: 0.6rem; max-width: 70ch; }
.byline { font-size: 0.8rem; }

/* ───────────────────────── accounts ───────────────────────── */
#auth-slot { display: inline-flex; align-items: center; gap: 0.6rem; }
#auth-slot:empty { display: none; }   /* dormant when unconfigured -> no nav layout shift */
.auth-me { display: inline-flex; align-items: center; gap: 0.4rem; max-width: 11rem; }
.auth-name { color: var(--text-muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-avatar {
    width: 1.5rem; height: 1.5rem; border-radius: 50%; object-fit: cover;
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.auth-avatar-fallback {
    background: var(--accent-color); color: #fff; font-size: 0.75rem; font-weight: 700;
}
.auth-btn {
    font: inherit; font-size: 0.85rem; cursor: pointer;
    background: none; color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.25rem 0.65rem; transition: border-color var(--transition), background var(--transition);
}
.auth-btn:hover { border-color: var(--secondary-color); }
.auth-btn-primary { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.auth-btn-primary:hover { background: var(--secondary-color); border-color: var(--secondary-color); color: #fff; }

/* sign-in modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-card {
    position: relative; background: var(--card-bg); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    width: min(92vw, 22rem); padding: 1.5rem 1.4rem 1.4rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.modal-x {
    position: absolute; top: 0.6rem; right: 0.6rem; background: none; border: none;
    color: var(--text-muted); font-size: 1rem; cursor: pointer; line-height: 1; padding: 0.25rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.3rem; }
.oauth-btn {
    font: inherit; font-size: 0.9rem; cursor: pointer; text-align: center;
    background: var(--card-bg); color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.55rem 0.7rem; transition: border-color var(--transition);
}
.oauth-btn:hover { border-color: var(--secondary-color); }
.modal-or { display: flex; align-items: center; gap: 0.6rem; color: var(--text-muted); font-size: 0.8rem; }
.modal-or::before, .modal-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.magic-form { display: flex; flex-direction: column; gap: 0.5rem; }
.magic-form input {
    font: inherit; font-size: 0.9rem; color: var(--text); background: var(--card-bg);
    border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.7rem;
}
.magic-form input:focus { outline: none; border-color: var(--secondary-color); }
.modal-msg { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.2rem; }
.modal-msg-err { color: var(--red); }

/* ───────────────────────── comments ───────────────────────── */
/* card footer expander — same checkbox+label pattern as .more-toggle */
.card-comments-bar { padding: 0.4rem 1.1rem 0.6rem; font-size: 0.8rem; }
.cmt-toggle-label {
    cursor: pointer; user-select: none; color: var(--text-muted);
    transition: color var(--transition);
}
.cmt-toggle-label:hover { color: var(--primary-color); }
.cmt-toggle-label::after { content: " ▾"; }
.cmt-toggle:checked ~ .card-comments-bar .cmt-toggle-label::after { content: " ▴"; }
.cmt-count { color: var(--text-muted); }
.card-comments { display: none; padding: 0 1.1rem 0.8rem; }
.cmt-toggle:checked ~ .card-comments { display: block; }

.cmt-head { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.5rem; }
.cmt-empty { color: var(--text-muted); font-size: 0.85rem; font-style: italic; padding: 0.3rem 0; }
.cmt-flash { font-size: 0.8rem; color: var(--text-muted); margin: 0.3rem 0; }
.cmt-flash-err { color: var(--red); }
.cmt-signin { padding: 0.3rem 0 0.6rem; }

.cmt-composer { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.9rem; }
.cmt-composer textarea, .cmt-edit-form textarea, .cmt-reply-form textarea {
    font: inherit; font-size: 0.88rem; color: var(--text); background: var(--card-bg);
    border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.65rem;
    resize: vertical; min-height: 3.2rem; width: 100%;
}
.cmt-composer textarea:focus, .cmt-edit-form textarea:focus, .cmt-reply-form textarea:focus {
    outline: none; border-color: var(--secondary-color);
}
.cmt-composer-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.cmt-composer-row select {
    font: inherit; font-size: 0.82rem; color: var(--text); background: var(--card-bg);
    border: 1px solid var(--border); border-radius: 8px; padding: 0.3rem 0.5rem; cursor: pointer;
}

/* @-mention filing picker */
.mention-pop {
    border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg);
    box-shadow: var(--shadow); max-height: 12rem; overflow-y: auto; margin: -0.2rem 0 0.4rem;
}
.mention-pop[hidden] { display: none; }
.mention-item {
    display: block; width: 100%; text-align: left; cursor: pointer;
    background: none; border: none; border-bottom: 1px solid var(--border);
    padding: 0.4rem 0.6rem; font: inherit; font-size: 0.82rem; color: var(--text);
}
.mention-item:last-child { border-bottom: none; }
.mention-item.active, .mention-item:hover { background: var(--bg); }
.mi-form { font-weight: 600; color: var(--primary-color); }
.mi-date { color: var(--text-muted); }
.mi-sum  { color: var(--text-muted); }
.cmt-mention-dead { color: var(--text-muted); }   /* @ref to a filing no longer in window */

.comment { padding: 0.6rem 0; border-top: 1px dashed var(--border); }
.comment.reply { margin-left: 1.4rem; border-top: 1px dotted var(--border); }
.comment.deleted .comment-author { opacity: 0.6; }
.comment-meta { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; font-size: 0.8rem; }
.comment-author { font-weight: 600; color: var(--text); }
.comment-time, .comment-edited { color: var(--text-muted); }
.cmt-filing {
    font-size: 0.72rem; color: var(--text-muted); background: var(--border);
    padding: 0.05rem 0.45rem; border-radius: 999px;
}
a.cmt-filing:hover { color: var(--primary-color); background: var(--accent-color); }
.comment-body { margin: 0.25rem 0 0.35rem; font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.comment-removed { color: var(--text-muted); font-style: italic; }
.comment-replies { margin-top: 0.4rem; }
.replies-toggle { display: inline-block; margin-top: 0.3rem; font-weight: 600; }

.cmt-actions { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.15rem; }
.cmt-actions:empty { display: none; }
.vote-btn {
    font: inherit; font-size: 0.78rem; cursor: pointer; color: var(--text-muted);
    background: none; border: 1px solid var(--border); border-radius: 999px;
    padding: 0.1rem 0.5rem; transition: color var(--transition), border-color var(--transition);
}
.vote-btn:hover { border-color: var(--secondary-color); color: var(--primary-color); }
.vote-btn.voted { color: var(--primary-color); border-color: var(--primary-color); font-weight: 600; }
.cmt-link {
    font: inherit; font-size: 0.78rem; cursor: pointer; color: var(--text-muted);
    background: none; border: none; padding: 0; transition: color var(--transition);
}
.cmt-link:hover { color: var(--primary-color); }
.cmt-link-danger:hover { color: var(--red); }
.cmt-viewall { display: inline-block; margin-top: 0.6rem; font-size: 0.82rem; }

/* ─────────────────────── per-company page ─────────────────────── */
.company-head { margin-bottom: 1rem; }
.back-link { display: inline-block; font-size: 0.85rem; margin-bottom: 0.8rem; }
.company-head .tick-row { font-size: 1.15rem; }
.company-card { margin-bottom: 1.5rem; }
.company-comments-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.6rem; }
.company-comments .card-comments { display: block; padding: 0; }

@media (max-width: 620px) {
    .auth-name { display: none; }
    .comment.reply { margin-left: 0.8rem; }
    .cmt-composer-row { align-items: stretch; }
    .cmt-composer-row select { flex: 1 1 auto; }
}
