/* ==========================================================================
   PARAMETRIK - TELAS DO SISTEMA (portal do cliente, ativação, painel admin)
   Usa os tokens de styles.css.
   ========================================================================== */

/* Cabeçalho escuro das áreas logadas */
.app-header { background: var(--ink); color: var(--paper); padding: 40px 0 32px; }
.app-body { padding-top: 40px; padding-bottom: 96px; }

.portal-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .6);
    margin-bottom: 8px;
}
.portal-badge::before { content: ""; width: 8px; height: 8px; background: var(--accent); }
.portal-badge-dark { color: var(--text-3); }

.client-profile-header { display: flex; align-items: center; gap: 20px; }
.client-avatar-large {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 22px;
    font-weight: 500;
    border-radius: var(--r);
}
.client-profile-info h1, .admin-top-bar h1 { font-size: clamp(26px, 3vw, 34px); }
.client-company-meta { color: rgba(255, 255, 255, .7); font-size: 14px; margin-top: 4px; }
.meta-sep { margin: 0 8px; opacity: .5; }

.admin-top-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-top: 28px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: var(--r);
}
.metric-card { padding: 18px 20px; border-left: 1px solid rgba(255, 255, 255, .14); }
.metric-card:first-child { border-left: none; }
.metric-title {
    display: block;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .55);
}
.metric-number { display: block; font-size: 30px; font-weight: 700; margin-top: 6px; color: var(--paper); }

.portal-section-title { margin-bottom: 20px; }
.portal-section-title h2 { font-size: 24px; margin-bottom: 4px; }
.portal-section-title p { color: var(--text-2); font-size: 15px; }

/* Cards de licença */
.client-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.client-lic-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; }
.lic-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.plugin-info { display: flex; align-items: center; gap: 12px; }
.plugin-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink);
    color: var(--paper);
    border-radius: var(--r);
}
.lic-title { font-size: 17px; font-weight: 600; }
.lic-meta { font-size: 13px; color: var(--text-3); display: inline-flex; gap: 6px; align-items: center; }
.lic-card-body { background: var(--muted); border-radius: var(--r); padding: 16px; }
.lic-details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.detail-label {
    display: block;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 2px;
}
.detail-val { font-size: 14px; font-weight: 600; }

/* Selos de status */
.badge-status, .badge-table {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--r-sm);
    white-space: nowrap;
}
.badge-status.active, .badge-table.active { background: var(--ok-soft); color: var(--ok); }
.badge-status.expired, .badge-table.expired { background: var(--warn-soft); color: var(--warn); }
.badge-status.blocked, .badge-table.blocked { background: var(--danger-soft); color: var(--danger); }

.empty-state-card {
    grid-column: 1 / -1;
    background: var(--paper);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r);
    padding: 48px 32px;
    text-align: center;
}
.empty-state-card i { font-size: 28px; color: var(--text-3); margin-bottom: 12px; }
.empty-state-card h3 { margin-bottom: 8px; }
.empty-state-card p { color: var(--text-2); max-width: 520px; margin: 0 auto 20px; }

/* Tabelas */
.table-container { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
.data-table th {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-3);
    background: var(--muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #FAFAF8; }
.pmk-panel .data-table th { background: transparent; }
.user-cell strong { display: block; }
.user-cell small { display: block; color: var(--text-3); }
.plugin-tag { font-size: 12px; font-weight: 600; background: var(--muted); padding: 3px 8px; border-radius: var(--r-sm); }
.action-cell { white-space: nowrap; }
.table-empty-msg { text-align: center; color: var(--text-3); padding: 32px !important; }

.btn-table-action {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--r);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--ink);
}
.btn-table-action:hover { background: var(--muted); }
.btn-table-action.block { color: var(--danger); }
.btn-table-action.block:hover { background: var(--danger-soft); }
.btn-table-action.unblock { color: var(--ok); }
.btn-table-action.unblock:hover { background: var(--ok-soft); }
.btn-table-action:disabled { opacity: .6; cursor: wait; }

/* Filtros do painel */
.admin-controls-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}
.search-box { position: relative; flex: 1; min-width: 260px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 14px; }
.search-box .field-input { padding-left: 36px; }
.filter-box { display: flex; align-items: center; gap: 8px; }
.filter-box label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.filter-box .field-select { width: auto; }

/* Abas */
.pmk-tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.pmk-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-3);
    cursor: pointer;
    white-space: nowrap;
}
.pmk-tab:hover { color: var(--ink); }
.pmk-tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* Painéis e utilidades */
.pmk-panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; }
.pmk-panel h2 { font-size: 24px; margin: 4px 0 6px; }
.pmk-panel h3 { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.pmk-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.pmk-section-gap { margin-top: 20px; }
.pmk-narrow { max-width: 580px; margin: 0 auto; }
.pmk-grow { flex: 1; }
.pmk-hint { display: block; color: var(--text-3); font-size: 13px; margin-top: 6px; }
.pmk-subtitle { margin: 20px 0 12px; font-size: 16px; }
.pmk-sep { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.pmk-loading { color: var(--text-3); padding: 24px; text-align: center; font-size: 14px; }
.pmk-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-left: 4px solid var(--danger);
    padding: 12px 16px;
    border-radius: var(--r);
    font-size: 14px;
}

.pmk-inline-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--muted);
    border-radius: var(--r);
    padding: 16px 18px;
}
.pmk-inline-card > i { font-size: 20px; }
.pmk-inline-card p { color: var(--text-2); font-size: 13px; }

.pmk-steps { padding-left: 20px; margin-bottom: 20px; color: var(--text-2); font-size: 14px; }
.pmk-steps li { margin-bottom: 6px; }

.pmk-kv { list-style: none; }
.pmk-kv li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

/* Assentos */
.pmk-seat-card { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.pmk-seat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pmk-seat-head span { color: var(--text-3); font-size: 13px; }
.pmk-seat-list { list-style: none; margin: 12px 0; }
.pmk-seat-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.pmk-seat-list li small { display: block; color: var(--text-3); }
.pmk-seat-list li > span:last-child { display: inline-flex; gap: 8px; align-items: center; }
.pmk-select-sm { height: 34px; font-size: 12px; max-width: 230px; }

.pmk-inline-form { display: flex; gap: 10px; margin-top: 12px; }
.pmk-inline-form .field-input { flex: 1; min-width: 0; }

.pmk-message-cell { max-width: 360px; white-space: pre-wrap; font-size: 13px; }

/* Ativação */
.pmk-code-input { font-family: var(--mono); font-size: 22px; letter-spacing: .15em; text-transform: uppercase; text-align: center; height: 52px; }
.pmk-activation-confirm { margin-top: 24px; }
.pmk-machine-box {
    display: flex;
    gap: 16px;
    align-items: center;
    background: var(--muted);
    border-left: 4px solid var(--accent);
    border-radius: var(--r);
    padding: 16px 20px;
    margin: 14px 0;
}
.pmk-machine-box i { font-size: 26px; }
.pmk-machine-box small { display: block; color: var(--text-3); }
.pmk-actions { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.pmk-success-box {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--ok-soft);
    color: var(--ok);
    border-left: 4px solid var(--ok);
    border-radius: var(--r);
    padding: 16px 20px;
    margin-top: 24px;
}
.pmk-success-box i { font-size: 22px; }
.pmk-success-box p { color: var(--text-2); }

/* Autenticação */
.pmk-auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 14px; }
.pmk-auth-links a, .pmk-check a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }
.pmk-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text-2); margin: 14px 0; }
.pmk-check input { margin-top: 3px; accent-color: var(--ink); }
.pmk-modal-wide { max-width: 640px; }

/* Gráfico simples */
.pmk-bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.pmk-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.pmk-bar span { display: block; width: 100%; background: var(--ink); min-height: 2px; }
.pmk-bar:hover span { background: var(--accent); }

/* Avisos */
.pmk-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 16px);
    background: var(--ink);
    color: var(--paper);
    padding: 12px 20px;
    border-radius: var(--r);
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 3000;
    max-width: calc(100vw - 32px);
    border-left: 4px solid var(--accent);
}
.pmk-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.pmk-toast.success { border-left-color: #4CC274; }
.pmk-toast.danger { border-left-color: #FF6B5E; }

@media (max-width: 860px) {
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .metric-card:nth-child(3) { border-left: none; }
    .metric-card:nth-child(n + 3) { border-top: 1px solid rgba(255, 255, 255, .14); }
}

/* ==========================================================================
   DASHBOARD DE USO (admin)
   Gráficos: grade e eixos recessivos, marcas finas, texto sempre em tinta
   (nunca na cor da série), cor de cada plugin fixa pela ordem do catálogo.
   ========================================================================== */
.dash { position: relative; --viz-grid: #E1E0D9; --viz-axis: #C3C2B7; --viz-muted: #898781; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.dash-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 16px;
    background: var(--muted);
    border-radius: var(--r);
    margin-bottom: 16px;
}
.dash-filter { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.dash-filter > span {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-3);
}
.dash-filter .field-select, .dash-filter .field-input { height: 38px; font-size: 14px; }
.dash-filter-actions { display: flex; gap: 8px; margin-left: auto; }

.dash-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    align-items: center;
    font-size: 13px;
    color: var(--text-3);
    margin-bottom: 16px;
}
.dash-live { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.dash-live-dot { width: 8px; height: 8px; border-radius: 50%; background: #0ca30c; box-shadow: 0 0 0 3px rgba(12, 163, 12, .18); }

/* Indicadores */
.dash-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--paper);
    margin-bottom: 20px;
}
.dash-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 18px 20px;
    border-left: 1px solid var(--line);
    border-top: 1px solid var(--line);
}
.dash-tile:nth-child(4n + 1) { border-left: none; }
.dash-tile:nth-child(-n + 4) { border-top: none; }
.dash-tile-label { font-size: 13px; color: var(--text-2); }
.dash-tile-value { font-size: 30px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.dash-tile-hint { font-size: 12px; color: var(--text-3); }
.dash-delta { font-size: 12px; font-weight: 600; margin-top: 4px; display: inline-flex; gap: 4px; align-items: baseline; }
.dash-delta.good { color: #006300; }
.dash-delta.bad { color: var(--danger); }
.dash-delta.flat { color: var(--text-3); font-weight: 500; }

/* Cartões */
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.dash-span-2 { grid-column: 1 / -1; }
.dash-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 20px;
    margin-bottom: 20px;
    min-width: 0;
}
.dash-grid-2 > .dash-card { margin-bottom: 0; }
.dash-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.dash-card-head h3 { font-size: 16px; font-weight: 600; }
.dash-card-head p { font-size: 13px; color: var(--text-3); margin-top: 2px; max-width: 640px; }
.dash-search { max-width: 320px; height: 38px; font-size: 14px; }

/* Gráficos */
.viz-wrap { width: 100%; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis { stroke: var(--viz-axis); stroke-width: 1; }
.viz-tick { font: 400 11px var(--font); fill: var(--viz-muted); font-variant-numeric: tabular-nums; }
.viz-hit { fill: transparent; cursor: crosshair; }
.viz-hit:hover { fill: rgba(14, 14, 14, .04); }
.viz-empty {
    padding: 40px 16px;
    text-align: center;
    font-size: 14px;
    color: var(--text-3);
    background: var(--muted);
    border-radius: var(--r);
}

.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; font-size: 13px; color: var(--text-2); }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.viz-key { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 8px; vertical-align: middle; }
.viz-key-neutral { background: var(--line-strong); }

.viz-tooltip {
    position: absolute;
    z-index: 50;
    pointer-events: none;
    white-space: pre-line;
    background: var(--ink);
    color: var(--paper);
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 10px;
    border-radius: var(--r);
    max-width: 260px;
}

/* Mapa de calor */
.heatmap { display: flex; flex-direction: column; gap: 2px; }
.heatmap-row { display: grid; grid-template-columns: 36px repeat(24, 1fr); gap: 2px; align-items: center; }
.heatmap-label { font-size: 11px; color: var(--viz-muted); }
.heatmap-cell { aspect-ratio: 1 / 1; border-radius: 2px; min-height: 10px; cursor: crosshair; }
.heatmap-cell:hover { outline: 2px solid var(--ink); outline-offset: -1px; }
.heatmap-hour { font-size: 10px; color: var(--viz-muted); text-align: left; white-space: nowrap; }
.heatmap-scale { display: flex; align-items: center; gap: 2px; justify-content: flex-end; margin-top: 10px; font-size: 11px; color: var(--viz-muted); }
.heatmap-scale i { width: 16px; height: 10px; border-radius: 2px; display: inline-block; }
.heatmap-scale span { margin: 0 6px; }

/* Tabelas do dashboard */
.dash-table { border: none; border-radius: 0; }
.dash-table .data-table th { background: transparent; }
.dash-table .data-table td { font-variant-numeric: tabular-nums; }
.dash-row-link { cursor: pointer; }
.dash-row-link:focus-visible td { background: var(--accent-soft); }

.nowrap { white-space: nowrap; }
.error-reason { display: block; font-family: var(--mono); font-size: 12px; color: var(--text-2); margin-top: 2px; padding-left: 16px; }
.dash-table code { font-family: var(--mono); font-size: 12.5px; }

.inline-bar {
    display: inline-block;
    width: 64px;
    height: 6px;
    background: var(--muted-2);
    border-radius: 3px;
    margin-right: 10px;
    vertical-align: middle;
    overflow: hidden;
}
.inline-bar span { display: block; height: 100%; border-radius: 3px; }

.meter { height: 8px; background: #CDE2FB; border-radius: 4px; overflow: hidden; margin-bottom: 4px; max-width: 220px; }
.meter span { display: block; height: 100%; background: #2a78d6; border-radius: 4px; }

.status-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text); }
.status-chip.success i { color: #0ca30c; }
.status-chip.warning i { color: #C98500; }
.status-chip.failure i { color: #d03b3b; }

/* Listas de versões */
.vlist-title {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-3);
    margin: 16px 0 8px;
}
.vlist-title:first-of-type { margin-top: 0; }
.vlist { list-style: none; }
.vlist li { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr 48px; gap: 12px; align-items: center; padding: 5px 0; font-size: 13px; }
.vlist-bar { height: 6px; background: var(--muted-2); border-radius: 3px; overflow: hidden; }
.vlist-bar span { display: block; height: 100%; background: #2a78d6; border-radius: 3px; }
.vlist-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* Atividade */
.feed { list-style: none; max-height: 420px; overflow-y: auto; }
.feed li {
    display: grid;
    grid-template-columns: 130px minmax(180px, 1.3fr) minmax(160px, 1fr) minmax(120px, 1fr);
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    align-items: center;
}
.feed li:last-child { border-bottom: none; }
.feed time { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.feed-who, .feed-detail { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-compact li { grid-template-columns: 130px 1fr 1fr; }
.dash-devices li { flex-direction: column; align-items: flex-start; }

@media (max-width: 1024px) {
    .dash-kpis { grid-template-columns: repeat(2, 1fr); }
    .dash-tile:nth-child(n) { border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
    .dash-tile:nth-child(2n + 1) { border-left: none; }
    .dash-tile:nth-child(-n + 2) { border-top: none; }
    .dash-grid-2 { grid-template-columns: 1fr; }
    .feed li { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 640px) {
    .dash-filter { min-width: 0; flex: 1 1 140px; }
    .dash-filter-actions { margin-left: 0; width: 100%; }
    .dash-tile-value { font-size: 24px; }
}

@media (max-width: 640px) {
    .pmk-panel { padding: 18px; }
    .pmk-grid-2, .client-cards-grid { grid-template-columns: 1fr; }
    .pmk-inline-form { flex-direction: column; }
    .pmk-inline-card { flex-direction: column; align-items: flex-start; }
    .client-profile-header { align-items: flex-start; }
    .lic-details-grid { grid-template-columns: 1fr; }
}
