/* MFFAIS — Global Styles */

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1a1a1a;
    background: #fff;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #0b57d0;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Layout ── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

.main-content {
    flex: 1;
    padding: 32px 0 48px;
}

/* ── Header / Nav ── */
.site-header {
    background: #1a2332;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.site-header .logo {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1.5px;
    text-decoration: none;
}

.site-header .logo:hover {
    text-decoration: none;
    opacity: 0.9;
}

.site-nav {
    display: flex;
    gap: 24px;
    list-style: none;
}

.site-nav a {
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s;
}

.site-nav a:hover,
.site-nav a.active {
    color: #fff;
    text-decoration: none;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

/* ── Footer ── */
.site-footer {
    background: #f5f6f8;
    border-top: 1px solid #e0e0e0;
    padding: 32px 0 24px;
    font-size: 13px;
    color: #555;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.footer-left,
.footer-center,
.footer-right {
    flex: 1;
    min-width: 180px;
}

.footer-center {
    text-align: center;
}

.footer-center a {
    margin: 0 8px;
    color: #555;
    font-size: 13px;
}

.footer-center a:hover {
    color: #0b57d0;
}

.footer-right {
    text-align: right;
}

.footer-disclaimer {
    border-top: 1px solid #e0e0e0;
    padding-top: 16px;
    font-size: 12px;
    color: #777;
    line-height: 1.5;
}

.footer-meta {
    margin-top: 12px;
    font-size: 11px;
    color: #999;
}

/* ── Hero ── */
.hero {
    text-align: center;
    padding: 48px 0 32px;
}

.hero h1 {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: 3px;
    color: #1a2332;
    margin-bottom: 12px;
}

.hero .tagline {
    font-size: 18px;
    color: #555;
    font-style: italic;
    margin-bottom: 8px;
}

.hero .description {
    font-size: 15px;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
}

/* ── Stats Bar ── */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 48px;
    padding: 20px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    margin: 24px 0;
}

.stat {
    text-align: center;
}

.stat .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1a2332;
}

.stat .stat-label {
    font-size: 13px;
    color: #777;
    margin-top: 2px;
}

/* ── Cards ── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    background: #fafbfc;
}

.card h3 {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.card .metric-value {
    font-size: 28px;
    font-weight: 700;
    color: #1a2332;
    margin-bottom: 6px;
}

.card .metric-value.positive {
    color: #137333;
}

.card .metric-value.negative {
    color: #c5221f;
}

.card .metric-sub {
    font-size: 13px;
    color: #777;
}

/* ── Featured Rankings ── */
.featured-rankings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 32px 0;
}

.featured-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #1a2332;
}

/* ── Tables ── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 16px 0;
}

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

thead th {
    background: #f5f6f8;
    border-bottom: 2px solid #e0e0e0;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #444;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

thead th:hover {
    background: #ebedf0;
}

thead th.sorted-asc::after {
    content: " \25B2";
    font-size: 10px;
}

thead th.sorted-desc::after {
    content: " \25BC";
    font-size: 10px;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

tbody tr:hover {
    background: #f8f9fa;
}

td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Search / Filter ── */
.filter-bar {
    margin-bottom: 16px;
}

.filter-bar input {
    width: 100%;
    max-width: 360px;
    padding: 10px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.filter-bar input:focus {
    border-color: #0b57d0;
    box-shadow: 0 0 0 2px rgba(11,87,208,0.15);
}

/* ── Buttons ──
   Shared with admin/styles.css (parity: public + admin use the same
   class vocabulary). Values lifted verbatim from admin so the two
   surfaces render identically.
   Ported 2026-04-23 to resolve unstyled-button issue on the
   calculator page's Add-to-Calculator modal and the per-row "+ Add"
   buttons in the All XBRL Tags table — those callsites already used
   `btn btn-primary` / `btn btn-outline` / `btn btn-sm btn-outline`
   class names expecting this block to exist.
   Existing .calc-btn pattern stays around for backward compatibility;
   new buttons should prefer .btn + .btn-primary / .btn-outline. */
.btn {
    display: inline-block;
    padding: 7px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: #1a2332; color: #fff; }
.btn-primary:hover { background: #2a3a52; }
.btn-outline { background: #fff; border: 1px solid #d0d0d0; color: #444; }
.btn-outline:hover { background: #f5f6f8; border-color: #aaa; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: #c5221f; color: #fff; }
.btn-danger:hover { background: #a01b19; }
.btn-success { background: #137333; color: #fff; }
.btn-success:hover { background: #0f5c29; }

/* Accessibility: explicit focus ring for keyboard nav. Uses the same
   blue + offset pattern already used by .filter-bar input:focus so
   focus styling is consistent sitewide. */
.btn:focus-visible {
    outline: 2px solid #0b57d0;
    outline-offset: 2px;
}

/* ── Settings page (/settings/profile/) ── */
.settings-page {
    max-width: 560px;
    margin: 32px auto;
    padding: 0 16px;
}
.settings-page h1 { margin-bottom: 8px; }
.settings-section {
    margin: 24px 0;
    padding: 20px 22px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}
.settings-section + .settings-section { margin-top: 20px; }
.settings-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: #1a2332;
    margin-bottom: 8px;
}
.settings-hint {
    font-size: 13px;
    color: #666;
    margin-bottom: 14px;
    line-height: 1.5;
}
.settings-form-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: wrap;
}
.settings-form-row input {
    flex: 1 1 220px;
    padding: 9px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.settings-form-row input:focus {
    border-color: #0b57d0;
    box-shadow: 0 0 0 2px rgba(11,87,208,0.12);
}
.settings-field { margin-bottom: 12px; }
.settings-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-bottom: 5px;
}
.settings-field input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.settings-field input:focus {
    border-color: #0b57d0;
    box-shadow: 0 0 0 2px rgba(11,87,208,0.12);
}
.settings-msg {
    margin-top: 10px;
    font-size: 13px;
    min-height: 1em;
}
.settings-msg-ok { color: #137333; }
.settings-msg-err { color: #c5221f; }
.sr-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Comments (Notes + Questions + Line-level) ──
   Shared by the company-page social sections, the line-level modal,
   and the /users/{name}/ profile feed. `.note-*` class names kept
   from the pre-threading implementation for selector stability. */
.comment-section { margin: 24px 0; }
.comment-section.collapsed .comment-section-body { display: none; }
.comment-section.collapsed .comment-toggle-indicator { transform: rotate(-90deg); }
.comment-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.comment-section-title {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.comment-toggle-indicator {
    font-size: 10px;
    color: #888;
    transition: transform 0.12s;
    display: inline-block;
    width: 10px;
}
.comment-count { font-size: 13px; color: #888; font-weight: 400; }
.comment-sort-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
}
.comment-sort {
    padding: 5px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}
.comment-sort:focus-visible {
    outline: 2px solid #0b57d0;
    outline-offset: 2px;
}
.comment-list { color: #333; }
.comment-list:empty::before {
    content: 'Loading…';
    color: #999;
    font-size: 13px;
}
.comment-join-nudge {
    font-size: 13px;
    color: #777;
    margin-top: 8px;
}
.comment-form {
    margin-top: 12px;
}
.comment-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.comment-form textarea:focus {
    border-color: #0b57d0;
    box-shadow: 0 0 0 2px rgba(11,87,208,0.12);
}
.comment-form-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.comment-form-err {
    margin-top: 6px;
    font-size: 12px;
    color: #c5221f;
}
.comment-inline-label {
    font-size: 13px;
    color: #555;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.comment-reply-btn {
    background: none;
    border: none;
    color: #0b57d0;
    font-size: 12px;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 4px;
}
.comment-reply-btn:hover { text-decoration: underline; }
.comment-reply-form-wrap {
    margin-left: 28px;
    margin-bottom: 8px;
}

/* Notes / questions items (shared selectors) */
.note-item {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}
.note-item:last-child { border-bottom: none; }
.note-reply {
    margin-left: 28px;
    padding-left: 12px;
    border-left: 2px solid #e8eef7;
    background: #fafbfc;
}
.note-meta { font-size: 12px; color: #777; margin-bottom: 4px; }
.note-content {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    word-wrap: break-word;
}
.note-actions {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.note-votes { font-size: 13px; font-weight: 600; color: #555; }
.vote-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 12px;
    cursor: pointer;
    color: #777;
}
.vote-btn:hover { background: #f0f0f0; }

.user-link {
    color: #1a2332;
    text-decoration: none;
    font-weight: 600;
}
.user-link:hover { color: #0b57d0; text-decoration: underline; }

.badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    vertical-align: middle;
}
.pending-badge { background: #fef7e0; color: #665; }
.private-badge { background: #e8eef7; color: #1a56db; }

.my-private-block { margin-bottom: 14px; }
.my-private-title {
    font-size: 14px;
    color: #555;
    margin-bottom: 8px;
    font-weight: 600;
}

/* ── User profile feed (/users/{name}/) ── */
.user-profile-page { max-width: 720px; margin: 32px auto; padding: 0 16px; }
.user-profile-header h1 { margin-bottom: 4px; }
.user-profile-meta { color: #777; font-size: 13px; margin-bottom: 20px; }
.user-feed-item {
    padding: 14px 0;
    border-bottom: 1px solid #eee;
}
.user-feed-item:last-child { border-bottom: none; }
.user-feed-ctx {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}
.user-feed-ctx a { color: #1a56db; text-decoration: none; }
.user-feed-ctx a:hover { text-decoration: underline; }
.user-feed-body {
    font-size: 14px;
    line-height: 1.55;
    color: #333;
    margin-bottom: 4px;
    word-wrap: break-word;
}
.user-feed-meta {
    font-size: 12px;
    color: #888;
}

/* ── Calculator Controls ── */
.calc-check {
    margin-right: 4px;
    cursor: pointer;
}

.calc-sign {
    background: #e8eef7;
    border: 1px solid #c0cfe0;
    border-radius: 3px;
    width: 22px;
    height: 22px;
    font-size: 14px;
    font-weight: 700;
    color: #1a56db;
    cursor: pointer;
    padding: 0;
    line-height: 20px;
    text-align: center;
    margin-right: 4px;
}

.calc-sign:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ── Section Headers ── */
.section-header {
    font-size: 20px;
    font-weight: 700;
    color: #1a2332;
    margin: 32px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
}

/* ── Badge ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: #e8eef7;
    color: #1a56db;
}

/* ── Company Page Header ── */
.company-header {
    margin-bottom: 24px;
}

.company-header h1 {
    font-size: 36px;
    font-weight: 800;
    color: #1a2332;
    margin-bottom: 4px;
}

.company-header .company-name {
    font-size: 18px;
    color: #555;
    font-weight: 400;
}

/* ── Company Page Layout (sidebar for ads) ── */
.page-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 32px;
}

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

.page-sidebar {
    padding-top: 8px;
}

/* ── Ranking Category Grid ── */
.ranking-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.ranking-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    background: #fff;
    transition: box-shadow 0.15s;
}

.ranking-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-decoration: none;
}

.ranking-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a2332;
    margin-bottom: 6px;
}

.ranking-card p {
    font-size: 13px;
    color: #666;
}

/* ── A-Z Tabs ── */
.az-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 20px;
}

.az-tabs a {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #444;
    text-decoration: none;
}

.az-tabs a:hover,
.az-tabs a.active {
    background: #1a2332;
    color: #fff;
    border-color: #1a2332;
    text-decoration: none;
}

/* ── Methodology ── */
.formula-box {
    background: #f5f6f8;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 16px 20px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 15px;
    margin: 16px 0;
}

.xbrl-fields {
    margin: 16px 0;
}

.xbrl-fields dt {
    font-weight: 600;
    color: #444;
    margin-top: 8px;
}

.xbrl-fields dd {
    color: #666;
    font-family: monospace;
    font-size: 13px;
    margin-left: 16px;
}

.methodology-disclaimer {
    margin-top: 32px;
    padding: 16px 20px;
    background: #fef7e0;
    border: 1px solid #f0d98c;
    border-radius: 6px;
    font-size: 13px;
    color: #665;
    line-height: 1.6;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .page-layout {
        grid-template-columns: 1fr;
    }

    .page-sidebar {
        order: -1;
    }

    .featured-rankings {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .site-nav {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: #1a2332;
        flex-direction: column;
        padding: 16px 24px;
        gap: 12px;
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }

    .site-nav.open {
        display: flex;
    }

    .hamburger {
        display: block;
    }

    .hero h1 {
        font-size: 32px;
    }

    .stats-bar {
        gap: 24px;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .footer-left,
    .footer-center,
    .footer-right {
        text-align: center;
    }

    .company-header h1 {
        font-size: 28px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    table {
        font-size: 13px;
    }

    thead th, tbody td {
        padding: 8px 10px;
    }
}

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

    .hero h1 {
        font-size: 24px;
        letter-spacing: 2px;
    }

    .stats-bar {
        flex-direction: column;
        gap: 12px;
    }
}
