/* ================================================================
   TEARSHEET — Financial Editorial Design System
   Instrument Serif + DM Sans + JetBrains Mono
   Warm paper palette · forest green & copper accents
   ================================================================ */

:root {
    /* Surfaces */
    --paper:        #FDFCF9;
    --paper-warm:   #F6F3ED;

    /* Ink hierarchy — rich, not flat gray */
    --ink:          #0C0C0B;
    --ink-secondary:#2B2B26;
    --ink-muted:    #52524A;
    --ink-ghost:    #8A8A80;

    /* Rules */
    --rule:         #CCC9C0;
    --rule-light:   #E2DFD8;

    /* Accents */
    --accent:       #0F2B21;
    --accent-mid:   #1A5C43;
    --accent-light: #E2EDE8;
    --accent-warm:  #B8722D;

    /* Semantic */
    --up:           #0E7A3D;
    --down:         #C4271C;

    /* Type */
    --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --font-body:    'DM Sans', -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
}

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

::selection {
    background: var(--accent);
    color: var(--paper);
}


/* ================================================================
   INDEX PAGE
   ================================================================ */
.index-page {
    min-height: 100vh;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-body);
}

.index-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.index-grain {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px;
    pointer-events: none;
}

/* Decorative corner marks — editorial registration marks */
.corner-mark {
    position: absolute;
    width: 24px;
    height: 24px;
    opacity: 0.12;
    z-index: 1;
}
.corner-mark::before,
.corner-mark::after {
    content: '';
    position: absolute;
    background: var(--paper);
}
.corner-mark::before { width: 1px; height: 100%; left: 0; }
.corner-mark::after  { width: 100%; height: 1px; top: 0; }

.corner-tl { top: 32px; left: 32px; }
.corner-tr { top: 32px; right: 32px; transform: scaleX(-1); }
.corner-bl { bottom: 32px; left: 32px; transform: scaleY(-1); }
.corner-br { bottom: 32px; right: 32px; transform: scale(-1); }

.index-content {
    text-align: center;
    padding: 48px 24px;
    position: relative;
    z-index: 2;
    max-width: 540px;
    width: 100%;
}

/* Staggered fade-in animation */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.index-dateline,
.index-masthead,
.masthead-double-rule,
.masthead-quote,
.masthead-thin-rule,
.search-form,
.index-footer-hints,
.index-colophon {
    animation: fadeUp 0.7s ease-out both;
}

.index-dateline       { animation-delay: 0s; }
.index-masthead       { animation-delay: 0.08s; }
.masthead-double-rule { animation-delay: 0.14s; }
.masthead-quote       { animation-delay: 0.22s; }
.masthead-thin-rule   { animation-delay: 0.28s; animation-name: fadeIn; }
.search-form          { animation-delay: 0.34s; }
.index-footer-hints   { animation-delay: 0.44s; }
.index-colophon       { animation-delay: 0.52s; animation-name: fadeIn; }

/* --- Dateline --- */
.index-dateline {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--ink-ghost);
    margin-bottom: 20px;
}

/* --- Masthead --- */
.index-masthead {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    margin-bottom: 0;
}

.masthead-rule {
    display: block;
    flex: 1;
    max-width: 80px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
}

.masthead-title {
    font-family: var(--font-display);
    font-size: 56px;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--paper);
    white-space: nowrap;
}

/* --- Double rule (newspaper masthead style) --- */
.masthead-double-rule {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 14px auto 22px;
    width: 100%;
    max-width: 420px;
}

.masthead-double-rule span {
    display: block;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.18) 15%, rgba(255,255,255,0.18) 85%, transparent 100%);
}

.masthead-double-rule span:first-child {
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.22) 15%, rgba(255,255,255,0.22) 85%, transparent 100%);
}

/* --- Quote --- */
.masthead-quote {
    margin: 0 auto 28px;
    max-width: 400px;
}

.masthead-quote p {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 17px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: -0.01em;
}

.masthead-quote cite {
    display: block;
    margin-top: 8px;
    font-family: var(--font-body);
    font-style: normal;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--accent-warm);
    opacity: 0.8;
}

/* --- Thin rule --- */
.masthead-thin-rule {
    width: 40px;
    height: 1px;
    background: rgba(255,255,255,0.12);
    margin: 0 auto 32px;
}

/* --- Search --- */
.search-form {
    max-width: 340px;
    margin: 0 auto;
}

.search-input-wrap { text-align: left; }

.search-label {
    display: block;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 8px;
}

.search-row {
    display: flex;
    gap: 0;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.search-row:focus-within {
    border-color: rgba(255,255,255,0.35);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}

.search-row input {
    flex: 1;
    padding: 14px 18px;
    background: rgba(255,255,255,0.05);
    border: none;
    color: var(--paper);
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 4px;
    text-transform: uppercase;
    outline: none;
}

.search-row input::placeholder {
    color: rgba(255,255,255,0.18);
    letter-spacing: 4px;
}

.search-row button {
    padding: 14px 20px;
    background: rgba(255,255,255,0.07);
    border: none;
    border-left: 1px solid rgba(255,255,255,0.1);
    color: var(--paper);
    cursor: pointer;
    transition: background 0.25s, color 0.25s;
    display: flex;
    align-items: center;
}

.search-row button:hover {
    background: var(--accent-mid);
    color: #fff;
}

/* --- Error --- */
.error {
    margin-top: 20px;
    color: #ef4444;
    font-size: 13px;
    font-weight: 500;
}

/* --- Footer hints --- */
.index-footer-hints {
    margin-top: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    font-size: 10px;
    font-weight: 400;
    color: var(--ink-ghost);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--ink-ghost);
    opacity: 0.4;
}

/* --- Colophon (bottom flourish) --- */
.index-colophon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 36px;
}

.colophon-rule {
    width: 32px;
    height: 1px;
    background: rgba(255,255,255,0.08);
}

.colophon-mark {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 4px;
    color: var(--ink-ghost);
    opacity: 0.35;
}


/* ================================================================
   TOOLBAR
   ================================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    height: 46px;
    background: var(--ink);
    position: sticky;
    top: 0;
    z-index: 100;
    font-family: var(--font-body);
}

.toolbar-brand {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--paper);
    text-decoration: none;
    margin-right: auto;
    letter-spacing: -0.01em;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.toolbar-brand:hover { opacity: 1; }

.toolbar-search {
    display: flex;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px;
    overflow: hidden;
}

.toolbar-search input {
    padding: 5px 10px;
    background: transparent;
    border: none;
    color: var(--paper);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    width: 100px;
    outline: none;
}

.toolbar-search input::placeholder {
    color: rgba(255,255,255,0.25);
}

.toolbar-search button {
    padding: 5px 8px;
    background: transparent;
    border: none;
    border-left: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.toolbar-search button:hover { color: var(--paper); }

.btn-export {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: rgba(255,255,255,0.7);
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-export:hover {
    background: rgba(255,255,255,0.14);
    color: var(--paper);
}


/* ================================================================
   REPORT SHELL
   ================================================================ */
.report-page {
    background: var(--paper-warm);
    min-height: 100vh;
    font-family: var(--font-body);
}

.report {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--paper);
    padding: 28px 36px 22px;
    min-height: calc(100vh - 46px);
    box-shadow: 0 0 0 1px var(--rule-light);
}


/* ================================================================
   HEADER
   ================================================================ */
.report-header {
    margin-bottom: 14px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.company-name {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 400;
    color: var(--ink);
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 7px;
}

.ticker-badge {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--accent);
    background: var(--accent-light);
    padding: 3px 10px;
    border-radius: 3px;
}

.meta-sep {
    width: 1px;
    height: 12px;
    background: var(--rule);
}

.meta-text {
    font-size: 11.5px;
    color: var(--ink-muted);
    font-weight: 400;
}

.header-price {
    text-align: right;
    flex-shrink: 0;
}

.price-currency {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--ink-muted);
    vertical-align: super;
    margin-right: 1px;
}

.price-value {
    font-family: var(--font-mono);
    font-size: 30px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.5px;
}

.price-delta {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
}

.price-delta.up   { color: var(--up); }
.price-delta.down { color: var(--down); }

.header-rule {
    height: 3px;
    background: var(--accent);
    margin-top: 12px;
    position: relative;
}

.header-rule::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--accent);
    opacity: 0.15;
}


/* ================================================================
   TOP SECTION — Info Panel (left) + Chart Panel (right)
   ================================================================ */
.top-section {
    display: grid;
    grid-template-columns: 330px 1fr;
    gap: 28px;
    margin: 16px 0 22px;
    align-items: stretch;
}

/* --- Info Panel --- */
.info-panel {
    background: var(--paper-warm);
    border: 1px solid var(--rule-light);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
}

.info-section-label {
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    margin-bottom: 8px;
}

.info-grid {
    display: flex;
    flex-direction: column;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dotted var(--rule-light);
}

.info-row:last-child { border-bottom: none; }

.info-k {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-muted);
}

.info-v {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
}

.info-sep {
    height: 1px;
    background: var(--rule);
    margin: 14px 0;
}

.info-desc {
    font-size: 11.5px;
    line-height: 1.65;
    color: var(--ink-secondary);
    overflow-y: auto;
    max-height: 220px;
    scrollbar-width: thin;
    scrollbar-color: var(--rule) transparent;
}

.info-desc::-webkit-scrollbar { width: 4px; }
.info-desc::-webkit-scrollbar-thumb {
    background: var(--rule);
    border-radius: 2px;
}

/* --- Chart Panel --- */
.chart-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chart-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
}

.toggle-group {
    display: flex;
    gap: 2px;
    background: var(--rule-light);
    border-radius: 6px;
    padding: 3px;
}

.toggle-btn {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    padding: 5px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--ink-ghost);
    white-space: nowrap;
}

.toggle-btn:hover {
    color: var(--ink-muted);
}

.toggle-btn--type.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 4px rgba(15, 43, 33, 0.3);
}

.toggle-btn--period.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-container {
    flex: 1;
    min-height: 260px;
    position: relative;
}

/* --- Z-score badges --- */
.z-badge {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    justify-content: flex-end;
}

.z-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.z-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--ink-ghost);
    letter-spacing: 0.3px;
}

.z-val {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 3px;
}

.z-val.z-mid {
    background: var(--accent-light);
    color: var(--accent);
}

.z-val.z-high {
    background: #FEE2E2;
    color: var(--down);
}

.z-val.z-low {
    background: #DCFCE7;
    color: var(--up);
}


/* ================================================================
   DATA TABLES
   ================================================================ */
.section-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 3px;
}

.section-header h2 {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 400;
    color: var(--accent);
    letter-spacing: -0.01em;
}

.table-unit {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 400;
    color: #8A8A80;
}

.tables-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.table-block { min-width: 0; }

.table-scroll {
    overflow-x: auto;
    scrollbar-width: none;
}

.table-scroll::-webkit-scrollbar { display: none; }

table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    table-layout: fixed;
}

thead th {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    color: var(--ink-muted);
    text-align: right;
    padding: 5px 5px 5px 3px;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
    letter-spacing: 0.5px;
    vertical-align: bottom;
}

thead th.th-label {
    text-align: left;
    width: 140px;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--ink);
    font-size: 10px;
    letter-spacing: -0.01em;
    vertical-align: bottom;
}

.th-year {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--ink-secondary);
    letter-spacing: 0.5px;
}

.th-date {
    display: block;
    font-family: var(--font-body);
    font-size: 7.5px;
    font-weight: 400;
    color: var(--ink-ghost);
    letter-spacing: 0;
    font-style: italic;
    margin-top: 1px;
}

.th-fy-sub {
    display: block;
    font-size: 7.5px;
    font-weight: 400;
    color: var(--ink-ghost);
    font-style: italic;
    letter-spacing: 0;
    margin-top: 1px;
}

tbody td {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    color: var(--ink-secondary);
    text-align: right;
    padding: 3.5px 5px 3.5px 3px;
    border-bottom: 1px solid var(--rule-light);
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td {
    background: var(--accent-light);
}

td.row-label {
    font-family: var(--font-body);
    font-size: 10.5px;
    font-weight: 500;
    color: var(--ink);
    text-align: left;
    letter-spacing: -0.01em;
}

.sub-val {
    font-style: italic;
    font-size: 9px;
    font-weight: 400;
    color: var(--ink-ghost);
}

/* Sub-rows (% y/y, % margin, bps y/y, CAGR) */
tr.sub-row td {
    font-size: 9px;
    font-weight: 400;
    color: var(--ink-ghost);
    font-style: italic;
    border-bottom: none;
    padding-top: 0;
    padding-bottom: 1px;
}

tr.sub-row td.row-label {
    font-size: 9px;
    font-weight: 400;
    color: var(--ink-ghost);
    font-style: italic;
    padding-left: 12px;
}

tr.sub-row:hover td {
    background: transparent;
}

/* Bold main rows (Revenue, Gross Profit, EBITDA, etc.) */
tr.bold-row td {
    font-weight: 600;
    color: var(--ink);
}

tr.bold-row td.row-label {
    font-weight: 600;
}

/* Section separator rows — line above, no line below */
tr.sep-row td {
    border-top: 1px solid var(--rule);
    border-bottom: none;
}

/* Remove bottom border from rows immediately before a sub-row */
tr:has(+ tr.sub-row) td {
    border-bottom: none;
}


/* ================================================================
   FOOTER
   ================================================================ */
.report-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 8px;
    border-top: 1px solid var(--rule);
    font-size: 9px;
    color: var(--ink-ghost);
    font-weight: 400;
    letter-spacing: 0.3px;
}


/* ================================================================
   PRINT
   ================================================================ */
@media print {
    .no-print { display: none !important; }

    body, .report-page { background: #fff !important; }

    .report {
        max-width: 100%;
        margin: 0;
        padding: 16px 20px 12px;
        box-shadow: none;
        min-height: auto;
    }

    .company-name { font-size: 24px; }
    .price-value  { font-size: 22px; }

    .top-section {
        grid-template-columns: 240px 1fr;
        gap: 14px;
    }

    .chart-container { min-height: 160px; }
    .info-desc { max-height: 140px; }

    .tables-grid { gap: 12px 18px; }

    table { font-size: 8.5px; }
    thead th { font-size: 7.5px; padding: 2px 3px; }
    .th-year { font-size: 8px; }
    .th-date { font-size: 6.5px; }
    .th-fy-sub { font-size: 6.5px; }
    tbody td { font-size: 8.5px; padding: 2px 3px; }
    td.row-label { font-size: 8.5px; }

    .section-header h2 { font-size: 11px; }
    .section-header { padding-bottom: 2px; margin-bottom: 3px; }

    .info-panel { padding: 10px 12px; }
    .info-section-label { font-size: 8px; }
    .info-k, .info-v { font-size: 9px; }
    .info-desc { font-size: 9px; }

    .chart-controls { margin-bottom: 4px; }
    .toggle-btn { font-size: 8px; padding: 2px 8px; }

    .report-footer { margin-top: 10px; }

    @page {
        size: landscape;
        margin: 0.25in;
    }
}
