/* ================================================================
   Monitoramento Public Equities — Unified Stylesheet
   Brand: DM Sans/Mono, Navy/Amber palette
   Merge: Monitor base + CASH3 dashboard components
   ================================================================ */

:root {
    /* --- Core palette (monitor naming) --- */
    --navy:       #1A2E52;
    --navy-light: #243B66;
    --navy-dark:  #2E4A7A;
    --blue:       #1F4E8C;
    --blue-light: #2A6ABF;
    --amber:      #C8922A;
    --amber-dim:  rgba(200,146,42,0.10);
    --amber-hover:rgba(200,146,42,0.18);
    --green:      #2D8C5A;
    --green-dim:  rgba(45,140,90,0.08);
    --red:        #C0392B;
    --red-dim:    rgba(192,57,43,0.08);

    /* --- Surfaces & backgrounds --- */
    --white:      #FFFFFF;
    --off-white:  #F7F8FA;
    --bg:         #EAECF2;
    --surface:    #FFFFFF;
    --surface-2:  #F2F4F8;

    /* --- Text --- */
    --text:       #2C3E50;
    --text-dim:   #5A6A7A;
    --text-muted: #8A96A6;
    --d-grey:     #3A4A5C;

    /* --- Borders --- */
    --border:       #D0D6E0;
    --border-light: #E0E4EC;
    --l-grey:       #E5E9F0;

    /* --- Aliases (CASH3 compat) --- */
    --navy-900: var(--navy);
    --navy-800: var(--navy-light);
    --navy-700: var(--navy-dark);
    --blue-600: var(--blue);
    --blue-500: var(--blue-light);
    --amber-500: var(--amber);
    --amber-400: #D4A843;
    --green-600: var(--green);
    --red-500:   var(--red);
    --gray-50:   var(--off-white);
    --gray-100:  var(--border-light);
    --gray-200:  var(--border);
    --gray-400:  var(--text-muted);
    --gray-600:  var(--d-grey);
    --gray-800:  var(--text);

    /* --- Typography --- */
    --font: 'DM Sans', sans-serif;
    --mono: 'DM Mono', monospace;

    /* --- Misc --- */
    --radius:    6px;
    --shadow-sm: 0 1px 3px rgba(26,46,82,0.06);
    --shadow-md: 0 4px 16px rgba(26,46,82,0.08);
    --shadow-lg: 0 8px 32px rgba(26,46,82,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ================================================================
   TOPBAR & NAVIGATION
   ================================================================ */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 54px;
    background: var(--navy);
    box-shadow: 0 2px 12px rgba(26,46,82,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 0; }

/* Title block with WIP badge */
.topbar-title-wrap {
    display: flex; align-items: center; gap: 10px;
    padding-right: 20px;
    margin-right: 4px;
    border-right: 1px solid rgba(255,255,255,0.15);
}
.logo {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    color: var(--amber);
    text-decoration: none;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.logo:hover { color: #fff; }
.wip-badge {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 600;
    color: #fff;
    background: rgba(200,146,42,0.35);
    border: 1px solid rgba(200,146,42,0.5);
    padding: 2px 7px;
    border-radius: 3px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Section tabs — main navigation (pages) */
.topbar-sections { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.section-tab {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    margin-bottom: -1px;
}
.section-tab:hover { color: rgba(255,255,255,0.8); border-bottom-color: rgba(255,255,255,0.2); }
.section-active {
    color: #fff !important;
    border-bottom-color: var(--amber) !important;
}

/* Sub-links — secondary nav (within a section), visually distinct from section tabs */
.topbar-right { display: flex; align-items: center; gap: 2px; }
.sub-link {
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 400;
    padding: 4px 10px;
    border-radius: 10px;
    transition: all 0.15s;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.sub-link:hover { color: #fff; background: rgba(255,255,255,0.08); }
.sub-active {
    color: #fff !important;
    background: rgba(255,255,255,0.12);
    font-weight: 500;
}

/* --- Ticker badge (CASH3 topbar legacy, used on company pages) --- */
.ticker-badge {
    font-family: var(--mono);
    font-size: 15px; font-weight: 500;
    color: var(--amber-400);
    background: rgba(200,146,42,0.12);
    padding: 4px 14px; border-radius: 4px;
}

/* ================================================================
   LAYOUT: Content containers
   ================================================================ */

.content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 40px;
}
.content-wide {
    max-width: 1600px;
}
/* CASH3 container alias */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 32px 48px;
}

/* ================================================================
   PAGE HEADERS
   ================================================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
}
.page-header .date {
    font-size: 13px; color: var(--text-muted);
    font-family: var(--mono);
}
.subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 3px;
}
.header-actions { display: flex; gap: 10px; align-items: center; }
.section-header { margin-bottom: 16px; }
.section-header h2 { font-size: 16px; font-weight: 700; color: var(--navy); }

/* ================================================================
   BUTTONS
   ================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn-primary {
    background: var(--navy); border-color: var(--navy); color: #fff;
    box-shadow: 0 2px 8px rgba(26,46,82,0.2);
}
.btn-primary:hover { background: var(--navy-light); border-color: var(--navy-light); color: #fff; }
.btn-accent {
    background: var(--amber); border-color: var(--amber); color: #fff;
    box-shadow: 0 2px 8px rgba(200,146,42,0.2);
}
.btn-accent:hover { background: #D9A23A; border-color: #D9A23A; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { border-color: var(--red); color: var(--red); background: var(--red-dim); box-shadow: none; }
.btn-danger:hover { background: rgba(192,57,43,0.15); }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ================================================================
   SUMMARY CARDS (Monitor dashboard)
   ================================================================ */

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}
.summary-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
}
.sc-value {
    font-family: var(--mono);
    font-size: 22px; font-weight: 700;
    color: var(--navy);
    display: block;
}
.sc-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    display: block;
}

/* ================================================================
   CARDS (CASH3 dashboard)
   ================================================================ */

.card {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}
.card-header h2 {
    font-size: 14px; font-weight: 600; color: var(--navy-light);
    text-transform: uppercase; letter-spacing: 0.5px;
}
.card-body { padding: 20px; }

/* ================================================================
   TABLES — Monitor (navy headers)
   ================================================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}
.data-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--navy);
    color: #fff;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-dim);
}
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* --- Light table variant (CASH3 style — gray headers) --- */
.data-table-light th {
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 11px;
    border-bottom: 1px solid var(--border-light);
}
.data-table-light {
    box-shadow: none;
    border: none;
}

.mono-cell { font-family: var(--mono); font-size: 12px; }
.ticker-cell { font-family: var(--mono); color: var(--navy); }

/* ================================================================
   VALUE COLORS
   ================================================================ */

.price-positive, .val-good { color: var(--green) !important; font-weight: 500; }
.price-negative, .val-bad  { color: var(--red)   !important; font-weight: 500; }
.val-neutral    { color: var(--text-dim); }
.val-highlight  { color: var(--navy) !important; font-weight: 600; }

/* ================================================================
   COLUMN GROUPS (Monitor tables)
   ================================================================ */

.col-group-start { border-left: 2px solid var(--border) !important; }
.data-table th.col-group-start { border-left: 2px solid rgba(255,255,255,0.15) !important; }
.data-table td.cg-alt { background: rgba(26,46,82,0.025); }

/* Header color groups */
.data-table th.hg-base   { background: var(--navy); }
.data-table th.hg-var    { background: #1E3A64; }
.data-table th.hg-target { background: #1A3358; }
.data-table th.hg-adtv   { background: #1E3A64; }
.data-table th.hg-rsi    { background: #1A3358; }
.data-table th.hg-size   { background: var(--navy); }
.data-table th.hg-rev    { background: #1E3A64; }
.data-table th.hg-margin { background: #1A3358; }
.data-table th.hg-lev    { background: #1E3A64; }
.data-table th.hg-mult   { background: #1A3358; }
.data-table th.hg-yield  { background: #1E3A64; }

/* ================================================================
   MONITOR TABLES — Wide layout
   ================================================================ */

.table-wide { max-width: 100%; overflow-x: auto; }
.table-wide .data-table {
    width: 100%;
    table-layout: auto;
    font-size: 12px;
}
.table-wide .data-table th,
.table-wide .data-table td {
    padding: 8px 10px;
    white-space: nowrap;
}

/* ================================================================
   STATUS PILLS
   ================================================================ */

.status-pill {
    font-family: var(--mono);
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.status-completed, .status-success { background: var(--green-dim); color: var(--green); }
.status-running { background: rgba(31,78,140,0.08); color: var(--blue); }
.status-failed  { background: var(--red-dim); color: var(--red); }
.status-pending { background: var(--surface-2); color: var(--text-muted); }
.status-partial { background: var(--amber-dim); color: var(--amber); }

/* ================================================================
   MONITOR SUB-TABS
   ================================================================ */

.monitor-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.monitor-tab {
    padding: 10px 22px;
    text-decoration: none;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    cursor: pointer;
}
.monitor-tab:hover { color: var(--navy); }
.monitor-tab.active {
    color: var(--navy);
    font-weight: 700;
    border-bottom-color: var(--amber);
}

/* --- Our-company highlight in sector tabs --- */
.data-table tbody tr.our-company { background: rgba(31,78,140,0.06); }
.data-table tbody tr.our-company td { font-weight: 600; color: var(--text); }
.data-table tbody tr.our-company:hover { background: rgba(31,78,140,0.10); }

/* ================================================================
   EARNINGS ROW COLORS
   ================================================================ */

.earnings-past td { color: var(--text-muted) !important; }
.earnings-upcoming { background: var(--amber-dim) !important; }
.earnings-upcoming td { color: var(--text) !important; }

/* ================================================================
   FILTER BAR
   ================================================================ */

.filter-bar { margin-bottom: 20px; }
.filter-form { display: flex; gap: 16px; align-items: flex-end; }
.filter-group label {
    display: block;
    font-size: 11px; font-weight: 600;
    color: var(--d-grey);
    margin-bottom: 4px;
}
.filter-group select {
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
.filter-group select:focus { outline: none; border-color: var(--blue); }

/* ================================================================
   COMPANY BLOCKS (Reports per-company sections)
   ================================================================ */

.company-block {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.cb-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 10px; padding-bottom: 8px;
    border-bottom: 2px solid var(--navy);
}
.cb-ticker {
    font-family: var(--mono);
    font-size: 16px; font-weight: 700;
    color: var(--navy);
}
.cb-name {
    font-size: 13px;
    color: var(--text-dim);
}
.cb-sector {
    font-family: var(--mono);
    font-size: 11px; color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px; border-radius: 3px;
}

/* ================================================================
   ALERTS
   ================================================================ */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid;
}
.alert-error { background: var(--red-dim); border-color: rgba(192,57,43,0.2); color: var(--red); }
.alert-info  { background: rgba(31,78,140,0.05); border-color: rgba(31,78,140,0.15); color: var(--text-dim); }

/* ================================================================
   EMPTY STATE
   ================================================================ */

.empty-state {
    text-align: center;
    padding: 56px;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 8px; font-size: 14px; }
.empty-state a { color: var(--blue); }

/* ================================================================
   STALE BANNER (CASH3 data freshness warning)
   ================================================================ */

.stale-banner {
    background: #FEF3CD;
    border-bottom: 2px solid #F0C040;
    color: #856404;
    padding: 10px 32px;
    font-size: 13px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
}
.stale-banner .icon { font-size: 16px; }

/* ================================================================
   CASH3 DASHBOARD — Selectors
   ================================================================ */

.selector-group {
    display: flex; gap: 4px;
}
.selector-group button {
    font-family: var(--mono);
    font-size: 12px; font-weight: 500;
    padding: 5px 12px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--d-grey);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.selector-group button:hover {
    border-color: var(--blue-light);
    color: var(--blue-light);
}
.selector-group button.active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

/* Checkbox toggles */
.checkbox-group { gap: 8px; }
.check-btn {
    display: flex; align-items: center; gap: 5px;
    font-family: var(--mono);
    font-size: 12px; font-weight: 500;
    color: var(--d-grey);
    cursor: pointer;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: all 0.15s;
    user-select: none;
}
.check-btn:hover { border-color: var(--blue-light); color: var(--blue-light); }
.check-btn input[type="checkbox"] {
    accent-color: var(--navy);
    width: 14px; height: 14px;
    cursor: pointer;
}

/* ================================================================
   CASH3 DASHBOARD — Layout grids
   ================================================================ */

.top-row {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 16px;
    margin-bottom: 16px;
}
.side-tables {
    display: flex; flex-direction: column; gap: 16px;
}
.bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.bottom-row-full {
    margin-bottom: 16px;
}

/* ================================================================
   CASH3 DASHBOARD — Chart
   ================================================================ */

.chart-wrap {
    position: relative;
    height: 320px;
}

/* ================================================================
   CASH3 DASHBOARD — Stats grid
   ================================================================ */

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.stat-box {
    background: var(--off-white);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: center;
}
.stat-box .label {
    font-size: 11px; font-weight: 500;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.stat-box .value {
    font-family: var(--mono);
    font-size: 20px; font-weight: 600;
    color: var(--navy);
}
.stat-box .value.positive { color: var(--green); }
.stat-box .value.negative { color: var(--red); }

/* ================================================================
   CASH3 DASHBOARD — EV Bridge
   ================================================================ */

.ev-bridge {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 4px 0;
}
.ev-item {
    text-align: center;
    flex: 1;
    padding: 8px 6px;
}
.ev-item .ev-label {
    font-size: 11px; color: var(--text-muted);
    font-weight: 500; text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}
.ev-item .ev-value {
    font-family: var(--mono);
    font-size: 16px; font-weight: 600;
}
.ev-item .ev-value.add { color: var(--navy); }
.ev-item .ev-value.sub { color: var(--red); }
.ev-arrow {
    font-size: 18px; color: var(--border);
    flex-shrink: 0;
}

/* ================================================================
   CASH3 DASHBOARD — Price display
   ================================================================ */

.price-display {
    display: flex; align-items: baseline; gap: 12px;
    margin-bottom: 16px;
}
.price-display .current {
    font-family: var(--mono);
    font-size: 28px; font-weight: 700;
    color: var(--navy);
}
.price-display .change {
    font-family: var(--mono);
    font-size: 14px; font-weight: 500;
}

/* ================================================================
   CASH3 DASHBOARD — Ownership bar
   ================================================================ */

.ownership-bar {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}
.ownership-bar div {
    transition: all 0.3s;
    cursor: pointer;
}
.ownership-bar div:hover { opacity: 0.85; }

/* ================================================================
   LANDING PAGE — Company cards
   ================================================================ */

.company-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.company-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.company-card:hover { box-shadow: var(--shadow-md); }
.company-card .cc-ticker {
    font-family: var(--mono);
    font-size: 18px; font-weight: 700;
    color: var(--navy);
}
.company-card .cc-name {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}
.company-card .cc-price {
    font-family: var(--mono);
    font-size: 20px; font-weight: 600;
    color: var(--navy);
    margin-top: 12px;
}
.company-card .cc-change {
    font-family: var(--mono);
    font-size: 13px; font-weight: 500;
    margin-left: 8px;
}
.company-card .cc-sector {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px; border-radius: 3px;
    margin-top: 12px;
    display: inline-block;
}
.company-card .cc-link {
    display: block;
    margin-top: 16px;
    font-size: 13px; font-weight: 600;
    color: var(--blue);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1100px) {
    .topbar { flex-wrap: wrap; height: auto; min-height: 54px; padding: 8px 16px; gap: 4px; }
    .topbar-left { flex-wrap: wrap; gap: 0; }
    .logo { font-size: 12px; padding-right: 16px; }
    .topbar-sections { margin-left: 4px; }
    .section-tab { font-size: 11px; padding: 4px 10px; }
}
@media (max-width: 900px) {
    .top-row { grid-template-columns: 1fr; }
    .bottom-row { grid-template-columns: 1fr; }
    .container { padding: 16px; }
    .content { padding: 16px; }
    .topbar-right { gap: 2px; }
    .nav-link { font-size: 11px; padding: 4px 6px; }
    .summary-cards { grid-template-columns: 1fr 1fr; }
    .filter-form { flex-wrap: wrap; }
}
