/* ============ Tema ============ */
:root {
  --brand: #4f46e5;
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f1f3f6; --surface-3: #e8ebf0;
  --border: #e3e6eb; --border-strong: #cdd2da;
  --text: #151922; --muted: #5b6474; --faint: #8b93a1;
  --ok: #15803d; --ok-soft: #e6f5eb; --warn: #b45309; --warn-soft: #fdf1df;
  --danger: #c62828; --danger-soft: #fdeaea; --info: #0369a1; --info-soft: #e3f1f9;
  --purple: #6d28d9; --purple-soft: #f0eafd;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.07);
  --shadow-lg: 0 16px 40px rgba(16,24,40,.18);
  --r: 12px; --r-sm: 8px; --side: 252px;
  --brand-soft: color-mix(in srgb, var(--brand) 11%, var(--surface));
  --brand-text: color-mix(in srgb, var(--brand) 78%, var(--text));
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d1016; --surface: #151922; --surface-2: #1b2029; --surface-3: #242a35;
  --border: #262c37; --border-strong: #363e4c;
  --text: #e8eaef; --muted: #a3abba; --faint: #6f788a;
  --ok: #4ade80; --ok-soft: #10291a; --warn: #fbbf24; --warn-soft: #2d220e;
  --danger: #f87171; --danger-soft: #321515; --info: #38bdf8; --info-soft: #0e2432;
  --purple: #c4b5fd; --purple-soft: #231b3b;
  --shadow: 0 1px 3px rgba(0,0,0,.45); --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  --brand-soft: color-mix(in srgb, var(--brand) 22%, var(--surface));
  --brand-text: color-mix(in srgb, var(--brand) 45%, #ffffff);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; } .mb-s { margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.ti { font-size: 18px; line-height: 1; vertical-align: -3px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.ok-t { color: var(--ok); } .warn-t { color: var(--warn); } .danger-t { color: var(--danger); } .info-t { color: var(--info); }

/* ============ Layout ============ */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 17px; }
.brand b { display: block; font-size: 15px; } .brand small { color: var(--muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.nav { padding: 10px 10px 20px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text); font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; text-align: left; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item .ti { color: var(--muted); }
.nav-item .chev { margin-left: auto; font-size: 15px; transition: transform .15s; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-text); }
.nav-item.active .ti { color: var(--brand-text); }
.nav-group.open > .nav-item .chev { transform: rotate(90deg); }
.nav-subs { display: none; padding: 2px 0 6px 18px; }
.nav-group.open .nav-subs { display: block; }
.nav-sub { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--r-sm); color: var(--muted); font-size: 13.5px; }
.nav-sub:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-sub.active { color: var(--brand-text); background: var(--brand-soft); font-weight: 500; }
.nav-sub .ti { font-size: 16px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 4px; font-weight: 600; }
.side-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 20px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.crumb { display: flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.crumb .ti { color: var(--faint); font-size: 15px; }
.crumb span { color: var(--muted); font-weight: 500; }
.content { padding: 22px 24px 48px; max-width: 1600px; width: 100%; }
.hamb { display: none; }
.scrim { display: none; }
.gsearch { position: relative; margin-left: auto; width: min(380px, 40vw); }
.gsearch input { width: 100%; padding: 8px 12px 8px 34px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; }
.gsearch input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); background: var(--surface); }
.gsearch > .ti { position: absolute; left: 11px; top: 9px; color: var(--faint); }
.gresults { position: absolute; top: 42px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; display: none; }
.gresults.show { display: block; }
.gres { display: flex; gap: 10px; align-items: center; padding: 9px 12px; cursor: pointer; }
.gres:hover { background: var(--surface-2); }
.gres small { color: var(--muted); display: block; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.bell { position: relative; }
.bell .count { position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.dropdown { position: absolute; right: 0; top: 46px; width: 360px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden; }
.dropdown .dd-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.dropdown .dd-body { max-height: 420px; overflow: auto; }
.ntf { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.ntf:hover { background: var(--surface-2); }
.ntf.unread { background: var(--brand-soft); }
.ntf .ti { margin-top: 2px; }
.userchip { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; position: relative; }
.userchip:hover { background: var(--surface-2); }
.userchip .who { line-height: 1.2; } .userchip .who small { color: var(--muted); display: block; font-size: 11.5px; }
.dd-item { display: flex; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; }
.dd-item:hover { background: var(--surface-2); }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .app.side-open .sidebar { transform: none; }
  .app.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .hamb { display: inline-flex; }
  .content { padding: 16px 16px 40px; }
  .topbar { padding: 0 12px; gap: 6px; }
  .gsearch { width: auto; flex: 1; }
  .userchip .who { display: none; }
  .crumb { display: none; }
}

/* ============ Componentes ============ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ti { font-size: 17px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); border-color: transparent; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
[data-theme="dark"] .btn-ok { color: #06240f; }
.btn-ok:hover { background: color-mix(in srgb, var(--ok) 88%, #000); }
.btn-danger { background: var(--surface); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 8px; border-radius: 999px; background: transparent; border: 0; color: var(--muted); cursor: pointer; display: inline-flex; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.btn-group button { border: 0; background: none; padding: 7px 12px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.btn-group button + button { border-left: 1px solid var(--border); }
.btn-group button.active { background: var(--brand-soft); color: var(--brand-text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.card.pad, .pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 0; }
.card-head h3 { display: flex; gap: 8px; align-items: center; }
.card-head .ti { color: var(--muted); }
.card-body { padding: 12px 18px 16px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 10px; }
.page-head h1 .ti { font-size: 24px; color: var(--brand-text); }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid transparent; }
.b-ok { background: var(--ok-soft); color: var(--ok); } .b-warn { background: var(--warn-soft); color: var(--warn); }
.b-danger { background: var(--danger-soft); color: var(--danger); } .b-info { background: var(--info-soft); color: var(--info); }
.b-brand { background: var(--brand-soft); color: var(--brand-text); } .b-purple { background: var(--purple-soft); color: var(--purple); }
.b-outline { background: transparent; border-color: var(--border); }
.badge .ti { font-size: 13px; vertical-align: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; cursor: pointer; color: var(--muted); }
.chip.active { background: var(--brand-soft); color: var(--brand-text); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatars { display: inline-flex; } .avatars .avatar { border: 2px solid var(--surface); margin-left: -6px; } .avatars .avatar:first-child { margin-left: 0; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: flex-start; }
.kpi[data-href] { cursor: pointer; } .kpi[data-href]:hover { border-color: var(--border-strong); }
.kpi .kico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); flex: none; }
.kpi .kico.ok { background: var(--ok-soft); color: var(--ok); } .kpi .kico.warn { background: var(--warn-soft); color: var(--warn); }
.kpi .kico.danger { background: var(--danger-soft); color: var(--danger); } .kpi .kico.info { background: var(--info-soft); color: var(--info); }
.kpi .klabel { color: var(--muted); font-size: 12.5px; }
.kpi .kval { font-size: 21px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
.kpi .ksub { font-size: 12px; color: var(--muted); }

.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; }
.progress.ok > div { background: var(--ok); } .progress.warn > div { background: var(--warn); } .progress.danger > div { background: var(--danger); }

/* Atenção */
.attention { border-left: 0; }
.att-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.att { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); cursor: pointer; border: 1px solid transparent; }
.att:hover { border-color: var(--border-strong); }
.att .ti { font-size: 20px; }
.att b { font-size: 18px; min-width: 26px; }
.att.danger .ti, .att.danger b { color: var(--danger); } .att.warn .ti, .att.warn b { color: var(--warn); } .att.info .ti, .att.info b { color: var(--info); }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; } .chart-box.short { height: 200px; }

/* Tabelas */
.tbl-tools { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tbl-extra { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1; }
.search { position: relative; }
.search input { padding-left: 32px !important; min-width: 220px; }
.search .ti { position: absolute; left: 10px; top: 9px; color: var(--faint); font-size: 16px; }
.tbl-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); user-select: none; }
.tbl th.sortable { cursor: pointer; } .tbl th.sortable:hover { color: var(--text); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); }
.tbl .acts { white-space: nowrap; text-align: right; }
.tbl-foot { padding: 10px 14px; color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); }
.tbl.compact td, .tbl.compact th { padding: 7px 10px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ti { font-size: 34px; color: var(--faint); display: block; margin: 0 auto 8px; }

/* Formulários */
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field .req { color: var(--danger); font-weight: 600; }
.field .err { color: var(--danger); font-size: 12px; }
.field .err:empty { display: none; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-9 { grid-column: span 9; }
@media (max-width: 640px) { .form-grid > * { grid-column: span 12 !important; } }
.form-section { grid-column: span 12; font-weight: 600; font-size: 13px; padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; display: flex; gap: 8px; align-items: center; }
.form-section:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.input-pre { display: flex; align-items: stretch; }
.input-pre span { padding: 8px 10px; border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.input-pre input { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text) !important; cursor: pointer; font-weight: 400 !important; }
.multi { display: flex; flex-wrap: wrap; gap: 6px; }
.multi label { display: inline-flex; gap: 6px; align-items: center; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 13px; color: var(--text); font-weight: 400; }
.multi label:has(input:checked) { background: var(--brand-soft); border-color: transparent; color: var(--brand-text); }
.items-tbl td { padding: 4px; border: 0; } .items-tbl th { padding: 4px; background: none; border: 0; }
.items-tbl input, .items-tbl select { padding: 6px 8px; }

/* Modal e drawer */
.modal-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; background: rgba(10,14,22,.45); animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; display: flex; flex-direction: column; animation: pop .14s; }
.modal.sm { max-width: 420px; } .modal.lg { max-width: 820px; } .modal.xl { max-width: 1100px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; flex-wrap: wrap; }
.drawer-wrap { position: fixed; inset: 0; z-index: 80; }
.drawer-bg { position: absolute; inset: 0; background: rgba(10,14,22,.35); animation: fade .12s; }
.drawer { position: absolute; right: 0; top: 0; bottom: 0; background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .18s; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 20px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 18px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer-actions:empty { display: none; }
.drawer-body { padding: 16px 20px 40px; overflow-y: auto; flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: .4; } }

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; max-width: 380px; animation: pop .15s; font-size: 13.5px; }
.toast.ok .ti { color: #4ade80; } .toast.warn .ti { color: #fbbf24; } .toast.danger .ti { color: #f87171; } .toast.info .ti { color: #7dd3fc; }

/* Abas */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 14px; background: none; border: 0; border-bottom: 2px solid transparent; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-text); border-bottom-color: var(--brand); }
.tcount { background: var(--surface-3); color: var(--muted); border-radius: 99px; padding: 0 7px; font-size: 11.5px; margin-left: 4px; }

/* Kanban */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 60vh; }
.kcol { flex: 0 0 284px; background: var(--surface-2); border-radius: var(--r); border: 1px solid var(--border); display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
.kcol.over { outline: 2px dashed var(--brand); outline-offset: -2px; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px 8px; font-size: 13px; }
.kcol-head b { flex: 1; font-weight: 600; }
.kcount { background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 0 8px; font-size: 12px; color: var(--muted); }
.ksum { font-size: 12px; padding: 0 12px 6px; color: var(--muted); }
.kcol-body { padding: 4px 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; box-shadow: var(--shadow); transition: border-color .12s, transform .12s; }
.kcard:hover { border-color: var(--border-strong); }
.kcard.dragging { opacity: .45; transform: rotate(1.5deg); }
.kcard .kt { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.kcard .ks { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kcard .kf { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.kcard .kf .grow { min-width: 10px; }
.kcard.accent-danger { border-left: 3px solid var(--danger); } .kcard.accent-ok { border-left: 3px solid var(--ok); } .kcard.accent-warn { border-left: 3px solid var(--warn); }
.kempty { color: var(--faint); font-size: 12.5px; text-align: center; padding: 14px 0; border: 1px dashed var(--border-strong); border-radius: 10px; }

/* Listas e timeline */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl { position: relative; padding-bottom: 14px; }
.tl::before { content: ''; position: absolute; left: -19px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }
.tl small { color: var(--muted); display: block; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item.click { cursor: pointer; } .list-item.click:hover { background: var(--surface-2); margin: 0 -10px; padding: 10px; border-radius: 8px; }
.ico-box { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.checklist label { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; cursor: pointer; background: var(--surface); }
.checklist label.done span { text-decoration: line-through; color: var(--muted); }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.file { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--surface); font-size: 12.5px; }
.file .thumb { height: 82px; border-radius: 7px; background: var(--surface-2); display: grid; place-items: center; margin-bottom: 8px; color: var(--faint); overflow: hidden; }
.file .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file .thumb .ti { font-size: 30px; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.note.warn { background: var(--warn-soft); color: var(--warn); } .note.ok { background: var(--ok-soft); color: var(--ok); } .note.danger { background: var(--danger-soft); color: var(--danger); }
.note .ti { margin-top: 1px; }
.stars { color: #f59e0b; letter-spacing: 1px; }
.seg-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 18px 0 8px; }

/* Agenda */
.agenda { display: grid; grid-template-columns: 56px repeat(6, minmax(130px, 1fr)); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); overflow: auto; }
.ag-h { position: sticky; top: 0; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 8px; font-size: 12.5px; font-weight: 600; text-align: center; z-index: 2; }
.ag-h.today { color: var(--brand-text); background: var(--brand-soft); }
.ag-hours { border-right: 1px solid var(--border); }
.ag-hour { height: 52px; font-size: 11px; color: var(--faint); text-align: right; padding: 2px 6px 0 0; border-bottom: 1px dashed var(--border); }
.ag-day { position: relative; border-right: 1px solid var(--border); }
.ag-day:last-child { border-right: 0; }
.ag-slot { height: 52px; border-bottom: 1px dashed var(--border); }
.ag-ev { position: absolute; left: 4px; right: 4px; border-radius: 7px; padding: 5px 7px; font-size: 12px; overflow: hidden; cursor: pointer; border-left: 3px solid; line-height: 1.3; }
.ag-ev b { display: block; font-size: 12px; }
.ag-ev.done { opacity: .62; }

/* Mapa */
.map { height: calc(100vh - 230px); min-height: 420px; border-radius: var(--r); border: 1px solid var(--border); z-index: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.pin { width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: var(--brand); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero h1 { font-size: 34px; line-height: 1.15; max-width: 480px; }
.login-hero p { opacity: .85; max-width: 460px; font-size: 15px; }
.login-hero .logo { width: 44px; height: 44px; border-radius: 12px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.login-hero .feat { display: flex; gap: 10px; align-items: center; margin: 8px 0; opacity: .92; }
.login-side { padding: 40px; overflow-y: auto; max-height: 100vh; }
.login-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.login-user { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: var(--text); }
.login-user:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.login-user small { color: var(--muted); display: block; }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; } .login-hero { padding: 28px; } .login-hero h1 { font-size: 24px; } .login-side { padding: 20px; max-height: none; } }

/* App de campo (celular) */
.mobile-shell { max-width: 480px; margin: 0 auto; }
.m-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.m-big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.m-big button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); font: inherit; font-size: 12.5px; color: var(--text); cursor: pointer; }
.m-big .ti { font-size: 24px; color: var(--brand-text); }
.phone-hint { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }

/* Base de conhecimento */
.kb { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.kb-tree a { display: flex; gap: 8px; padding: 6px 10px; border-radius: 7px; color: var(--text); align-items: center; }
.kb-tree a:hover { background: var(--surface-2); text-decoration: none; }
.kb-tree a.active { background: var(--brand-soft); color: var(--brand-text); }
.kb-tree .sub { padding-left: 18px; }
.kb-article { line-height: 1.7; font-size: 15px; }
.kb-article h2 { margin: 18px 0 8px; } .kb-article h3 { margin: 16px 0 6px; }
.kb-article ul, .kb-article ol { padding-left: 22px; }
.kb-article code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.editor { min-height: 280px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 12px 14px; background: var(--surface); line-height: 1.7; }
.editor:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); }
.ed-tools { display: flex; gap: 4px; margin-bottom: 6px; }
@media (max-width: 860px) { .kb { grid-template-columns: 1fr; } }

/* Mídia */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.media { border-radius: var(--r); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.media .mthumb { height: 130px; display: grid; place-items: center; color: #fff; position: relative; }
.media .mthumb .ti { font-size: 34px; opacity: .9; }
.media .mthumb .dur { position: absolute; bottom: 6px; right: 8px; background: rgba(0,0,0,.55); padding: 1px 6px; border-radius: 5px; font-size: 11px; }
.media .minfo { padding: 10px 12px; font-size: 12.5px; }

/* Etiquetas */
.labels { display: grid; gap: 0; background: #fff; color: #000; margin: 0 auto; }
.labels.a4 { grid-template-columns: repeat(3, 70mm); width: 210mm; padding: 8mm 0; justify-content: center; }
.labels.a4 .label { width: 70mm; height: 36mm; }
.labels.termica { grid-template-columns: 100mm; width: 100mm; }
.labels.termica .label { width: 100mm; height: 50mm; page-break-after: always; }
.label { border: 1px dashed #bbb; padding: 3mm; display: flex; gap: 3mm; align-items: center; font-family: 'Inter', sans-serif; overflow: hidden; }
.label .qr { flex: none; }
.label .loc { font-size: 20px; font-weight: 800; letter-spacing: .02em; line-height: 1; }
.labels.termica .label .loc { font-size: 30px; }
.label .lname { font-size: 10px; font-weight: 600; line-height: 1.2; margin: 3px 0; max-height: 2.4em; overflow: hidden; }
.labels.termica .label .lname { font-size: 13px; }
.label .lmeta { font-size: 8.5px; color: #333; line-height: 1.35; }
.labels.termica .label .lmeta { font-size: 11px; }
.label-preview { background: var(--surface-2); padding: 20px; border-radius: var(--r); overflow: auto; }

/* Documentos e proposta */
.doc-root { min-height: 100vh; background: var(--surface-2); padding: 24px 12px 60px; }
.doc-bar { max-width: 860px; margin: 0 auto 16px; display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.paper { max-width: 860px; margin: 0 auto; background: #fff; color: #1a1d24; border-radius: 6px; box-shadow: var(--shadow-lg); padding: 56px 64px; font-size: 13.5px; line-height: 1.65; }
.paper h1 { font-size: 22px; margin-bottom: 4px; } .paper h2 { font-size: 15px; margin: 22px 0 8px; }
.paper .muted { color: #5b6474; }
.paper table { width: 100%; border-collapse: collapse; margin: 10px 0; } .paper td, .paper th { border: 1px solid #ddd; padding: 6px 9px; text-align: left; font-size: 13px; }
.paper .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 60px; text-align: center; font-size: 12.5px; }
.paper .sign div { border-top: 1px solid #333; padding-top: 6px; }
.stamp { display: inline-flex; gap: 8px; align-items: center; border: 2px solid #15803d; color: #15803d; padding: 6px 12px; border-radius: 8px; font-weight: 600; transform: rotate(-2deg); }
@media (max-width: 700px) { .paper { padding: 28px 22px; } }

.prop { max-width: 960px; margin: 0 auto; background: #fff; color: #1a1d24; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-lg); }
.prop-cover { background: var(--brand); color: #fff; padding: 64px 64px 56px; position: relative; overflow: hidden; }
.prop-cover::after { content: ''; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 50%; background: rgba(255,255,255,.08); }
.prop-cover::before { content: ''; position: absolute; right: 80px; bottom: -160px; width: 300px; height: 300px; border-radius: 50%; background: rgba(255,255,255,.06); }
.prop-cover .pbrand { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 70px; position: relative; z-index: 1; }
.prop-cover .pbrand .logo { width: 36px; height: 36px; border-radius: 10px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; }
.prop-cover h1 { font-size: 40px; line-height: 1.1; max-width: 620px; position: relative; z-index: 1; letter-spacing: -.02em; }
.prop-cover p { font-size: 17px; opacity: .9; margin-top: 14px; position: relative; z-index: 1; }
.prop-cover .pmeta { display: flex; gap: 28px; margin-top: 40px; font-size: 13px; opacity: .9; position: relative; z-index: 1; flex-wrap: wrap; }
.prop-cover .pmeta b { display: block; font-size: 15px; }
.prop-sec { padding: 44px 64px; border-bottom: 1px solid #eceef2; }
.prop-sec h2 { font-size: 24px; letter-spacing: -.01em; margin-bottom: 6px; }
.prop-sec .lead { color: #5b6474; font-size: 15.5px; max-width: 720px; line-height: 1.7; }
.prop-amb { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 24px; }
.prop-amb .amb { border: 1px solid #e6e8ee; border-radius: 14px; padding: 20px; break-inside: avoid; }
.prop-amb .amb .aico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); margin-bottom: 12px; }
.prop-amb .amb .aico .ti { font-size: 22px; }
.prop-amb .amb h3 { font-size: 16px; margin-bottom: 8px; }
.prop-amb .amb ul { margin: 0; padding-left: 18px; color: #3d4452; font-size: 14px; line-height: 1.65; }
.prop-inc { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 24px; margin-top: 18px; }
.prop-inc div { display: flex; gap: 10px; align-items: center; font-size: 14.5px; }
.prop-inc .ti { color: var(--brand); font-size: 20px; }
.prop-inv { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; margin-top: 24px; align-items: stretch; }
.prop-inv .big { background: #111827; color: #fff; border-radius: 16px; padding: 28px; }
.prop-inv .big small { opacity: .7; font-size: 13px; }
.prop-inv .big .v { font-size: 40px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0; }
.prop-inv .cond { border: 1px solid #e6e8ee; border-radius: 16px; padding: 24px; font-size: 14px; }
.prop-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 22px; }
.prop-steps div { border-top: 3px solid var(--brand); padding-top: 10px; font-size: 13px; color: #3d4452; }
.prop-steps b { display: block; color: #1a1d24; font-size: 14px; margin-bottom: 2px; }
.prop-foot { padding: 32px 64px; display: flex; justify-content: space-between; align-items: center; gap: 20px; background: #fafbfc; flex-wrap: wrap; }
@media (max-width: 760px) {
  .prop-cover, .prop-sec, .prop-foot { padding-left: 24px; padding-right: 24px; }
  .prop-cover h1 { font-size: 28px; }
  .prop-amb, .prop-inc, .prop-inv { grid-template-columns: 1fr; }
  .prop-steps { grid-template-columns: 1fr 1fr; }
}

.keypad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.keypad { border: 1px solid #d8dbe2; border-radius: 12px; padding: 14px; background: #f7f8fa; break-inside: avoid; }
.keypad .kp { background: #fff; border: 1px solid #cfd3db; border-radius: 10px; padding: 10px; display: grid; gap: 6px; }
.keypad .key { border: 1px solid #e1e4ea; border-radius: 6px; padding: 7px; text-align: center; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #222; }

/* Impressão */
@media print {
  @page { margin: 10mm; }
  html, body { background: #fff !important; }
  .sidebar, .topbar, .no-print, .toasts, .doc-bar { display: none !important; }
  .app { display: block; } .content { padding: 0; max-width: none; }
  .doc-root { padding: 0; background: #fff; }
  .paper, .prop { box-shadow: none; border-radius: 0; max-width: none; }
  .prop-cover, .prop-inv .big { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .prop-sec { break-inside: avoid-page; }
  .label-preview { padding: 0; background: #fff; }
  .labels .label { border-color: transparent; }
}

/* ============ Celular e telas estreitas ============ */
html { overflow-x: hidden; }
.main { overflow-x: clip; }
.grid > *, .kb > *, .form-grid > *, .toolbar > *, .page-head > * { min-width: 0; max-width: 100%; }
.btn-group { max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.btn-group::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.btn-group button { white-space: nowrap; flex: none; }
.tabs { scrollbar-width: none; }
.tbl-scroll .tbl th:first-child, .tbl-scroll .tbl td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.tbl-scroll .tbl th:first-child { background: var(--surface-2); }
.tbl-scroll .tbl tfoot td:first-child { background: var(--surface-2); }
.tbl tbody tr.click:hover td:first-child { background: var(--surface-2); }
.ag-list .ag-day-h { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin: 16px 0 8px; }
.ag-list .ag-day-h.today { color: var(--brand-text); }
.ag-item { display: flex; gap: 12px; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; margin-bottom: 8px; cursor: pointer; border-left: 4px solid var(--faint); box-shadow: var(--shadow); }
.ag-item .hr { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 54px; }
.ag-item .hr small { display: block; font-weight: 400; color: var(--muted); }

@media (max-width: 960px) {
  input, select, textarea, .gsearch input { font-size: 16px; }
  .dropdown { position: fixed; left: 8px; right: 8px; top: calc(62px + env(safe-area-inset-top, 0px)); width: auto; max-width: none; }
  .content { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .kb { grid-template-columns: minmax(0, 1fr); }
  .modal-wrap { padding: 12px 8px; }
  .modal-body { padding: 16px 14px; }
  .modal-head, .modal-foot { padding-left: 14px; padding-right: 14px; }
  .drawer-head, .drawer-actions { padding-left: 14px; padding-right: 14px; }
  .drawer-body { padding: 14px 14px calc(60px + env(safe-area-inset-bottom, 0px)); }
  .kanban { scroll-snap-type: x mandatory; min-height: 0; }
  .kcol { flex-basis: 82vw; max-width: 320px; scroll-snap-align: start; max-height: none; }
  .search, .search input { width: 100%; min-width: 0; }
  .tbl-tools .search { flex: 1 1 100%; }
  .toolbar select, .toolbar input { min-width: 0; }
  .page-head h1 { font-size: 20px; }
  .dl { grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .tbl.stackable thead { display: none; }
  .tbl.stackable, .tbl.stackable tbody, .tbl.stackable tr, .tbl.stackable td { display: block; width: 100%; }
  .tbl.stackable tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .tbl.stackable tbody tr:last-child { border-bottom: 0; }
  .tbl.stackable td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; position: static; background: transparent !important; }
  .tbl.stackable td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: left; flex: none; max-width: 45%; }
  .tbl.stackable td:first-child { display: block; text-align: left; font-size: 15px; padding-bottom: 6px; }
  .tbl.stackable td:first-child::before, .tbl.stackable td[data-label=""]::before { display: none; }
  .tbl.stackable td:empty { display: none; }
  .tbl.stackable td.acts { justify-content: flex-end; padding-top: 8px; flex-wrap: wrap; }
  .tbl.stackable tfoot { display: block; }
  .tbl.stackable tfoot tr { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 14px; background: var(--surface-2); }
  .tbl.stackable tfoot td { display: block; width: auto; padding: 0; background: transparent; border: 0; }
  .tbl.stackable tfoot td::before { display: none; }
  .tbl.stackable .empty { padding: 24px 8px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px; gap: 8px; flex-direction: column; }
  .kpi .kico { width: 30px; height: 30px; }
  .kpi .kval { font-size: 18px; }
  .att-list { grid-template-columns: 1fr; }
  .content { padding-left: 12px; padding-right: 12px; }
  .drawer-actions .btn { flex: 1 1 auto; justify-content: center; }
}
.tbl .tv:empty { display: none; }
@media (max-width: 640px) {
  .tbl.stackable td > .tv { min-width: 0; text-align: right; overflow-wrap: anywhere; }
  .tbl.stackable td:first-child > .tv { text-align: left; }
  .tbl.stackable td:has(> .tv:empty) { display: none; }
  .tbl.stackable td.acts > .tv { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
  .tbl.stackable td .tv .row { justify-content: flex-end; }
  .tbl.stackable td:first-child .tv .row { justify-content: flex-start; }
}
