/* ============================================================
   LPS Dashboard — Dark default + Light theme (LPS branded)
   ============================================================ */

:root {
  /* Dark mode (default) */
  --bg: #07070b;
  --bg-subtle: #0d0d14;
  --bg-card: #11111a;
  --bg-elevated: #161622;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.10);
  --accent: #34d399;
  --accent-strong: #2bbb89;
  --accent-glow: rgba(52, 211, 153, 0.18);
  --violet: #a78bfa;
  --violet-glow: rgba(167, 139, 250, 0.18);
  --sky: #60a5fa;
  --sky-glow: rgba(96, 165, 250, 0.18);
  --amber: #fbbf24;
  --amber-glow: rgba(251, 191, 36, 0.18);
  --teal-glow: rgba(45, 212, 191, 0.18);
  --emerald-glow: rgba(16, 185, 129, 0.18);
  --text: #e6e6ef;
  --text-muted: rgba(255, 255, 255, 0.55);
  --text-dim: rgba(255, 255, 255, 0.35);
  --danger: #f87171;
  --warning: #fbbf24;
  --logo-filter: brightness(0) invert(1);
  --header-bg: rgba(7, 7, 11, 0.75);
  --grid-line: rgba(255, 255, 255, 0.04);
  --grid-bg-1: rgba(255, 255, 255, 0.03);
  --shadow-card: 0 0 0 1px rgba(255,255,255,0.02), 0 24px 48px -24px rgba(0,0,0,0.6);
}

/* Light mode — LPS branded (azul, branco, cinza) */
body[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-subtle: #ffffff;
  --bg-card: #ffffff;
  --bg-elevated: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  /* LPS blue — extraído do logo */
  --accent: #3344B5;
  --accent-strong: #28369a;
  --accent-glow: rgba(51, 68, 181, 0.10);
  --violet: #6366f1;
  --violet-glow: rgba(99, 102, 241, 0.10);
  --sky: #0284c7;
  --sky-glow: rgba(2, 132, 199, 0.10);
  --amber: #d97706;
  --amber-glow: rgba(217, 119, 6, 0.10);
  --teal-glow: rgba(20, 184, 166, 0.10);
  --emerald-glow: rgba(16, 185, 129, 0.10);
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --danger: #dc2626;
  --warning: #d97706;
  --logo-filter: none;
  --header-bg: rgba(255, 255, 255, 0.85);
  --grid-line: rgba(15, 23, 42, 0.06);
  --grid-bg-1: rgba(15, 23, 42, 0.025);
  --shadow-card: 0 1px 3px rgba(15,23,42,0.06), 0 4px 16px -4px rgba(15,23,42,0.08);
}

/* ── Base ──────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased; line-height: 1.55;
  transition: background 0.25s ease, color 0.25s ease;
}
html { overflow-x: hidden; }
body { min-height: 100vh; position: relative; overflow-x: hidden; }

body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background-image:
    linear-gradient(var(--grid-bg-1) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-bg-1) 1px, transparent 1px);
  background-size: 48px 48px; opacity: 0.5;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(ellipse at top, var(--accent-glow), transparent 60%);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── Components ────────────────────────────── */
.card {
  border-radius: 16px; border: 1px solid var(--border);
  background: var(--bg-card); backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.input {
  width: 100%; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-subtle); padding: 10px 14px; color: var(--text);
  font-size: 14px; outline: none; transition: all 0.2s;
}
.input::placeholder { color: var(--text-dim); }
.input:focus {
  border-color: var(--accent); background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; padding: 11px 16px; border-radius: 12px;
  font-weight: 600; font-size: 14px; transition: all 0.2s; width: 100%;
}
body[data-theme="light"] .btn-primary { color: #ffffff; }
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 0 24px var(--accent-glow); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted);
  padding: 9px 14px; border-radius: 10px; font-size: 13px; transition: all 0.2s;
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text); }
.icon-btn {
  display: grid; place-items: center; height: 36px; width: 36px;
  border: 1px solid var(--border); background: var(--bg-card); border-radius: 10px;
  color: var(--text-muted); transition: all 0.2s;
}
.icon-btn:hover { background: var(--bg-elevated); color: var(--text); border-color: var(--border-strong); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-subtle);
  padding: 2px 10px; font-size: 11px; font-weight: 500;
}
.pill-accent { border-color: rgba(52,211,153,0.3); background: rgba(52,211,153,0.1); color: var(--accent); }
body[data-theme="light"] .pill-accent { border-color: rgba(51,68,181,0.25); background: rgba(51,68,181,0.08); color: var(--accent); }
.pill-warn { border-color: rgba(251,191,36,0.3); background: rgba(251,191,36,0.1); color: var(--warning); }
.pill-danger { border-color: rgba(248,113,113,0.3); background: rgba(248,113,113,0.1); color: var(--danger); }

.stat-label { font-size: 11px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); }
.stat-value { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Tooltips simples (info icons) ─────────── */
.info-tip { position: relative; display: inline-flex; align-items: center; cursor: help; margin-left: 4px; }
.info-tip svg { width: 12px; height: 12px; color: var(--text-dim); }
.info-tip:hover svg { color: var(--accent); }
.info-tip[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border-strong); padding: 8px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none;
  white-space: normal; width: max-content; max-width: 240px; line-height: 1.4;
  opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 100;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.4);
}
.info-tip:hover::after { opacity: 1; }

/* ── Layout login ─────────────────────────── */
.login-page { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
@media (max-width: 900px) { .login-page { grid-template-columns: 1fr; } .login-page .brand-pane { display: none; } }
.brand-pane { padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.brand-pane::before {
  content: ""; position: absolute; top: -120px; left: -120px; height: 380px; width: 380px;
  border-radius: 50%; background: var(--accent-glow); filter: blur(80px);
}
.brand-pane::after {
  content: ""; position: absolute; bottom: -80px; right: -80px; height: 380px; width: 380px;
  border-radius: 50%; background: var(--violet-glow); filter: blur(80px);
}
.brand-pane > * { position: relative; }
.brand-hero h1 { font-size: 44px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; }
.brand-hero h1 .accent {
  background: linear-gradient(90deg, var(--accent), var(--sky));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-hero p { margin-top: 14px; max-width: 380px; color: var(--text-muted); font-size: 15px; }
.features { margin-top: 30px; display: grid; gap: 10px; max-width: 380px; }
.feature { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-muted); }
.feature-icon { display: grid; place-items: center; height: 34px; width: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-card); }
.feature-icon svg { width: 16px; height: 16px; stroke: var(--accent); fill: none; stroke-width: 2; }
.brand-footer { font-size: 11px; color: var(--text-dim); }

.brand-mark { display: flex; align-items: center; gap: 12px; }
.brand-mark img { height: 36px; width: auto; filter: var(--logo-filter); transition: filter 0.25s; }
.brand-mark-text { font-weight: 600; letter-spacing: -0.01em; font-size: 16px; }

.login-form-pane { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-form { width: 100%; max-width: 360px; }
.login-form h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.login-form > p { margin-top: 6px; color: var(--text-muted); font-size: 14px; }
.form-fields { margin-top: 28px; display: grid; gap: 14px; }
.field-group { display: grid; gap: 6px; }
.field-label { font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }
.error-box {
  border-radius: 10px; background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.2);
  padding: 10px 12px; font-size: 13px; color: #fca5a5;
}
body[data-theme="light"] .error-box { color: #b91c1c; }

/* ── Dashboard ────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--border);
  background: var(--header-bg); backdrop-filter: blur(20px);
  transition: background 0.25s, border-color 0.25s;
}
.app-header-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 20px;
  height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.header-brand { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0; }
.header-brand img { height: 28px; width: auto; filter: var(--logo-filter); transition: filter 0.25s; flex-shrink: 0; }
.header-brand-text { font-size: 14px; font-weight: 600; }
.header-brand-sub { display: block; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); margin-top: 1px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  border: 1px solid var(--border); background: var(--bg-card); border-radius: 8px;
}
.user-chip .dot {
  height: 8px; width: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.user-chip .email { font-size: 12px; color: var(--text-muted); }

@media (max-width: 640px) {
  .user-chip { display: none !important; }
  .app-header-inner { padding: 0 14px; height: 56px; }
  .header-brand img { height: 24px; }
  .header-brand-text { font-size: 13px; }
}

.app-main { max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; }
@media (max-width: 640px) { .app-main { padding: 20px 14px 40px; } }

/* Hero */
.hero-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.hero-row h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.hero-sub { margin-top: 4px; font-size: 14px; color: var(--text-muted); }
@media (max-width: 640px) {
  .hero-row h1 { font-size: 22px; }
  .hero-sub { font-size: 13px; }
}

/* Section heads (with subtitle) */
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-top: 32px; margin-bottom: 12px; gap: 10px; flex-wrap: wrap;
}
.section-head .head-title h2 { margin-top: 3px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.section-head .head-title .section-desc { margin-top: 4px; font-size: 12px; color: var(--text-muted); max-width: 540px; line-height: 1.5; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { height: 8px; width: 8px; border-radius: 50%; }
.legend .ok { background: var(--accent); }
.legend .err { background: var(--danger); }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1024px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .kpi-grid { grid-template-columns: 1fr; gap: 10px; } }
.kpi-card { position: relative; overflow: hidden; padding: 20px; transition: all 0.2s; }
.kpi-card:hover { border-color: var(--border-strong); }
.kpi-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; }
.kpi-card.accent::before  { background: linear-gradient(135deg, var(--accent-glow), transparent 60%); }
.kpi-card.violet::before  { background: linear-gradient(135deg, var(--violet-glow), transparent 60%); }
.kpi-card.sky::before     { background: linear-gradient(135deg, var(--sky-glow), transparent 60%); }
.kpi-card.amber::before   { background: linear-gradient(135deg, var(--amber-glow), transparent 60%); }
.kpi-card.teal::before    { background: linear-gradient(135deg, var(--teal-glow), transparent 60%); }
.kpi-card.emerald::before { background: linear-gradient(135deg, var(--emerald-glow), transparent 60%); }
.kpi-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; position: relative; }
.kpi-card-top > div:first-child { min-width: 0; flex: 1; }
.kpi-card-icon {
  display: grid; place-items: center; height: 36px; width: 36px;
  border: 1px solid var(--border); background: var(--bg-subtle); border-radius: 10px;
  color: var(--text-muted); flex-shrink: 0;
}
.kpi-card-icon svg { width: 15px; height: 15px; stroke-width: 2; fill: none; stroke: currentColor; }
.kpi-hint { font-size: 11px; color: var(--text-dim); margin-top: 6px; line-height: 1.4; }

/* Comparison grid */
.comparison-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1024px) { .comparison-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .comparison-grid { grid-template-columns: 1fr; } }
.comparison-card { padding: 18px; }
.comparison-row { display: flex; align-items: baseline; gap: 12px; margin-top: 6px; }
.comparison-row .stat-value { font-size: 26px; }
.comparison-hint { margin-top: 6px; font-size: 11px; color: var(--text-dim); line-height: 1.4; }
.delta { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.delta.up { color: var(--accent); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--text-muted); }

/* Charts grid */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-card { padding: 22px; }
@media (max-width: 640px) { .chart-card { padding: 16px; } }
.chart { width: 100%; height: 220px; position: relative; }

/* Heatmap */
.heatmap-wrap { overflow-x: auto; margin: -4px; padding: 4px; }
.heatmap-table { border-collapse: separate; border-spacing: 3px; margin: 0 auto; min-width: 100%; }
.heatmap-table th { font-size: 9px; font-weight: 500; color: var(--text-dim); padding: 2px 4px; text-align: center; }
.heatmap-table td.day-label {
  font-size: 11px; color: var(--text-muted); text-align: right;
  padding-right: 8px; font-weight: 500; position: sticky; left: 0;
  background: var(--bg-card); z-index: 2;
}
.heatmap-cell {
  width: 20px; height: 20px; border-radius: 4px;
  background: var(--bg-elevated);
  transition: transform 0.15s; cursor: default; position: relative;
}
.heatmap-cell:hover { transform: scale(1.4); z-index: 2; }
.heatmap-cell[data-count]:hover::after {
  content: attr(data-tooltip); position: absolute; bottom: 130%; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  padding: 4px 8px; border-radius: 6px; color: var(--text);
  font-size: 11px; white-space: nowrap; pointer-events: none; z-index: 3;
}
@media (max-width: 640px) {
  .heatmap-cell { width: 16px; height: 16px; }
  .heatmap-table th { font-size: 8px; }
}

/* Donut */
.donut-legend-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.donut-legend-item:last-child { border-bottom: none; }
.donut-legend-label { display: inline-flex; align-items: center; gap: 8px; }
.donut-legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend-value { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.donut-legend-pct { color: var(--text-dim); font-size: 11px; margin-left: 6px; }

/* Tables */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 460px; }
.data-table th {
  text-align: left; padding: 12px 16px; font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim);
  border-bottom: 1px solid var(--border); background: var(--bg-subtle);
}
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-elevated); }
.data-table td.t-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.data-table .status-pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  font-weight: 500; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.data-table td.empty { color: var(--text-dim); text-align: center; padding: 40px 16px; font-style: italic; }

/* Mobile: stack table rows as cards (sem horizontal scroll) */
@media (max-width: 640px) {
  .table-scroll { overflow-x: visible; }
  .data-table { min-width: 0; font-size: 13px; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr { display: block; width: 100%; }
  .data-table tr {
    padding: 14px 14px;
    border-bottom: 1px solid var(--border);
  }
  .data-table tr:last-child { border-bottom: none; }
  .data-table td {
    display: block; padding: 0; border: none;
    white-space: normal; word-break: break-word;
  }
  /* 1ª célula (data) — pequena, em cima */
  .data-table tr td:first-child {
    font-size: 11px; color: var(--text-dim); margin-bottom: 6px;
    font-weight: 500; letter-spacing: 0.04em;
  }
  /* Status pill + duração — inline na linha de baixo */
  .data-table tr td:nth-child(3),
  .data-table tr td:nth-child(4) {
    display: inline-block;
    margin-top: 10px; margin-right: 12px;
    text-align: left !important;
    vertical-align: middle;
  }
  .data-table tr td:nth-child(4) {
    font-size: 11px; color: var(--text-dim);
  }
  .data-table td.empty { display: block !important; }
  .data-table tr:hover td { background: transparent; }
  .data-table tr:active { background: var(--bg-elevated); }
}

/* Workflow cards */
.workflow-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 4px; }
@media (max-width: 900px) { .workflow-grid { grid-template-columns: 1fr; } }
.wf-card { padding: 20px; transition: all 0.2s; }
.wf-card:hover { border-color: var(--border-strong); }
.wf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.wf-name { font-size: 14px; font-weight: 600; }
.wf-meta { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.wf-metrics { margin-top: 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.wf-metric .stat-label { font-size: 10px; }
.wf-metric .stat-value { font-size: 18px; }
.wf-foot {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim); display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: 6px;
}

/* Pulse + flash */
.pulse-dot {
  display: inline-block; height: 6px; width: 6px; border-radius: 50%; background: var(--accent);
  animation: pulse-anim 1.8s ease-in-out infinite;
}
@keyframes pulse-anim { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.85); } }
.pill.flash { animation: pillFlash 1.2s ease-out; }
@keyframes pillFlash {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  100% { box-shadow: 0 0 0 16px transparent; }
}

/* Sparkline */
.sparkline { display: block; margin-top: 12px; width: 100%; height: 32px; }

/* Empty state */
.empty-state { padding: 60px 24px; text-align: center; }
.empty-state h3 { font-size: 18px; font-weight: 600; }
.empty-state p { color: var(--text-muted); margin-top: 6px; font-size: 14px; max-width: 480px; margin-left: auto; margin-right: auto; }

/* Anim helpers */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card), var(--bg-elevated), var(--bg-card));
  background-size: 200% 100%; animation: shimmer 2s linear infinite; border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.4s ease-out both; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
