/* Admin Web · CirculaFlow (admin.circulaflow.com.br)
 * Paleta dark canônica + accents diferenciados por grupo na sidebar.
 * Inter + JetBrains Mono. Densidade alta. Tom Stripe/Linear.
 */

:root {
    --bg-primary:        #0F0F14;
    --bg-card:           #1A1A24;
    --bg-card-elev:      #22223A;
    --border-subtle:     #2A2A3E;

    --primary-blue:      #5B5FEF;
    --accent-cyan:       #00D4FF;
    --success-green:     #00C896;
    --alert-orange:      #FF9500;
    --error-red:         #FF4757;
    --accent-lavender:   #A78BFA;
    --accent-pink:       #F472B6;
    --neutral-slate:     #5C6175;

    --text-primary:      #FFFFFF;
    --text-secondary:    #8A8FA8;
    --text-muted:        #5C6175;

    --gradient-primary:  linear-gradient(135deg, #5B5FEF 0%, #00D4FF 100%);
    --gradient-lite:     linear-gradient(135deg, #A78BFA 0%, #F472B6 100%);
    --gradient-success:  linear-gradient(135deg, #00C896 0%, #00A876 100%);

    --fill-primary-soft:  rgba(91, 95, 239, 0.15);
    --fill-cyan-soft:     rgba(0, 212, 255, 0.15);
    --fill-success-soft:  rgba(0, 200, 150, 0.15);
    --fill-alert-soft:    rgba(255, 149, 0, 0.15);
    --fill-error-soft:    rgba(255, 71, 87, 0.15);
    --fill-lavender-soft: rgba(167, 139, 250, 0.15);

    --radius-sm:  8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

html, body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; }

a { color: var(--accent-cyan); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border-subtle);
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 14px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-name {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.admin-badge {
    font-size: 9px;
    color: #fff;
    background: var(--gradient-primary);
    padding: 2px 8px;
    border-radius: 100px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    box-shadow: 0 0 12px rgba(91, 95, 239, 0.4);
}

.sidebar-group {
    padding: 10px 12px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    margin-top: 6px;
}
.sidebar-group:first-of-type { border-top: none; margin-top: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }

.sidebar-nav a {
    display: flex; align-items: center; gap: 0;
    padding: 7px 12px; border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12.5px; font-weight: 500;
    text-decoration: none;
    transition: background 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
                color 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
                box-shadow 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
                transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    margin: 1px 4px;
}
.sidebar-nav a svg { flex-shrink: 0; transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), color 180ms; }

.sidebar-nav a:hover {
    background: var(--bg-card-elev);
    color: var(--text-primary);
    transform: translateX(2px);
}
.sidebar-nav a:hover svg { color: var(--accent-color, var(--primary-blue)); }
.sidebar-nav a.active {
    background: linear-gradient(90deg, color-mix(in srgb, var(--accent-color, var(--primary-blue)) 20%, transparent), var(--bg-card-elev) 60%);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-color, var(--primary-blue)) 25%, transparent);
}
.sidebar-nav a.active svg { color: var(--accent-color, var(--primary-blue)); }

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: -8px; top: 6px; bottom: 6px;
    width: 3px;
    background: var(--accent-color, var(--primary-blue));
    border-radius: 0 2px 2px 0;
}

[data-group="main"]    .sidebar-nav a { --accent-color: var(--primary-blue); }
[data-group="lite"]    .sidebar-nav a { --accent-color: var(--accent-lavender); }
[data-group="afil"]    .sidebar-nav a { --accent-color: var(--accent-pink); }
[data-group="sistema"] .sidebar-nav a { --accent-color: var(--neutral-slate); }

.sidebar-nav .icon {
    width: 16px;
    text-align: center;
}

.sidebar-nav .badge {
    margin-left: auto;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--fill-primary-soft);
    color: var(--primary-blue);
}

.sidebar-nav .badge.warn {
    background: var(--fill-alert-soft);
    color: var(--alert-orange);
}

.sidebar-footer {
    margin-top: auto;
    padding: 10px;
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-muted);
}

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 52px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
}

.topbar .title { font-size: 16px; font-weight: 700; }
.topbar .spacer { flex: 1; }

.topbar .system-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 4px 12px;
    background: var(--fill-success-soft);
    border-radius: 100px;
}

.topbar .system-status .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--success-green);
    box-shadow: 0 0 8px rgba(0, 200, 150, 0.55);
    position: relative;
}
.topbar .system-status .dot::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: 50%;
    background: var(--success-green);
    animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
    0%   { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(2.6); opacity: 0; }
}

.content { flex: 1; overflow: auto; padding: 20px 24px; }

.page-header {
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.page-header .h1 { font-size: 20px; font-weight: 700; }
.page-header .sub { font-size: 12px; color: var(--text-secondary); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }

.kpi {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex; flex-direction: column; gap: 4px;
}

.kpi-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.kpi-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 4px;
}

.kpi-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.kpi-trend.up   { color: var(--success-green); }
.kpi-trend.down { color: var(--error-red); }

/* Cards genéricos */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
}

.card-body { padding: 16px; }
.card-body.no-pad { padding: 0; }

/* Tabela densa */
table { width: 100%; border-collapse: collapse; font-size: 12px; }

table thead th {
    text-align: left;
    padding: 8px 16px;
    background: var(--bg-card-elev);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

table tbody td {
    padding: 10px 16px;
    border-top: 1px solid var(--border-subtle);
}

table tbody tr:hover { background: var(--bg-card-elev); }

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 120ms;
    text-decoration: none;
    background: transparent;
    color: var(--text-primary);
}

.btn-primary { background: var(--primary-blue); }
.btn-primary { transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease; }
.btn-primary:hover {
    background: var(--gradient-primary);
    box-shadow: 0 0 24px rgba(91, 95, 239, 0.35);
    transform: translateY(-1px);
}

.btn-success { background: var(--success-green); }
.btn-danger  { background: var(--error-red); }

.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-card-elev); color: var(--text-primary); }

.btn-sm { padding: 4px 10px; font-size: 11px; }

/* Pills */
.pill {
    display: inline-flex; align-items: center;
    padding: 2px 8px; border-radius: 100px;
    font-size: 9px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
}

.pill-success { background: var(--fill-success-soft); color: var(--success-green); }
.pill-pending { background: var(--fill-alert-soft); color: var(--alert-orange); }
.pill-error   { background: var(--fill-error-soft); color: var(--error-red); }
.pill-info    { background: var(--fill-cyan-soft); color: var(--accent-cyan); }
.pill-slate   { background: rgba(92, 97, 117, 0.18); color: var(--neutral-slate); }
.pill-lite    { background: var(--fill-lavender-soft); color: var(--accent-lavender); }
.pill-vip     { background: var(--gradient-lite); color: #fff; box-shadow: 0 0 12px rgba(244, 114, 182, 0.35); }

/* Inputs */
.input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-card-elev);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
}
.input:focus { outline: none; border-color: var(--primary-blue); }

select.input {
    background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
    background-position: calc(100% - 18px) center, calc(100% - 13px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    appearance: none;
    padding-right: 32px;
}

.toolbar {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.toolbar .input { width: auto; min-width: 200px; }

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 12px;
}

.alert-error   { background: var(--fill-error-soft); color: var(--error-red); }
.alert-success { background: var(--fill-success-soft); color: var(--success-green); }

.empty-state {
    text-align: center;
    padding: 36px 16px;
    color: var(--text-secondary);
}
.empty-state .icon { font-size: 36px; margin-bottom: 8px; opacity: 0.6; }

/* Login */
.login-container {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}

.login-card {
    width: 100%; max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 36px 28px;
}

.login-header { text-align: center; margin-bottom: 24px; }
.login-header h1 {
    font-size: 22px; font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    margin-bottom: 6px;
}
.login-header .sub { font-size: 12px; color: var(--text-secondary); }

.login-form { display: flex; flex-direction: column; gap: 12px; }

.label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.btn-block { width: 100%; padding: 12px; font-size: 14px; }

/* ─── Tipografia utilitária extra (espelha mock cflow/) ──────────── */
.t-title-l    { font-size: 15px; font-weight: 700; }
.t-headline-s { font-size: 20px; font-weight: 700; line-height: 1.2; }
.t-body-s     { font-size: 12px; color: var(--text-secondary); }

/* ─── fpill (filter pill — usado em filtros de Activity Feed e ranges) ─ */
.fpill {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: 100px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 120ms;
}
.fpill:hover { border-color: var(--primary-blue); color: var(--text-primary); }
.fpill.active {
    background: var(--fill-primary-soft);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

/* ─── Live dot pulsante ──────────────────────────────────────────── */
.live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success-green);
    position: relative;
    flex-shrink: 0;
}
.live-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--success-green);
    animation: pulse 1.8s ease-out infinite;
}

/* ─── Activity feed (lateral direito do dashboard) ────────────────── */
.activity-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.activity-head {
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 8px;
}
.activity-filters {
    padding: 8px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--border-subtle);
}
.activity-list { overflow: auto; flex: 1; min-height: 0; }
.activity-row {
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 120ms;
}
.activity-row:hover { background: var(--bg-card-elev); }
.activity-row:last-child { border-bottom: none; }
.activity-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}
.activity-dot.ok      { background: var(--success-green); box-shadow: 0 0 0 3px rgba(0,200,150,0.13); }
.activity-dot.info    { background: var(--accent-cyan);   box-shadow: 0 0 0 3px rgba(0,212,255,0.13); }
.activity-dot.err     { background: var(--error-red);     box-shadow: 0 0 0 3px rgba(255,71,87,0.13); }
.activity-dot.warn    { background: var(--alert-orange);  box-shadow: 0 0 0 3px rgba(255,149,0,0.13); }
.activity-dot.neutral { background: var(--text-secondary); box-shadow: 0 0 0 3px rgba(138,143,168,0.13); }
.activity-dot.lite    { background: var(--accent-lavender); box-shadow: 0 0 0 3px rgba(167,139,250,0.13); }

/* ─── Page header (KPIs + content layout) ─────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}
.page-header-title { font-size: 20px; font-weight: 700; line-height: 1.2; }
.page-header-sub   { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ─── Dashboard layout: main content + activity sidebar ────────────── */
.dash-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
    align-items: start;
}

/* ─── KPI accent bar ──────────────────────────────────────────────── */
.kpi-accent {
    position: absolute;
    left: 0; top: 14px; bottom: 14px;
    width: 2px;
    border-radius: 0 2px 2px 0;
}

/* ─── Method badge ────────────────────────────────────────────────── */
.gradient-badge {
    background: var(--gradient-primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@media (max-width: 1100px) {
    .dash-layout { grid-template-columns: 1fr; }
}

/* ─── Modal genérico ─────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.modal-large { max-width: 760px; }
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}
.modal-title { font-size: 16px; font-weight: 700; flex: 1; }
.modal-close {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover { background: var(--bg-card-elev); color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.modal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.modal-grid-1 { grid-column: 1 / -1; }
.field-help { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.code-block {
    background: var(--bg-card-elev);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-cyan);
    word-break: break-all;
    user-select: all;
    -webkit-user-select: all;
}

@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .sidebar { width: 100%; height: auto; flex-direction: row; overflow-x: auto; }
    .app-shell { flex-direction: column; }
    .sidebar-nav { flex-direction: row; gap: 2px; }
    .sidebar-group { display: none; }
    .sidebar-footer { display: none; }
    .sidebar-nav a.active::before { display: none; }
}

/* ─── Effects layer (mock fidelity) ──────────────────────────────── */

.card {
    transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
                border-color 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
                box-shadow 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.card.card-hoverable:hover,
.kpi:hover,
.activity-card:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.kpi {
    transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
                border-color 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
                box-shadow 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.input:focus {
    box-shadow: 0 0 0 3px var(--fill-primary-soft);
}

.btn-success { transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease; }
.btn-success:hover {
    background: var(--gradient-success);
    box-shadow: 0 0 20px rgba(0, 200, 150, 0.32);
    transform: translateY(-1px);
}
.btn-danger { transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease; }
.btn-danger:hover {
    background: var(--gradient-error);
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.32);
    transform: translateY(-1px);
}
.btn-ghost { transition: all 180ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.btn-ghost:hover { border-color: var(--border-strong); }

.pill-info    { box-shadow: inset 0 0 0 1px rgba(0, 212, 255, 0.18); }
.pill-success { box-shadow: inset 0 0 0 1px rgba(0, 200, 150, 0.18); }
.pill-pending { box-shadow: inset 0 0 0 1px rgba(255, 149, 0, 0.18); }
.pill-error   { box-shadow: inset 0 0 0 1px rgba(255, 71, 87, 0.18); }
.pill-lite    { box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.18); }

.kpi-accent {
    box-shadow: 0 0 12px var(--accent-color, var(--primary-blue));
}

.modal-backdrop {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: backdropIn 180ms ease-out;
}
.modal {
    box-shadow: var(--shadow-modal, 0 12px 40px rgba(0, 0, 0, 0.55));
    animation: modalIn 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(2px); }
    to   { opacity: 1; transform: none; }
}
.fade-in,
.content > .kpi-grid,
.content > .card,
.content > .page-header { animation: fadeIn 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }

table tbody tr { transition: background 120ms ease; }
table tbody tr:hover { background: rgba(91, 95, 239, 0.04); }

.subtab { transition: color 180ms, border-bottom-color 180ms; }
.subtab.active { box-shadow: 0 -1px 0 0 var(--primary-blue) inset, 0 4px 12px -8px var(--primary-blue); }
