/* ==========================================================================
   TIXIA ERP — Tema base (protótipo de layout)
   Cor institucional Exatron: #1C435D (primária) e #006492 (secundária),
   extraídas do kit de cores do site exatron.com.br.
   Todos os valores visuais saem destes tokens. No projeto React, este arquivo
   vira o "design tokens" (CSS variables) consumido pelos componentes.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Marca */
  --brand: #1c435d;
  --brand-strong: #133246;
  --brand-2: #006492;
  --brand-soft: #e7eff5;
  --brand-soft-2: #cfe0eb;

  /* Superfícies */
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #dde3ea;
  --border-strong: #c3cdd7;

  /* Texto */
  --text: #15222d;
  --text-2: #4a5967;
  --text-3: #7a8896;
  --link: #006492;

  /* Inputs */
  --input-bg: #ffffff;
  --input-ro: #f1f4f7;
  --focus: #006492;
  --focus-ring: rgba(0, 100, 146, .22);

  /* Navegação (menu lateral / superior) */
  --nav-bg: #1c435d;
  --nav-bg-2: #163650;
  --nav-text: #c3d4e0;
  --nav-text-strong: #ffffff;
  --nav-muted: #86a3b8;
  --nav-hover: rgba(255, 255, 255, .07);
  --nav-active: rgba(255, 255, 255, .13);
  --nav-indicator: #5cb8ea;

  /* Estados (sempre acompanhados de ícone/texto) */
  --ok: #157a42;      --ok-bg: #e2f3e9;
  --warn: #8f5d00;    --warn-bg: #fcf1d6;
  --danger: #b83228;  --danger-bg: #fbe6e3;
  --info: #006492;    --info-bg: #e0eff7;
  --neutral-bg: #edf0f3;

  /* Linhas da grade com status (substitui o verde/azul chapado do ERP atual) */
  --row-ok: #f1faf4;
  --row-sel: #e3eef6;
  --row-hover: #f5f8fb;

  /* Gráficos — paleta categórica validada (CVD) com azul da marca em 1º */
  --s1: #1f6fa3; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #6250d6;
  --grid: #e6eaee; --axis: #c3cdd7;

  /* Escala */
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-1: 0 1px 2px rgba(16, 32, 48, .06), 0 1px 1px rgba(16, 32, 48, .04);
  --shadow-2: 0 6px 24px rgba(16, 32, 48, .12), 0 2px 6px rgba(16, 32, 48, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font);
  --font-logo: "Orbitron", var(--font-display);
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* Densidade (compacta por padrão: ERP é tela de digitação) */
  --fs: 13px;
  --fs-sm: 12px;
  --ctl-h: 30px;
  --gap: 12px;
  --row-h: 32px;
  --label-w: 120px;
}

:root[data-font="grotesk"] { --font: "Space Grotesk", system-ui, sans-serif; }
:root[data-font="sora"] { --font: "Sora", system-ui, sans-serif; --fs: 12.5px; }
:root[data-font="exo"] { --font: "Exo 2", system-ui, sans-serif; }
:root[data-font="inter"] { --font: "Inter", system-ui, sans-serif; }

:root[data-density="comfortable"] {
  --fs: 14px;
  --fs-sm: 12.5px;
  --ctl-h: 36px;
  --gap: 16px;
  --row-h: 40px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --_auto-dark: 1; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #2a6c97;
  --brand-strong: #3d84b3;
  --brand-2: #4aa8db;
  --brand-soft: #172b3a;
  --brand-soft-2: #1f3c52;
  --bg: #0d141a;
  --surface: #141e27;
  --surface-2: #18242f;
  --surface-3: #1e2c38;
  --border: #283846;
  --border-strong: #38495a;
  --text: #e5edf3;
  --text-2: #a8b7c4;
  --text-3: #7a8b99;
  --link: #6cbbe8;
  --input-bg: #101921;
  --input-ro: #1a2530;
  --focus: #4aa8db;
  --focus-ring: rgba(74, 168, 219, .28);
  --nav-bg: #0f2231;
  --nav-bg-2: #0b1a26;
  --ok: #4cc67e;     --ok-bg: #12301f;
  --warn: #f0b43c;   --warn-bg: #33270c;
  --danger: #f07368; --danger-bg: #3a1714;
  --info: #6cbbe8;   --info-bg: #10293a;
  --neutral-bg: #1e2a35;
  --row-ok: #13261b;
  --row-sel: #1b3345;
  --row-hover: #192632;
  --s1: #3d8fc6; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #9085e9;
  --grid: #24323e; --axis: #38495a;
  --shadow-2: 0 8px 28px rgba(0, 0, 0, .45);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; font-family: var(--font-display); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--mono); font-size: .95em; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
::selection { background: var(--brand-soft-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ==========================================================================
   SHELL
   ========================================================================== */
.app { display: flex; height: 100vh; overflow: hidden; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content { flex: 1; overflow: auto; padding: 16px 20px 24px; }
.app.layout-topbar { flex-direction: column; }

/* ---------- Marca (logo) ---------- */
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none !important; white-space: nowrap; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, #2b78a8, #006492);
  display: grid; place-items: center; font-family: var(--font-logo); font-weight: 800; font-size: 15px; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.brand-name { font-family: var(--font-logo); font-weight: 700; letter-spacing: .12em; font-size: 14px; line-height: 1.1; }
.brand-name small { display: block; font-family: var(--font-display); font-weight: 500; font-size: 10.5px; color: var(--nav-muted); letter-spacing: .08em; text-transform: uppercase; }

/* ---------- Menu lateral ---------- */
.sidebar {
  width: 252px; flex: none; background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; transition: width .18s ease;
}
.sidebar.collapsed { width: 60px; }
.sidebar-head { height: 56px; display: flex; align-items: center; padding: 0 14px; background: var(--nav-bg-2); gap: 8px; }
.sidebar.collapsed .sidebar-head { justify-content: center; padding: 0; }
.sidebar.collapsed .brand-name, .sidebar.collapsed .nav-label, .sidebar.collapsed .nav-caret,
.sidebar.collapsed .nav-section-title, .sidebar.collapsed .sidebar-search, .sidebar.collapsed .nav-sub,
.sidebar.collapsed .sidebar-foot-text, .sidebar.collapsed .nav-badge { display: none; }
.sidebar-search { padding: 12px 12px 6px; }
.sidebar-search .nav-input {
  width: 100%; height: 32px; border-radius: 6px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18); color: #fff; padding: 0 10px 0 32px; font-size: 13px;
}
.sidebar-search .nav-input::placeholder { color: var(--nav-muted); }
.sidebar-search .search-wrap { position: relative; }
.sidebar-search .search-wrap svg { position: absolute; left: 9px; top: 8px; color: var(--nav-muted); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 8px 12px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav-section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--nav-muted); padding: 14px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none;
  color: var(--nav-text); padding: 0 10px; height: 34px; border-radius: 6px; cursor: pointer;
  text-align: left; font-size: 13px; position: relative; text-decoration: none !important;
}
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }
.nav-item:hover { background: var(--nav-hover); color: var(--nav-text-strong); }
.nav-item.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--nav-indicator); }
.nav-item .nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-caret { transition: transform .15s; opacity: .7; }
.nav-item.open .nav-caret { transform: rotate(90deg); }
.nav-sub { margin: 2px 0 6px 21px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.12); }
.nav-sub .nav-item { height: 30px; font-size: 12.5px; color: var(--nav-text); }
.nav-sub .nav-item.active::before { left: -13px; top: 6px; bottom: 6px; }
.nav-badge { background: rgba(255,255,255,.14); color: #fff; font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 10px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 8px; }

/* ---------- Cabeçalho branco (layouts lateral e híbrido) ---------- */
.header {
  height: 56px; flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.header .crumbs { flex: 1; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; }
.crumbs b { color: var(--text); font-weight: 600; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; height: 34px; width: 340px; max-width: 34vw;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px;
  padding: 0 10px; color: var(--text-3); cursor: pointer; font-size: 13px;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span { flex: 1; text-align: left; }
kbd {
  font-family: var(--font); font-size: 10.5px; border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--text-2); background: var(--surface);
}
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px;
  border: 0; background: none; color: var(--text-2); cursor: pointer; position: relative; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #d9432f; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.company-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 12px; color: var(--text-2); white-space: nowrap; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 6px 3px 3px; border-radius: 20px; }
.user-chip:hover { background: var(--surface-3); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-2); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.user-chip .who { line-height: 1.15; font-size: 12.5px; }
.user-chip .who small { display: block; color: var(--text-3); font-size: 11px; }

/* ---------- Menu superior ---------- */
.topnav { background: var(--nav-bg); color: var(--nav-text); flex: none; position: relative; z-index: 30; }
.topnav-row { height: 52px; display: flex; align-items: center; gap: 6px; padding: 0 16px; }
.topnav .brand { margin-right: 18px; }
.topnav-menu { display: flex; align-items: stretch; height: 100%; flex: 1; min-width: 0; }
.topnav-item { position: relative; display: flex; }
.topnav-link {
  display: flex; align-items: center; gap: 6px; padding: 0 11px; border: 0; background: none; cursor: pointer;
  color: var(--nav-text); font-size: 13px; white-space: nowrap; height: 52px; position: relative;
}
.topnav-link:hover, .topnav-item.open .topnav-link { color: #fff; background: var(--nav-hover); }
.topnav-link.active { color: #fff; font-weight: 600; }
.topnav-link.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--nav-indicator); }
.topnav .icon-btn { color: var(--nav-text); }
.topnav .icon-btn:hover { background: var(--nav-hover); color: #fff; }
.topnav .icon-btn .dot { border-color: var(--nav-bg); }
.topnav .avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.mega {
  position: absolute; top: 100%; left: 0; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 0 0 10px 10px; box-shadow: var(--shadow-2);
  padding: 14px; display: grid; grid-auto-flow: column; gap: 6px 24px; min-width: 260px; z-index: 40;
}
.mega-col { min-width: 200px; }
.mega-col h5 { margin: 4px 8px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; }
.mega a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; color: var(--text); font-size: 13px; text-decoration: none; }
.mega a:hover { background: var(--brand-soft); color: var(--brand); }
.mega a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.mega a svg { color: var(--text-3); }
.subbar {
  height: 40px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.subbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 8px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 6px; border: 0; background: none; cursor: pointer; color: var(--text-2); font-size: 12.5px; }
.chip-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Layout híbrido: trilho de ícones + abas de janelas ---------- */
.rail { width: 64px; flex: none; background: var(--nav-bg); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 2px; z-index: 31; }
.rail .brand { margin-bottom: 12px; }
.rail-btn {
  width: 52px; min-height: 48px; border: 0; background: none; border-radius: 8px; cursor: pointer;
  color: var(--nav-text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 9.5px; letter-spacing: .02em; padding: 4px 0;
}
.rail-btn:hover { background: var(--nav-hover); color: #fff; }
.rail-btn.active { background: var(--nav-active); color: #fff; }
.rail-spacer { flex: 1; }
.flyout {
  position: absolute; left: 64px; top: 0; bottom: 0; width: 264px; background: var(--surface);
  border-right: 1px solid var(--border); box-shadow: var(--shadow-2); z-index: 30; display: flex; flex-direction: column;
}
.flyout-head { padding: 16px 16px 8px; }
.flyout-head h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; color: var(--brand); }
.flyout-body { overflow-y: auto; padding: 0 8px 16px; }
.flyout-body h5 { margin: 12px 8px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; }
.flyout-body a { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; color: var(--text); font-size: 13px; text-decoration: none; }
.flyout-body a:hover { background: var(--brand-soft); color: var(--brand); }
.flyout-body a .star { margin-left: auto; color: var(--text-3); opacity: 0; }
.flyout-body a:hover .star { opacity: 1; }
.wintabs { height: 40px; flex: none; display: flex; align-items: flex-end; gap: 2px; padding: 0 12px; background: var(--surface-3); border-bottom: 1px solid var(--border); overflow-x: auto; }
.wintab {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 12px; max-width: 220px;
  border-radius: 8px 8px 0 0; color: var(--text-2); cursor: pointer; font-size: 12.5px; white-space: nowrap; border: 1px solid transparent; border-bottom: 0;
}
.wintab:hover { background: rgba(255,255,255,.5); }
.wintab.active { background: var(--surface); color: var(--text); font-weight: 600; border-color: var(--border); margin-bottom: -1px; height: 33px; }
.wintab .t { overflow: hidden; text-overflow: ellipsis; }
.wintab .x { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 4px; color: var(--text-3); }
.wintab .x:hover { background: var(--surface-3); color: var(--text); }
.wintab .mod { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }

/* ==========================================================================
   PÁGINA
   ========================================================================== */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title h1 { font-size: 21px; letter-spacing: -.01em; }
.page-title .code { font-family: var(--mono); color: var(--text-3); font-size: 15px; }
.page-sub { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }
.page-head .spacer { flex: 1; }

/* Barra de ações (substitui a toolbar de ícones grandes) */
.toolbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
  margin-bottom: 12px;
}
.toolbar .divider { width: 1px; align-self: stretch; margin: 4px 4px; background: var(--border); }
.toolbar .grow { flex: 1; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 6px;
  border: 0; background: none; cursor: pointer; color: var(--text-2); font-size: 13px; white-space: nowrap;
}
.tb-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.tb-btn:disabled { opacity: .4; cursor: default; }
.tb-btn.primary { background: var(--brand); color: #fff; }
.tb-btn.primary:hover:not(:disabled) { background: var(--brand-strong); color: #fff; }
.tb-btn .count { background: var(--brand-2); color: #fff; font-size: 10.5px; padding: 0 6px; border-radius: 9px; font-weight: 700; }
.tb-btn.icon-only { padding: 0; width: 32px; justify-content: center; }
.tb-btn .caret { margin-left: -2px; opacity: .6; }
.goto { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.goto input { width: 96px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--ctl-h);
  padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); cursor: pointer; font-size: var(--fs); font-weight: 500; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn.secondary { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
:root[data-theme="dark"] .btn.secondary { color: var(--link); }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: var(--ctl-h); padding: 0; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft-2); position: relative; z-index: 1; font-weight: 600; }
:root[data-theme="dark"] .btn-group .btn.on { color: var(--link); }

/* ---------- Cartões e seções ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); min-height: 44px; }
.card-head h3 { font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.card-head h3 svg { color: var(--brand-2); }
.card-head .spacer { flex: 1; }
.card-body { padding: 14px; }
.card-body.flush { padding: 0; }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600;
  display: flex; align-items: center; gap: 8px; margin: 4px 0 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Abas ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; padding: 0 6px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 0; background: none; cursor: pointer;
  color: var(--text-2); font-size: 13px; white-space: nowrap; position: relative;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); font-weight: 600; }
:root[data-theme="dark"] .tab.active { color: var(--link); }
.tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: currentColor; border-radius: 2px; }
.tab .count { font-size: 11px; background: var(--surface-3); color: var(--text-2); padding: 0 6px; border-radius: 9px; font-weight: 600; }
.tab .err { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px var(--gap); align-items: start; }
.span-1 { grid-column: span 1; } .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; }
.span-10 { grid-column: span 10; } .span-12 { grid-column: span 12; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 4px; min-height: 16px; white-space: nowrap; }
.field .req { color: var(--danger); }
.field > .lbl a { color: var(--link); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.field .hint { font-size: 11.5px; color: var(--text-3); }
.field .error-msg { font-size: 11.5px; color: var(--danger); display: flex; align-items: center; gap: 4px; }
/* Rótulo à esquerda — disposição do ERP atual */
.labels-left .field { flex-direction: row; align-items: flex-start; gap: 8px; }
.labels-left .field > label, .labels-left .field > .lbl { width: var(--label-w); flex: none; justify-content: flex-end; text-align: right; height: var(--ctl-h); }
.labels-left .field > .ctl { flex: 1; min-width: 0; }
.labels-left .field.lbl-auto > label, .labels-left .field.lbl-auto > .lbl { width: auto; }
.ctl { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ctl-row { display: flex; gap: 6px; align-items: center; min-width: 0; }

.input, .select, .textarea {
  width: 100%; height: var(--ctl-h); border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--input-bg); color: var(--text); padding: 0 9px; font: inherit; font-size: var(--fs); min-width: 0;
  transition: border-color .1s, box-shadow .1s;
}
.textarea { height: auto; min-height: 60px; padding: 7px 9px; resize: vertical; line-height: 1.45; }
.select { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8896' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }
.input[readonly], .input:disabled, .textarea[readonly] { background: var(--input-ro); color: var(--text-2); border-color: var(--border); }
.input.num, .input.money { text-align: right; font-variant-numeric: tabular-nums; }
.input.code { font-family: var(--mono); font-size: 12.5px; }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(184, 50, 40, .12); }
.input.strong { font-weight: 700; color: var(--text); }
.input-wrap { position: relative; display: flex; min-width: 0; flex: 1; }
.input-wrap .input { padding-right: 30px; }
.input-wrap .adorn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; display: flex; }
.input-wrap .prefix { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 12px; pointer-events: none; }
.input-wrap .prefix + .input { padding-left: 30px; }

/* Lookup: código pequeno + descrição grande (padrão herdado do ERP atual) */
.lookup { display: flex; min-width: 0; flex: 1; }
.lookup .input { border-radius: 0; margin-left: -1px; }
.lookup .lk-code { flex: none; border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; font-family: var(--mono); font-size: 12.5px; }
.lookup .lk-desc { flex: 1; }
.lookup .lk-btn {
  flex: none; width: var(--ctl-h); height: var(--ctl-h); margin-left: -1px; border: 1px solid var(--border-strong);
  border-radius: 0 var(--radius) var(--radius) 0; background: var(--surface-2); color: var(--text-2); cursor: pointer; display: grid; place-items: center;
}
.lookup .lk-btn:hover { background: var(--brand-soft); color: var(--brand); }
.lookup .input:focus { position: relative; z-index: 1; }
.lookup.no-btn .lk-desc { border-radius: 0 var(--radius) var(--radius) 0; }

.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: var(--fs); color: var(--text); user-select: none; min-height: var(--ctl-h); }
.check input { width: 16px; height: 16px; accent-color: var(--brand-2); margin: 0; }
.check.disabled { color: var(--text-3); cursor: default; }
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--brand-2); }
.switch input:checked + span::before { transform: translateX(14px); }

.segmented { display: inline-flex; background: var(--surface-3); border-radius: 7px; padding: 2px; gap: 2px; }
.segmented button { border: 0; background: none; height: calc(var(--ctl-h) - 4px); padding: 0 12px; border-radius: 5px; cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.segmented button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1); }

/* Lista de checkboxes em chips (Tipo de Agente) */
.chip-checks { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px;
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--text-2); user-select: none;
}
.chip-check:hover { border-color: var(--brand-2); }
.chip-check.on { background: var(--brand-soft); border-color: var(--brand-2); color: var(--brand); font-weight: 600; }
:root[data-theme="dark"] .chip-check.on { color: var(--link); }

/* ---------- Badges / status ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--text-2); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.brand { background: var(--brand); color: #fff; }
.badge.outline { background: none; border: 1px solid var(--border-strong); }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); font-size: 12.5px; border: 1px solid transparent; }
.alert svg { flex: none; margin-top: 1px; }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.danger { background: var(--danger-bg); color: var(--danger); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert b { font-weight: 600; }

/* Info "cartão" do agente */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); font-weight: 500; }

/* Totais */
.totals { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 12.5px; }
.totals .k { color: var(--text-2); }
.totals .k a { color: var(--link); }
.totals .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.totals .sum { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 2px; font-weight: 700; font-size: 13.5px; color: var(--text); }

/* Rodapé fixo de formulário */
.form-footer {
  position: sticky; bottom: -24px; margin: 16px -20px -24px; padding: 10px 20px; background: var(--surface);
  border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; z-index: 5;
  box-shadow: 0 -4px 12px rgba(16,32,48,.05);
}
.form-footer .grand { display: flex; gap: 28px; align-items: baseline; }
.form-footer .grand div { display: flex; flex-direction: column; }
.form-footer .grand small { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.form-footer .grand b { font-family: var(--font-display); font-size: 19px; font-variant-numeric: tabular-nums; }

/* Stepper de workflow (Status do pedido) */
.stepper { display: flex; align-items: center; gap: 0; }
.step { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; font-size: 12px; color: var(--text-3); }
.step .n { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-weight: 700; font-size: 11px; flex: none; background: var(--surface); }
.step .line { flex: 1; height: 2px; background: var(--border); min-width: 12px; }
.step.done { color: var(--text-2); }
.step.done .n { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.step.done .line { background: var(--brand-2); }
.step.current { color: var(--text); font-weight: 600; }
.step.current .n { border-color: var(--brand-2); color: var(--brand-2); box-shadow: 0 0 0 4px var(--focus-ring); }
.step:last-child { flex: none; }

/* ==========================================================================
   TABELAS
   ========================================================================== */
.table-wrap { overflow: auto; position: relative; }
.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs); }
.dt th {
  font-family: var(--font-display); letter-spacing: .01em;
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--text-2);
  font-size: 12px; height: 36px; padding: 0 10px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.dt th.sortable { cursor: pointer; }
.dt th.sortable:hover { color: var(--text); }
.dt th .th-in { display: inline-flex; align-items: center; gap: 4px; }
.dt th.num .th-in { flex-direction: row-reverse; }
.dt th .sort-ico { opacity: .35; }
.dt th.sorted .sort-ico { opacity: 1; color: var(--brand-2); }
.dt td { height: var(--row-h); padding: 0 10px; border-bottom: 1px solid var(--border); white-space: nowrap; color: var(--text); }
.dt td.wrap { white-space: normal; }
.dt tbody tr:hover td { background: var(--row-hover); }
.dt tbody tr.selected td { background: var(--row-sel); }
.dt tbody tr.tone-ok td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.dt tbody tr.tone-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.dt tbody tr.tone-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.dt tbody tr.tone-info td:first-child { box-shadow: inset 3px 0 0 var(--info); }
.dt tbody tr.clickable { cursor: pointer; }
.dt tbody tr.focused td { background: var(--row-sel); }
.dt tbody tr.focused td:first-child { box-shadow: inset 3px 0 0 var(--brand-2); }
.dt td.sel, .dt th.sel { width: 36px; padding: 0 0 0 12px; }
.dt td.sel input, .dt th.sel input { width: 15px; height: 15px; accent-color: var(--brand-2); vertical-align: middle; }
.dt tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.dt .cell-input { width: 100%; height: calc(var(--row-h) - 6px); border: 1px solid transparent; background: transparent; border-radius: 4px; padding: 0 6px; font: inherit; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.dt .cell-input:hover { border-color: var(--border-strong); background: var(--input-bg); }
.dt .cell-input:focus { outline: none; border-color: var(--focus); background: var(--input-bg); box-shadow: 0 0 0 2px var(--focus-ring); }
.dt .row-actions { opacity: 0; display: inline-flex; gap: 2px; }
.dt tr:hover .row-actions { opacity: 1; }
.dt .code-cell { font-family: var(--mono); font-size: 12px; color: var(--text); }
.dt .sub { display: block; font-size: 11.5px; color: var(--text-3); }
.dt.zebra tbody tr:nth-child(even) td { background: var(--surface-2); }
.dt.zebra tbody tr:nth-child(even):hover td { background: var(--row-hover); }
.dt.grid td, .dt.grid th { border-right: 1px solid var(--border); }

.table-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.table-bar .grow { flex: 1; }
.table-foot { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 2px; }
.pager button { min-width: 28px; height: 28px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: 12.5px; display: grid; place-items: center; }
.pager button:hover:not(:disabled) { background: var(--surface-3); }
.pager button.on { background: var(--brand); color: #fff; font-weight: 600; }
.pager button:disabled { opacity: .35; cursor: default; }
.bulkbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--brand); color: #fff; font-size: 13px;
}
.bulkbar .btn { height: 28px; font-size: 12.5px; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #fff; }
.bulkbar .btn:hover { background: rgba(255,255,255,.22) !important; }

.view-tabs { display: flex; gap: 4px; }
.view-tab { height: 30px; padding: 0 12px; border-radius: 6px; border: 0; background: none; cursor: pointer; color: var(--text-2); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.view-tab:hover { background: var(--surface-3); }
.view-tab.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
:root[data-theme="dark"] .view-tab.on { color: var(--link); }
.view-tab .count { font-size: 11px; color: var(--text-3); font-weight: 500; }

.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 10px; border-radius: 14px; background: var(--surface-3); font-size: 12px; color: var(--text-2); }
.filter-chip b { color: var(--text); font-weight: 600; }
.filter-chip button { border: 0; background: none; cursor: pointer; color: var(--text-3); display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; }
.filter-chip button:hover { background: var(--border); color: var(--text); }

/* ---------- Menu de contexto / dropdown ---------- */
.menu {
  position: fixed; z-index: 100; min-width: 240px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-2); padding: 5px; font-size: 13px;
}
.menu .mi { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 9px; border: 0; background: none; border-radius: 5px; cursor: pointer; text-align: left; color: var(--text); font-size: 13px; }
.menu .mi:hover:not(:disabled) { background: var(--brand-soft); }
.menu .mi:disabled { color: var(--text-3); cursor: default; }
.menu .mi svg { color: var(--text-3); flex: none; }
.menu .mi .kbd { margin-left: auto; color: var(--text-3); font-size: 11.5px; }
.menu .msep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu .mhead { padding: 6px 9px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 600; }

/* ---------- Modal / drawer / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 22, 32, .45); z-index: 90; display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; animation: fade .12s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-2); width: min(760px, 94vw); max-height: 80vh; display: flex; flex-direction: column; animation: pop .14s ease; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; flex: 1; }
.modal-body { padding: 14px 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 92vw); background: var(--surface); box-shadow: var(--shadow-2); z-index: 91; display: flex; flex-direction: column; animation: slide .16s ease; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #15222d; color: #fff; border-radius: 8px; box-shadow: var(--shadow-2); font-size: 13px; animation: pop .15s ease; }
.toast svg { flex: none; }
.toast.ok svg { color: #5bd38d; } .toast.danger svg { color: #ff8a80; } .toast.info svg { color: #7cc8f0; }

/* Paleta de comandos (Ctrl+K) */
.cmdk { width: min(620px, 94vw); }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.cmdk-input input { flex: 1; height: 52px; border: 0; background: none; font: inherit; font-size: 15px; color: var(--text); outline: none; }
.cmdk-list { max-height: 50vh; overflow: auto; padding: 6px; }
.cmdk-group { padding: 8px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 600; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--text); text-decoration: none !important; }
.cmdk-item.on { background: var(--brand-soft); }
.cmdk-item small { margin-left: auto; color: var(--text-3); font-size: 11.5px; }
.cmdk-item svg { color: var(--text-3); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { padding: 14px 16px; }
.kpi .k { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 6px 0 4px; letter-spacing: -.01em; }
.kpi .d { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--brand-2); border-radius: 3px; }

/* ---------- Gráficos ---------- */
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-legend i.line { height: 2px; border-radius: 1px; width: 14px; }
.chart-legend i.dash { height: 0; border-top: 2px dashed; width: 14px; border-radius: 0; background: none !important; }
.chart-tip { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-2); padding: 8px 10px; font-size: 12px; min-width: 160px; }
.chart-tip .t { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.chart-tip .r { display: flex; align-items: center; gap: 8px; color: var(--text-2); padding: 1px 0; }
.chart-tip .r b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tip .r i { width: 8px; height: 8px; border-radius: 2px; }
.recharts-text { fill: var(--text-3); font-size: 11.5px; }
.recharts-cartesian-axis-tick-value { font-variant-numeric: tabular-nums; }

/* ---------- Dock de configurações do protótipo ---------- */
.dock { position: fixed; right: 16px; bottom: 76px; z-index: 80; }
.dock-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--brand-2); color: #fff; cursor: pointer; box-shadow: var(--shadow-2); display: grid; place-items: center; }
.dock-panel { position: absolute; right: 0; bottom: 54px; width: 290px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-2); padding: 14px; display: grid; gap: 12px; animation: pop .14s ease; }
.dock-panel h4 { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.dock-panel .opt { display: grid; gap: 6px; }
.dock-panel .opt > span { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 600; }
.dock-panel .segmented { width: 100%; }
.dock-panel .segmented button { flex: 1; padding: 0 6px; }

/* Estado vazio / skeleton */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .ico { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; margin: 0 auto 12px; color: var(--text-3); }
.empty h4 { color: var(--text); font-size: 14px; margin-bottom: 4px; }
.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 4px; height: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* Utilitários */
.row { display: flex; gap: var(--gap); align-items: center; }
.col { display: flex; flex-direction: column; gap: var(--gap); }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mb { margin-bottom: 12px; }
.mt { margin-top: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .company-chip, .user-chip .who { display: none; }
}
@media (max-width: 760px) {
  .app-content { padding: 12px 16px 20px; }
  .sidebar:not(.collapsed) { position: fixed; z-index: 60; height: 100%; }
  .form-grid > [class*="span-"] { grid-column: span 12; }
  .labels-left .field { flex-direction: column; gap: 4px; }
  .labels-left .field > label, .labels-left .field > .lbl { width: auto; justify-content: flex-start; height: auto; }
  .search-trigger { width: auto; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .kpis { grid-template-columns: 1fr; }
}

/* Seção forçada com rótulo acima dentro de tela com rótulo à esquerda */
.labels-left .labels-top .field { flex-direction: column; gap: 4px; }
.labels-left .labels-top .field > label, .labels-left .labels-top .field > .lbl { width: auto; height: auto; justify-content: flex-start; text-align: left; }

/* Barra de ações se adapta à largura disponível */
.toolbar { container-type: inline-size; }
@container (max-width: 1360px) { .tb-btn.sec2 .tb-l { display: none; } .tb-btn.sec2 { padding: 0 8px; } }
@container (max-width: 1120px) { .tb-btn.sec .tb-l { display: none; } .tb-btn.sec { padding: 0 8px; } .goto span { display: none; } }

/* Itens de menu sem tela no protótipo: visíveis, porém desabilitados */
.nav-item.disabled, .mega a.disabled, .flyout a.disabled { opacity: .45; cursor: not-allowed; pointer-events: auto; }
.nav-item.disabled:hover, .mega a.disabled:hover, .flyout a.disabled:hover { background: transparent; color: inherit; }

/* ==========================================================================
   TELAS MENORES — notebooks 1366×768 (≈ 1366×650 úteis no navegador)
   ========================================================================== */
/* Menu lateral sobreposto abaixo de 1440px (controlado pelo AppShell) */
.sidebar-slot { display: contents; }
.sidebar-slot.small { display: block; position: relative; width: 60px; flex: none; z-index: 70; }
.sidebar-slot.small .sidebar { position: absolute; top: 0; left: 0; height: 100%; }
.sidebar-slot.small .sidebar:not(.collapsed) { box-shadow: 8px 0 32px rgba(10, 20, 30, .28); }
.sb-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 30, .28); z-index: 65; animation: pop .12s ease; }

/* Abas com setas quando não cabem */
.tabs-wrap { position: relative; }
.tabs-wrap .tabs { scrollbar-width: none; }
.tabs-wrap .tabs::-webkit-scrollbar { display: none; }
.tabs-arrow {
  position: absolute; top: 0; bottom: 1px; width: 34px; z-index: 2; border: 0; cursor: pointer; color: var(--text-2);
  display: grid; place-items: center;
}
.tabs-arrow.l { left: 0; background: linear-gradient(90deg, var(--surface) 55%, transparent); justify-items: start; padding-left: 4px; }
.tabs-arrow.r { right: 0; background: linear-gradient(270deg, var(--surface) 55%, transparent); justify-items: end; padding-right: 4px; }
.tabs-arrow:hover { color: var(--brand-2); }

/* Largura até 1440px: cabeçalho e rótulos mais enxutos */
@media (max-width: 1440px) {
  :root { --label-w: 106px; }
  .header { gap: 10px; padding: 0 14px; }
  .search-trigger { width: 230px; }
  .company-chip span, .company-chip .chip-text { display: none; }
  .app-content { padding: 12px 14px 20px; }
  .form-footer { bottom: -20px; margin: 12px -14px -20px; padding: 8px 14px; }
  .kpi { padding: 12px 14px; }
  .kpi .v { font-size: 23px; }
}

/* Altura até 820px (1366×768, 1280×720, 1440×900 com zoom): ganha ~120px de área útil */
@media (max-height: 820px) {
  .header, .sidebar-head { height: 48px; }
  .app-content { padding-top: 10px; }
  .page-head { margin-bottom: 8px; gap: 12px; }
  .page-title h1 { font-size: 18px; }
  .page-title .code { font-size: 13.5px; }
  .page-sub { font-size: 11.5px; margin-top: 1px; }
  .toolbar { padding: 4px; margin-bottom: 8px; }
  .tab { height: 34px; padding: 0 10px; }
  .card-head { min-height: 38px; padding: 7px 12px; }
  .card-body { padding: 10px 12px; }
  .mb { margin-bottom: 10px; }
  .kpis { gap: 10px; margin-bottom: 10px; }
  .kpi { padding: 10px 12px; }
  .kpi .v { font-size: 21px; margin: 3px 0 2px; }
  .form-footer .grand b { font-size: 16px; }
  .form-footer .grand { gap: 20px; }
  .nav-item { height: 31px; }
  .nav-section-title { padding: 10px 10px 4px; }
  .sidebar-search { padding: 8px 10px 4px; }
  .dock { bottom: 64px; right: 12px; }
  .dock-btn { width: 38px; height: 38px; }
  .field .hint { font-size: 11px; }
}
.search-trigger span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1440px) {
  .goto span { display: none; }
  .goto input { width: 92px; }
}
