/* ─────────────────────────────────────────────
   BIA — Binswanger Intelligence Assistant
   Paleta: Navy #0d1f35 / Red #e8001d / Sora
   ───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy:        #0d1f35;
    --navy-mid:    #112540;
    --navy-light:  #1e3a5f;
    --navy-muted:  #2a4a72;
    --red:         #e8001d;
    --red-hover:   #c4001a;
    --white:       #ffffff;
    --surface:     #f0f4f8;
    --surface-2:   #e4eaf2;
    --border:      #d0dae8;
    --text-main:   #0d1f35;
    --text-muted:  #5a7089;
    --text-light:  #8fa3bb;
    --sev-critical-bg:   #fff0f0;
    --sev-critical-text: #991b1b;
    --sev-critical-bar:  #e8001d;
    --sev-high-bg:       #fff7ed;
    --sev-high-text:     #9a3412;
    --sev-high-bar:      #ea580c;
    --sev-medium-bg:     #fffbeb;
    --sev-medium-text:   #92400e;
    --sev-medium-bar:    #d97706;
    --sev-low-bg:        #f0f4f8;
    --sev-low-text:      #374151;
    --sev-low-bar:       #64748b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow:    0 2px 12px rgba(13,31,53,.08);
    --shadow-md: 0 4px 24px rgba(13,31,53,.12);
}

html { font-size: 16px; }

body {
    font-family: 'Sora', 'Segoe UI', Arial, sans-serif;
    background: var(--surface);
    color: var(--text-main);
    min-height: 100vh;
}

/* ── Layout ─────────────────────────────────── */
.app {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 20px 48px;
}

/* ── Header ─────────────────────────────────── */
.bia-header {
    background: var(--navy);
    width: 100vw;
    position: relative;
    left: 50%;
    margin-left: -50vw;
    margin-bottom: 32px;
}

.bia-header-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 28px;
}

.bia-logo { display: flex; align-items: center; gap: 14px; }

.bia-logo-mark {
    width: 36px; height: 36px;
    background: var(--red);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; color: #fff;
    letter-spacing: -.5px; flex-shrink: 0;
}

.bia-logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.bia-logo-text strong { color: #fff; font-size: .95rem; font-weight: 700; letter-spacing: .02em; }
.bia-logo-text span   { color: #7da4c5; font-size: .72rem; font-weight: 400; }

.bia-header-actions { display: flex; align-items: center; gap: 10px; }

.btn-header {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    font-size: .8rem; font-weight: 600; font-family: inherit;
    text-decoration: none; cursor: pointer; border: none;
    transition: background .15s, opacity .15s;
}

.btn-header-ghost {
    background: rgba(255,255,255,.08);
    color: #c9d8e8;
    border: 1px solid rgba(255,255,255,.12);
}
.btn-header-ghost:hover { background: rgba(255,255,255,.14); }
.btn-header-red         { background: var(--red); color: #fff; }
.btn-header-red:hover   { background: var(--red-hover); }

.header-clock { font-size: .75rem; color: #7da4c5; font-weight: 500; padding: 0 4px; }

/* ── Section title ──────────────────────────── */
.section-title {
    font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .1em;
    color: var(--text-light); margin-bottom: 12px;
}

/* ── Cards ──────────────────────────────────── */
.cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 18px 20px 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: relative; overflow: hidden;
    cursor: pointer;
    transition: box-shadow .15s, transform .15s;
}

.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.card.active-filter {
    border-color: var(--navy-light);
    box-shadow: 0 0 0 2px var(--navy-light), var(--shadow-md);
}

.card::before {
    content: ''; position: absolute;
    left: 0; top: 0; bottom: 0; width: 4px;
    border-radius: 4px 0 0 4px;
    background: var(--sev-low-bar);
}

.card.card-critical::before   { background: var(--sev-critical-bar); }
.card.card-high::before       { background: var(--sev-high-bar); }
.card.card-medium::before     { background: var(--sev-medium-bar); }
.card.card-governance::before { background: var(--navy-muted); }

.card-label {
    font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted); margin-bottom: 10px; padding-left: 8px;
}

.card-count {
    font-size: 2rem; font-weight: 800;
    color: var(--text-main); line-height: 1;
    padding-left: 8px; margin-bottom: 4px;
}

.card-amount {
    font-size: .8rem; font-weight: 600;
    color: var(--text-muted); padding-left: 8px; margin-bottom: 0;
}

.card-footer {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-top: 10px; min-height: 0; gap: 8px;
}

.card-footer:empty       { display: none; }
.card-footer .card-delta { margin-left: 0; }

.card-delta {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: .72rem; font-weight: 700;
    padding: 3px 8px; border-radius: 99px;
}

.card-delta.delta-up      { background: #fff0f0; color: #991b1b; }
.card-delta.delta-down    { background: #f0fdf4; color: #166534; }
.card-delta.delta-neutral { background: var(--surface-2); color: var(--text-muted); opacity: .45; font-size: .65rem; }

/* ── Sparkline ──────────────────────────────── */
.sparkline-wrap { flex-shrink: 0; line-height: 0; opacity: .85; transition: opacity .15s; }
.card:hover .sparkline-wrap { opacity: 1; }
.sparkline { display: block; width: 72px; height: 24px; overflow: visible; }
.sparkline-empty { width: 48px; height: 16px; background: var(--border); border-radius: 3px; opacity: .3; }

/* ── Filter bar ─────────────────────────────── */
.filter-bar {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 18px; margin-bottom: 20px;
    display: flex; align-items: center; gap: 16px;
    flex-wrap: wrap; box-shadow: var(--shadow);
}

.filter-group  { display: flex; align-items: center; gap: 8px; }
.filter-label  { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.filter-count  { font-size: .75rem; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

.filter-select, .filter-input {
    font-family: inherit; font-size: .82rem;
    color: var(--text-main); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 7px 10px; outline: none; transition: border-color .15s;
}

.filter-select { font-weight: 500; cursor: pointer; min-width: 140px; }
.filter-input  { width: 200px; }
.filter-select:focus, .filter-input:focus { border-color: var(--navy-light); }

.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
    padding: 5px 12px; border-radius: 99px;
    font-size: .75rem; font-weight: 700;
    border: 2px solid transparent;
    cursor: pointer; transition: all .12s; user-select: none;
}

.chip-all      { background: var(--navy);            color: #fff;                    border-color: var(--navy); }
.chip-critical { background: var(--sev-critical-bg); color: var(--sev-critical-text); border-color: var(--sev-critical-bg); }
.chip-high     { background: var(--sev-high-bg);     color: var(--sev-high-text);     border-color: var(--sev-high-bg); }
.chip-medium   { background: var(--sev-medium-bg);   color: var(--sev-medium-text);   border-color: var(--sev-medium-bg); }
.chip-low      { background: var(--sev-low-bg);      color: var(--sev-low-text);      border-color: var(--sev-low-bg); }

.chip.active.chip-critical { border-color: var(--sev-critical-text); }
.chip.active.chip-high     { border-color: var(--sev-high-text); }
.chip.active.chip-medium   { border-color: var(--sev-medium-text); }
.chip.active.chip-low      { border-color: var(--sev-low-text); }
.chip.active.chip-all      { border-color: var(--navy); }

.btn-clear-filter {
    font-family: inherit; font-size: .75rem; font-weight: 600;
    color: var(--red); background: none; border: none;
    cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm); display: none;
}
.btn-clear-filter:hover   { background: var(--surface-2); }
.btn-clear-filter.visible { display: inline-block; }

/* ── Panel / Table ──────────────────────────── */
.panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}

.panel-header h2 { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.panel-header p  { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 1100px;
}

thead th {
    text-align: left;
    font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted); background: var(--surface);
    padding: 10px 16px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky; top: 0; z-index: 10;
}

/*thead th:nth-child(1) { width: 88px;  }*/
/*thead th:nth-child(2) { width: 160px; }*/
/*thead th:nth-child(3) { width: 110px; }*/
/*thead th:nth-child(4) { width: 145px; }*/
/*thead th:nth-child(5) { width: 110px; }*/
/*thead th:nth-child(6) { width: 110px; }*/
/*thead th:nth-child(7) { width: 82px;  }*/
/*thead th:nth-child(8) { width: 68px;  }*/
/*thead th:nth-child(9) { width: auto;  }*/
thead th:nth-child(1) { width: 90px;  }  /* Prioridade */
thead th:nth-child(2) { width: 220px; }  /* Negócio */
thead th:nth-child(3) { width: 120px; }  /* Responsável */
thead th:nth-child(4) { width: 155px; }  /* Tipo */
thead th:nth-child(5) { width: 125px; }  /* Valor relevante */
thead th:nth-child(6) { width: 125px; }  /* Valor do negócio */
thead th:nth-child(7) { width: 90px;  }  /* Atualizado */
thead th:nth-child(8) { width: 72px;  }  /* Score */
thead th:nth-child(9) { width: auto;  }  /* Diagnóstico */

tbody tr { transition: background .1s; }
tbody tr:hover      { background: #f8fafd; }
tbody tr.row-hidden { display: none; }

td {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f4f8;
    vertical-align: middle;
    font-size: .83rem;
}

.td-deal a { color: var(--navy); font-weight: 700; text-decoration: none; font-size: .85rem; }
.td-deal a:hover { color: var(--red); text-decoration: underline; }

.td-deal .deal-meta { margin-top: 3px; font-size: .72rem; color: var(--text-muted); line-height: 1.5; }
.td-deal .deal-meta span + span::before { content: ' · '; opacity: .5; }

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 99px;
    font-size: .7rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap;
}

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.badge.critical        { background: var(--sev-critical-bg); color: var(--sev-critical-text); }
.badge.critical::before{ background: var(--sev-critical-bar); }
.badge.high            { background: var(--sev-high-bg);     color: var(--sev-high-text); }
.badge.high::before    { background: var(--sev-high-bar); }
.badge.medium          { background: var(--sev-medium-bg);   color: var(--sev-medium-text); }
.badge.medium::before  { background: var(--sev-medium-bar); }
.badge.low             { background: var(--sev-low-bg);      color: var(--sev-low-text); }
.badge.low::before     { background: #94a3b8; }

.alert-type-tag {
    display: inline-block; font-size: .72rem; font-weight: 600;
    color: var(--navy-light); background: #e8f0fb;
    padding: 3px 8px; border-radius: 4px;
}

.td-value strong { font-size: .88rem; font-weight: 700; color: var(--text-main); display: block; }
.td-value small  { font-size: .72rem; color: var(--text-muted); }

.score-bar-wrap { display: flex; align-items: center; gap: 6px; }
.score-bar-bg   { flex: 1; height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 40px; }
.score-bar-fill { height: 100%; border-radius: 99px; background: var(--navy-light); transition: width .3s; }
.score-number   { font-size: .72rem; font-weight: 700; color: var(--text-muted); width: 24px; text-align: right; }

.td-diag strong { font-size: .76rem; font-weight: 600; color: var(--text-main); display: block; margin-bottom: 3px; line-height: 1.4; }
.td-diag small  { font-size: .7rem; color: var(--text-muted); line-height: 1.45; display: block; }

/* ── Pagination ─────────────────────────────── */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface);
}

.pagination-info     { font-size: .78rem; color: var(--text-muted); }
.pagination-controls { display: flex; gap: 4px; }

.page-btn {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--white); font-size: .78rem; font-weight: 600;
    font-family: inherit; color: var(--text-main);
    cursor: pointer; transition: all .12s;
}

.page-btn:hover    { background: var(--surface-2); }
.page-btn.active   { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Empty state ────────────────────────────── */
.empty-state { text-align: center; padding: 64px 24px; color: var(--text-muted); }
.empty-state svg { opacity: .25; margin-bottom: 16px; }
.empty-state p   { font-size: .9rem; }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 1100px) { .cards { grid-template-columns: repeat(3, 1fr); } }

@media (max-width: 700px) {
    .app { padding: 0 12px 32px; }
    .bia-header { margin-bottom: 24px; }
    .cards { grid-template-columns: 1fr 1fr; }
    .filter-bar { flex-direction: column; align-items: flex-start; }
    .filter-input { width: 100%; }
}