/* ============================================================
   Bigmater · Manutenção — operations console
   Light, data-dense, action-first. No build step.
   ============================================================ */

:root {
  color-scheme: light;

  /* Neutrals */
  --bg: #f5f6f9;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, #eef2ff 0%, rgba(238, 242, 255, 0) 55%),
    radial-gradient(900px 500px at -5% 0%, #eef6ff 0%, rgba(238, 246, 255, 0) 45%), var(--bg);
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --surface-muted: #f1f3f8;
  --ink: #0d1426;
  --ink-2: #3b4660;
  --muted: #6b7689;
  --faint: #97a1b4;
  --line: #e7eaf1;
  --line-2: #dde1ea;

  /* Brand */
  --brand: #2554ff;
  --brand-ink: #1d44d6;
  --brand-soft: #eaf0ff;
  --brand-softer: #f3f6ff;

  /* Status */
  --bad: #e11d48;
  --bad-soft: #fff0f3;
  --bad-line: #fbcfd9;
  --warn: #c2730a;
  --warn-strong: #e08a0b;
  --warn-soft: #fff7e9;
  --warn-line: #f6e0b5;
  --ok: #0d9f6e;
  --ok-soft: #e9faf2;
  --ok-line: #bdeed7;
  --idle: #6b7689;
  --idle-soft: #f0f2f7;
  --idle-line: #dfe3ec;

  /* Geometry */
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(13, 20, 38, 0.05);
  --shadow-sm: 0 1px 2px rgba(13, 20, 38, 0.04), 0 4px 12px rgba(13, 20, 38, 0.04);
  --shadow-md: 0 2px 6px rgba(13, 20, 38, 0.05), 0 14px 34px rgba(13, 20, 38, 0.08);
  --shadow-pop: 0 10px 30px rgba(13, 20, 38, 0.14), 0 2px 8px rgba(13, 20, 38, 0.08);

  --topbar-h: 64px;
  --maxw: 1240px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg-grad);
  background-attachment: fixed;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv05" 1, "ss01" 1;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

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

svg.ic {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: -0.14em;
}

/* ============================================================
   App shell
   ============================================================ */
.app-root {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--topbar-h);
  padding: 0 clamp(16px, 4vw, 34px);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(1.5) blur(12px);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 0 0 auto;
}

.brand-logo {
  height: 26px;
  width: auto;
  display: block;
  /* logo art is on a white background; multiply drops the white into the bar */
  mix-blend-mode: multiply;
}
.brand-sep {
  width: 1px;
  height: 22px;
  background: var(--line-2);
  flex: 0 0 auto;
}
.brand-cap {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Module switcher (Manutenção / Recursos Humanos) */
.mod-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.mod-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.mod-btn .ic {
  font-size: 15px;
}
.mod-btn:hover {
  color: var(--ink);
  background: var(--surface-muted);
}
.mod-btn.active {
  color: var(--brand-ink);
  background: var(--brand-soft);
}

.brand-login {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 22px;
}
.brand-login .brand-logo {
  height: 38px;
}
.brand-login .brand-cap {
  font-size: 12.5px;
  color: var(--faint);
}

.global-search {
  position: relative;
  flex: 1 1 420px;
  max-width: 460px;
  margin-left: 6px;
}
.global-search .ic {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--faint);
  pointer-events: none;
}
.global-search input {
  width: 100%;
  height: 40px;
  padding: 0 64px 0 38px;
  background: var(--surface-muted);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.global-search input::placeholder {
  color: var(--faint);
}
.global-search input:focus {
  outline: none;
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.global-search kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 1px 7px;
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
}

.search-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 60;
  max-height: 60vh;
  overflow: auto;
}
.search-pop .empty {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}
.search-res {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
}
.search-res:hover {
  background: var(--brand-softer);
}
.search-res .plate {
  font-weight: 700;
  letter-spacing: -0.01em;
}
.search-res .sub {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
}

/* Nav */
.nav-wrap {
  position: sticky;
  top: var(--topbar-h);
  z-index: 30;
  background: rgba(245, 246, 249, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex;
  gap: 4px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 7px clamp(16px, 4vw, 34px);
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar {
  display: none;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-link .ic {
  font-size: 16px;
}
.nav-link:hover {
  color: var(--ink);
  background: var(--surface-muted);
}
.nav-link.active {
  color: var(--brand-ink);
  background: var(--brand-soft);
}
.nav-link .badge {
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  display: inline-grid;
  place-items: center;
  background: var(--bad);
  color: #fff;
}

/* Main */
.main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 30px) clamp(16px, 4vw, 34px) 80px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: clamp(21px, 3vw, 26px);
  font-weight: 800;
  letter-spacing: -0.025em;
}
.page-head p {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 3px;
}
.view {
  animation: viewIn 0.32s var(--ease) both;
}
@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform 0.06s, background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn .ic {
  font-size: 16px;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 84, 255, 0.3), 0 6px 16px rgba(37, 84, 255, 0.22);
}
.btn-primary:hover {
  background: var(--brand-ink);
}
.btn-ghost {
  background: var(--surface);
  border-color: var(--line-2);
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
}
.btn-ghost:hover {
  border-color: var(--faint);
  color: var(--ink);
}
.btn-subtle {
  background: var(--surface-muted);
  color: var(--ink-2);
}
.btn-subtle:hover {
  background: #e9ecf3;
  color: var(--ink);
}
.btn-danger {
  background: var(--surface);
  border-color: var(--bad-line);
  color: var(--bad);
}
.btn-danger:hover {
  background: var(--bad-soft);
}
.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.menu {
  position: relative;
}
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 230px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 70;
  animation: viewIn 0.16s var(--ease) both;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 0;
  background: none;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.menu-item .ic {
  font-size: 16px;
  color: var(--faint);
}
.menu-item:hover {
  background: var(--brand-softer);
  color: var(--ink);
}
.menu-item.danger {
  color: var(--bad);
}
.menu-item.danger .ic {
  color: var(--bad);
}
.menu-item.danger:hover {
  background: var(--bad-soft);
}
.menu-sep {
  height: 1px;
  background: var(--line);
  margin: 5px 6px;
}

/* ============================================================
   Cards / panels
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.panel-pad {
  padding: clamp(16px, 2.4vw, 22px);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head .ttl {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.panel-head .sub {
  font-size: 12.5px;
  color: var(--muted);
}
.panel-head .ph-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--surface-muted);
  color: var(--ink-2);
  font-size: 17px;
}
.panel-head .spacer {
  margin-left: auto;
}

.grid {
  display: grid;
  gap: 14px;
}

/* ============================================================
   KPI strip
   ============================================================ */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--idle-line);
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.kpi.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.kpi .kpi-top {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}
.kpi .kpi-top .ic {
  font-size: 15px;
}
.kpi .kpi-val {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.kpi .kpi-note {
  font-size: 11.5px;
  color: var(--faint);
}
.kpi.t-bad::before {
  background: var(--bad);
}
.kpi.t-bad .kpi-top,
.kpi.t-bad .kpi-val {
  color: var(--bad);
}
.kpi.t-warn::before {
  background: var(--warn-strong);
}
.kpi.t-warn .kpi-top,
.kpi.t-warn .kpi-val {
  color: var(--warn);
}
.kpi.t-ok::before {
  background: var(--ok);
}
.kpi.t-ok .kpi-top {
  color: var(--ok);
}
.kpi.t-idle::before {
  background: var(--idle);
}

/* ============================================================
   Painel layout
   ============================================================ */
.painel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.col-stack {
  display: grid;
  gap: 16px;
}

/* Worklist */
.worklist-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.seg {
  display: inline-flex;
  background: var(--surface-muted);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: none;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}
.seg button .n {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}
.seg button:hover {
  color: var(--ink);
}
.seg button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}
.seg button.active.t-bad {
  color: var(--bad);
}
.seg button.active.t-warn {
  color: var(--warn);
}

.rows {
  display: flex;
  flex-direction: column;
}
.row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 16px 13px 18px;
  border-bottom: 1px solid var(--line);
  position: relative;
  transition: background 0.12s;
}
.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}
.row:last-child {
  border-bottom: 0;
}
.row:hover {
  background: var(--surface-2);
}
.row.s-bad::before {
  background: var(--bad);
}
.row.s-warn::before {
  background: var(--warn-strong);
}
.row.s-ok::before {
  background: var(--ok);
}
.row.s-missing::before {
  background: var(--idle);
}
.row-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--ink-2);
  font-size: 18px;
}
.row-main {
  min-width: 0;
  flex: 1 1 auto;
}
.row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.row-title .plate {
  white-space: nowrap;
}
.row-title .wl-svc {
  color: var(--ink-2);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}
.row-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-2);
}
.row-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}
.row-summary {
  text-align: right;
  font-size: 12.5px;
}
.row-summary strong {
  display: block;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.row-summary.s-bad strong {
  color: var(--bad);
}
.row-summary.s-warn strong {
  color: var(--warn);
}
.row-summary span {
  color: var(--faint);
}
.row .chev {
  color: var(--faint);
  font-size: 18px;
}

/* status chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px 0 7px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip .ic {
  font-size: 13px;
}
.chip .dotc {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.chip.s-bad {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: var(--bad-line);
}
.chip.s-bad .dotc {
  background: var(--bad);
}
.chip.s-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-line);
}
.chip.s-warn .dotc {
  background: var(--warn-strong);
}
.chip.s-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-line);
}
.chip.s-ok .dotc {
  background: var(--ok);
}
.chip.s-missing {
  background: var(--idle-soft);
  color: var(--idle);
  border-color: var(--idle-line);
}
.chip.s-missing .dotc {
  background: var(--idle);
}

/* mini list (side column) */
.mini {
  display: flex;
  flex-direction: column;
}
.mini-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}
.mini-item:last-child {
  border-bottom: 0;
}
.mini-item:hover {
  background: var(--surface-2);
}
.mini-main {
  min-width: 0;
  flex: 1;
}
.mini-main strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-main span {
  font-size: 12px;
  color: var(--muted);
}
.mini-val {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  white-space: nowrap;
}

/* analysis */
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.metric {
  background: #fff;
  padding: 13px 15px;
}
.metric .m-val {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.metric .m-lab {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
}
.barlist {
  display: grid;
  gap: 10px;
  padding: 4px 2px;
}
.barline {
  display: grid;
  gap: 5px;
}
.barline .bl-top {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}
.barline .bl-top span {
  color: var(--ink-2);
  font-weight: 500;
}
.barline .bl-top b {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
}
.bartrack {
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  overflow: hidden;
}
.bartrack > i {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, #5b82ff, var(--brand));
}

/* histogram (vertical columns for distributions) */
.histo {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 6px 0 2px;
}
.histo-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.histo-n {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.histo-bz {
  width: 100%;
  height: 144px;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(var(--surface-muted), var(--surface-muted)) bottom / 100% 1px no-repeat;
  border-radius: 7px 7px 0 0;
}
.histo-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 7px 7px 0 0;
  transition: height 0.5s var(--ease);
}
.histo-x {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

/* ============================================================
   Tables (fleet, history)
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.subtabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px;
  gap: 2px;
  box-shadow: var(--shadow-xs);
}
.subtabs a,
.subtabs button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.subtabs a .ic,
.subtabs button .ic {
  font-size: 15px;
}
.subtabs a .n,
.subtabs button .n {
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--faint);
}
.subtabs a:hover,
.subtabs button:hover {
  color: var(--ink);
}
.subtabs a.active,
.subtabs button.active {
  background: var(--brand);
  color: #fff;
}
.subtabs a.active .n,
.subtabs button.active .n {
  color: rgba(255, 255, 255, 0.7);
}

.search-inline {
  position: relative;
  flex: 1 1 220px;
  max-width: 320px;
}
/* Dentro de um campo de filtro (coluna flex), o flex-basis de 220px viraria ALTURA e
   esticava a caixa — o ícone da lupa caía para baixo. Aqui a altura é só a do input. */
.field .search-inline {
  flex: 0 0 auto;
  max-width: none;
}
.search-inline .ic {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 16px;
}
.search-inline input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-xs);
  font-size: 13.5px;
}
.search-inline input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.table-wrap {
  overflow-x: auto;
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
}
table.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-2);
}
table.tbl th.r,
table.tbl td.r {
  text-align: right;
}
table.tbl td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.tbl tr:last-child td {
  border-bottom: 0;
}
table.tbl tbody tr {
  transition: background 0.12s;
  cursor: pointer;
}
table.tbl tbody tr:hover {
  background: var(--surface-2);
}
.cell-plate {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cell-plate .ic {
  color: var(--faint);
  font-size: 17px;
}
.cell-desc {
  color: var(--ink-2);
}
.cell-sub {
  color: var(--muted);
  font-size: 12.5px;
}

/* Frota: coluna Trator + reordenação + chassis */
.select-sm {
  height: 32px;
  padding: 0 26px 0 10px;
  font-size: 12.5px;
  min-width: 96px;
}
.ord-cell {
  width: 34px;
  padding-right: 0 !important;
}
.ord-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ord-btns button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 18px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--faint);
  font-size: 13px;
}
.ord-btns button:hover:not(:disabled) {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.ord-btns button:disabled {
  opacity: 0.25;
  cursor: default;
}
.tag-btn {
  cursor: pointer;
  border: 0;
  transition: background 0.15s, color 0.15s;
}
.tag-btn:hover {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.tag-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: default;
}
.tag-select .select-sm {
  height: 26px;
  min-width: 84px;
  font-size: 12px;
  border-radius: 8px;
}
.chassis-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.chassis-form .input {
  height: 34px;
  width: 200px;
  font-size: 13px;
}

/* Cartões de serviço: cue como botão + modo histórico */
button.svc-cue {
  width: calc(100% + 30px);
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
}
button.svc-cue:hover {
  color: var(--brand-ink);
  background: var(--brand-softer);
}
/* Vista de histórico de um serviço: largura total dentro da grelha de cartões */
.svc.svc-hist {
  grid-column: 1 / -1;
  padding: 0;
  cursor: default;
}
.svc-hist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.svc-hist-head .svc-name {
  font-size: 15px;
}
.svc-hist-count {
  color: var(--muted);
  font-weight: 500;
  font-size: 12.5px;
  margin-left: 4px;
}
.svc-hist-list {
  padding: 0 4px;
}

/* Ficha: galeria + foto de perfil */
.detail-photo {
  overflow: hidden;
  padding: 0;
  background: var(--surface-muted);
}
.detail-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
}
.gal-item {
  margin: 0;
  position: relative;
}
.gal-item a {
  display: block;
  cursor: zoom-in;
}
.gal-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}
.gal-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface-muted);
  display: block;
}
.gal-item.is-profile img {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.gal-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}
.gal-actions button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
}
.gal-actions button:hover {
  color: var(--ink);
  border-color: var(--faint);
}
.gal-actions button.active {
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-color: var(--brand);
}
.gal-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  aspect-ratio: 1;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.gal-add:hover {
  border-color: var(--brand);
  color: var(--brand-ink);
  background: var(--brand-softer);
}
.gal-add .ic {
  font-size: 19px;
}
/* Documento (não-imagem: PDF, etc.) — cartão com ícone + nome, clicável para abrir */
.gal-doc a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  aspect-ratio: 1;
  padding: 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.gal-doc a:hover {
  border-color: var(--brand);
  background: var(--brand-softer);
}
.gal-doc a .ic {
  font-size: 30px;
  color: var(--brand);
}
.gal-doc-name {
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* Diversos */
.misc-form {
  grid-template-columns: 220px 150px minmax(0, 1fr) auto !important;
}

/* Equipamento: remoção (double-step) */
.danger-zone {
  padding: 14px 16px;
  border-style: dashed;
}
.dz-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.dz-hint {
  color: var(--muted);
  font-size: 13px;
}
.dz-warn {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-2);
  font-size: 13.5px;
  margin-bottom: 12px;
}
.dz-warn .ic {
  color: var(--bad);
  flex: 0 0 auto;
  font-size: 17px;
}

/* Equipamento: histórico editável + cartões por data */
.hist-add {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}
.hist-add form {
  display: grid;
  grid-template-columns: 150px 210px 120px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.hist-add .btn {
  height: 40px;
}
.hist-filter {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 180px 150px 150px auto;
  gap: 10px;
  align-items: end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.hist-filter .btn {
  height: 40px;
}
.hline.clickable {
  cursor: pointer;
}
.hline.hline-edit {
  display: block;
  background: var(--brand-softer);
}
.svc-plain .svc-metrics {
  margin-top: 10px;
}
.svc-note-text {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* RH: edit-in-place + ocorrências */
.emp-edit {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  padding: 16px;
}
textarea.input {
  min-height: 76px;
  padding: 9px 12px;
  line-height: 1.45;
  resize: vertical;
}
.emp-notes {
  margin: 14px 16px 16px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border-radius: var(--r-md);
  font-size: 13.5px;
  color: var(--ink-2);
  white-space: pre-wrap;
  line-height: 1.5;
}
/* Colaborador: avatar/foto de perfil (clique = ver em grande) */
.emp-avatar-wrap {
  position: relative;
  flex: 0 0 auto;
}
button.emp-avatar {
  border: 0;
  padding: 0;
  font: inherit;
}
.emp-avatar {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.emp-avatar-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.42);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}
.emp-avatar:hover .emp-avatar-hint {
  opacity: 1;
}
.emp-avatar-hint .ic {
  font-size: 20px;
}
.emp-avatar-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bad);
  color: #fff;
  border: 2px solid var(--surface);
  font-size: 11px;
  cursor: pointer;
}
.emp-thumb {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  vertical-align: middle;
  border: 1px solid var(--line-2);
  background: var(--surface-muted);
}
/* Cartão (mobile): a foto preenche o quadrado do ícone, sem "bola dentro do quadrado" */
.row-icon-photo {
  padding: 0;
  overflow: hidden;
  background: var(--surface-muted);
}
.row-icon-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Controlos de foto no formulário de editar colaborador */
.emp-photo-edit {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.emp-photo-preview {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 26px;
}
.emp-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Lightbox — ver foto em grande com fundo esbatido */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  cursor: zoom-out;
  animation: bm-fade 0.12s ease;
}
@keyframes bm-fade {
  from {
    opacity: 0;
  }
}
.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: var(--r-md);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}
.occ-add {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}
.occ-add form {
  display: grid;
  grid-template-columns: 150px 165px minmax(0, 1fr) 230px auto;
  gap: 10px;
  align-items: end;
}
.occ-add .btn {
  height: 40px;
}
.hline .btn {
  justify-self: end;
}
.input-file {
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.input-file::file-selector-button {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  margin-right: 8px;
  cursor: pointer;
}
.occ-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}
.occ-thumb {
  display: block;
  cursor: zoom-in;
  border: 0;
  padding: 0;
  background: none;
}
.occ-thumb img {
  display: block;
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--surface-muted);
}
/* Anexo tipo documento (PDF, etc.) numa ocorrência */
.occ-doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 190px;
  height: 52px;
  padding: 0 12px;
  background: var(--surface-muted);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
}
.occ-doc .ic {
  flex: 0 0 auto;
  font-size: 18px;
}
.occ-doc span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Editar anexos de uma ocorrência (remover / adicionar) */
.occ-media-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.occ-media-cell {
  position: relative;
  display: inline-flex;
}
.occ-media-x {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bad);
  color: #fff;
  border: 2px solid var(--surface);
  font-size: 10px;
  cursor: pointer;
  z-index: 2;
}
.occ-media-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 52px;
  padding: 0 14px;
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  background: var(--surface-muted);
}
.occ-media-add:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* Definições: acessos */
.access-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding-bottom: 14px;
}
.access-row .access-del {
  height: 40px;
}

/* header Definições active state */
.topbar-actions .btn.active {
  color: var(--brand-ink);
  background: var(--brand-soft);
}

/* mobile cards for fleet */
.cards {
  display: none;
  flex-direction: column;
}
.fcard {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.fcard:last-child {
  border-bottom: 0;
}
.fcard-main {
  min-width: 0;
  flex: 1;
}
.fcard-main .ftop {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fcard-main .ftop strong {
  font-weight: 700;
}
.fcard-main .fmeta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

/* ============================================================
   Equipment detail
   ============================================================ */
.detail-top {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: clamp(16px, 2.4vw, 22px);
  flex-wrap: wrap;
}
.detail-id {
  display: flex;
  gap: 15px;
  align-items: center;
  min-width: 0;
}
.detail-id-main {
  min-width: 0;
  flex: 1 1 auto;
}
.equip-edit .form-grid {
  max-width: 620px;
}
.equip-edit .form-actions {
  margin-top: 12px;
}
.detail-icon {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  font-size: 26px;
  color: var(--brand-ink);
  background: var(--brand-soft);
}
.detail-id h2 {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.detail-id .d-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 2px;
}
.detail-tags {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  flex-wrap: wrap;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-muted);
  border-radius: var(--r-pill);
  padding: 3px 10px;
}
.tag .ic {
  font-size: 13px;
  color: var(--faint);
}
.detail-km {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.km-field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}
.km-field .kin {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.km-field input {
  width: 130px;
  border: 0;
  padding: 0 4px 0 12px;
  height: 40px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: none;
}
.km-field input:focus {
  outline: none;
}
.km-field .kin:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.km-field .unit {
  color: var(--faint);
  font-size: 13px;
  padding-right: 12px;
}

.svc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.svc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 15px;
  position: relative;
  overflow: hidden;
}
.svc::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--idle-line);
}
.svc.s-bad::before {
  background: var(--bad);
}
.svc.s-warn::before {
  background: var(--warn-strong);
}
.svc.s-ok::before {
  background: var(--ok);
}
.svc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.svc-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.svc-name .ic {
  color: var(--faint);
  font-size: 17px;
}
.svc-summary {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  padding-left: 25px;
}
.svc-summary.s-bad {
  color: var(--bad);
  font-weight: 600;
}
.svc-summary.s-warn {
  color: var(--warn);
  font-weight: 600;
}
.svc-prog {
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  overflow: hidden;
  margin-bottom: 12px;
}
.svc-prog > i {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  transition: width 0.5s var(--ease);
}
.svc.s-bad .svc-prog > i {
  background: var(--bad);
}
.svc.s-warn .svc-prog > i {
  background: var(--warn-strong);
}
.svc.s-ok .svc-prog > i {
  background: var(--ok);
}
.svc.s-missing .svc-prog > i {
  background: var(--idle-line);
}
.svc-metrics {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.svc-metrics .m {
  display: flex;
  flex-direction: column;
}
.svc-metrics .m span {
  font-size: 11px;
  color: var(--faint);
}
.svc-metrics .m strong {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.svc-metrics .m.r {
  text-align: right;
  align-items: flex-end;
}

/* reminders */
.rem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.rem:last-child {
  border-bottom: 0;
}
.rem-main {
  flex: 1;
  min-width: 0;
}
.rem-main strong {
  font-weight: 600;
}
.rem-main span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

/* history list */
.hist {
  display: flex;
  flex-direction: column;
}
.hline {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.hline:last-child {
  border-bottom: 0;
}
.hline:hover {
  background: var(--surface-2);
}
.hdate {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hdate small {
  display: block;
  font-weight: 500;
  color: var(--faint);
  font-size: 11px;
}
.hdesc {
  min-width: 0;
}
.hdesc strong {
  font-weight: 600;
  letter-spacing: -0.01em;
}
.hdesc span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.hkm {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  white-space: nowrap;
}
.src {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  padding: 1px 7px;
}

/* ============================================================
   Forms
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.input,
.select,
.textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 0 12px;
  height: 40px;
  font-size: 13.5px;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea {
  height: auto;
  padding: 10px 12px;
  min-height: 76px;
  resize: vertical;
  line-height: 1.5;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7689' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 34px;
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.hint {
  font-size: 12px;
  color: var(--muted);
}
.help {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  color: var(--faint);
  cursor: help;
}
.help .ic {
  font-size: 14px;
}

/* collapsible */
details.fold {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
details.fold > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
details.fold > summary::-webkit-details-marker {
  display: none;
}
details.fold > summary .ic {
  font-size: 17px;
  color: var(--brand);
}
details.fold > summary .chev {
  margin-left: auto;
  color: var(--faint);
  transition: transform 0.2s var(--ease);
  font-size: 18px;
}
details.fold[open] > summary .chev {
  transform: rotate(90deg);
}
details.fold > summary .sub {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
}
.fold-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

/* settings */
.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* empty / misc */
.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.empty .ic {
  font-size: 26px;
  color: var(--line-2);
  display: block;
  margin: 0 auto 8px;
}
.note {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.55;
}
.section-gap {
  margin-top: 16px;
}
.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 4px 2px 10px;
}

/* ============================================================
   Login
   ============================================================ */
.save-error-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 16px;
  background: #fef2f2;
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid #fecaca;
}
.save-error-bar button {
  border: 1px solid currentColor;
  border-radius: var(--r-pill);
  padding: 3px 11px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  background: #fff;
}

.boot-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.boot-loading .spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--line-2);
  border-top-color: var(--brand);
  animation: bm-spin 0.8s linear infinite;
}
@keyframes bm-spin {
  to {
    transform: rotate(360deg);
  }
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 34px 30px;
}
.login .brand {
  margin-bottom: 22px;
}
.login h1 {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.login .lead {
  color: var(--muted);
  font-size: 13.5px;
  margin: 4px 0 22px;
}
.login .field {
  margin-bottom: 14px;
}
.login .btn {
  width: 100%;
  height: 44px;
  margin-top: 6px;
}
.err {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bad-soft);
  border: 1px solid var(--bad-line);
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  margin-bottom: 16px;
}
.login-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--faint);
  text-align: center;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: #0d1426;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-pop);
  display: flex;
  align-items: center;
  gap: 9px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease);
  z-index: 100;
}
.toast .ic {
  font-size: 16px;
  color: #6ee7b7;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Analytics page (charts, distributions)
   ============================================================ */
.card-link {
  display: block;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
}
.card-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-2);
}
.head-link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand);
}
.head-link .ic {
  font-size: 15px;
}

.analytics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.analytics .span-2 {
  grid-column: 1 / -1;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.tiles .metric {
  background: #fff;
  padding: 14px 16px;
}
.tiles .metric.accent .m-val {
  color: var(--brand-ink);
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 6px 2px;
  flex-wrap: wrap;
}
.donut {
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
}
.donut-num {
  font-size: 30px;
  font-weight: 800;
  fill: var(--ink);
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
}
.donut-lab {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  fill: var(--faint);
  text-anchor: middle;
  text-transform: uppercase;
}
.legend {
  display: grid;
  gap: 9px;
  flex: 1 1 160px;
  min-width: 0;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--ink-2);
}
.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.legend-val {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.legend-val small {
  color: var(--faint);
  font-weight: 600;
}

.hbars {
  display: grid;
  gap: 10px;
}
.hbar {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
}
.hbar-lab {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hbar-track {
  height: 9px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  overflow: hidden;
}
.hbar-track > i {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  transition: width 0.5s var(--ease);
}
.hbar-val {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  white-space: nowrap;
}

.stackrow {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 13px;
}
.stackrow:last-child {
  margin-bottom: 0;
}
.stack-lab {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}
.stack-lab .ic {
  font-size: 15px;
  color: var(--faint);
}
.stack {
  display: flex;
  height: 16px;
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--surface-muted);
}
.stack > i {
  height: 100%;
  transition: width 0.5s var(--ease);
}
.stack-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.stack-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.stack-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

/* ============================================================
   Service cards: click-to-register + inline edit
   ============================================================ */
.btn-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-line);
}
.btn-ok:hover {
  background: #d6f4e6;
  color: var(--ok);
}
.st-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--faint);
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.st-hint .ic {
  font-size: 13px;
}
.svc.clickable {
  cursor: pointer;
  padding-bottom: 0;
}
.svc.clickable:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.svc.clickable:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.svc-cue {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 13px -15px 0;
  padding: 9px 15px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.svc-cue .ic {
  font-size: 14px;
}
.svc.clickable:hover .svc-cue {
  color: var(--brand);
  background: var(--brand-softer);
}
.svc.editing {
  grid-column: span 2;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.svc-edit-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 4px 0 14px;
}
.svc.editing .form-grid {
  gap: 12px;
}
.svc.editing .field label {
  font-size: 12px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 940px) {
  .painel-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .analytics {
    grid-template-columns: minmax(0, 1fr);
  }
  .mod-switch .label {
    display: none;
  }
  .mod-btn {
    padding: 8px 10px;
  }
  .mod-btn .ic {
    font-size: 17px;
  }
  .topbar-actions .label {
    display: none;
  }
  .topbar-actions .btn {
    padding: 0;
    width: 40px;
  }
}
@media (max-width: 720px) {
  .kpis {
    grid-template-columns: repeat(2, 1fr);
  }
  .seg {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .seg::-webkit-scrollbar {
    display: none;
  }
  .seg button {
    flex: 0 0 auto;
  }
  .subtabs {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .subtabs::-webkit-scrollbar {
    display: none;
  }
  .subtabs a {
    flex: 0 0 auto;
  }
  .search-inline {
    max-width: none;
  }
  .occ-add form {
    grid-template-columns: 1fr 1fr;
  }
  .occ-add form .field:nth-child(4),
  .occ-add form .field:nth-child(5),
  .occ-add form .btn {
    grid-column: 1 / -1;
  }
  .hist-add form {
    grid-template-columns: 1fr 1fr !important;
  }
  .hist-add form .field:nth-child(5),
  .hist-add form .btn {
    grid-column: 1 / -1;
  }
  .misc-form .field:nth-child(4) {
    grid-column: 1 / -1;
  }
  .hist-filter {
    grid-template-columns: 1fr 1fr;
  }
  .hist-filter .field:nth-child(1),
  .hist-filter .btn {
    grid-column: 1 / -1;
  }
  .svc-hist-head {
    flex-direction: column;
    align-items: stretch;
  }
  .access-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .access-row .access-del {
    justify-self: start;
  }
  .global-search kbd {
    display: none;
  }
  table.tbl {
    display: none;
  }
  /* O mapa de obrigações não tem versão em cartões — mantém a tabela com scroll lateral */
  table.tbl.obl-tbl {
    display: table;
  }
  .cards {
    display: flex;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .detail-km {
    margin-left: 0;
    width: 100%;
  }
  .hline {
    grid-template-columns: 1fr auto;
    grid-template-areas: "date km" "desc desc";
    gap: 6px 12px;
  }
  .hdate {
    grid-area: date;
  }
  .hkm {
    grid-area: km;
    text-align: right;
  }
  .hdesc {
    grid-area: desc;
  }
}
@media (max-width: 560px) {
  .topbar {
    gap: 10px;
  }
  .brand-sep {
    display: none;
  }
  .brand-logo {
    height: 24px;
  }
  .mod-btn {
    padding: 8px 8px;
  }
  .global-search {
    min-width: 0;
    flex: 1 1 0%;
  }
  /* o Exportar vive nas Definições; no telemóvel sai do header */
  .topbar-actions .menu {
    display: none;
  }
  .topbar-actions .label {
    display: none;
  }
  .topbar-actions .btn {
    padding: 0;
    width: 36px;
  }
  .row-summary span {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Obrigações — mapa anual, chips por tipo, editor
   ============================================================ */
.section-gap-sm {
  margin-top: 12px;
}
.obl-scroll {
  overflow-x: auto;
}
.obl-tbl {
  min-width: 980px;
}
.obl-tbl th.obl-m {
  text-align: center;
  min-width: 64px;
}
.obl-tbl td.obl-name {
  min-width: 170px;
}
.obl-tbl th.obl-now,
.obl-tbl td.obl-now {
  background: var(--brand-soft);
}
.obl-ent-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.obl-ent-btn strong {
  display: block;
  font-weight: 700;
}
.obl-ent-btn .sub {
  font-size: 11.5px;
  color: var(--faint);
}
.obl-ent-btn:hover strong {
  color: var(--brand);
}
.obl-group td {
  background: var(--surface-muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  padding: 8px 12px;
}
.obl-group .ic {
  font-size: 14px;
  vertical-align: -2px;
  margin-right: 4px;
}
.obl-group .n {
  font-weight: 600;
  color: var(--faint);
}
.obl-cell {
  cursor: pointer;
  text-align: center;
  vertical-align: middle;
  min-width: 64px;
}
.obl-cell:hover {
  box-shadow: inset 0 0 0 2px var(--brand);
  border-radius: 6px;
}
/* Chips de obrigação */
.oc {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 1.5px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.oc-seguro {
  background: #e3e9fd;
  color: #2c43c4;
}
.oc-iuc {
  background: #fdf1d7;
  color: #92600a;
}
.oc-inspecao {
  background: #ddf3e7;
  color: #0f7a43;
}
.oc-tacografo {
  background: #efe6fc;
  color: #6d3fc0;
}
.oc-outro {
  background: var(--surface-muted);
  color: var(--ink-2);
}
.oc .oc-x {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  color: inherit;
  font-size: 9px;
  cursor: pointer;
  padding: 0;
}
.oc .oc-x:hover {
  background: var(--bad);
  color: #fff;
}
.obl-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.obl-hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--faint);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.obl-now-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-radius: var(--r-pill);
  padding: 2px 8px;
  vertical-align: 2px;
  margin-left: 4px;
}
/* Editor (overlay) */
.obl-overlay {
  position: fixed;
  inset: 0;
  z-index: 195;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: bm-fade 0.12s ease;
}
.obl-editor {
  width: min(560px, 100%);
  padding: 16px;
  max-height: 82vh;
  overflow-y: auto;
}
.obl-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.obl-editor-head strong {
  font-size: 16px;
  display: block;
}
.obl-editor-head .sub {
  font-size: 12.5px;
  color: var(--muted);
}
.obl-editor-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px;
  background: var(--surface-muted);
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.obl-editor-items .oc {
  font-size: 12.5px;
}
.obl-none {
  font-size: 12.5px;
  color: var(--faint);
}
@media (max-width: 720px) {
  .obl-tbl {
    min-width: 760px;
  }
  .obl-tbl th.obl-m,
  .obl-cell {
    min-width: 52px;
  }
}
.toolbar .select {
  width: auto;
  flex: 0 0 auto;
  min-width: 150px;
}
.obl-mes-list .hline {
  grid-template-columns: minmax(96px, max-content) 1fr auto;
}
/* Obrigações: em desktop a página alarga para o mapa caber sem scroll horizontal */
.main-wide {
  max-width: 1820px;
}
.obl-tbl {
  width: 100%;
}
.obl-tbl .oc {
  font-size: 10.5px;
  padding: 2px 6px;
  margin: 1px;
}
table.obl-tbl td,
table.obl-tbl th {
  padding-left: 5px;
  padding-right: 5px;
}
table.obl-tbl td.obl-name {
  min-width: 128px;
}
.obl-tbl .oc {
  padding: 2px 5px;
}
/* Obrigações: seletor de ano */
.obl-year {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px;
  box-shadow: var(--shadow-xs);
}
.obl-year strong {
  font-size: 13.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 0 6px;
}
.obl-year button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.obl-year button:hover {
  background: var(--surface-muted);
  color: var(--ink);
}
/* Ficha de obrigações de uma viatura */
.obl-view-tags {
  margin-bottom: 12px;
}
.obl-view-list {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 14px;
  max-height: 46vh;
  overflow-y: auto;
}
.obl-view-list .hline {
  padding: 9px 12px;
}
.obl-view-list .hdate small {
  display: block;
  font-weight: 500;
  color: var(--faint);
}
