/* ---------------------------------------------------------------------
   PixelNews — flat, modern intelligence-dashboard theme.
   Rule: no gradients, no box/text shadows, anywhere. Flat fills + hairline
   rules + deliberate color blocking only. Primary accent is #dc2626.
   Typography: Space Grotesk (display) + Inter (body) + JetBrains Mono
   (data/metadata) — a contemporary product-UI pairing, not a newspaper face.
------------------------------------------------------------------------ */

:root {
    --red: #dc2626;
    --red-dark: #991b1b;
    --red-tint: #fdeeee;
    --ink: #17140f;
    --ink-soft: #44403c;
    --grey: #78716c;
    --line: #e2e0dc;
    --paper: #faf9f6;
    --paper-alt: #f1efe9;
    --white: #ffffff;
    --positive: #15803d;
    --positive-tint: #ecfdf3;
    --negative: #b91c1c;
    --negative-tint: #fef1f1;
    --neutral: #78716c;

    --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 24px;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -------------------------- Header -------------------------- */
.site-header {
    background: var(--white);
    border-bottom: 3px solid var(--red);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 16px 24px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 14px;
    height: 14px;
    background: var(--red);
    display: inline-block;
    border-radius: 3px;
}
.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 21px;
    letter-spacing: -0.01em;
}
.brand-accent { color: var(--red); }
.main-nav {
    display: flex;
    gap: 24px;
    flex: 1;
}
.nav-link {
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
}
.nav-link:hover {
    color: var(--red);
    text-decoration: none;
    border-bottom-color: var(--red);
}
.header-refresh { display: flex; align-items: center; gap: 10px; }

/* -------------------------- Buttons -------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 18px;
    border: 1.5px solid var(--red);
    background: var(--red);
    color: var(--white);
    cursor: pointer;
    border-radius: 6px;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn.is-loading { cursor: progress; opacity: 0.85; }
.btn:disabled { cursor: progress; }

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    opacity: 0.85;
    animation: pixelnews-spin 0.7s linear infinite;
    flex-shrink: 0;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }

@keyframes pixelnews-spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(23, 20, 15, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.loading-overlay.is-visible { display: flex; }
.loading-overlay-box {
    background: var(--white);
    border-radius: 8px;
    padding: 28px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: var(--red);
}
.loading-overlay-text {
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    text-align: center;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); text-decoration: none; }
.btn-outline { background: transparent; color: var(--red); }
.btn-outline:hover { background: var(--red); color: var(--white); }
.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--ink-soft);
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn-small { padding: 6px 12px; font-size: 11.5px; }
.btn-on-red {
    background: var(--white);
    color: var(--red);
    border-color: var(--white);
}
.btn-on-red:hover { background: var(--ink); color: var(--white); border-color: var(--ink); }

/* -------------------------- Flash messages -------------------------- */
.flash {
    margin-top: 18px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--red);
    background: var(--white);
    font-size: 14px;
    border-radius: 4px;
}
.flash-success { border-left-color: var(--positive); }
.flash-warning { border-left-color: #b45309; }
.flash-error { border-left-color: var(--negative); }

.live-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--red-tint);
    color: var(--red-dark);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 20px;
}
.live-banner .spinner { border-color: var(--red-dark); border-top-color: transparent; }

/* -------------------------- Page layout -------------------------- */
.page-main { padding: 32px 24px 64px; }

.page-title {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 0 0 6px;
}
.page-subtitle {
    color: var(--grey);
    font-size: 14.5px;
    margin: 0 0 28px;
    max-width: 70ch;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--red);
    margin: 0 0 8px;
}

/* -------------------------- Stat strip -------------------------- */
.stat-strip {
    display: flex;
    border: 1px solid var(--line);
    background: var(--white);
    margin-bottom: 28px;
    border-radius: 6px;
    overflow: hidden;
}
.stat {
    flex: 1;
    padding: 18px 22px;
    border-right: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat:last-child { border-right: none; }
.stat-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--red-tint);
    color: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    display: block;
}
.stat-label {
    font-size: 11px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--grey);
}

/* -------------------------- Tag / filter row -------------------------- */
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.tag-pill {
    display: inline-block;
    padding: 7px 13px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    background: var(--white);
    border-radius: 20px;
    transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.tag-pill:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.tag-pill.active { background: var(--red); border-color: var(--red); color: var(--white); }

/* -------------------------- Company grid -------------------------- */
.company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.company-card {
    border: 1px solid var(--line);
    background: var(--white);
    padding: 0;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color .15s ease;
}
.company-card-top {
    height: 4px;
    background: var(--line);
}
.company-card.is-priority .company-card-top { background: var(--red); }
.company-card-body {
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.company-card:hover { border-color: var(--red); }
.company-card-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.company-card:hover .company-card-name { color: var(--red); }
.company-card-meta {
    font-size: 11.5px;
    color: var(--grey);
    font-family: var(--font-mono);
}
.company-card-industries { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    padding: 3px 9px;
    background: var(--paper-alt);
    color: var(--ink-soft);
    border-radius: 12px;
}
.chip-priority { background: var(--red-tint); color: var(--red-dark); }
.company-card-count {
    margin-top: auto;
    font-size: 12.5px;
    font-family: var(--font-mono);
    color: var(--ink-soft);
    border-top: 1px solid var(--line);
    padding-top: 8px;
}

/* -------------------------- Company detail header -------------------------- */
.company-header {
    border: 1px solid var(--line);
    background: var(--white);
    padding: 26px 28px;
    margin-bottom: 28px;
    border-radius: 6px;
}
.company-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}
.company-header h1 {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 0 0 4px;
}
.company-header-meta {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--grey);
    margin-bottom: 14px;
}
.company-about {
    font-size: 15px;
    color: var(--ink-soft);
    line-height: 1.65;
    max-width: 70ch;
}
.company-header-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* -------------------------- Day panels (feed + detail) -------------------------- */
.day-group {
    margin-bottom: 26px;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: var(--white);
}
.day-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 20px;
    background: var(--ink);
    flex-wrap: wrap;
}
.day-heading-left { display: flex; align-items: center; gap: 12px; }
.day-heading-left svg { width: 16px; height: 16px; color: var(--white); opacity: 0.85; flex-shrink: 0; }
.day-heading h2 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    color: var(--white);
    letter-spacing: -0.005em;
}
.day-heading .day-count {
    font-size: 11.5px;
    font-family: var(--font-mono);
    color: #d6d3cd;
}
.day-heading .btn { padding: 6px 14px; font-size: 11px; }

.article-list { display: flex; flex-direction: column; padding: 4px 0; }
.article-row {
    display: grid;
    grid-template-columns: 4px 1fr;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    transition: background-color .15s ease;
}
.article-row:last-child { border-bottom: none; }
.article-row:hover { background: var(--paper-alt); }
.article-accent { background: var(--line); border-radius: 2px; }
.article-row.sentiment-positive .article-accent { background: var(--positive); }
.article-row.sentiment-negative .article-accent { background: var(--negative); }
.article-row.sentiment-neutral .article-accent,
.article-row .article-accent { background: var(--red); opacity: 0.85; }

.article-title {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.005em;
    margin: 0 0 6px;
    color: var(--ink);
    line-height: 1.4;
}
.article-title a { color: var(--ink); }
.article-title a:hover { color: var(--red); text-decoration: none; }
.article-meta {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--grey);
    margin-bottom: 8px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.article-summary {
    font-size: 14px;
    color: var(--ink-soft);
    max-width: 80ch;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.article-link {
    font-size: 12.5px;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}
.article-link svg { width: 12px; height: 12px; }

.sentiment {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10px;
    padding: 2px 9px;
    border-radius: 10px;
}
.sentiment::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.sentiment-positive { color: var(--positive); background: var(--positive-tint); }
.sentiment-negative { color: var(--negative); background: var(--negative-tint); }
.sentiment-neutral { color: var(--neutral); background: var(--paper-alt); }

.industry-tag {
    background: var(--paper-alt);
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
}
.industry-tag.priority { background: var(--red-tint); color: var(--red-dark); }

/* -------------------------- Forms -------------------------- */
.form-card {
    border: 1px solid var(--line);
    background: var(--white);
    padding: 28px;
    max-width: 640px;
    border-radius: 6px;
}
.form-row { margin-bottom: 18px; }
.form-row label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: var(--font-mono);
    color: var(--ink-soft);
    margin-bottom: 6px;
}
.form-row input[type=text],
.form-row input[type=url],
.form-row input[type=email],
.form-row input[type=password],
.form-row textarea,
.form-row select {
    width: 100%;
    border: 1.5px solid var(--line);
    padding: 10px 12px;
    font-size: 14px;
    font-family: var(--font-body);
    border-radius: 4px;
    background: var(--white);
    color: var(--ink);
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
    outline: none;
    border-color: var(--red);
}
.form-row .help-text { font-size: 12px; color: var(--grey); margin-top: 4px; }
.field-error { font-size: 12px; color: var(--negative); margin-top: 4px; }

/* -------------------------- Auth pages -------------------------- */
.auth-page { max-width: 640px; }
.auth-switch { margin-top: 16px; font-size: 13.5px; color: var(--ink-soft); }

/* -------------------------- Home / marketing page -------------------------- */
.hero { padding: 24px 0 44px; max-width: 780px; }
.hero-title {
    font-family: var(--font-display);
    font-size: 40px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 4px 0 16px;
}
.hero-subtitle { font-size: 16px; color: var(--ink-soft); line-height: 1.65; max-width: 62ch; margin-bottom: 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-large { padding: 13px 26px; font-size: 14px; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 48px;
}
.feature-card {
    border: 1px solid var(--line);
    background: var(--white);
    border-radius: 8px;
    padding: 20px;
}
.feature-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--red-tint);
    color: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.feature-icon svg { width: 19px; height: 19px; }
.feature-card h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--ink);
}
.feature-card p { font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; margin: 0; }

.how-it-works { padding: 8px 0 40px; border-top: 1px solid var(--line); }
.how-it-works .eyebrow { margin-top: 32px; }
.step-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-top: 8px;
}
.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--red);
    color: var(--white);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 10px;
}
.step h4 { font-family: var(--font-display); font-size: 15.5px; margin: 0 0 5px; color: var(--ink); }
.step p { font-size: 13px; color: var(--ink-soft); line-height: 1.55; margin: 0; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.checkbox-grid label { display: flex; align-items: center; gap: 6px; font-weight: 500; text-transform: none; font-size: 13.5px; }

/* -------------------------- Empty state -------------------------- */
.empty-state {
    border: 1px dashed var(--line);
    background: var(--white);
    padding: 48px 24px;
    text-align: center;
    color: var(--grey);
    border-radius: 8px;
}
.empty-state svg { width: 32px; height: 32px; color: var(--red); opacity: 0.7; margin-bottom: 14px; }
.empty-state strong { color: var(--ink); display: block; margin-bottom: 6px; font-size: 16px; font-family: var(--font-display); }

/* -------------------------- Pagination -------------------------- */
.pagination { display: flex; gap: 8px; margin-top: 20px; }
.pagination a, .pagination span {
    border: 1px solid var(--line);
    padding: 6px 12px;
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--ink-soft);
    border-radius: 4px;
}
.pagination a:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.pagination .current { background: var(--red); color: var(--white); border-color: var(--red); }

/* -------------------------- Footer -------------------------- */
.site-footer {
    border-top: 1px solid var(--line);
    background: var(--white);
    margin-top: 40px;
}
.footer-inner {
    display: flex;
    justify-content: space-between;
    padding: 18px 24px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--grey);
    flex-wrap: wrap;
    gap: 6px;
}

/* -------------------------- Responsive -------------------------- */

/* Tablet and small laptop */
@media (max-width: 760px) {
    .wrap { padding: 0 18px; }
    .header-inner { flex-wrap: wrap; gap: 14px; }
    .main-nav { order: 3; width: 100%; gap: 16px; }
    .header-refresh { margin-left: auto; }
    .page-title { font-size: 28px; }
    .company-header-top { flex-direction: column; }
    .company-header-actions { width: 100%; }
    .company-header-actions form,
    .company-header-actions .btn { flex: 1; }
    .company-header-actions form button { width: 100%; justify-content: center; }
    .company-header-actions a.btn { justify-content: center; }
    .stat-strip { flex-wrap: wrap; }
    .stat { flex: 1 1 50%; border-bottom: 1px solid var(--line); }
    .day-heading { flex-direction: column; align-items: flex-start; }
    .day-heading .btn { width: 100%; justify-content: center; }
    .company-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* Phones */
@media (max-width: 560px) {
    .wrap { padding: 0 14px; }
    .page-main { padding: 24px 14px 48px; }

    .header-inner { padding: 12px 14px; gap: 10px; }
    .brand-name { font-size: 18px; }
    .main-nav { gap: 14px; }
    .nav-link { font-size: 12.5px; }
    .header-refresh { width: 100%; order: 4; }
    .header-refresh .btn { width: 100%; justify-content: center; }

    .page-title { font-size: 23px; }
    .page-subtitle { font-size: 13px; }
    .eyebrow { font-size: 10.5px; }

    .stat-strip { flex-direction: column; border-radius: 6px; }
    .stat { flex: 1 1 100%; border-right: none; padding: 14px 16px; }
    .stat:not(:last-child) { border-bottom: 1px solid var(--line); }
    .stat-value { font-size: 22px; }

    .tag-row { gap: 6px; }
    .tag-pill { padding: 6px 11px; font-size: 11.5px; }

    .company-grid { grid-template-columns: 1fr; gap: 12px; }
    .company-card-body { padding: 14px 16px 16px; }
    .company-card-name { font-size: 16.5px; }

    .company-header { padding: 18px 16px; border-radius: 6px; }
    .company-header h1 { font-size: 22px; }
    .company-header-meta { font-size: 11.5px; }
    .company-header-actions { flex-direction: column; gap: 8px; }

    .day-group { border-radius: 6px; }
    .day-heading { padding: 12px 14px; }
    .day-heading h2 { font-size: 15px; }
    .day-heading-left { flex-wrap: wrap; row-gap: 4px; }

    .article-row { grid-template-columns: 3px 1fr; gap: 12px; padding: 14px 16px; }
    .article-title { font-size: 14.5px; }
    .article-meta { gap: 8px; font-size: 10.5px; }
    .article-summary { font-size: 13.5px; -webkit-line-clamp: 3; }

    .form-card { padding: 18px 16px; border-radius: 6px; }

    .empty-state { padding: 36px 18px; }

    .pagination { flex-wrap: wrap; }

    .footer-inner { flex-direction: column; gap: 4px; padding: 16px 14px; }

    .loading-overlay-box { padding: 22px 26px; margin: 0 20px; }
    .hero-title { font-size: 27px; }
    .hero-subtitle { font-size: 14.5px; }
    .hero-actions .btn { width: 100%; justify-content: center; }
}

/* Accessibility: visible focus ring, no motion by default */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
    /* Loading spinners are functional (they communicate "still working"),
       not decorative, so a full stop looks like the page is frozen/broken
       rather than just respecting a motion preference. Swap the spin for
       a gentle opacity pulse instead of no motion at all. */
    .spinner {
        animation: pixelnews-pulse 1.4s ease-in-out infinite !important;
    }
}

@keyframes pixelnews-pulse {
    0%, 100% { opacity: 0.25; }
    50% { opacity: 1; }
}