/* ============================================================================
   Farol de Metas — Design tokens + componentes
   Inspiração: Andon industrial. Sem gradientes, sem sombras suaves.
   ============================================================================ */

:root {
  /* Background / surface */
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-raised: #FAFBFC;

  /* Text */
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-disabled: #94A3B8;

  /* Borders */
  --border: #E4E7EC;
  --border-strong: #CBD5E1;
  --border-subtle: #F1F5F9;

  /* Brand */
  --accent: #0F2847;        /* azul blueprint */
  --accent-hover: #1E40AF;
  --accent-soft: #EEF2F6;

  /* Status (Andon) */
  --status-green: #15803D;
  --status-green-soft: #DCFCE7;
  --status-yellow: #B45309;
  --status-yellow-soft: #FEF3C7;
  --status-red: #B91C1C;
  --status-red-soft: #FEE2E2;
  --status-gray: #94A3B8;
  --status-gray-soft: #F1F5F9;

  /* Spacing (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Radius */
  --radius: 4px;
  --radius-sm: 3px;

  /* Font */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

/* Base ---------------------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button { font-family: inherit; cursor: pointer; }

.mono { font-family: var(--font-mono); letter-spacing: -0.01em; }

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

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

.sidebar {
  width: 240px;
  background: #0F172A;
  color: #E2E8F0;
  padding: 20px 0;
  flex-shrink: 0;
}
.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px 24px;
  border-bottom: 1px solid #1E293B;
}
.sidebar-brand { font-size: 14px; font-weight: 600; color: #FFFFFF; }
.sidebar-section { padding: 20px 0 8px; }
.sidebar-section-title {
  font-size: 10px; color: #64748B; font-weight: 600;
  padding: 0 20px 10px;
  letter-spacing: 0.4px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: #CBD5E1; font-size: 13px; font-weight: 500;
  text-decoration: none;
}
.sidebar-link:hover { color: #FFFFFF; background: #1E293B; }
.sidebar-link.active {
  color: #FFFFFF;
  background: #1E293B;
  border-left: 3px solid var(--status-yellow);
}
.sidebar-footer {
  margin-top: 60px;
  padding: 16px 20px;
  border-top: 1px solid #1E293B;
}

.main { flex: 1; padding: 28px 40px 48px; min-width: 0; }
.main-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.breadcrumb { font-size: 11px; color: var(--text-disabled); margin-bottom: 4px; }
.main-title { margin: 0; font-size: 22px; font-weight: 600; }
.main-subtitle { margin: 6px 0 0; font-size: 13px; color: var(--text-secondary); }

/* Andon logo mark ----------------------------------------------------------- */

.andon-mark {
  display: flex; flex-direction: column; gap: 2px;
  padding: 5px 4px;
  background: #0F172A; border-radius: 3px;
}
.andon-mark .lamp { width: 8px; height: 8px; border-radius: 50%; }
.andon-mark .lamp.green { background: var(--status-green); }
.andon-mark .lamp.yellow { background: var(--status-yellow); }
.andon-mark .lamp.red { background: var(--status-red); }

/* Top header (public dashboard) --------------------------------------------- */

.top-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.top-brand { display: flex; align-items: center; gap: 14px; }
.top-brand-name { font-size: 15px; font-weight: 600; }
.top-brand-sub { font-size: 12px; color: var(--text-secondary); }

.top-nav { display: flex; align-items: center; gap: 28px; }
.top-nav a { font-size: 13px; color: var(--text-secondary); }
.top-nav a.active {
  color: var(--text); font-weight: 500;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}

/* Filter bar ---------------------------------------------------------------- */

.filterbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.filterbar .label {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  margin-right: 4px;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.chip.active { border-color: var(--accent); }
.chip .k { color: var(--text-muted); font-size: 12px; }
.chip .v { font-weight: 500; }

/* Buttons ------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  font-size: 13px; font-weight: 500;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
}
.btn:hover { background: var(--surface-raised); color: var(--text); }
.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}
.btn-primary:hover { background: #0B1F3B; color: #FFFFFF; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 11px 20px; font-size: 14px; }
.btn-block { display: flex; width: 100%; text-align: center; justify-content: center; }

/* Card ---------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-body { padding: 20px; }

/* KPI tile ------------------------------------------------------------------ */

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--status-gray);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.kpi.green { border-left-color: var(--status-green); }
.kpi.yellow { border-left-color: var(--status-yellow); }
.kpi.red { border-left-color: var(--status-red); }

.kpi-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.kpi-value {
  font-size: 38px; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1;
  margin-bottom: 14px;
}
.kpi-value .unit { font-size: 20px; color: var(--text-muted); font-weight: 500; }
.kpi-bar {
  height: 6px; background: var(--border-subtle);
  border-radius: 3px; overflow: hidden;
  margin-bottom: 10px;
}
.kpi-bar-fill { height: 100%; }
.kpi-foot {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-muted);
}
.kpi-delta { font-weight: 500; }

/* Status dot / badge -------------------------------------------------------- */

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot.green { background: var(--status-green); }
.dot.yellow { background: var(--status-yellow); }
.dot.red { background: var(--status-red); }
.dot.gray { background: var(--status-gray); }

.pill {
  display: inline-block;
  padding: 4px 10px;
  font-size: 13px; font-weight: 600;
  border-radius: var(--radius);
}
.pill.green { background: var(--status-green-soft); color: var(--status-green); }
.pill.yellow { background: var(--status-yellow-soft); color: var(--status-yellow); }
.pill.red { background: var(--status-red-soft); color: var(--status-red); }
.pill.gray { background: var(--status-gray-soft); color: var(--status-gray); }

/* Andon table (dashboard) --------------------------------------------------- */

.andon-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.andon-row, .andon-head {
  display: grid;
  grid-template-columns: 24px 220px 1fr 340px 100px;
  align-items: center;
  padding: 14px 20px 14px 0;
}
.andon-head {
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  padding-top: 12px; padding-bottom: 12px;
}
.andon-row { border-bottom: 1px solid var(--border-subtle); }
.andon-row:last-child { border-bottom: none; }

.andon-stripe-wrap { display: flex; justify-content: center; }
.andon-stripe { width: 4px; height: 40px; border-radius: 2px; background: var(--status-gray); }
.andon-stripe.green { background: var(--status-green); }
.andon-stripe.yellow { background: var(--status-yellow); }
.andon-stripe.red { background: var(--status-red); }

.andon-cell-code {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-muted); font-weight: 500;
  margin-bottom: 2px;
}
.andon-cell-name { font-size: 14px; font-weight: 500; }
.andon-cell-op { font-size: 12.5px; color: var(--text-secondary); padding-right: 20px; }

.score-row { display: flex; gap: 14px; }
.score-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 44px;
}
.score-dot { width: 14px; height: 14px; border-radius: 50%; }
.score-pct {
  font-size: 10px; color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Code badge ---------------------------------------------------------------- */

.code-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
}
.code-badge.vago { background: var(--status-gray-soft); color: var(--status-gray); }

/* Level tag (Supervisor / Group Leader / Team Leader) ----------------------- */

.level-tag {
  display: inline-block;
  padding: 2px 7px;
  font-size: 10px; font-weight: 600;
  color: #FFFFFF;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}
.level-tag.gerente { background: #0F172A; }
.level-tag.supervisor { background: #1E293B; }
.level-tag.group-leader { background: #475569; }
.level-tag.team-leader { background: #64748B; }

/* Form ---------------------------------------------------------------------- */

.field { margin-bottom: 20px; }
.field-label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field-label .optional { color: var(--text-disabled); font-weight: 400; }
.field-hint {
  font-size: 11px; color: var(--text-muted);
  margin-top: 4px;
}
.input, .select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); }
.input-readonly {
  background: var(--surface-raised);
  color: var(--text-secondary);
}

/* Avatar -------------------------------------------------------------------- */

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
  background: #DBEAFE; color: #1E40AF;
  flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.gray { background: var(--status-gray-soft); color: var(--status-gray); }

/* Stats strip --------------------------------------------------------------- */

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.stat-card.warn { border-left: 3px solid var(--status-yellow); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 600; }
.stat-value small { font-size: 12px; color: var(--text-disabled); font-weight: 500; }

/* Section header ------------------------------------------------------------ */

.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 18px;
}
.section-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.section-header .meta { font-size: 13px; color: var(--text-secondary); }

/* Legend -------------------------------------------------------------------- */

.legend { display: flex; align-items: center; gap: 18px; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item .dot { width: 8px; height: 8px; }

/* Pagination ---------------------------------------------------------------- */

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px;
  font-size: 12px; color: var(--text-muted);
}

/* Tree node (organograma) --------------------------------------------------- */

.tree { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tree-node {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.tree-node.gerente { background: var(--surface-raised); padding-left: 20px; border-bottom-color: var(--border); }
.tree-node.supervisor { background: var(--surface-raised); padding-left: 40px; border-bottom-color: var(--border); }
.tree-node.group-leader { padding-left: 68px; }
.tree-node.team-leader { padding-left: 96px; }

.tree-chevron { width: 18px; color: var(--text-muted); font-size: 11px; }

/* Utility ------------------------------------------------------------------- */

.hide { display: none; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-disabled { color: var(--text-disabled); }
.font-mono { font-family: var(--font-mono); }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
