/* ==========================================================================
   ERP Prowel — Design System (erp.css)
   --------------------------------------------------------------------------
   Paleta: azul-petróleo profundo + neutros frios + cores semânticas.
   Tipografia: pilha de sistema (sem fontes externas), numerais tabulares.
   Grade de 8px · cantos de 8px · sombras discretas.
   ========================================================================== */

:root {
  /* Neutros */
  --bg: oklch(0.972 0.004 240);
  --surface: oklch(0.993 0.001 240);
  --surface-2: oklch(0.962 0.005 240);
  --surface-3: oklch(0.946 0.006 240);
  --fg: oklch(0.245 0.02 245);
  --fg-strong: oklch(0.185 0.025 245);
  --muted: oklch(0.5 0.018 245);
  --muted-2: oklch(0.58 0.014 245);
  --border: oklch(0.905 0.006 240);
  --border-strong: oklch(0.835 0.009 240);

  /* Primária — azul-petróleo profundo */
  --accent: oklch(0.4 0.07 225);
  --accent-hover: oklch(0.46 0.07 225);
  --accent-active: oklch(0.34 0.07 225);
  --accent-ink: oklch(0.4 0.07 225);
  --accent-soft: oklch(0.956 0.017 225);
  --accent-soft-2: oklch(0.922 0.03 225);
  --on-accent: oklch(0.985 0.002 225);

  /* Barra lateral */
  --sb-bg: oklch(0.235 0.028 242);
  --sb-border: oklch(0.3 0.025 242);
  --sb-fg: oklch(0.72 0.012 242);
  --sb-fg-strong: oklch(0.97 0.004 242);
  --sb-hover: oklch(0.288 0.028 242);
  --sb-active-bg: oklch(0.4 0.07 225);
  --sb-active-fg: oklch(0.985 0.002 225);

  /* Semântica */
  --green: oklch(0.55 0.12 155);
  --green-ink: oklch(0.4 0.1 155);
  --green-soft: oklch(0.955 0.035 155);
  --green-dark: oklch(0.42 0.1 160);
  --green-dark-ink: oklch(0.33 0.09 160);
  --green-dark-soft: oklch(0.93 0.045 160);

  --amber: oklch(0.76 0.13 80);
  --amber-ink: oklch(0.47 0.1 75);
  --amber-soft: oklch(0.965 0.04 85);

  --red: oklch(0.55 0.17 25);
  --red-ink: oklch(0.43 0.15 25);
  --red-soft: oklch(0.955 0.03 25);

  --blue: oklch(0.55 0.11 250);
  --blue-ink: oklch(0.42 0.1 250);
  --blue-soft: oklch(0.955 0.025 250);

  --purple: oklch(0.55 0.15 305);
  --purple-ink: oklch(0.4 0.12 305);
  --purple-soft: oklch(0.955 0.025 305);

  --orange: oklch(0.64 0.15 50);
  --orange-ink: oklch(0.45 0.12 45);
  --orange-soft: oklch(0.96 0.03 55);

  --gray-ink: oklch(0.47 0.01 245);
  --gray-soft: oklch(0.94 0.005 245);

  /* Tipografia */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 24px;

  /* Métricas */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-full: 999px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  --shadow-sm: 0 1px 2px oklch(0.2 0.02 240 / 0.06);
  --shadow-md: 0 4px 14px -4px oklch(0.2 0.02 240 / 0.14);
  --shadow-lg: 0 16px 40px -12px oklch(0.2 0.02 240 / 0.25);

  --sidebar-w: 236px;
}

/* ==========================================================================
   Reset & base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p { margin: 0; }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

button { font-family: inherit; }

::selection { background: var(--accent-soft-2); color: var(--fg-strong); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.up { text-transform: uppercase; letter-spacing: 0.04em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.ml-auto { margin-left: auto; }

.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }

.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--green-ink); }
.text-danger { color: var(--red-ink); }
.text-warning { color: var(--amber-ink); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm { font-size: var(--fs-sm); }
.fs-xs { font-size: var(--fs-xs); }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.icon--sm { width: 15px; height: 15px; }
.icon--lg { width: 20px; height: 20px; }
.icon--xl { width: 22px; height: 22px; }

/* ==========================================================================
   Shell / layout de aplicação
   ========================================================================== */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sb-bg);
  color: var(--sb-fg);
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform 0.22s ease;
}

.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--sb-border);
  color: var(--sb-fg-strong);
  text-decoration: none;
}
.sidebar__brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; flex: none;
}
.brand-word { font-size: var(--fs-md); font-weight: 700; letter-spacing: 0.01em; line-height: 1.1; }
.brand-word small { display: block; font-size: 10px; font-weight: 600; color: var(--sb-fg); letter-spacing: 0.08em; }

.sidebar__nav { flex: 1 1 auto; overflow-y: auto; padding: 12px 10px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-group__label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: oklch(0.55 0.01 242);
  padding: 0 10px; margin-bottom: 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; margin-bottom: 2px;
  border-radius: var(--radius);
  color: var(--sb-fg);
  font-size: var(--fs-base); font-weight: 500;
  text-decoration: none; position: relative;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-item .icon { width: 17px; height: 17px; }
.nav-item:hover { background: var(--sb-hover); color: var(--sb-fg-strong); text-decoration: none; }
.nav-item.is-active {
  background: var(--sb-active-bg); color: var(--sb-active-fg);
}
.nav-item.is-active::before {
  content: ""; position: absolute; left: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0;
  background: var(--on-accent);
}
.nav-item:focus-visible { outline-color: var(--sb-active-fg); }
.nav-item__label { flex: 1 1 auto; }
.nav-item .badge { background: var(--sb-border); color: var(--sb-fg-strong); }

.sidebar__footer { padding: 12px 10px; border-top: 1px solid var(--sb-border); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px; border-radius: var(--radius);
  color: var(--sb-fg);
}
.user-chip__meta { flex: 1 1 auto; min-width: 0; }
.user-chip__name { font-size: var(--fs-sm); font-weight: 600; color: var(--sb-fg-strong); line-height: 1.3; }
.user-chip__role { font-size: 11px; color: var(--sb-fg); }
.icon-btn--ghost {
  border: 0; background: transparent; color: inherit;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: inline-grid; place-items: center; cursor: pointer;
}
.icon-btn--ghost:hover { background: var(--sb-hover); color: var(--sb-fg-strong); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.mobile-bar {
  display: none; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.mobile-bar .brand-word { color: var(--fg-strong); }
.mobile-bar .brand-word small { color: var(--muted); }

.sidebar-overlay {
  position: fixed; inset: 0; background: oklch(0.2 0.02 240 / 0.5);
  z-index: 35; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}

.page-header {
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.page-header__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header__main { min-width: 0; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent-ink); }
.breadcrumb .icon { width: 13px; height: 13px; color: var(--muted-2); }
.page-title { font-size: var(--fs-xl); font-weight: 700; color: var(--fg-strong); letter-spacing: -0.01em; line-height: 1.2; }
.page-subtitle { font-size: var(--fs-sm); color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

.content { padding: 24px 28px 48px; flex: 1 1 auto; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card__title { font-size: var(--fs-md); font-weight: 600; color: var(--fg-strong); }
.card__sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.card__actions { display: flex; align-items: center; gap: var(--sp-2); }
.card__body { padding: 16px; }
.card--flush .card__body { padding: 0; }

/* ==========================================================================
   KPI cards
   ========================================================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-4); }
.kpi-grid--3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.kpi { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kpi__label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em; color: var(--muted); text-transform: uppercase; }
.kpi__icon {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); flex: none;
}
.kpi__icon--green { background: var(--green-soft); color: var(--green-ink); }
.kpi__icon--amber { background: var(--amber-soft); color: var(--amber-ink); }
.kpi__icon--red { background: var(--red-soft); color: var(--red-ink); }
.kpi__icon--blue { background: var(--blue-soft); color: var(--blue-ink); }
.kpi__value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.01em; color: var(--fg-strong); font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi__value small { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi__note { margin-top: 8px; font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 5px; }
.kpi__note .up, .kpi__note .down { font-weight: 700; }
.kpi--accent { border-top: 2px solid var(--accent); }
.kpi__delta-up { color: var(--green-ink); font-weight: 700; }
.kpi__delta-down { color: var(--red-ink); font-weight: 700; }

/* ==========================================================================
   Botões
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: var(--fs-base); font-weight: 600; line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}
.btn:hover { text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }

.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:active { background: var(--accent-active); }

.btn--secondary { background: var(--surface); border-color: var(--border-strong); color: var(--fg); }
.btn--secondary:hover { background: var(--surface-2); border-color: oklch(0.72 0.01 240); color: var(--fg-strong); }
.btn--secondary:active { background: var(--surface-3); }

.btn--ghost { background: transparent; color: var(--fg); }
.btn--ghost:hover { background: var(--surface-2); color: var(--fg-strong); }

.btn--danger { background: var(--red); color: oklch(0.985 0.002 25); }
.btn--danger:hover { background: oklch(0.48 0.17 25); }
.btn--danger:active { background: oklch(0.42 0.16 25); }

.btn--sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn--xs { height: 26px; padding: 0 9px; font-size: var(--fs-xs); }
.btn--icon { width: 36px; padding: 0; }
.btn--icon.btn--sm { width: 30px; }
.btn--block { width: 100%; }

.btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.btn-group .btn { border: 0; border-radius: 0; height: 34px; }
.btn-group .btn + .btn { border-left: 1px solid var(--border-strong); }

/* ==========================================================================
   Formulários
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--fg); }
.field__label .req { color: var(--red-ink); }
.field__hint { font-size: var(--fs-xs); color: var(--muted); }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-family: inherit; font-size: var(--fs-base);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 84px; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:hover, .select:hover, .textarea:hover { border-color: oklch(0.72 0.01 240); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6b84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input--icon { position: relative; }
.input--icon .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.input--icon .input { padding-left: 34px; }
.search { width: 100%; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-base); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-base); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track { width: 34px; height: 19px; border-radius: var(--radius-full); background: var(--border-strong); position: relative; transition: background 0.15s ease; flex: none; }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform 0.15s ease; }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(15px); }

/* ==========================================================================
   Pills de status
   ========================================================================== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.4; white-space: nowrap;
  border: 1px solid transparent;
}
.pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.pill--green { background: var(--green-soft); color: var(--green-ink); }
.pill--green-dark { background: var(--green-dark-soft); color: var(--green-dark-ink); }
.pill--amber { background: var(--amber-soft); color: var(--amber-ink); }
.pill--red { background: var(--red-soft); color: var(--red-ink); }
.pill--blue { background: var(--blue-soft); color: var(--blue-ink); }
.pill--purple { background: var(--purple-soft); color: var(--purple-ink); }
.pill--orange { background: var(--orange-soft); color: var(--orange-ink); }
.pill--gray { background: var(--gray-soft); color: var(--gray-ink); }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-full);
  font-size: 10px; font-weight: 700; line-height: 1;
  background: var(--surface-3); color: var(--muted);
}

/* ==========================================================================
   Abas
   ========================================================================== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 10px 14px; font-size: var(--fs-base); font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.14s ease, border-color 0.14s ease;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--fg); }
.tab.is-active { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tab .badge { background: var(--surface-3); color: var(--muted); }
.tab.is-active .badge { background: var(--accent-soft); color: var(--accent-ink); }

/* ==========================================================================
   Tabelas
   ========================================================================== */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
.table th, .table td { text-align: left; padding: 11px 14px; vertical-align: middle; }
.table thead th {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.table tbody td { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }
.table .row-link { cursor: pointer; }
.table .cell-strong { font-weight: 600; color: var(--fg-strong); }
.table .cell-id { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--accent-ink); white-space: nowrap; }
.table .cell-sub { font-size: var(--fs-xs); color: var(--muted); }

th[data-sort-key] { cursor: pointer; user-select: none; }
th[data-sort-key]:hover { color: var(--fg); }
th[data-sort-key]::after { content: "↕"; margin-left: 6px; opacity: 0.4; font-weight: 400; }
th[data-sort-key][data-dir="asc"]::after { content: "↑"; opacity: 1; color: var(--accent-ink); }
th[data-sort-key][data-dir="desc"]::after { content: "↓"; opacity: 1; color: var(--accent-ink); }

.table-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.table-info { font-size: var(--fs-sm); color: var(--muted); }

.pagination { display: flex; align-items: center; gap: 4px; }
.pagination__btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); font-size: var(--fs-sm); cursor: pointer;
}
.pagination__btn:hover:not(:disabled) { background: var(--surface-2); color: var(--fg-strong); }
.pagination__btn.is-current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pagination__btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pagination__ellipsis { padding: 0 4px; color: var(--muted); }

/* ==========================================================================
   Alertas / avisos
   ========================================================================== */
.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); }
.alert__icon { width: 20px; height: 20px; flex: none; display: grid; place-items: center; }
.alert__body { flex: 1 1 auto; min-width: 0; }
.alert__title { font-size: var(--fs-base); font-weight: 600; color: var(--fg-strong); }
.alert__text { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.alert--info { border-color: var(--accent-soft-2); background: var(--accent-soft); }
.alert--info .alert__icon { color: var(--accent-ink); }
.alert--warn { border-color: oklch(0.9 0.05 85); background: var(--amber-soft); }
.alert--warn .alert__icon { color: var(--amber-ink); }
.alert--danger { border-color: oklch(0.9 0.03 25); background: var(--red-soft); }
.alert--danger .alert__icon { color: var(--red-ink); }
.alert--success { border-color: oklch(0.9 0.04 155); background: var(--green-soft); }
.alert--success .alert__icon { color: var(--green-ink); }

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty__icon {
  width: 44px; height: 44px; margin: 0 auto 12px; border-radius: var(--radius);
  display: grid; place-items: center; background: var(--surface-3); color: var(--muted);
}
.empty__title { font-size: var(--fs-md); font-weight: 600; color: var(--fg-strong); }
.empty__text { font-size: var(--fs-sm); margin-top: 4px; max-width: 360px; margin-left: auto; margin-right: auto; }

/* ==========================================================================
   Avatar
   ========================================================================== */
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: var(--fs-xs); font-weight: 700;
}
.avatar--sm { width: 26px; height: 26px; font-size: 10px; }
.avatar--lg { width: 44px; height: 44px; font-size: var(--fs-md); }
.avatar--green { background: var(--green-soft); color: var(--green-ink); }
.avatar--amber { background: var(--amber-soft); color: var(--amber-ink); }
.avatar--red { background: var(--red-soft); color: var(--red-ink); }
.avatar--blue { background: var(--blue-soft); color: var(--blue-ink); }
.avatar--purple { background: var(--purple-soft); color: var(--purple-ink); }

/* ==========================================================================
   Filtros
   ========================================================================== */
.filter-bar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.filter-bar .input, .filter-bar .select { width: auto; min-width: 150px; }
.filter-bar .search-wrap { flex: 1 1 220px; min-width: 200px; max-width: 320px; }

.filter-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 16px; }
.filter-panel__title { font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-strong); margin-bottom: 12px; }
.filter-group + .filter-group { margin-top: 18px; }
.filter-group__label { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px; }
.filter-option { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; font-size: var(--fs-base); color: var(--fg); cursor: pointer; }
.filter-option .count { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.filter-option:hover { color: var(--fg-strong); }
.filter-option.is-active { color: var(--accent-ink); font-weight: 600; }

/* ==========================================================================
   Detalhe (cabeçalho + campos)
   ========================================================================== */
.detail-head { padding: 18px 20px; }
.detail-head__main { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-head__title { font-size: var(--fs-xl); font-weight: 700; color: var(--fg-strong); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-head__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: var(--fs-sm); color: var(--muted); }
.detail-head__meta .sep { color: var(--border-strong); }
.detail-head__actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; }
.kv { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv__label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.kv__value { font-size: var(--fs-md); font-weight: 500; color: var(--fg-strong); word-break: break-word; }
.kv__value.mono { font-size: var(--fs-base); }

/* ==========================================================================
   Linha do tempo
   ========================================================================== */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px; background: var(--border-strong); }
.timeline__item { position: relative; padding-bottom: 22px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__marker {
  position: absolute; left: -22px; top: 3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
}
.timeline__item--done .timeline__marker { border-color: var(--green); background: var(--green); }
.timeline__item--warn .timeline__marker { border-color: var(--amber); background: var(--amber); }
.timeline__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.timeline__title { font-size: var(--fs-base); font-weight: 600; color: var(--fg-strong); margin-top: 2px; }
.timeline__text { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; max-width: 720px; }

/* ==========================================================================
   Kanban
   ========================================================================== */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); align-items: start; }
.kanban-col { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; }
.kanban-col__head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.kanban-col__title { font-size: var(--fs-sm); font-weight: 700; color: var(--fg-strong); }
.kanban-col__count { margin-left: auto; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.kanban-col__body { padding: 10px; display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow-sm); }
.kcard__title { font-size: var(--fs-base); font-weight: 600; color: var(--fg-strong); line-height: 1.35; }
.kcard__meta { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; line-height: 1.5; }
.kcard__footer { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.kcard__due { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--muted); }
.priority { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 600; }
.priority::before { content: ""; width: 7px; height: 7px; border-radius: 2px; }
.priority--high { color: var(--red-ink); }
.priority--high::before { background: var(--red); }
.priority--med { color: var(--amber-ink); }
.priority--med::before { background: var(--amber); }
.priority--low { color: var(--blue-ink); }
.priority--low::before { background: var(--blue); }

/* ==========================================================================
   Gráfico de barras
   ========================================================================== */
.chart { padding: 16px; }
.chart__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.legend { display: flex; align-items: center; gap: 14px; font-size: var(--fs-sm); color: var(--muted); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend__swatch--a { background: var(--accent); }
.legend__swatch--b { background: var(--border-strong); }

.chart__frame { position: relative; height: 240px; }
.chart__grid { position: absolute; inset: 0 0 28px 0; display: flex; flex-direction: column; justify-content: space-between; }
.chart__gridline { border-top: 1px dashed var(--border); }
.chart__ylabels { position: absolute; left: 0; top: -6px; bottom: 28px; width: 44px; display: flex; flex-direction: column; justify-content: space-between; font-size: 10px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.chart__yl { transform: translateY(-50%); }
.chart__bars { position: absolute; left: 52px; right: 0; top: 0; bottom: 28px; display: flex; align-items: flex-end; gap: 8px; }
.chart__group { flex: 1 1 0; display: flex; align-items: flex-end; gap: 3px; height: 100%; }
.bar { flex: 1 1 0; border-radius: 3px 3px 0 0; min-width: 4px; position: relative; transition: filter 0.14s ease; }
.bar--a { background: var(--accent); }
.bar--b { background: var(--border-strong); }
.bar:hover { filter: brightness(1.08); }
.bar::after {
  content: attr(data-label); position: absolute; left: 50%; bottom: calc(100% + 6px);
  transform: translateX(-50%); background: var(--fg-strong); color: var(--surface);
  font-size: 10px; font-weight: 600; padding: 3px 6px; border-radius: 4px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.12s ease; z-index: 5;
}
.bar:hover::after { opacity: 1; }
.chart__xlabels { position: absolute; left: 52px; right: 0; bottom: 0; display: flex; gap: 8px; height: 22px; }
.chart__x { flex: 1 1 0; font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; }

/* ==========================================================================
   Arquivos
   ========================================================================== */
.upload-zone {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 22px; text-align: center; color: var(--muted); background: var(--surface);
}
.upload-zone__title { font-size: var(--fs-base); font-weight: 600; color: var(--fg-strong); }
.upload-zone__text { font-size: var(--fs-xs); margin-top: 3px; }

.file-list { display: flex; flex-direction: column; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.file-item:last-child { border-bottom: 0; }
.file-item__icon { width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.file-item__name { font-size: var(--fs-base); font-weight: 600; color: var(--fg-strong); }
.file-item__meta { font-size: var(--fs-xs); color: var(--muted); }
.file-item__actions { margin-left: auto; display: flex; gap: 4px; }

/* ==========================================================================
   Modal / dialog
   ========================================================================== */
dialog.dialog {
  border: 0; padding: 0; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); background: var(--surface); color: var(--fg);
  width: min(520px, calc(100vw - 32px));
}
dialog.dialog::backdrop { background: oklch(0.2 0.02 240 / 0.5); }
.dialog__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog__title { font-size: var(--fs-lg); font-weight: 700; color: var(--fg-strong); }
.dialog__body { padding: 20px; }
.dialog__footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); padding: 14px 20px; border-top: 1px solid var(--border); }

/* ==========================================================================
   Login
   ========================================================================== */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 500px at 50% -10%, oklch(0.34 0.05 225 / 0.55), transparent 60%),
    oklch(0.21 0.03 235);
  color: var(--fg);
}
.login__card {
  width: min(400px, 100%); background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 32px;
}
.login__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login__brand .brand-mark { width: 40px; height: 40px; border-radius: var(--radius); }
.login__brand-name { font-size: var(--fs-xl); font-weight: 700; color: var(--fg-strong); letter-spacing: -0.01em; line-height: 1.1; }
.login__brand-name small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.06em; margin-top: 2px; }
.login__title { font-size: var(--fs-lg); font-weight: 700; color: var(--fg-strong); }
.login__hint { font-size: var(--fs-sm); color: var(--muted); margin-top: 4px; margin-bottom: 20px; }
.login__form .field + .field { margin-top: 14px; }
.login__form .btn { margin-top: 20px; }
.login__note {
  margin-top: 18px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: var(--fs-xs); display: flex; align-items: flex-start; gap: 8px;
}
.login__note .icon { width: 15px; height: 15px; margin-top: 1px; }
.login__footer { margin-top: 20px; text-align: center; font-size: var(--fs-xs); color: var(--muted); }

/* ==========================================================================
   Design System (página de documentação)
   ========================================================================== */
.ds-hero { padding: 22px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.ds-hero h1 { font-size: var(--fs-2xl); font-weight: 700; color: var(--fg-strong); letter-spacing: -0.01em; }
.ds-hero p { color: var(--muted); font-size: var(--fs-md); margin-top: 6px; max-width: 720px; }

.ds-section { margin-top: 32px; }
.ds-section__title { font-size: var(--fs-lg); font-weight: 700; color: var(--fg-strong); }
.ds-section__desc { font-size: var(--fs-sm); color: var(--muted); margin-top: 4px; margin-bottom: 16px; max-width: 720px; }

.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--sp-3); }
.swatch { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.swatch__chip { height: 64px; }
.swatch__meta { padding: 10px 12px; border-top: 1px solid var(--border); }
.swatch__name { font-size: var(--fs-sm); font-weight: 600; color: var(--fg-strong); }
.swatch__value { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 2px; }

.comp-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
.comp-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--sp-4); align-items: start; }
.comp-label { font-size: var(--fs-sm); color: var(--muted); padding-top: 4px; }
.comp-preview {
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}

.type-sample { display: flex; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.type-sample__size { width: 52px; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); flex: none; }
.type-sample__text { color: var(--fg-strong); }

.spacing-row { display: flex; align-items: center; gap: 14px; padding: 6px 0; }
.spacing-row__label { width: 48px; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); }
.spacing-row__bar { height: 14px; background: var(--accent-soft-2); border-radius: 3px; }

/* ==========================================================================
   Responsivo
   ========================================================================== */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 20px; }
  .page-header { padding: 18px 20px 14px; }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app-shell.is-nav-open .sidebar { transform: translateX(0); }
  .app-shell.is-nav-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .mobile-bar { display: flex; }
}

@media (max-width: 720px) {
  .kpi-grid, .kpi-grid--3 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: 1fr; }
  .comp-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .page-header { padding: 14px 16px 12px; }
  .page-header__row { align-items: flex-start; flex-direction: column; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
}
