/* =========================================================
   D78 Intelligence — estilo base (padrão visual iOS)
   Tokens → base → layout → componentes → páginas → responsivo
   ========================================================= */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f7f7fa;
  --surface-3: #ececf1;
  --sidebar-bg: rgba(248, 248, 251, .86);
  --text: #1c1c1e;
  --text-2: #5f5f66;
  --text-3: #8e8e93;
  --separator: rgba(60, 60, 67, .14);
  --separator-strong: rgba(60, 60, 67, .24);

  --accent: #0a6cff;
  --accent-hover: #0059d6;
  --accent-soft: rgba(10, 108, 255, .10);
  --on-accent: #ffffff;
  --success: #248a3d;
  --success-soft: rgba(52, 199, 89, .14);
  --warning: #b25000;
  --warning-soft: rgba(255, 149, 0, .16);
  --critical: #d70015;
  --critical-soft: rgba(255, 59, 48, .12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --shadow-pop: 0 10px 40px rgba(0, 0, 0, .16), 0 2px 8px rgba(0, 0, 0, .08);
  --focus: 0 0 0 3px rgba(10, 108, 255, .35);

  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300;
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;

  --sidebar-w: 264px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 60px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

:root[data-theme="dark"] {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300;
  --chart-grid: #2c2c2a;
  --chart-axis: #383835;
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #232326;
  --surface-3: #2c2c2e;
  --sidebar-bg: rgba(22, 22, 24, .86);
  --text: #f5f5f7;
  --text-2: #b4b4bb;
  --text-3: #8e8e93;
  --separator: rgba(84, 84, 88, .45);
  --separator-strong: rgba(84, 84, 88, .7);
  --accent: #3d8bff;
  --accent-hover: #64a2ff;
  --accent-soft: rgba(61, 139, 255, .18);
  --success: #32d74b;
  --success-soft: rgba(50, 215, 75, .16);
  --warning: #ff9f0a;
  --warning-soft: rgba(255, 159, 10, .18);
  --critical: #ff453a;
  --critical-soft: rgba(255, 69, 58, .18);
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .06);
  --focus: 0 0 0 3px rgba(61, 139, 255, .5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300;
    --chart-grid: #2c2c2a;
    --chart-axis: #383835;
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #232326;
    --surface-3: #2c2c2e;
    --sidebar-bg: rgba(22, 22, 24, .86);
    --text: #f5f5f7;
    --text-2: #b4b4bb;
    --text-3: #8e8e93;
    --separator: rgba(84, 84, 88, .45);
    --separator-strong: rgba(84, 84, 88, .7);
    --accent: #3d8bff;
    --accent-hover: #64a2ff;
    --accent-soft: rgba(61, 139, 255, .18);
    --success: #32d74b;
    --success-soft: rgba(50, 215, 75, .16);
    --warning: #ff9f0a;
    --warning-soft: rgba(255, 159, 10, .18);
    --critical: #ff453a;
    --critical-soft: rgba(255, 69, 58, .18);
    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-pop: 0 12px 40px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .06);
    --focus: 0 0 0 3px rgba(61, 139, 255, .5);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.47 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -.01em;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); letter-spacing: -.02em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-3); padding: .1em .35em; border-radius: 5px; }
pre { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px; overflow: auto; max-height: 260px; margin: 6px 0; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
::selection { background: var(--accent-soft); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ic .fill, .ic-fill { fill: currentColor; stroke: none; }
.ic-sm { width: 16px; height: 16px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { left: 8px; }

.muted { color: var(--text-2); }
.hint { display: block; color: var(--text-3); font-size: 13px; margin-top: 4px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.t-right { text-align: right; }
.eyebrow { font-size: 13px; color: var(--text-3); font-weight: 500; margin-bottom: 2px; }
.eyebrow a { color: inherit; }

/* ---------- Logo ---------- */
.logo-mark { width: 34px; height: 34px; flex: none; }
.logo-bg { fill: var(--text); }
.logo-text { fill: var(--bg); font-family: var(--font-display); font-size: 14px; font-weight: 700; letter-spacing: -.6px; }
.logo-dot { fill: var(--accent); }

/* ---------- Layout do app ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--sidebar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--separator);
  z-index: 40;
  transition: width .25s var(--ease), transform .25s var(--ease);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 10px 16px; min-height: var(--topbar-h); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-text { font-family: var(--font-display); font-size: 17px; white-space: nowrap; letter-spacing: -.02em; }
.brand-text strong { font-weight: 700; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; scrollbar-width: thin; }
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav-section + .nav-section { margin-top: 14px; }
.nav-section-title { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 4px 10px 6px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 10px;
  color: var(--text); font-size: 14.5px; white-space: nowrap;
  transition: background .15s;
}
.nav-item:hover { background: var(--surface-3); text-decoration: none; }
.nav-item.is-active { background: var(--accent); color: var(--on-accent); }
.nav-item.is-active .ic { color: var(--on-accent); }
.nav-item .ic { color: var(--text-2); }
.nav-item.is-disabled { color: var(--text-3); cursor: default; }
.nav-item.is-disabled:hover { background: transparent; }
.nav-item.is-disabled .ic { color: var(--text-3); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-phase { font-size: 11px; font-weight: 600; color: var(--text-3); background: var(--surface-3); border-radius: 6px; padding: 1px 6px; }
.sidebar-foot { padding: 10px 20px 16px; font-size: 12px; color: var(--text-3); }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .25s var(--ease); }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
}
.topbar-title { font-size: 17px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.main { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 24px 24px 40px; }
.main:focus { box-shadow: none; }
.app-footer { padding: 16px 24px 24px; font-size: 12px; color: var(--text-3); text-align: center; }

/* Menu recolhido (desktop) */
.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.sidebar-collapsed .shell { margin-left: var(--sidebar-w-collapsed); }
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-phase,
.sidebar-collapsed .nav-section-title,
.sidebar-collapsed .sidebar-foot { display: none; }
.sidebar-collapsed .sidebar-head { flex-direction: column; padding: 14px 8px 8px; }
.sidebar-collapsed .brand { justify-content: center; }
.sidebar-collapsed .nav { padding: 4px 8px; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar-collapsed .nav-section + .nav-section { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--separator); }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .32); z-index: 35; }
.mobile-only { display: none; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  font: 500 14.5px/1 var(--font); letter-spacing: -.01em;
  color: var(--accent); background: var(--accent-soft);
  border: 0; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .08s, opacity .15s;
}
.btn:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 16%, transparent); }
.btn:active { transform: scale(.98); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--critical-soft); color: var(--critical); }
.btn-block { width: 100%; height: 44px; font-size: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icon-btn.mobile-only { display: none; }

.segmented { display: inline-flex; padding: 2px; background: var(--surface-3); border-radius: 10px; }
.segmented button { width: 32px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.segmented button .ic { width: 17px; height: 17px; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* ---------- Menu do usuário ---------- */
.menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 4px 8px 4px 4px; border-radius: 12px; cursor: pointer; color: var(--text); font: inherit; }
.user-chip:hover { background: var(--surface-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--text); color: var(--bg); font-size: 13px; font-weight: 600; }
.user-chip-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.user-name { font-size: 14px; font-weight: 600; }
.user-role { font-size: 12px; color: var(--text-3); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 6px; z-index: 50; }
.menu-header { padding: 8px 10px 10px; font-size: 13px; color: var(--text-3); border-bottom: 1px solid var(--separator); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; color: var(--text); background: transparent; border: 0; font: inherit; font-size: 14.5px; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item.danger { color: var(--critical); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.card + .card, .card + section, section + .card, .kpi-grid + .card { margin-top: 16px; }
.card-title { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.card-title.spaced { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--separator); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > .card + .card { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 28px; font-weight: 700; line-height: 1.15; }

.notice { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.notice .card-title { margin-bottom: 4px; }
.notice-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.notice-warning .notice-icon { background: var(--warning-soft); color: var(--warning); }
.notice-inline { display: flex; align-items: center; gap: 8px; background: var(--warning-soft); color: var(--text); padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.kpi-grid .card + .card { margin-top: 0; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-height: 112px; }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kpi-label { font-size: 13.5px; color: var(--text-2); font-weight: 500; }
.kpi-ic { color: var(--text-3); }
.kpi-value { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: auto; }
.kpi-value-sm { font-size: 20px; }
.kpi-foot { font-size: 13px; color: var(--text-3); }
.kpi.tone-warning .kpi-ic { color: var(--warning); }
.kpi.tone-critical .kpi-ic { color: var(--critical); }

/* ---------- Etapas ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.steps li { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--separator); }
.steps li:first-child { border-top: 0; padding-top: 4px; }
.steps li > div { display: flex; flex-direction: column; gap: 2px; }
.steps li .muted { font-size: 14px; }
.step-dot { width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.steps .is-done .step-dot { background: var(--success-soft); color: var(--success); }
.steps .is-current .step-dot { background: var(--accent); color: var(--on-accent); }

/* ---------- Formulários ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form.narrow { max-width: 520px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.input {
  width: 100%; height: 42px; padding: 0 12px;
  font: 15px var(--font); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--separator); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none; appearance: none;
}
select.input { padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
select.input[multiple] { height: auto; padding: 6px; background-image: none; }
select.input[multiple] option { padding: 6px 8px; border-radius: 6px; }
.input:hover { border-color: var(--separator-strong); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); background: var(--surface); }
.input::placeholder { color: var(--text-3); }
.input-group { position: relative; display: flex; }
.input-group .input { padding-right: 44px; }
.input-addon { position: absolute; right: 4px; top: 4px; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.input-addon:hover { color: var(--text); background: var(--surface-3); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 12px; top: 11px; color: var(--text-3); width: 19px; height: 19px; }
.input-icon .input { padding-left: 38px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; align-items: center; margin-top: 4px; flex-wrap: wrap; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--separator); font-size: 15px; cursor: pointer; }
.switch { -webkit-appearance: none; appearance: none; width: 51px; height: 31px; border-radius: 31px; background: var(--surface-3); position: relative; cursor: pointer; flex: none; transition: background .2s; margin: 0; border: 1px solid var(--separator); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.switch:checked { background: var(--success); border-color: transparent; }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { box-shadow: var(--focus); }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14.5px; padding: 5px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check input:disabled + span { color: var(--text-2); }

.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; padding: 16px; }
.filters .field { min-width: 160px; }
.filters .field.grow { flex: 1; min-width: 220px; }
.filters-actions { display: flex; gap: 8px; }
.filters + .card { margin-top: 0; }

/* ---------- Tabelas ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text-3); padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--separator); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--separator); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th.t-right { text-align: right; }
.table .empty { text-align: center; color: var(--text-3); padding: 36px 16px; }
.actions { white-space: nowrap; }
.actions .inline, form.inline { display: inline; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 12px; border-top: 1px solid var(--separator); }

.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 12.5px; font-weight: 500; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-critical { background: var(--critical-soft); color: var(--critical); }
.pill-muted { background: transparent; color: var(--text-3); border: 1px solid var(--separator); }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14.5px; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; text-align: right; }

.audit-details summary { cursor: pointer; color: var(--accent); }
.audit-details[open] { min-width: 280px; }

/* ---------- Perfis ---------- */
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.role-grid .card + .card { margin-top: 0; }
.role-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.role-head .card-title { margin-bottom: 2px; }
.role-head .muted { font-size: 14px; }
.perm-group { border: 0; border-top: 1px solid var(--separator); margin: 0; padding: 10px 0 0; }
.perm-group legend { font-size: 12.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 0 0 4px; float: left; width: 100%; }
.perm-group legend + * { clear: both; }

/* ---------- Mensagens ---------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; }
.flash-stack:not(:empty) { margin-bottom: 16px; }
.flash { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-size: 14.5px; background: var(--surface); box-shadow: var(--shadow); border-left: 4px solid var(--text-3); animation: flash-in .25s var(--ease); }
.flash span { flex: 1; }
.flash-success { border-left-color: var(--success); }
.flash-success > .ic { color: var(--success); }
.flash-error { border-left-color: var(--critical); }
.flash-error > .ic { color: var(--critical); }
.flash-warning { border-left-color: var(--warning); }
.flash-warning > .ic { color: var(--warning); }
.flash-info { border-left-color: var(--accent); }
.flash-info > .ic { color: var(--accent); }
.flash-close { border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 2px; border-radius: 6px; display: flex; }
.flash-close .ic { width: 18px; height: 18px; }
.flash.is-leaving { opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Erros ---------- */
.error-card { max-width: 520px; margin: 40px auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 28px; }
.error-code { font-family: var(--font-display); font-size: 56px; font-weight: 700; color: var(--text-3); letter-spacing: -.04em; line-height: 1; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; background: var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius-xl); padding: 32px 28px; box-shadow: var(--shadow-pop); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand .logo-mark { width: 46px; height: 46px; }
.auth-name { font-family: var(--font-display); font-size: 21px; letter-spacing: -.02em; }
.auth-name strong { font-weight: 700; }
.auth-tag { font-size: 13px; color: var(--text-3); }
.auth-title { font-size: 24px; font-weight: 700; margin-bottom: 16px; }
.auth-card > .muted { margin: -6px 0 16px; font-size: 14.5px; }
.auth-foot { margin-top: 20px; font-size: 12.5px; color: var(--text-3); }
.link-subtle { color: var(--text-2); font-size: 14.5px; }


/* ---------- Fases 2–4: análise, OS, importação ---------- */
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.spaced-top { margin-top: 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.card-head .card-title { margin-bottom: 8px; }
.card-title-pad { padding: 18px 20px 6px; margin: 0; }
.card-foot { padding: 14px 20px 18px; border-top: 1px solid var(--separator); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.action-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.action-row .card-title { margin-bottom: 4px; }
.dl-inline { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--separator); }
.dl-inline dd { text-align: left; }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.notice-inline.is-ok { background: var(--success-soft); }
.notice-inline.is-bad { background: var(--critical-soft); }
.log-output { margin-top: 14px; max-height: 320px; white-space: pre-wrap; }
.code-area { height: auto; min-height: 420px; padding: 12px; font: 12.5px/1.5 var(--mono); white-space: pre; tab-size: 2; resize: vertical; }
.help { font-size: 13.5px; color: var(--text-2); }
.help summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.help ul { margin: 8px 0 0; padding-left: 18px; }
.help li { margin: 4px 0; }
.gap-list { background: var(--warning-soft); border-radius: var(--radius-sm); padding: 10px 14px; margin: 10px 0 14px; font-size: 13.5px; }
.gap-list ul { margin: 4px 0 0; padding-left: 18px; }
.input-file { height: auto; padding: 9px 10px; }
.bordered { border: 1px solid var(--separator); border-radius: var(--radius); margin-top: 12px; }
.table-compact td, .table-compact th { padding: 9px 12px; }
.clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-cell { max-width: 560px; color: var(--text-2); font-size: 14px; }
.stat-row { display: flex; gap: 28px; flex-wrap: wrap; margin: 6px 0 14px; }
.stat-row > div { display: flex; flex-direction: column; }
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat-label { font-size: 13px; color: var(--text-3); }
.mapping { margin: 6px 0 10px; font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; gap: 4px; align-items: center; background: var(--surface-3); border-radius: 8px; padding: 3px 8px; font-size: 12.5px; }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.plain-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.plain-list li { padding: 4px 0; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 20px; }
.kv-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv-grid span { font-size: 12.5px; color: var(--text-3); }
.kv-grid strong { font-weight: 500; font-size: 14.5px; overflow-wrap: anywhere; }

.original-text { font-size: 15px; line-height: 1.7; white-space: normal; overflow-wrap: anywhere; }
.report-block + .report-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--separator); }
.report-block.is-old { opacity: .6; }
.report-meta { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.hl { border-radius: 4px; padding: 1px 2px; background: var(--surface-3); color: inherit; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hl-anomalia { background: var(--warning-soft); box-shadow: inset 0 -2px 0 var(--warning); }
.hl-recomendacao { background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); }
.hl-anomalia.hl-recomendacao { background: linear-gradient(var(--warning-soft), var(--accent-soft)); box-shadow: inset 0 -2px 0 var(--accent); }
.hl-servico_executado { background: var(--success-soft); box-shadow: inset 0 -2px 0 var(--success); }
.hl-inspecao_ok, .hl-observacao, .hl-substituicao_nao_realizada { background: var(--surface-3); box-shadow: inset 0 -2px 0 var(--text-3); }
.legend .hl { padding: 2px 6px; }

.excerpt { font-size: 12.5px; color: var(--text-3); margin-top: 3px; font-style: italic; }
.row-child td { background: var(--surface-2); font-size: 13.5px; }
.row-child td:first-child { padding-left: 28px; }
.row-muted td { opacity: .55; }
.row-note td { border-top: 0; padding-top: 0; }
.table tbody tr.row-note:hover td { background: transparent; }

.seg-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.seg-tabs a { display: inline-flex; gap: 6px; align-items: center; padding: 7px 12px; border-radius: 10px; background: var(--surface); color: var(--text-2); font-size: 14px; box-shadow: var(--shadow); }
.seg-tabs a span { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.seg-tabs a:hover { text-decoration: none; color: var(--text); }
.seg-tabs a.is-active { background: var(--text); color: var(--bg); }
.seg-tabs a.is-active span { color: var(--bg); opacity: .7; }

.review-card { display: flex; flex-direction: column; gap: 10px; }
.review-card.is-focus { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.review-title { font-size: 16px; margin-left: 6px; }
.review-head .muted { margin-top: 6px; }
.quote { margin: 0; padding: 10px 14px; border-left: 3px solid var(--separator-strong); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 14.5px; }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] { flex-basis: 100%; }
.reclass-form { margin-top: 10px; padding: 14px; background: var(--surface-2); border-radius: var(--radius); max-width: 640px; }


/* ---------- Fase 5: equipamentos ---------- */
.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 16px; }
.kpi-grid + .card, .kpi-grid + .grid-2 { margin-top: 16px; }
.change-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.change-cell { display: flex; flex-direction: column; gap: 3px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.change-cell strong { font-family: var(--font-display); font-size: 20px; letter-spacing: -.02em; }
.change-cell.is-empty strong { color: var(--text-3); }
.change-label { font-size: 12.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { display: grid; grid-template-columns: 96px 1fr; gap: 16px; position: relative; padding: 0 0 18px; }
.timeline > li::before { content: ""; position: absolute; left: 103px; top: 8px; bottom: 0; width: 2px; background: var(--separator); }
.timeline > li:last-child::before { display: none; }
.tl-date { font-size: 13px; font-weight: 600; color: var(--text-2); padding-top: 2px; text-align: right; }
.tl-body { position: relative; padding-left: 18px; }
.tl-body::before { content: ""; position: absolute; left: -9px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.tl-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 14px; }
.readings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.readings-grid strong { display: block; margin-bottom: 6px; }
.filter-check { align-self: center; padding-bottom: 8px; }


/* ---------- Fase 6: dashboard ---------- */
.section-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin: 22px 0 10px; letter-spacing: -.01em; }
.section-title:first-of-type { margin-top: 6px; }
.kpi-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi-link { color: inherit; transition: transform .12s var(--ease), box-shadow .12s; }
.kpi-link:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 0 0 1px var(--separator-strong), var(--shadow); }
.kpi-foot { font-size: 12.5px; }
.dash-filters { margin-bottom: 8px; }
.dash-filters .field { min-width: 140px; }
.aging { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding: 14px 20px; }
.aging > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.aging-cells { display: flex; gap: 10px; flex-wrap: wrap; }
.aging-cells > div { display: flex; align-items: baseline; gap: 8px; padding: 8px 14px; border-radius: var(--radius); background: var(--surface-2); }
.aging-cells strong { font-family: var(--font-display); font-size: 22px; letter-spacing: -.02em; }
.aging-cells span { font-size: 13px; color: var(--text-2); }
.aging-cells .is-warning { background: var(--warning-soft); }
.aging-cells .is-critical { background: var(--critical-soft); }
.chart-card { margin-top: 16px; }
.chart-card .card-title { margin-bottom: 2px; }
.chart-head { display: flex; justify-content: space-between; gap: 12px; }
.chart-box { position: relative; height: 260px; margin: 12px 0 6px; }
.chart-box-lg { height: 300px; }
.chart-box-donut { height: 200px; width: 200px; margin: 0; flex: none; }
.donut-wrap { display: flex; align-items: center; gap: 28px; margin-top: 14px; flex-wrap: wrap; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 180px; font-size: 14px; color: var(--text-2); }
.donut-legend li { display: flex; align-items: center; gap: 8px; }
.donut-legend strong { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch-1 { background: var(--series-1); } .swatch-2 { background: var(--series-2); } .swatch-3 { background: var(--series-3); }
.swatch-4 { background: var(--series-4); } .swatch-5 { background: var(--series-5); } .swatch-6 { background: var(--series-6); }
.empty-chart { padding: 40px 0; text-align: center; }
.grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
.grid-even { align-items: stretch; margin-bottom: 16px; }
.grid-even > .card, .grid-even > .card + .card { margin-top: 16px; }
.kpi-grid-6 .kpi-label { min-height: 2.5em; }
.kpi-grid-6 .kpi-value { margin-top: auto; }
.kpi-grid-6 .kpi-foot { min-height: 2.6em; }

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

/* ---------- Fase 7: recomendações ---------- */
a.notice { color: inherit; text-decoration: none; }
a.notice:hover { text-decoration: none; box-shadow: var(--shadow), 0 0 0 1px var(--separator-strong); }
.notice-critical { box-shadow: var(--shadow), inset 3px 0 0 var(--critical); }
.notice-critical .notice-icon { background: var(--critical-soft); color: var(--critical); }
.notice-accent { box-shadow: var(--shadow), inset 3px 0 0 var(--accent); }
.notice .grow { flex: 1; min-width: 0; }
.seg-tabs a.tab-critical:not(.is-active) span { color: var(--critical); font-weight: 600; }
.row-critical td:first-child { box-shadow: inset 3px 0 0 var(--critical); }
.text-critical { color: var(--critical); }
.col-check { width: 36px; }
.col-check .check { margin: 0; }
.bulk-bar { margin-top: 16px; }
.bulk-fields { box-shadow: none; padding: 0; margin: 8px 0 4px; background: transparent; }
.spaced-top-sm { margin-top: 8px; }
.suggest-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; padding: 12px 0 0; margin-top: 12px; border-top: 1px solid var(--separator); }
.suggest-row > div:first-child { flex: 1; min-width: 240px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.segmented-radio { display: flex; gap: 8px; flex-wrap: wrap; }
.segmented-radio label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; cursor: pointer; color: var(--text); }
.segmented-radio input { accent-color: var(--accent); margin: 0; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 10px 0 10px 16px; border-left: 2px solid var(--separator); position: relative; }
.history li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.history-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; font-size: 14.5px; }
.rule-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.rule-form .field { margin: 0; }
.rule-form .rule-notes { grid-column: 1 / -2; }
.input-sm { height: 32px; padding: 0 28px 0 10px; font-size: 13.5px; width: auto; }


/* ---------- Fase 8: relatórios ---------- */
.lead { max-width: 900px; margin: -4px 0 20px; font-size: 15px; line-height: 1.55; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; margin-bottom: 24px; }
.report-card { display: flex; gap: 14px; align-items: flex-start; color: inherit; text-decoration: none; margin: 0; transition: box-shadow .15s; }
.report-card:hover { text-decoration: none; box-shadow: var(--shadow), 0 0 0 1px var(--separator-strong); }
.report-ic { width: 36px; height: 36px; flex: none; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.report-txt { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.report-txt strong { font-weight: 600; font-size: 15px; }
.report-go { color: var(--text-3); align-self: center; }
.report-meta-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 14px; }
.report-table-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.report-table-head .card-title { margin: 0; }
.report-note { padding: 0 20px 8px; margin: 0; }
.report-table td { vertical-align: top; }
.report-table { font-size: 13.5px; }
@media (min-width: 901px) {
  .report-table .col-descricao { min-width: 300px; }
  .report-table .col-cliente, .report-table .col-equipamento, .report-table .col-tecnico { min-width: 130px; }
}
.report-grid > .card, .report-grid > .card + .card { margin: 0; }
.report-table .excerpt { margin-top: 4px; }
.report-kpis { margin-bottom: 18px; }


/* ---------- Fase 10: IA ---------- */
.ai-box { margin: 10px 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); display: flex; flex-direction: column; gap: 4px; }
.ai-box.is-error { background: var(--warning-soft); }
.ai-summary { white-space: pre-line; line-height: 1.6; }

/* ---------- Fase 9: alertas e configurações ---------- */
.bell { position: relative; }
.bell .badge { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--critical); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums; box-shadow: 0 0 0 2px var(--surface); }
.row-unread td:nth-child(2) strong::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; }
.rule-card.is-off { opacity: .72; }
.rule-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.rule-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; align-items: end; }
.rule-grid .span-2 { grid-column: span 2; }
.rule-grid .span-all { grid-column: 1 / -1; }
.rule-grid .form-actions { grid-column: 1 / -1; }
.rule-switches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 24px; margin: 4px 0 8px; }
.inline-add { display: inline-flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.inline-add .input-sm { width: 150px; }
.input-num { max-width: 180px; }
.settings-form { max-width: 880px; }
.setting-row { padding: 6px 0; border-top: 1px solid var(--separator); }
.setting-row:first-of-type { border-top: 0; }
textarea.mono { font: 12.5px/1.5 var(--mono); }

@media (max-width: 1280px) {
  .kpi-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .change-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .rule-grid, .rule-switches { grid-template-columns: 1fr; }
  .rule-grid .span-2 { grid-column: auto; }
  .form-grid-2, .rule-form { grid-template-columns: 1fr; }
  .rule-form .rule-notes { grid-column: auto; }
  .row-critical td:first-child { box-shadow: none; }
  .table tbody tr.row-critical { box-shadow: var(--shadow), inset 3px 0 0 var(--critical); }
  .mobile-only, .icon-btn.mobile-only { display: inline-flex; }
  .sidebar { transform: translateX(-100%); width: min(86vw, var(--sidebar-w)); box-shadow: var(--shadow-pop); }
  .sidebar-open .sidebar { transform: none; }
  .shell, .sidebar-collapsed .shell { margin-left: 0; }
  .sidebar-collapse { display: none; }
  .sidebar-collapsed .sidebar { width: min(86vw, var(--sidebar-w)); }
  .sidebar-collapsed .brand-text, .sidebar-collapsed .nav-label, .sidebar-collapsed .nav-phase,
  .sidebar-collapsed .nav-section-title, .sidebar-collapsed .sidebar-foot { display: initial; }
  .sidebar-collapsed .nav-item { justify-content: flex-start; padding: 8px 10px; }
  .topbar { padding: 0 12px; }
  .user-chip-text { display: none; }
  .main { padding: 16px 16px 32px; }
}

@media (max-width: 640px) {
  .page-title { font-size: 24px; }
  .kpi-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-box-donut { margin: 0 auto; }
  .change-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline > li { grid-template-columns: 1fr; gap: 2px; padding-left: 18px; }
  .timeline > li::before { left: 5px; }
  .tl-date { text-align: left; }
  .tl-body { padding-left: 0; }
  .tl-body::before { left: -19px; top: -16px; }
  .clip, .text-cell { max-width: none; white-space: normal; }
  .row-child td:first-child { padding-left: 0; }
  .code-area { min-height: 300px; }
  .theme-switch { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { min-height: 96px; padding: 14px; }
  .kpi-value { font-size: 28px; }
  .filters .field, .filters .field.grow { min-width: 100%; }
  .filters-actions { width: 100%; }
  .filters-actions .btn { flex: 1; }
  .role-grid { grid-template-columns: 1fr; }
  /* Tabela vira lista de cartões */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--separator); }
  .table td { border: 0; padding: 3px 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; text-align: right; }
  .table td .pill { white-space: normal; }
  .table td > div { flex-basis: 100%; }
  .table td[data-label]::before { content: attr(data-label); color: var(--text-3); font-size: 13px; text-align: left; }
  .table td.t-right { justify-content: flex-end; padding-top: 6px; }
  .table tbody tr:hover td { background: transparent; }
  .auth-card { padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
