/* ============================================================
   Orquestrador RPA — CSC
   Identidade preservada: azul #1B0DAE, Montserrat, IBM Plex Mono.
   Reestruturado: hierarquia, escala tipográfica e layout.
   ============================================================ */

:root {
    --blue: #1B0DAE;
    --blue-light: #3D2FD4;
    --blue-dark: #140A8C;
    --blue-50: #EDEAFC;
    --blue-100: #D5D0F8;
    --success: #137333;
    --success-bg: #E6F4EA;
    --warning: #B06000;
    --warning-bg: #FEF7E0;
    --danger: #C4320A;
    --danger-bg: #FEE4E2;

    --gray-50: #F8F9FB;
    --gray-100: #F1F3F6;
    --gray-200: #E4E7EC;
    --gray-300: #CFD5E0;
    --gray-400: #98A1B3;   /* apenas bordas/ícones decorativos — 2.6:1, nunca texto */
    --gray-500: #6B7588;   /* piso de texto secundário — 4.6:1 em branco */
    --gray-600: #4E5A6E;
    --gray-700: #344054;
    --gray-800: #1D2939;
    --gray-900: #101828;
    --white: #FFFFFF;

    --panel-bg: #FFFFFF;
    --glass-border: rgba(16, 24, 40, 0.08);

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 8px -2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.06), 0 12px 24px -6px rgba(16, 24, 40, 0.10);
    --shadow-lg: 0 8px 16px -4px rgba(16, 24, 40, 0.08), 0 32px 56px -12px rgba(16, 24, 40, 0.20);

    /* Escala tipográfica — amplitude 11px → 32px (2.9:1), passos legíveis */
    --fs-xs:   0.6875rem;  /* 11px — eyebrow, micro-label */
    --fs-sm:   0.8125rem;  /* 13px — corpo secundário, tabela */
    --fs-base: 0.9375rem;  /* 15px — corpo */
    --fs-lg:   1.125rem;   /* 18px — título de painel */
    --fs-xl:   1.5rem;     /* 24px — título de página */
    --fs-2xl:  2rem;       /* 32px — estado ao vivo, números */

    --r-sm: 0.375rem;
    --r-md: 0.625rem;
    --r-lg: 1rem;

    --sidebar-w: 264px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-900);
    font-size: var(--fs-base);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Foco visível em toda a interface */
:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

.ambient-background {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(circle at 15% 45%, rgba(27, 13, 174, 0.045) 0%, transparent 55%),
                radial-gradient(circle at 88% 20%, rgba(27, 13, 174, 0.03) 0%, transparent 50%);
}

/* ---------- Layout ---------- */

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

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    padding: 1.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-logo { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2.25rem; }
.sidebar-logo img { height: 36px; }
.sidebar-logo h1 {
    font-size: var(--fs-base);
    font-weight: 800;
    margin: 0;
    color: var(--blue-dark);
    line-height: 1.25;
    letter-spacing: -0.015em;
    white-space: nowrap;
}
/* Mesma regra do login: nome do produto numa linha só. */
.sidebar-logo h1 span {
    color: var(--gray-500);
    font-weight: 700;
}

.sidebar h3 {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500);
    font-weight: 700;
    margin: 1.75rem 0 0.625rem;
}
.sidebar h3:first-of-type { margin-top: 0; }

.nav-group { display: flex; flex-direction: column; gap: 0.25rem; }

.nav-foot { margin-top: auto; padding-top: 1.5rem; }

/* Botão da gaveta: só existe no celular (ligado na media query de 900px).
   Seletor com o pai de propósito: `.nav-menu-btn` sozinho tem a mesma
   especificidade de `.btn { display: flex }`, que está mais abaixo no arquivo
   e ganhava — o botão aparecia no desktop. */
.sidebar > .nav-menu-btn { display: none; margin-left: 0.25rem; }

/* Papéis: o operador não vê o que não pode fazer.
   A UI só esconde — quem barra de verdade é o servidor (_ROTAS_MASTER). */
.papel-operador .so-master { display: none !important; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-top: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--r-md);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
}
.user-avatar {
    flex: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--gray-200);
    color: var(--gray-700);
    font-size: var(--fs-sm);
    font-weight: 800;
}
.user-chip.is-master .user-avatar { background: var(--blue-50); color: var(--blue); }
.user-meta { min-width: 0; line-height: 1.25; }
.user-meta strong {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--gray-900);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-meta span {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--gray-500);
    letter-spacing: 0.03em;
}
.user-chip.is-master .user-meta span { color: var(--blue); }

.main-content {
    flex: 1;
    min-width: 0;
    padding: 1.75rem 2.5rem 3rem;
    max-width: 1360px;
}

/* ---------- Cabeçalho ---------- */

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.header-top h2 {
    margin: 0;
    font-size: var(--fs-xl);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--gray-900);
}
.header-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ---------- Abas Operação / Configuração ---------- */

.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 1.5rem;
}
.tab {
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--gray-500);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.625rem 0.875rem;
    margin-bottom: -1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.15s;
}
.tab:hover { color: var(--gray-800); }
.tab[aria-selected="true"] { color: var(--blue); border-bottom-color: var(--blue); }
.tab .tab-count {
    font-size: var(--fs-xs);
    font-weight: 700;
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 2px 7px;
    border-radius: 999px;
}
.tab[aria-selected="true"] .tab-count { background: var(--blue-50); color: var(--blue); }

.tab-panel[hidden] { display: none; }

/* ---------- Barra de estado operacional ---------- */

.statusbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    background: var(--white);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.125rem 1.5rem;
    margin-bottom: 1.25rem;
}

.statusbar-live { display: flex; align-items: center; gap: 0.875rem; min-width: 0; flex: 1 1 380px; }

.pulse {
    position: relative;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--gray-400);
    flex: none;
}
.pulse.on { background: var(--success); }
.pulse.on::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px solid var(--success);
    animation: ripple 1.8s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
@keyframes ripple {
    0%   { transform: scale(0.6); opacity: 0.9; }
    100% { transform: scale(1.9); opacity: 0; }
}

.statusbar-text { min-width: 0; }
.statusbar-text .state {
    font-size: var(--fs-2xl);
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.1;
    color: var(--gray-900);
    white-space: nowrap;
}
.statusbar-text .state.idle { color: var(--gray-500); }
.statusbar-text .detail {
    font-size: var(--fs-sm);
    color: var(--gray-600);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.statusbar-metrics { display: flex; align-items: stretch; gap: 0; margin-left: auto; }
.metric { padding: 0 1.375rem; border-left: 1px solid var(--gray-200); }
.metric:first-child { border-left: none; }
.metric dt {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
    color: var(--gray-500);
    margin: 0 0 3px;
    white-space: nowrap;
}
.metric dd {
    margin: 0;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.1;
}
.metric dd.good { color: var(--success); }
.metric dd.bad  { color: var(--danger); }
.metric dd small { font-size: var(--fs-sm); color: var(--gray-500); font-weight: 600; }

/* ---------- Painéis ---------- */

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.panel + .panel { margin-top: 1.25rem; }

.panel-head {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1.125rem 1.375rem;
    border-bottom: 1px solid var(--gray-100);
}
.panel-head h2 {
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 0;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.panel-head svg { color: var(--gray-500); flex: none; }
.panel-head .head-aside { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.panel-body { padding: 1.375rem; min-width: 0; }
.panel-body.flush { padding: 0; }

.panel-note {
    color: var(--gray-600);
    font-size: var(--fs-sm);
    line-height: 1.55;
    margin: 0 0 1.25rem;
    max-width: 72ch;
}

/* ---------- Herói: monitor ao vivo + log ---------- */

.hero {
    display: grid;
    grid-template-columns: 1.75fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    align-items: stretch;
}
.hero > .panel { margin-top: 0; }

/* O monitor manda na altura da linha; o log se ajusta a ela. */
.hero .monitor-body { flex: none; }

.monitor-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0B1020;
    border-radius: var(--r-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.monitor-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.monitor-frame img[hidden] { display: none; }

.monitor-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    color: #6E7A96;
    text-align: center;
    padding: 1.5rem;
}
.monitor-empty strong { color: #C3CCE4; font-size: var(--fs-base); font-weight: 700; }
.monitor-empty span { font-size: var(--fs-sm); max-width: 34ch; line-height: 1.5; }

.monitor-overlay {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(to top, rgba(8, 12, 26, 0.92), rgba(8, 12, 26, 0));
    color: #EAEEF9;
    font-size: var(--fs-sm);
    font-weight: 600;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.monitor-overlay.show { transform: translateY(0); }
.monitor-overlay .badge-live {
    font-size: var(--fs-xs);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--danger);
    color: #fff;
    padding: 3px 8px;
    border-radius: var(--r-sm);
    flex: none;
}
.monitor-overlay .step {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Log tipado ---------- */

/* O log é posicionado de forma absoluta para que a quantidade de linhas
   nunca dite a altura da linha do herói — quem manda é o monitor 16:9. */
.log-body { flex: 1; min-height: 240px; position: relative; }

.logview {
    position: absolute;
    inset: 0.75rem;
    background: #0B1020;
    border-radius: var(--r-md);
    padding: 0.875rem 0;
    overflow-y: auto;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: var(--fs-sm);
    line-height: 1.55;
    scrollbar-width: thin;
    scrollbar-color: #2A3452 transparent;
}
.logview::-webkit-scrollbar { width: 10px; }
.logview::-webkit-scrollbar-thumb { background: #2A3452; border-radius: 999px; border: 3px solid #0B1020; }

.log-line {
    display: flex;
    gap: 0.5rem;
    padding: 2px 1rem 2px 0.875rem;
    border-left: 2px solid transparent;
    color: #C3CCE4;
    white-space: pre-wrap;
    word-break: break-word;
}
.log-line .glyph { flex: none; width: 1.2em; text-align: center; opacity: 0.95; }
.log-line.is-step    { color: #A9B5D1; }
.log-line.is-ok      { color: #5EE39B; border-left-color: rgba(94, 227, 155, 0.45); }
.log-line.is-warn    { color: #FFC96B; border-left-color: rgba(255, 201, 107, 0.45); }
.log-line.is-error   { color: #FF8F7A; border-left-color: var(--danger); background: rgba(196, 50, 10, 0.10); font-weight: 600; }
.log-line.is-start   { color: #EAEEF9; font-weight: 700; }

.log-trace {
    margin: 0.375rem 0.875rem;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.07);
}
.log-trace > summary {
    cursor: pointer;
    list-style: none;
    padding: 0.375rem 0.75rem;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #8B97B5;
}
.log-trace > summary::-webkit-details-marker { display: none; }
.log-trace > summary::before { content: '▸ '; }
.log-trace[open] > summary::before { content: '▾ '; }
.log-trace > summary:hover { color: #C3CCE4; }
.log-trace pre {
    margin: 0;
    padding: 0 0.75rem 0.625rem;
    color: #7C88A6;
    font-size: var(--fs-xs);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-empty { padding: 1.5rem 1rem; color: #6E7A96; text-align: center; font-size: var(--fs-sm); }

/* ---------- Progresso do lote ---------- */

.batch-box {
    border: 1px solid var(--blue-100);
    background: var(--blue-50);
    border-radius: var(--r-md);
    padding: 1rem 1.125rem;
}
.batch-box .row {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 0.5rem;
}
.batch-box .phase { font-weight: 800; color: var(--blue-dark); font-size: var(--fs-base); }
.batch-box .counts { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: var(--fs-sm); color: var(--gray-700); font-weight: 600; }
.batch-track { height: 6px; border-radius: 999px; background: rgba(27, 13, 174, 0.14); margin: 0.75rem 0 0.5rem; overflow: hidden; }
.batch-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 999px;
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.batch-box .msg { margin: 0; color: var(--gray-600); font-size: var(--fs-sm); }

/* ---------- Ritmo de produção (sparkline) ---------- */

.ritmo {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.75rem;
    align-items: center;
}

.ritmo-hero { min-width: 0; }
.ritmo-hero .valor {
    font-size: var(--fs-2xl);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--blue);
    white-space: nowrap;
}
.ritmo-hero .rotulo {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
    color: var(--gray-500);
    margin-top: 5px;
    max-width: 14ch;
    line-height: 1.35;
}

.ritmo-plot { position: relative; min-width: 0; }
.ritmo-plot svg { display: block; width: 100%; height: 64px; overflow: visible; }

.ritmo-legenda {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    font-size: var(--fs-xs);
    color: var(--gray-500);
    font-weight: 600;
}
.ritmo-legenda b {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    color: var(--gray-800);
    font-weight: 700;
}

.ritmo-tip {
    position: absolute;
    pointer-events: none;
    background: var(--gray-900);
    color: #fff;
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    white-space: nowrap;
    transform: translate(-50%, -130%);
    opacity: 0;
    transition: opacity 0.12s;
    z-index: 2;
}
.ritmo-tip.show { opacity: 1; }

.ritmo-vazio { color: var(--gray-500); font-size: var(--fs-sm); }

@media (max-width: 640px) {
    .ritmo { grid-template-columns: 1fr; gap: 1rem; }
    .ritmo-hero .rotulo { max-width: none; }
}

/* ---------- Botões ---------- */

.btn {
    font-family: inherit;
    font-weight: 600;
    font-size: var(--fs-sm);
    padding: 0.625rem 0.875rem;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    text-decoration: none;
    width: 100%;
    text-align: left;
}
.btn:active { transform: translateY(1px); }
.btn svg { flex: none; }

.btn-primary { background-color: var(--blue-50); color: var(--blue); }
.btn-primary:hover { background-color: var(--blue-100); }

.btn-ghost { background-color: transparent; color: var(--gray-700); }
.btn-ghost:hover { background-color: var(--gray-100); color: var(--blue); }

.btn-danger { background-color: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background-color: #FECDCA; }

.btn-warning,
.btn-solid {
    background-color: var(--blue);
    color: #fff;
    width: auto;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}
.btn-warning:hover, .btn-solid:hover { background-color: var(--blue-dark); }

.btn-outline {
    background: var(--white);
    color: var(--gray-700);
    border-color: var(--gray-200);
    width: auto;
    justify-content: center;
}
.btn-outline:hover { border-color: var(--gray-300); background: var(--gray-50); }

.btn-icon { width: auto; padding: 0.5rem; justify-content: center; }

/* ---------- Formulários ---------- */

.form-control {
    padding: 0.5625rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: var(--fs-sm);
    color: var(--gray-900);
    background: var(--white);
    outline: none;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(27, 13, 174, 0.10);
}
.form-control::placeholder { color: var(--gray-500); }

.field { display: flex; flex-direction: column; gap: 0.3125rem; min-width: 0; }
.field > label {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--gray-600);
}
.field .hint { font-size: var(--fs-xs); color: var(--gray-500); font-weight: 500; text-transform: none; letter-spacing: 0; }

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.875rem 1rem;
    align-items: end;
}
.field-grid .span-2 { grid-column: span 2; }

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex-wrap: wrap;
    margin-top: 1.125rem;
    padding-top: 1.125rem;
    border-top: 1px solid var(--gray-100);
}
.form-actions .spacer { margin-left: auto; }

.check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    white-space: nowrap;
}
.check input { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }

.chip-set { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.chip-set .chip-label {
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
    margin-right: 0.125rem;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--gray-700);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    padding: 0.3125rem 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--gray-300); }
.chip input { width: 14px; height: 14px; accent-color: var(--blue); cursor: pointer; }
.chip:has(input:checked) { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue); }

.preview-line {
    color: var(--blue);
    font-size: var(--fs-sm);
    font-weight: 700;
    margin: 0.875rem 0 0;
    min-height: 1.3em;
}

/* ---------- Tabelas ---------- */

/* Rola nos dois eixos dentro do próprio painel: a página nunca rola na horizontal. */
.table-scroll { max-height: 336px; max-width: 100%; overflow: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    padding: 0.625rem 1.375rem;
    font-weight: 700;
    font-size: var(--fs-xs);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
td {
    padding: 0.6875rem 1.375rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-800);
    font-size: var(--fs-sm);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }
.cell-empty { text-align: center; color: var(--gray-500); padding: 2rem 1rem; }
.num { text-align: right; }

.mono-text {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: var(--fs-sm);
    font-variant-numeric: tabular-nums;
}
.cell-name { font-weight: 700; color: var(--gray-900); }
.cell-code { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-weight: 700; color: var(--blue); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
}
.badge-ok      { background: var(--success-bg); color: var(--success); border-color: rgba(19, 115, 51, 0.20); }
.badge-error   { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(196, 50, 10, 0.20); }
.badge-running { background: var(--blue-50);    color: var(--blue);    border-color: var(--blue-100); }
.badge-neutral { background: var(--gray-100);   color: var(--gray-600); border-color: var(--gray-200); }

.filter-input {
    width: 180px;
    padding: 0.375rem 0.625rem;
    font-size: var(--fs-sm);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-md);
    font-family: inherit;
    color: var(--gray-900);
    outline: none;
}
.filter-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(27, 13, 174, 0.10); }
.row-count { font-size: var(--fs-xs); font-weight: 700; color: var(--gray-500); white-space: nowrap; }

/* ---------- Status pill do cabeçalho ---------- */

.status-indicator {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: var(--white); padding: 0.4375rem 0.875rem; border-radius: 999px;
    border: 1px solid var(--gray-200); font-weight: 700; font-size: var(--fs-sm);
    color: var(--gray-700);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background-color: var(--gray-400); flex: none; }
.dot.running { background-color: var(--success); box-shadow: 0 0 0 3px rgba(19, 115, 51, 0.18); }

/* ---------- Spotlight / modais ---------- */

.spotlight-overlay {
    position: fixed; inset: 0;
    background: rgba(16, 24, 40, 0.45);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex; justify-content: center; padding: 12vh 1rem 1rem;
    opacity: 0; pointer-events: none;
    transition: opacity 0.18s;
    overflow-y: auto;
}
.spotlight-overlay.active { opacity: 1; pointer-events: auto; }
.spotlight-modal {
    background: var(--white); width: 100%; max-width: 600px; height: max-content;
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--gray-200);
    overflow: hidden;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.spotlight-overlay.active .spotlight-modal { transform: translateY(0) scale(1); }
.spotlight-input {
    width: 100%; padding: 1.25rem 1.5rem; font-size: var(--fs-lg);
    background: transparent; border: none; color: var(--gray-900);
    font-family: inherit; outline: none; border-bottom: 1px solid var(--gray-200); font-weight: 600;
}
.spotlight-results { max-height: 320px; overflow-y: auto; }
.spotlight-item {
    padding: 0.875rem 1.5rem; cursor: pointer; font-weight: 600; font-size: var(--fs-base);
    display: flex; justify-content: space-between; align-items: center;
    color: var(--gray-700); transition: background-color 0.1s;
}
.spotlight-item:hover, .spotlight-item.selected { background: var(--blue-50); color: var(--blue); }

.modal-title { margin: 0 0 0.25rem; font-size: var(--fs-lg); font-weight: 800; color: var(--gray-900); letter-spacing: -0.015em; }
.modal-sub { color: var(--gray-600); font-size: var(--fs-sm); margin: 0 0 1.5rem; }
.modal-sub strong { color: var(--blue); }

.kbd-hint {
    font-size: var(--fs-xs); background: var(--gray-100); padding: 3px 7px; border-radius: var(--r-sm);
    color: var(--gray-600); font-family: 'IBM Plex Mono', ui-monospace, monospace; border: 1px solid var(--gray-200);
    font-weight: 600;
}

/* ============================================================
   LOGIN
   ============================================================ */

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }

/* Lado da marca */
.login-brand {
    position: relative;
    background: var(--blue-dark);
    color: #fff;
    padding: 3.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}
.login-brand::before {
    /* Malha discreta: a tela que o robô observa, reduzida a um gesto. */
    content: '';
    position: absolute;
    inset: -20%;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(ellipse 70% 60% at 70% 35%, #000 0%, transparent 72%);
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 70% 35%, #000 0%, transparent 72%);
}
.login-brand > * { position: relative; }

.login-brand-top { display: flex; align-items: center; gap: 0.875rem; }
.login-brand-top img { height: 38px; filter: brightness(0) invert(1); }
.login-brand-top strong {
    font-size: var(--fs-lg);
    font-weight: 800;
    letter-spacing: -0.015em;
    line-height: 1.2;
    white-space: nowrap;
}
/* Nome do produto numa linha só: "CSC - Scraplet". */
.login-brand-top strong span {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.66);
}

.login-hero { display: flex; flex-direction: column; gap: 2.25rem; }

.login-robo {
    display: block;
    width: 100%;
    max-width: 460px;
    height: auto;
    /* Sai do padding à direita: o robô encosta na borda e ganha escala. */
    margin-right: -3.5rem;
    align-self: flex-end;
}

/* Telas baixas: a ilustração é a primeira a ceder espaço. */
@media (max-height: 720px) {
    .login-robo { display: none; }
}

.login-pitch h2 {
    font-size: 2.5rem;
    line-height: 1.08;
    letter-spacing: -0.035em;
    font-weight: 800;
    margin: 0 0 1rem;
    max-width: 15ch;
    text-wrap: balance;
}
.login-pitch p {
    margin: 0;
    font-size: var(--fs-base);
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.72);
    max-width: 46ch;
}

.login-facts { display: flex; gap: 2.25rem; flex-wrap: wrap; }
.login-facts div { min-width: 0; }
.login-facts dt {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
}
.login-facts dd {
    margin: 0;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: var(--fs-base);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
}

/* Lado do formulário */
.login-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    background: var(--white);
}
.login-form { width: 100%; max-width: 372px; }

.login-mobile-brand { display: none; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.login-mobile-brand img { height: 34px; }
.login-mobile-brand strong { font-size: var(--fs-base); font-weight: 800; color: var(--blue-dark); }

.login-form h1 {
    font-size: var(--fs-xl);
    font-weight: 800;
    letter-spacing: -0.025em;
    margin: 0 0 0.375rem;
    color: var(--gray-900);
}
.login-form > p {
    margin: 0 0 2rem;
    color: var(--gray-600);
    font-size: var(--fs-sm);
    line-height: 1.55;
}

.login-field { margin-bottom: 1.125rem; }
.login-field label {
    display: block;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray-600);
    margin-bottom: 0.375rem;
}
.login-field .form-control { padding: 0.6875rem 0.875rem; font-size: var(--fs-base); }

.login-senha { position: relative; }
.login-senha .form-control { padding-right: 3.25rem; }
.login-senha button {
    position: absolute;
    top: 50%;
    right: 0.375rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem 0.5rem;
    border-radius: var(--r-sm);
    color: var(--gray-500);
    font-family: inherit;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.login-senha button:hover { color: var(--blue); background: var(--blue-50); }

.login-erro {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    background: var(--danger-bg);
    border: 1px solid rgba(196, 50, 10, 0.22);
    color: var(--danger);
    padding: 0.75rem 0.875rem;
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.45;
    margin-bottom: 1.25rem;
}
.login-erro svg { flex: none; margin-top: 1px; }

.login-aviso {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--warning);
}
.login-aviso.show { display: flex; }

.login-submit {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem;
    font-size: var(--fs-base);
    margin-top: 0.5rem;
}
.login-submit[aria-busy="true"] { opacity: 0.72; pointer-events: none; }

.login-rodape {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--gray-100);
    font-size: var(--fs-xs);
    color: var(--gray-500);
    line-height: 1.6;
}
.login-rodape strong { color: var(--gray-700); font-weight: 700; }

@media (max-width: 1320px) {
    .login-brand { padding: 2.75rem; }
    .login-robo { max-width: 372px; margin-right: -2.75rem; }
    .login-hero { gap: 1.75rem; }
    .login-pitch h2 { font-size: 2.05rem; }
    .login-facts { gap: 1.5rem; }
    .login-facts dd { font-size: var(--fs-sm); }
}

@media (max-width: 900px) {
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .login-mobile-brand { display: flex; }
    .login-form-side { align-items: flex-start; padding: 3rem 1.5rem; background: var(--gray-50); }
    .login-form {
        background: var(--white);
        border: 1px solid var(--glass-border);
        border-radius: var(--r-lg);
        box-shadow: var(--shadow-sm);
        padding: 1.75rem 1.5rem;
        max-width: 420px;
        margin: 0 auto;
    }
}

/* ---------- Entrada suave ---------- */

.stagger-item { animation: staggerFadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both; }
.stagger-1 { animation-delay: 0.02s; }
.stagger-2 { animation-delay: 0.08s; }
.stagger-3 { animation-delay: 0.14s; }
@keyframes staggerFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Modo TV (parede da operação) ---------- */

.tv-mode-active .sidebar,
.tv-mode-active .header-top,
.tv-mode-active .tabs,
.tv-mode-active #panel-config { display: none; }
.tv-mode-active .app-container { display: block; }
.tv-mode-active .main-content {
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}
.tv-mode-active .statusbar { margin-bottom: 0; }
.tv-mode-active .statusbar-text .state { font-size: 2.75rem; }
.tv-mode-active .hero { flex: 1; min-height: 0; margin-bottom: 0; }
.tv-mode-active .hero > .panel { min-height: 0; }
.tv-mode-active .monitor-frame { aspect-ratio: auto; height: 100%; }
.tv-mode-active #op-tables { display: none; }

/* ---------- Responsivo ---------- */

@media (max-width: 1180px) {
    .hero { grid-template-columns: 1fr; }
    .log-body { min-height: 300px; }
    .main-content { padding: 1.5rem 1.75rem 2.5rem; }
}

@media (max-width: 900px) {
    .sidebar {
        position: sticky;
        top: 0;
        width: 100%;
        flex: none;
        height: auto;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.625rem 1rem;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }
    .app-container { flex-direction: column; }
    .sidebar-logo { margin: 0 auto 0 0; gap: 0.5rem; }
    .sidebar-logo img { height: 28px; }
    .sidebar h3 { display: none; }
    .nav-group { flex-direction: row; flex-wrap: wrap; gap: 0.5rem; }
    .nav-group .btn { width: auto; }
    .nav-foot { margin-top: 0; padding-top: 0; }
    .sidebar .nav-search { display: none; }
    .user-chip { margin-top: 0; padding: 0.375rem 0.625rem; background: none; border: none; }
    .user-chip .user-meta span { display: none; }
    .main-content { padding: 1.25rem 1.25rem 2.5rem; }
    .statusbar-metrics { margin-left: 0; width: 100%; padding-top: 1rem; border-top: 1px solid var(--gray-200); }
    .metric:first-child { padding-left: 0; }

    /* No celular a navegação vira gaveta: só o essencial fica na barra.
       Antes, "Gravar Robô" + "Sair" + o chip de usuário empilhavam ~500px
       antes de qualquer conteúdo — metade da tela gasta em menu. */
    .nav-group .so-master,
    .nav-group #logout-link,
    .user-chip { display: none !important; }
    .sidebar > .nav-menu-btn { display: inline-flex; }
    .sidebar.aberta .nav-group .so-master,
    .sidebar.aberta .nav-group #logout-link,
    .sidebar.aberta .user-chip { display: inline-flex !important; }
    .sidebar.aberta { flex-wrap: wrap; }

    /* O botão da gaveta é filho direto da .sidebar (não está num .nav-group),
       então não pegava o `width: auto` e esticava a linha inteira. */
    .sidebar > .nav-menu-btn { width: auto; flex: 0 0 auto; }

    /* Alvos de toque: mínimo 44px (Apple HIG / Material). Estavam em 35–39. */
    .btn, .form-control, .filter-input, .tab { min-height: 44px; }
    .btn-icon { min-width: 44px; }
    .check input, .chip input { width: 20px; height: 20px; }
    .check { min-height: 44px; }
}

@media (max-width: 640px) {
    .header-top h2 { font-size: 1.25rem; }
    .statusbar-text .state { font-size: 1.5rem; white-space: normal; }

    /* Métricas em grade 2×N em vez de empilhadas: cinco linhas de ~100px
       viravam meia tela de rolagem antes de chegar no monitor. */
    .statusbar-metrics {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.875rem 0;
    }
    .metric { padding: 0 0.75rem; border-left: 1px solid var(--gray-200); }
    .metric:nth-child(odd) { padding-left: 0; border-left: none; }
    .metric dd { font-size: 1.125rem; }
    .tabs { overflow-x: auto; }
    .panel-head, .panel-body { padding-left: 1rem; padding-right: 1rem; }
    thead th, td { padding-left: 1rem; padding-right: 1rem; }
    .field-grid { grid-template-columns: 1fr; }
    .field-grid .span-2 { grid-column: span 1; }
    .btn-warning, .btn-solid, .btn-outline { width: 100%; }
    .form-actions .spacer { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

@media print {
    .sidebar, .ambient-background, .btn, .spotlight-overlay, .tabs { display: none !important; }
    body, .main-content { background: #fff !important; color: #000 !important; margin: 0; padding: 0; }
    .panel { border: 1px solid #ccc !important; box-shadow: none !important; page-break-inside: avoid; }
    .logview { background: #f4f4f4 !important; }
    .log-line { color: #000 !important; }
    .app-container { display: block; }
    .tab-panel[hidden] { display: block !important; }
    .table-scroll { max-height: none; overflow: visible; }
}
