/* ═══════════════════════════════════════════════════════════════
   VaporCRM · Design System — "Lightning em azul Vapor"

   Estrutura de CRM profissional ao estilo Salesforce Lightning:
   barra global branca (marca, pesquisa, utilizador), barra de separadores
   por módulo, faixa da marca por trás de um cartão de cabeçalho com o
   mosaico colorido do módulo, painel de números com divisórias e
   listas densas. O traço próprio: a faixa azul leva linhas de vapor.

   Azul #2D66BD (principal) · #2E67BE (secundário) · Branco (terciário)
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* ── Marca ─────────────────────────────────────────────────── */
    --blue-900: #142F5A;
    --blue-800: #1B3F77;
    --blue-700: #24539B;
    --blue-600: #2D66BD;   /* principal   */
    --blue-500: #2E67BE;   /* secundário  */
    --blue-400: #4A80D0;
    --blue-300: #8FB0E4;
    --blue-200: #C9D8F1;
    --blue-100: #E8EFFA;
    --blue-50:  #F3F6FC;
    --white:    #FFFFFF;

    --accent:        var(--blue-600);
    --accent-2:      var(--blue-500);
    --accent-dark:   var(--blue-700);
    --accent-hover:  var(--blue-700);
    --accent-light:  var(--blue-400);
    --accent-dim:    var(--blue-100);
    --accent-glow:   rgba(45, 102, 189, 0.30);
    --blue:          var(--blue-500);
    --blue-dim:      var(--blue-100);
    --blue-glow:     var(--blue-200);

    /* ── Cores dos módulos (mosaicos) ──────────────────────────── */
    --obj-inicio:        #2D66BD;
    --obj-clientes:      #5867E8;
    --obj-produtos:      #8E5FD0;
    --obj-vendas:        #E07A2E;
    --obj-stock:         #0E8C8C;
    --obj-inventario:    #C58A12;
    --obj-colaboradores: #2E8B57;
    --obj-analise:       #D24D78;

    /* ── Superfícies ───────────────────────────────────────────── */
    --bg-base:       #F0F2F6;
    --bg-surface:    var(--white);
    --bg-card:       var(--white);
    --bg-elevated:   #F6F7FA;
    --bg-hover:      #F3F6FC;

    /* ── Linhas ────────────────────────────────────────────────── */
    --border:        #E3E7EE;
    --border-strong: #CDD4DF;
    --border-accent: var(--blue-200);

    /* ── Texto ─────────────────────────────────────────────────── */
    --text-primary:   #1A2233;
    --text-secondary: #3F4859;
    --text-muted:     #677185;
    --text-dim:       #9AA3B2;

    /* ── Semântica ─────────────────────────────────────────────── */
    --success:        #2E7D46;
    --success-dim:    #E6F4EA;
    --success-border: #B9DEC4;
    --warning:        #9A5B00;
    --warning-dim:    #FDF2DC;
    --warning-border: #F1D39C;
    --danger:         #C23934;
    --danger-dim:     #FCE9E8;
    --danger-border:  #F2C2BF;
    --info:           #5867E8;
    --info-dim:       #ECEEFD;

    /* ── Tipografia ────────────────────────────────────────────── */
    --font:         'Source Sans 3', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-display: var(--font);
    --font-body:    var(--font);

    --fs-xs:   0.75rem;    /* 12 */
    --fs-sm:   0.8125rem;  /* 13 */
    --fs-base: 0.875rem;   /* 14 */
    --fs-md:   1rem;       /* 16 */
    --fs-lg:   1.125rem;   /* 18 */
    --fs-xl:   1.375rem;   /* 22 */
    --fs-num:  1.5rem;     /* 24 */

    /* ── Compat ────────────────────────────────────────────────── */
    --navy:        var(--text-primary);
    --navy-dark:   var(--blue-900);
    --navy-light:  var(--blue-700);
    --gold:        var(--warning);

    /* ── Geometria: controlos 4px, cartões 8px, modais 10px ────── */
    --radius-sm: 4px;
    --radius:    4px;
    --radius-lg: 8px;
    --radius-xl: 10px;

    /* ── Sombras ───────────────────────────────────────────────── */
    --shadow-sm:     0 1px 2px rgba(26, 34, 51, 0.06), 0 2px 6px -2px rgba(26, 34, 51, 0.08);
    --shadow:        0 2px 4px rgba(26, 34, 51, 0.06), 0 8px 20px -8px rgba(26, 34, 51, 0.14);
    --shadow-card:   var(--shadow-sm);
    --shadow-lg:     0 24px 60px -16px rgba(20, 47, 90, 0.40), 0 4px 12px rgba(26, 34, 51, 0.08);
    --shadow-accent: none;

    --focus-ring: 0 0 0 3px rgba(46, 103, 190, 0.25);

    /* ── Faixa da marca com linhas de vapor ────────────────────── */
    --band-h: 8.5rem;
    --band: linear-gradient(115deg, var(--blue-700) 0%, var(--blue-600) 45%, #3772C9 100%);
    --vapor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='136'%3E%3Cg fill='none' stroke='%23fff' stroke-width='1.2'%3E%3Cpath stroke-opacity='.16' d='M0 26c20-10 40-10 60 0s40 10 60 0 40-10 60 0 40 10 60 0'/%3E%3Cpath stroke-opacity='.10' d='M0 66c20-10 40-10 60 0s40 10 60 0 40-10 60 0 40 10 60 0'/%3E%3Cpath stroke-opacity='.05' d='M0 106c20-10 40-10 60 0s40 10 60 0 40-10 60 0 40 10 60 0'/%3E%3C/g%3E%3C/svg%3E");
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--font); font-weight: 700; color: var(--text-primary); }
strong, b { font-weight: 700; }
::selection { background: var(--blue-200); color: var(--blue-900); }

:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-dim); }

a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-700); text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════
   SHELL
   ═══════════════════════════════════════════════════════════════ */

.app {
    display: grid;
    grid-template-rows: auto auto 1fr;
    height: 100vh;
    overflow: hidden;
}
.app-main {
    overflow-y: auto;
    min-width: 0;
    background:
        var(--vapor) repeat-x left top / 240px var(--band-h),
        var(--band) no-repeat left top / 100% var(--band-h),
        var(--bg-base);
    background-attachment: local, local, local;
}

/* ── Barra global ──────────────────────────────────────────────── */
.gh {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 58px;
    padding: 0 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 30;
}
.gh-brand { display: inline-flex; align-items: center; flex: 0 0 auto; border-radius: var(--radius); }
.gh-brand:hover { text-decoration: none; }
.gh-logo { display: block; height: 44px; width: auto; }

.gh-search {
    position: relative;
    flex: 1 1 auto;
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    align-items: center;
}
.gh-search svg { position: absolute; left: .75rem; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.gh-search input {
    width: 100%;
    height: 34px;
    padding: 0 .9rem 0 2.25rem;
    font-family: var(--font);
    font-size: var(--fs-base);
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.gh-search input::placeholder { color: var(--text-muted); }
.gh-search input:focus { background: var(--white); border-color: var(--blue-500); box-shadow: var(--focus-ring); }

.gh-user { position: relative; flex: 0 0 auto; }
.gh-user__btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    height: 36px;
    padding: 0 .4rem 0 .25rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    font-family: var(--font);
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-primary);
}
.gh-user__btn:hover, .gh-user__btn[aria-expanded="true"] { background: var(--bg-elevated); border-color: var(--border); }
.gh-user__chev { width: 14px; height: 14px; color: var(--text-muted); }
.gh-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--blue-100);
    color: var(--blue-700);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: .02em;
    flex: 0 0 auto;
}
.gh-avatar--lg { width: 40px; height: 40px; font-size: var(--fs-sm); }

.menu-scrim { position: fixed; inset: 0; z-index: 40; }
.gh-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 41;
    width: 260px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: .4rem;
    animation: crm-drop .14s ease-out;
}
.gh-menu__who { display: flex; align-items: center; gap: .7rem; padding: .7rem .7rem .8rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.gh-menu__who strong { display: block; font-size: var(--fs-base); }
.gh-menu__who span { font-size: var(--fs-sm); color: var(--text-muted); }
.gh-menu__item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .7rem;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    font-family: var(--font);
    font-size: var(--fs-base);
    color: var(--text-primary);
    text-align: left;
}
.gh-menu__item svg { width: 16px; height: 16px; color: var(--text-muted); }
.gh-menu__item:hover { background: var(--bg-hover); }

/* ── Barra de separadores ──────────────────────────────────────── */
.tabs {
    display: flex;
    align-items: stretch;
    height: 42px;
    padding: 0 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--border-strong);
    box-shadow: 0 2px 3px -2px rgba(26, 34, 51, .12);
    position: relative;
    z-index: 20;
}
.tabs__app {
    display: flex;
    align-items: center;
    padding-right: 1.1rem;
    margin-right: .35rem;
    border-right: 1px solid var(--border);
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}
.tabs__list {
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    scrollbar-width: none;
    min-width: 0;
}
.tabs__list::-webkit-scrollbar { display: none; }
.tab {
    display: flex;
    align-items: center;
    padding: 0 .85rem;
    font-size: var(--fs-base);
    font-weight: 400;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    border-top: 3px solid transparent;
    transition: color .12s, border-color .12s, background-color .12s;
}
.tab:hover { color: var(--text-primary); background: var(--bg-elevated); border-bottom-color: var(--border-strong); text-decoration: none; }
.tab.active { color: var(--text-primary); font-weight: 600; border-bottom-color: var(--blue-600); }
.tab:focus-visible { outline-offset: -2px; }

/* ═══════════════════════════════════════════════════════════════
   PÁGINA
   ═══════════════════════════════════════════════════════════════ */

.page-wrap, .prod-page {
    --page-x: 1rem;
    font-family: var(--font);
    color: var(--text-primary);
    padding: 1rem var(--page-x) 2.5rem;
    display: flex;
    flex-direction: column;
    gap: .875rem;
}

/* ── Cabeçalho de página (cartão sobre a faixa) ────────────────── */
.ph {
    display: flex;
    align-items: center;
    gap: .875rem;
    flex-wrap: wrap;
    padding: 1rem 1.125rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.ph__id { min-width: 0; flex: 1 1 auto; }
.ph__module { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.2; }
.ph__title {
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.2;
    margin-top: .1rem;
    color: var(--text-primary);
}
.ph__actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.obj-tile {
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    color: var(--white);
    background: var(--obj-inicio);
}
.obj-tile svg { width: 22px; height: 22px; }
.obj-tile--inicio        { background: var(--obj-inicio); }
.obj-tile--clientes      { background: var(--obj-clientes); }
.obj-tile--produtos      { background: var(--obj-produtos); }
.obj-tile--vendas        { background: var(--obj-vendas); }
.obj-tile--stock         { background: var(--obj-stock); }
.obj-tile--inventario    { background: var(--obj-inventario); }
.obj-tile--colaboradores { background: var(--obj-colaboradores); }
.obj-tile--analise       { background: var(--obj-analise); }

/* Compat: cabeçalhos antigos que ainda não usam <PageHeader> */
.page-hdr, .prod-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.125rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.page-title, .prod-title { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.page-sub, .prod-subtitle { margin-top: .2rem; color: var(--text-muted); font-size: var(--fs-base); }
.page-eyebrow, .prod-eyebrow { display: none; }
.page-heading { font-size: var(--fs-xl); font-weight: 700; color: var(--text-primary); }

/* ── Botões ────────────────────────────────────────────────────── */
.btn-grad, .btn-primary-grad, .btn-ui-ghost, .btn-ghost, .btn-ui-danger, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    cursor: pointer;
    height: 34px;
    padding: 0 1rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: var(--fs-base);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background-color .12s, border-color .12s, color .12s;
}
.btn-grad svg, .btn-primary-grad svg, .btn-ui-ghost svg, .btn-ghost svg { width: 14px; height: 14px; }
.btn-grad, .btn-primary-grad { color: var(--white); background: var(--blue-600); border-color: var(--blue-600); }
.btn-grad:hover, .btn-primary-grad:hover { color: var(--white); background: var(--blue-700); border-color: var(--blue-700); text-decoration: none; }
.btn-grad:disabled, .btn-primary-grad:disabled { opacity: .5; cursor: not-allowed; }

.btn-ui-ghost, .btn-ghost { background: var(--white); border-color: var(--border-strong); color: var(--blue-600); }
.btn-ui-ghost:hover, .btn-ghost:hover { background: var(--bg-elevated); color: var(--blue-700); }

.btn-ui-danger, .btn-danger { color: var(--white); background: var(--danger); border-color: var(--danger); }
.btn-ui-danger:hover, .btn-danger:hover { background: #A52E2A; border-color: #A52E2A; color: var(--white); }

.btn-ui-info {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    cursor: pointer;
    height: 28px;
    padding: 0 .7rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--blue-600);
    background: var(--white);
    border: 1px solid var(--border-strong);
}
.btn-ui-info:hover { background: var(--bg-elevated); }

/* Bootstrap (formulários antigos) */
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: var(--white); font-family: var(--font); font-weight: 600; border-radius: var(--radius); }
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-secondary, .btn-outline-secondary { border-color: var(--border-strong); color: var(--blue-600); background: var(--white); font-family: var(--font); border-radius: var(--radius); }
.btn-secondary:hover, .btn-outline-secondary:hover { background: var(--bg-elevated); color: var(--blue-700); }
.form-control, .form-select { border: 1px solid var(--border-strong); border-radius: var(--radius); font-family: var(--font); }
.form-control:focus, .form-select:focus { border-color: var(--blue-500); box-shadow: var(--focus-ring); }
.form-label { font-weight: 600; font-size: var(--fs-sm); color: var(--text-secondary); margin-bottom: 4px; }
.text-muted { color: var(--text-muted) !important; }
.badge { font-family: var(--font); font-weight: 600; border-radius: 999px; font-size: var(--fs-xs); padding: 3px 9px; }
.bg-success { background: var(--success-dim) !important; color: var(--success) !important; }
.bg-danger  { background: var(--danger-dim)  !important; color: var(--danger)  !important; }
.bg-warning { background: var(--warning-dim) !important; color: var(--warning) !important; }
.bg-primary { background: var(--accent-dim)  !important; color: var(--accent-dark) !important; }

.blazor-error-boundary { background: var(--danger-dim); border: 1px solid var(--danger-border); padding: 1rem 1.25rem; color: var(--danger); border-radius: var(--radius-lg); }
.blazor-error-boundary::after { content: "Ocorreu um erro inesperado. Recarrega a página para continuar."; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); border-radius: var(--radius-sm); }
.invalid { outline: 1px solid var(--danger); border-radius: var(--radius-sm); }
.validation-message { color: var(--danger); font-size: var(--fs-xs); margin-top: 4px; }

/* ── Painel de números (um cartão, células com divisórias) ─────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .9rem 1.125rem;
    min-width: 0;
    border-left: 1px solid var(--border);
    color: inherit;
}
.stat-card:first-child { border-left: none; }
a.stat-card:hover { background: var(--bg-hover); text-decoration: none; }
.stat-card__icon {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 6px;
    display: grid;
    place-items: center;
}
.stat-card__icon svg { width: 18px; height: 18px; }
.stat-card__icon--blue, .stat-card__icon--teal { background: var(--blue-100); color: var(--blue-600); }
.stat-card__icon--amber  { background: var(--warning-dim); color: var(--warning); }
.stat-card__icon--green  { background: var(--success-dim); color: var(--success); }
.stat-card__icon--slate  { background: #ECEFF4; color: #5B6577; }
.stat-card__icon--purple { background: var(--info-dim); color: var(--info); }
.stat-card__body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.stat-card__label { font-size: var(--fs-sm); color: var(--text-muted); }
.stat-card__value {
    font-size: var(--fs-num) !important;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.01em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-card__note { font-size: var(--fs-xs); color: var(--text-muted); }

/* ── Cartão de lista ───────────────────────────────────────────── */
.tbl-card, .table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.tbl-toolbar, .table-card__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1rem;
    flex-wrap: wrap;
    padding: .75rem 1.125rem;
    border-bottom: 1px solid var(--border);
}
.tbl-heading, .table-card__heading {
    margin: 0;
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: .5rem;
}
.tbl-heading svg, .table-card__heading svg { width: 16px; height: 16px; color: var(--text-muted); }
.tbl-count {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-secondary);
    background: #ECEFF4;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}
.tbl-link { font-size: var(--fs-sm); font-weight: 600; }

/* ── Pesquisa ──────────────────────────────────────────────────── */
.search-wrap, .search-box { position: relative; display: flex; align-items: center; min-width: 280px; }
.search-wrap svg, .search-box svg { position: absolute; left: .7rem; color: var(--text-muted); pointer-events: none; width: 15px; height: 15px; }
.search-wrap input, .search-box input {
    width: 100%;
    height: 32px;
    font-family: var(--font);
    font-size: var(--fs-base);
    color: var(--text-primary);
    padding: 0 .8rem 0 2.1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--white);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.search-wrap input::placeholder, .search-box input::placeholder { color: var(--text-dim); }
.search-wrap input:focus, .search-box input:focus { border-color: var(--blue-500); box-shadow: var(--focus-ring); }

/* ── Tabela ────────────────────────────────────────────────────── */
.t-scroll, .table-scroll { overflow-x: auto; }
.crm-table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); font-family: var(--font); }
.crm-table thead th {
    text-align: left;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: .5rem .875rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.crm-table tbody td {
    padding: .55rem .875rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}
.crm-table thead th:first-child, .crm-table tbody td:first-child { padding-left: 1.125rem; }
.crm-table thead th:last-child, .crm-table tbody td:last-child { padding-right: 1.125rem; }
.crm-table thead th.tc, .crm-table thead th.ta-c, .crm-table tbody td.tc, .crm-table tbody td.ta-c { text-align: center; }
.crm-table tbody tr:hover td { background: var(--bg-hover); }
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table .t-bold { font-weight: 600; color: var(--text-primary); }
.t-mono, .mono { font-variant-numeric: tabular-nums; }
.crm-table .t-muted { color: var(--text-muted); font-size: var(--fs-sm); }

.row-cell { display: flex; align-items: center; gap: .65rem; }
.row-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--blue-100);
    color: var(--blue-700);
    font-weight: 700;
    font-size: var(--fs-xs);
    flex-shrink: 0;
}
.row-name { font-weight: 600; color: var(--text-primary); }
.row-sub  { font-size: var(--fs-xs); color: var(--text-muted); }

.code-chip {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Estados (pills) ───────────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: .15rem .55rem;
    border-radius: 999px;
    line-height: 1.35;
    font-family: var(--font);
    white-space: nowrap;
    border: 1px solid transparent;
}
.pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill--ok     { background: var(--success-dim); color: var(--success); border-color: var(--success-border); }
.pill--warn   { background: var(--warning-dim); color: var(--warning); border-color: var(--warning-border); }
.pill--danger { background: var(--danger-dim);  color: var(--danger);  border-color: var(--danger-border); }
.pill--info, .pill--points { background: var(--blue-100); color: var(--blue-700); border-color: var(--blue-200); }
.pill--purple { background: var(--info-dim); color: var(--info); border-color: #D3D7FA; }
.pill--muted  { background: #ECEFF4; color: var(--text-muted); border-color: var(--border); }

/* ── Ações de linha ────────────────────────────────────────────── */
.row-actions { display: inline-flex; gap: .25rem; }
.icon-btn {
    width: 28px; height: 28px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--white);
    cursor: pointer;
    color: var(--text-muted);
    transition: background-color .12s, color .12s, border-color .12s;
}
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn--edit:hover, .icon-btn--view:hover { color: var(--blue-600); background: var(--blue-50); border-color: var(--blue-300); }
.icon-btn--del:hover { color: var(--danger); background: var(--danger-dim); border-color: var(--danger-border); }

/* ── Estados vazios / carregamento ─────────────────────────────── */
.state-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: var(--fs-base);
    text-align: center;
}
.state-msg > svg { width: 48px; height: 48px; padding: 12px; border-radius: 50%; background: var(--bg-elevated); color: var(--text-dim); }
.state-msg--good > svg { background: var(--success-dim); color: var(--success); }
.crm-spinner, .spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--blue-100);
    border-top-color: var(--blue-600);
    border-radius: 50%;
    animation: crm-spin .7s linear infinite;
}

/* ── Modais ────────────────────────────────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 50, 0.55);
    display: grid;
    place-items: center;
    padding: 1.5rem;
    z-index: 1050;
    animation: crm-fade .15s ease;
    font-family: var(--font);
}
.sheet {
    width: 100%;
    max-width: 640px;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: crm-pop .2s cubic-bezier(.2, .8, .25, 1);
}
.sheet--sm { max-width: 440px; }
.sheet--lg { max-width: 760px; }
.sheet--xl { max-width: 980px; }

.sheet__banner {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.sheet__banner-icon {
    flex: 0 0 auto;
    width: 36px; height: 36px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: var(--blue-600);
    color: var(--white);
}
.sheet__banner-icon svg { width: 18px; height: 18px; }
.sheet__title { margin: 0; font-size: var(--fs-lg); font-weight: 700; color: var(--text-primary); line-height: 1.25; }
.sheet__sub { margin: .1rem 0 0; font-size: var(--fs-sm); color: var(--text-muted); }
.sheet__close {
    flex: 0 0 auto;
    margin-left: auto;
    width: 30px; height: 30px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--white);
    color: var(--text-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
}
.sheet__close:hover { background: var(--bg-elevated); color: var(--text-primary); }
.sheet__body { padding: 1.25rem; max-height: 68vh; overflow-y: auto; }
.sheet__body--center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .5rem; padding-top: 2rem; }
.sheet__footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .8rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}
.sheet__footer--center { justify-content: center; }

/* ── Formulários ───────────────────────────────────────────────── */
.form-sec, .form-section { margin-bottom: 1.5rem; }
.form-sec:last-child, .form-section:last-child { margin-bottom: 0; }
.form-sec__label, .form-section__label {
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: .8rem;
    padding: .4rem .7rem;
    background: var(--bg-elevated);
    border-radius: var(--radius);
}
.fld-grid, .field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
.fld-grid--3, .field-grid--3 { grid-template-columns: repeat(3, 1fr); }
.fld-grid--1 { grid-template-columns: 1fr; }
.fld, .field { display: flex; flex-direction: column; gap: .3rem; }
.fld--full, .field--full { grid-column: 1 / -1; }
.fld label, .field label { font-size: var(--fs-sm); font-weight: 400; color: var(--text-secondary); }
.fld .req, .field .req { color: var(--danger); }
.fld input, .fld select, .fld textarea,
.field input, .field select, .field textarea {
    width: 100%;
    font-family: var(--font);
    font-size: var(--fs-base);
    color: var(--text-primary);
    height: 34px;
    padding: 0 .7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--white);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.fld input[type=checkbox], .field input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue-600); }
.fld textarea, .field textarea { height: auto; padding: .5rem .7rem; resize: vertical; min-height: 80px; }
.fld input::placeholder, .fld textarea::placeholder,
.field input::placeholder, .field textarea::placeholder { color: var(--text-dim); }
.fld input:focus, .fld select:focus, .fld textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-500); box-shadow: var(--focus-ring); }
.fld input[readonly], .fld textarea[readonly] { background: var(--bg-elevated); color: var(--text-muted); cursor: default; }
.input-prefix, .input-affix { position: relative; display: flex; align-items: center; }
.input-prefix__sym, .input-affix__icon { position: absolute; left: .7rem; font-weight: 600; font-size: var(--fs-base); color: var(--text-muted); pointer-events: none; }
.input-prefix input, .input-affix input { padding-left: 1.7rem; }

.danger-badge {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--danger);
    background: var(--danger-dim);
    margin-bottom: .25rem;
}

.alert-inline {
    background: var(--warning-dim);
    color: var(--warning);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
    padding: .55rem .8rem;
    font-size: var(--fs-sm);
    margin-top: .5rem;
}
.alert-inline--danger { background: var(--danger-dim); color: var(--danger); border-color: var(--danger-border); }

/* ── Animações (só em resposta a ações) ────────────────────────── */
@keyframes crm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes crm-pop  { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes crm-drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes crm-spin { to { transform: rotate(360deg); } }

/* ── Análise ───────────────────────────────────────────────────── */
.analise-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}
.analise-badge svg { color: var(--success); }

.analise-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .875rem; }
.analise-card--full { grid-column: 1 / -1; }

.rank-row { display: flex; align-items: center; gap: .8rem; }
.rank-num {
    flex: 0 0 auto;
    width: 24px; height: 24px;
    border-radius: 4px;
    display: grid;
    place-items: center;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-muted);
    background: #ECEFF4;
    font-variant-numeric: tabular-nums;
}
.rank-gold   { background: var(--blue-600); color: var(--white); }
.rank-silver { background: var(--blue-200); color: var(--blue-800); }
.rank-bronze { background: var(--blue-100); color: var(--blue-700); }

.tipo-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 2px; background: var(--blue-500); }

.rank-bar-wrap { flex: 1; display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.rank-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.rank-name { font-size: var(--fs-base); font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-val  { font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-bar-track { height: 6px; border-radius: 99px; background: #ECEFF4; overflow: hidden; }
.rank-bar-fill { height: 100%; border-radius: 99px; background: var(--blue-600); transition: width .6s cubic-bezier(.2, .8, .25, 1); }
.rank-bar-fill--gold { background: var(--blue-300); }

/* ── Responsivo ────────────────────────────────────────────────── */
@media (max-width: 1080px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card:nth-child(3) { border-left: none; }
    .stat-card:nth-child(n+3) { border-top: 1px solid var(--border); }
}
@media (max-width: 900px) {
    .analise-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .gh { gap: .75rem; padding: 0 .75rem; }
    .gh-user__name, .gh-user__chev { display: none; }
    .gh-logo { height: 38px; }
    .tabs { padding: 0; }
    .tabs__app { display: none; }
    .page-wrap, .prod-page { --page-x: .625rem; padding-top: .625rem; }
    .ph { padding: .875rem; }
    .ph__title { font-size: var(--fs-lg); }
    .ph__actions { width: 100%; }
    .ph__actions > * { flex: 1 1 auto; }
    .stat-grid { grid-template-columns: 1fr; }
    .stat-card { border-left: none; border-top: 1px solid var(--border); }
    .stat-card:first-child { border-top: none; }
    .search-wrap, .search-box { min-width: 100%; }
    .tbl-toolbar, .table-card__toolbar { flex-direction: column; align-items: stretch; }
    .fld-grid, .fld-grid--3, .field-grid, .field-grid--3 { grid-template-columns: 1fr; }
    .sheet__body { padding: 1rem; }
    .sheet__banner, .sheet__footer { padding-left: 1rem; padding-right: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
