/* ===== APP SHELL ===== */
/* Source-of-truth: linear-layout.html */

/* ===== LAYOUT ===== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  transition: grid-template-columns .25s ease;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  min-width: 0;
  overflow-x: hidden;
  transition: padding .25s ease, background-color .25s, border-color .25s;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 4px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 8px;
  min-height: 64px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: padding .25s ease, background .15s, color .15s;
  min-width: 0;
  overflow: hidden;
}
.brand:hover { background: var(--surface-2); color: var(--text); }
.brand:focus-visible {
  outline: none;
  background: var(--surface-2);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.brand-mark {
  height: 30px;
  width: auto;
  flex-shrink: 0;
  color: #4A59F5;
}
.brand-nome {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-strong);
  white-space: nowrap;
}
.brand-nome-e { color: #4A59F5; }

.user-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  min-height: 40px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  min-width: 0;
  transition: padding .25s ease, background .15s, border-color .15s;
}
.user-card:hover { border-color: var(--border-strong); }
.user-card .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  font-weight: 600;
  font-size: 11.5px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-card .user-meta { min-width: 0; flex: 1; }
.user-card .user-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.user-card .user-email {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 1px;
}

.nav { flex: 1; display: flex; flex-direction: column; flex-wrap: nowrap; gap: 1px; min-width: 0; overflow-x: hidden; overflow-y: auto; }
.nav-section { padding: 10px 6px 4px; font-size: 10.5px; font-weight: 500; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; }
.nav-section:first-child { padding-top: 6px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  min-height: 32px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  transition: background .12s ease, color .12s ease, padding .25s ease;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.nav-item > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: var(--surface-3);
  color: var(--text);
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.nav-item.active .badge { background: var(--accent); color: #fff; }
.nav-item.has-children::after {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--dim);
  border-bottom: 1.5px solid var(--dim);
  transform: rotate(45deg);
  margin-left: auto;
  transition: transform .15s;
}
.nav-item.has-children.open::after { transform: rotate(-135deg); }

.nav-sub { padding: 2px 0 4px 26px; display: flex; flex-direction: column; gap: 1px; }
.nav-sub .nav-item { padding: 5px 10px; font-size: 12.5px; }

.sidebar-footer {
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.theme-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  min-height: 32px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12.5px;
  transition: padding .25s ease, background .15s ease, color .15s ease;
  width: 100%;
}
.theme-row:hover { background: var(--surface-2); color: var(--text); }
.theme-row .theme-switch { margin-left: auto; }

.theme-switch {
  --toggle-size: 8px;
  --container-width: 5.625em;
  --container-height: 2.5em;
  --container-radius: 6.25em;
  --container-light-bg: #3D7EAE;
  --container-night-bg: #1D1F2C;
  --circle-container-diameter: 3.375em;
  --sun-moon-diameter: 2.125em;
  --sun-bg: #ECCA2F;
  --moon-bg: #C4C9D1;
  --spot-color: #959DB1;
  --circle-container-offset: calc((var(--circle-container-diameter) - var(--container-height)) / 2 * -1);
  --stars-color: #fff;
  --clouds-color: #F3FDFF;
  --back-clouds-color: #AACADF;
  --transition: .5s cubic-bezier(0, -0.02, 0.4, 1.25);
  --circle-transition: .3s cubic-bezier(0, -0.02, 0.35, 1.17);
}
.theme-switch, .theme-switch *, .theme-switch *::before, .theme-switch *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-size: var(--toggle-size);
}
.theme-switch__container {
  width: var(--container-width);
  height: var(--container-height);
  background-color: var(--container-light-bg);
  border-radius: var(--container-radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0em -0.062em 0.062em rgba(0, 0, 0, 0.25), 0em 0.062em 0.125em rgba(255, 255, 255, 0.94);
  transition: var(--transition);
  position: relative;
}
.theme-switch__container::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  box-shadow: 0em 0.05em 0.187em rgba(0, 0, 0, 0.25) inset, 0em 0.05em 0.187em rgba(0, 0, 0, 0.25) inset;
  border-radius: var(--container-radius);
}
.theme-switch__checkbox { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.theme-switch__checkbox:focus-visible + .theme-switch__container { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-switch__circle-container {
  width: var(--circle-container-diameter);
  height: var(--circle-container-diameter);
  background-color: rgba(255, 255, 255, 0.1);
  position: absolute;
  left: var(--circle-container-offset);
  top: var(--circle-container-offset);
  border-radius: var(--container-radius);
  box-shadow: inset 0 0 0 3.375em rgba(255, 255, 255, 0.1), inset 0 0 0 3.375em rgba(255, 255, 255, 0.1), 0 0 0 0.625em rgba(255, 255, 255, 0.1), 0 0 0 1.25em rgba(255, 255, 255, 0.1);
  display: flex;
  transition: var(--circle-transition);
  pointer-events: none;
}
.theme-switch__sun-moon-container {
  pointer-events: auto;
  position: relative;
  z-index: 2;
  width: var(--sun-moon-diameter);
  height: var(--sun-moon-diameter);
  margin: auto;
  border-radius: var(--container-radius);
  background-color: var(--sun-bg);
  box-shadow: 0.062em 0.062em 0.062em 0em rgba(254, 255, 239, 0.61) inset, 0em -0.062em 0.062em 0em #a1872a inset;
  filter: drop-shadow(0.062em 0.125em 0.125em rgba(0, 0, 0, 0.25)) drop-shadow(0em 0.062em 0.125em rgba(0, 0, 0, 0.25));
  overflow: hidden;
  transition: var(--transition);
}
.theme-switch__moon {
  transform: translateX(100%);
  width: 100%;
  height: 100%;
  background-color: var(--moon-bg);
  border-radius: inherit;
  box-shadow: 0.062em 0.062em 0.062em 0em rgba(254, 255, 239, 0.61) inset, 0em -0.062em 0.062em 0em #969696 inset;
  transition: var(--transition);
  position: relative;
}
.theme-switch__spot {
  position: absolute;
  top: 0.75em;
  left: 0.312em;
  width: 0.75em;
  height: 0.75em;
  border-radius: var(--container-radius);
  background-color: var(--spot-color);
  box-shadow: 0em 0.0312em 0.062em rgba(0, 0, 0, 0.25) inset;
}
.theme-switch__spot:nth-of-type(2) {
  width: 0.375em;
  height: 0.375em;
  top: 0.937em;
  left: 1.375em;
}
.theme-switch__spot:nth-last-of-type(3) {
  width: 0.25em;
  height: 0.25em;
  top: 0.312em;
  left: 0.812em;
}
.theme-switch__clouds {
  width: 1.25em;
  height: 1.25em;
  background-color: var(--clouds-color);
  border-radius: var(--container-radius);
  position: absolute;
  bottom: -0.625em;
  left: 0.312em;
  box-shadow: 0.937em 0.312em var(--clouds-color), -0.312em -0.312em var(--back-clouds-color), 1.437em 0.375em var(--clouds-color), 0.5em -0.125em var(--back-clouds-color), 2.187em 0 var(--clouds-color), 1.25em -0.062em var(--back-clouds-color), 2.937em 0.312em var(--clouds-color), 2em -0.312em var(--back-clouds-color), 3.625em -0.062em var(--clouds-color), 2.625em 0em var(--back-clouds-color), 4.5em -0.312em var(--clouds-color), 3.375em -0.437em var(--back-clouds-color), 4.625em -1.75em 0 0.437em var(--clouds-color), 4em -0.625em var(--back-clouds-color), 4.125em -2.125em 0 0.437em var(--back-clouds-color);
  transition: 0.5s cubic-bezier(0, -0.02, 0.4, 1.25);
}
.theme-switch__stars-container {
  position: absolute;
  color: var(--stars-color);
  top: -100%;
  left: 0.312em;
  width: 2.75em;
  height: auto;
  transition: var(--transition);
}
.theme-switch__checkbox:checked + .theme-switch__container {
  background-color: var(--container-night-bg);
}
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__circle-container {
  left: calc(100% - var(--circle-container-offset) - var(--circle-container-diameter));
}
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__circle-container:hover {
  left: calc(100% - var(--circle-container-offset) - var(--circle-container-diameter) - 0.187em);
}
.theme-switch__circle-container:hover {
  left: calc(var(--circle-container-offset) + 0.187em);
}
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__moon {
  transform: translate(0);
}
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__clouds {
  bottom: -4.062em;
}
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__stars-container {
  top: 50%;
  transform: translateY(-50%);
}

/* ===== MAIN ===== */
.main { min-width: 0; overflow-x: hidden; }

.topbar {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.breadcrumb .sep { color: var(--dim); }
.breadcrumb .cur { color: var(--text); font-weight: 500; }

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

.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--muted);
  transition: all .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }

.content { padding: 28px 32px 80px; width: 100%; }

/* ===== PAGE HEAD ===== */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 4px; color: var(--text); }
.page-sub { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

/* ===== BUTTONS ===== */
.btn-primary {
  padding: 7px 12px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 13px;
  transition: opacity .15s;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary:hover { opacity: .85; color: var(--bg); }
.btn-ghost {
  padding: 6px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  transition: all .15s;
  background: var(--surface);
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.is-disabled { opacity: .5; pointer-events: none; }

/* ===== STATS ROW ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stat {
  padding: 14px 18px;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
  position: relative;
  text-align: left;
  text-decoration: none;
  color: inherit;
  display: block;
}
.stat:last-child { border-right: none; }
.stat:hover { background: var(--surface-2); }
.stat.active { background: var(--surface-2); }
.stat.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
}
.stat-row { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.stat-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 400; }
.stat-value { font-size: 24px; font-weight: 600; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; line-height: 1; color: var(--text); }

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  flex-wrap: wrap;
}
.toolbar-fields {
  display: flex; align-items: center; gap: 8px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}
.toolbar-actions {
  display: flex; align-items: center; gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.toolbar .search-inline {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color .15s, background .15s, box-shadow .15s;
  min-width: 0;
}
.toolbar .search-inline:hover { border-color: var(--border-strong); }
.toolbar .search-inline:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.toolbar .search-inline--placa { width: 220px; }
.toolbar .search-inline--md { width: 220px; }
.toolbar .search-inline--date { width: 170px; cursor: pointer; }
.toolbar .search-inline svg { color: var(--dim); flex-shrink: 0; }
.toolbar input[type="text"],
.toolbar input[type="date"] {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 13px;
  width: 100%;
  outline: none;
  font-family: inherit;
  line-height: 1;
}
.toolbar input[type="date"] { color-scheme: dark; }
[data-theme="light"] .toolbar input[type="date"] { color-scheme: light; }
.toolbar input::placeholder { color: var(--dim); }
.toolbar .filter-chip,
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  white-space: nowrap;
}
.toolbar .filter-chip:hover,
.filter-chip:hover { background: var(--surface-2); }
.toolbar .filter-chip svg,
.filter-chip svg { width: 12px; height: 12px; color: var(--muted); }
.toolbar .filter-chip .v-count,
.filter-chip .v-count {
  color: var(--bg);
  background: var(--accent);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.toolbar .filter-chip--primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 500;
}
.toolbar .filter-chip--primary:hover { opacity: .88; background: var(--text); color: var(--bg); }
.toolbar .filter-chip--primary svg { color: var(--bg); }
.toolbar .clear {
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: none;
  padding: 0 4px;
}
.toolbar .clear:hover { color: var(--text); }

/* ===== TABLE ===== */
table.t { font-size: 13px; font-variant-numeric: tabular-nums; width: 100%; border-collapse: collapse; }
table.t thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 500;
  color: var(--muted);
  font-size: 11.5px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  white-space: nowrap;
}
table.t thead th a { color: inherit; text-decoration: none; }
table.t thead th a:hover { color: var(--text); }
table.t tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  line-height: 1.4;
  vertical-align: middle;
}
table.t tbody tr { transition: background .12s; }
table.t tbody tr:hover td { background: var(--surface); }
table.t tbody tr.row-cancelada td { opacity: .55; }

.placa { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.02em; }
.id, .id-cell { color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.resp-link { color: var(--text); text-decoration: none; }
.resp-link:hover { text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 3px; }
.vistorias-list-t .resp-link { display: inline-block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.filial-text { color: var(--muted); }
.tel-text { color: var(--text); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 6px; }
.tel-text .wa { color: var(--green); opacity: .65; transition: opacity .15s; display: inline-flex; }
.tel-text:hover .wa { opacity: 1; }
.tel-text .wa svg { width: 13px; height: 13px; }
.data-text { color: var(--muted); }

.status-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-size: 12.5px; white-space: nowrap; }
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

.row-actions { display: flex; gap: 2px; justify-content: flex-end; align-items: center; }
.row-actions > .row-action-btn,
.row-actions > button,
.row-actions > a,
.row-actions > .row-action-form > button {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text);
  transition: all .12s;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.row-actions > .row-action-btn:hover,
.row-actions > button:hover,
.row-actions > a:hover,
.row-actions > .row-action-form > button:hover { background: var(--surface-2); color: var(--text); }
.row-actions .row-action-edit:hover { color: var(--accent); background: var(--accent-soft); }
.row-actions .row-action-attach:hover { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.row-actions .row-action-danger:hover { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.row-actions > .row-action-btn > svg,
.row-actions > a > svg,
.row-actions > .row-action-form > button > svg { width: 14px; height: 14px; }
.row-action-form { display: inline; margin: 0; }

.table-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}
.pag { display: flex; gap: 6px; align-items: center; }
.pag-btn {
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: var(--text);
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.pag-btn:hover { background: var(--surface-2); }
.pag-btn.disabled { opacity: .4; cursor: not-allowed; }

/* Laravel paginator default styles override */
.pagination, nav[role="navigation"] ul.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
nav[role="navigation"] svg { width: 14px; height: 14px; }
nav[role="navigation"] a, nav[role="navigation"] span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface);
  font-size: 12.5px;
  text-decoration: none;
  transition: all .15s;
}
nav[role="navigation"] a:hover { background: var(--surface-2); }
nav[role="navigation"] [aria-current="page"] span { background: var(--text); color: var(--bg); border-color: var(--text); }
nav[role="navigation"] [aria-disabled="true"] span { opacity: .4; }

/* Logout button in sidebar */
.logout-form { margin: 0; padding: 0; }
.logout-btn { width: 100%; text-align: left; background: none; border: none; font-family: inherit; }

/* ===== BOOTSTRAP COMPAT (durante migração) ===== */
/* Override Bootstrap text/bg utilities pra ficar legível no tema escuro */
.text-muted { color: var(--muted) !important; }
.text-secondary { color: var(--muted) !important; }
.text-primary { color: var(--accent) !important; }
.text-danger { color: var(--red) !important; }
.text-success { color: var(--green) !important; }
.text-warning { color: var(--amber) !important; }
.text-info { color: var(--accent) !important; }
.text-dark { color: var(--text) !important; }
.text-light { color: var(--text) !important; }
.text-white { color: var(--text-strong) !important; }
.text-body { color: var(--text) !important; }

/* Background utilities */
.bg-light { background-color: var(--surface-2) !important; color: var(--text); }
.bg-white { background-color: var(--surface) !important; color: var(--text); }
.bg-dark { background-color: var(--bg) !important; color: var(--text); }
.bg-body { background-color: var(--bg) !important; }
.bg-primary { background-color: var(--accent) !important; color: var(--bg); }
.bg-secondary { background-color: var(--surface-3) !important; color: var(--text); }
.bg-success { background-color: color-mix(in srgb, var(--green) 18%, transparent) !important; color: var(--green); }
.bg-danger { background-color: color-mix(in srgb, var(--red) 18%, transparent) !important; color: var(--red); }
.bg-warning { background-color: color-mix(in srgb, var(--amber) 18%, transparent) !important; color: var(--amber); }
.bg-info { background-color: color-mix(in srgb, var(--accent) 18%, transparent) !important; color: var(--accent); }

/* Borders */
.border, .border-top, .border-bottom, .border-start, .border-end, .border-left, .border-right { border-color: var(--border) !important; }

/* Card */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  box-shadow: none;
}
.card-header, .card-footer {
  background-color: transparent;
  border-color: var(--border);
  color: var(--text);
}
.card-title { color: var(--text); }
.card-body { color: var(--text); }

/* Form controls Bootstrap */
.form-control, .form-select {
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  font-family: inherit;
}
.form-control:focus, .form-select:focus {
  background-color: var(--surface);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-control::placeholder { color: var(--dim); }
.form-control-sm { font-size: 12.5px; padding: 5px 10px; }
.form-label { color: var(--muted); font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.form-check-input {
  background-color: var(--surface);
  border-color: var(--border-strong);
}
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-label { color: var(--text); }
.input-group-text {
  background-color: var(--surface-2);
  border-color: var(--border);
  color: var(--muted);
}

/* Bootstrap buttons override pra harmonizar */
.btn {
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  transition: all .15s;
}
.btn-outline-primary {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}
.btn-outline-primary:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-outline-secondary {
  border-color: var(--border-strong);
  color: var(--text);
  background: transparent;
}
.btn-outline-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline-danger {
  border-color: var(--red);
  color: var(--red);
  background: transparent;
}
.btn-outline-danger:hover {
  background: var(--red);
  color: var(--bg);
}
.btn-link { color: var(--accent); text-decoration: none; }
.btn-link:hover { color: var(--accent); text-decoration: underline; }
.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { background: var(--surface-3); color: var(--text); }

/* Badges Bootstrap */
.badge {
  font-weight: 500;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
}
.badge.bg-primary { background-color: var(--accent) !important; color: var(--bg); }
.badge.bg-secondary { background-color: var(--surface-3) !important; color: var(--text); }
.badge.bg-success { background-color: color-mix(in srgb, var(--green) 22%, transparent) !important; color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 40%, transparent); }
.badge.bg-danger { background-color: color-mix(in srgb, var(--red) 22%, transparent) !important; color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }
.badge.bg-warning { background-color: color-mix(in srgb, var(--amber) 22%, transparent) !important; color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent); }
.badge.bg-info { background-color: color-mix(in srgb, var(--accent) 22%, transparent) !important; color: var(--accent); }

/* Bootstrap Modal — restyle */
.modal-content {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.modal-footer {
  border-top: 1px solid var(--border);
  background: transparent;
}
.modal-title { color: var(--text); font-weight: 600; font-size: 15px; }
.btn-close { filter: invert(0.7); }
[data-theme="light"] .btn-close { filter: none; }

/* Alerts Bootstrap */
.alert {
  border-radius: var(--radius-md);
  border: 1px solid;
  padding: 10px 14px;
  font-size: 13px;
}
.alert-success {
  background-color: color-mix(in srgb, var(--green) 12%, transparent);
  border-color: color-mix(in srgb, var(--green) 35%, transparent);
  color: var(--green);
}
.alert-danger {
  background-color: color-mix(in srgb, var(--red) 12%, transparent);
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
  color: var(--red);
}
.alert-warning {
  background-color: color-mix(in srgb, var(--amber) 12%, transparent);
  border-color: color-mix(in srgb, var(--amber) 35%, transparent);
  color: var(--amber);
}
.alert-info {
  background-color: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

/* Dropdowns Bootstrap */
.dropdown-menu {
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  border-radius: var(--radius-md);
}
.dropdown-item { color: var(--text); }
.dropdown-item:hover, .dropdown-item:focus {
  background-color: var(--surface-2);
  color: var(--text);
}
.dropdown-divider { border-color: var(--border); }

/* Pagination Bootstrap */
.page-link {
  background-color: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.page-link:hover {
  background-color: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.page-item.active .page-link {
  background-color: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.page-item.disabled .page-link {
  background-color: var(--surface);
  color: var(--dim);
  border-color: var(--border);
}

/* HR */
hr { border-color: var(--border); opacity: 1; }

/* Spinner */
.spinner-border { color: var(--accent); }

/* Form muted small text inside modals */
.modal small.text-muted { color: var(--muted) !important; }

/* ===== SIDEBAR COLLAPSED STATE ===== */
.app:has(.sidebar.collapsed) { grid-template-columns: 64px 1fr; }

.sidebar.collapsed {
  padding: 14px 8px;
}
.sidebar.collapsed .sidebar-header {
  padding: 4px 0 14px;
}
.sidebar.collapsed .brand {
  justify-content: center;
  padding: 4px;
}
.sidebar.collapsed .brand-nome { display: none; }
.sidebar.collapsed .brand-mark { height: 26px; }

.sidebar.collapsed .user-card {
  padding: 4px 10px;
  background: transparent;
  border-color: transparent;
}
.sidebar.collapsed .user-card .user-meta { display: none; }

.sidebar.collapsed .nav-section { visibility: hidden; pointer-events: none; }
.sidebar.collapsed .nav-item {
  padding: 6px 16px;
}
.sidebar.collapsed .nav-item > span,
.sidebar.collapsed .nav-item .badge { display: none; }

.sidebar.collapsed .theme-row {
  padding: 6px 0;
  justify-content: center;
}
.sidebar.collapsed .theme-row .theme-label { display: none; }
.sidebar.collapsed .theme-row .theme-switch { margin-left: 0; --toggle-size: 7px; }

.sidebar.collapsed .logout-btn {
  padding: 6px 16px;
}
.sidebar.collapsed .logout-btn > span,
.sidebar.collapsed .logout-form span { display: none; }

/* ===== MOBILE TOGGLE / BACKDROP (default hidden) ===== */
.mobile-menu-toggle { display: none; }
.sidebar-backdrop { display: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  /* === App layout: single column === */
  .app { grid-template-columns: 1fr; transition: none; }
  .app:has(.sidebar.collapsed) { grid-template-columns: 1fr; }

  /* === Sidebar as overlay drawer === */
  .sidebar {
    display: flex;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    height: 100vh;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    border-right: 1px solid var(--border);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  /* Force expanded layout on mobile: collapsed state ignored in drawer */
  .sidebar.collapsed { padding: 14px 12px; }
  .sidebar.collapsed .brand-nome { display: inline; }
  .sidebar.collapsed .brand-mark { height: 30px; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 6px 10px; }
  .sidebar.collapsed .nav-item > span,
  .sidebar.collapsed .nav-item .badge { display: inline; }
  .sidebar.collapsed .user-card { padding: 6px 8px; background: var(--surface-2); border-color: var(--border); }
  .sidebar.collapsed .user-card .user-meta { display: block; }
  .sidebar.collapsed .nav-section { visibility: visible; }
  .sidebar.collapsed .theme-row,
  .sidebar.collapsed .logout-btn { justify-content: flex-start; padding: 6px 10px; }
  .sidebar.collapsed .theme-row .theme-switch { margin-left: auto; --toggle-size: 8px; }
  .sidebar.collapsed .theme-row .theme-label,
  .sidebar.collapsed .logout-btn > span,
  .sidebar.collapsed .logout-form span { display: inline; }

  /* === Backdrop === */
  body.sidebar-overlay-active .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1000;
  }
  body.sidebar-overlay-active { overflow: hidden; }

  /* === Hamburger button === */
  .mobile-menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    flex-shrink: 0;
  }

  /* === Topbar === */
  .topbar { padding: 0 12px; gap: 6px; height: 48px; }
  .topbar-right .icon-btn { width: 32px; height: 32px; }
  .breadcrumb { font-size: 12.5px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .breadcrumb > span { overflow: hidden; text-overflow: ellipsis; }

  /* === Content === */
  .content { padding: 16px 12px 60px; }

  /* === Page head: stack === */
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .page-title { font-size: 18px; }
  .head-actions { width: 100%; flex-wrap: wrap; }
  .head-actions .btn-primary,
  .head-actions .btn-ghost { flex: 1 1 auto; justify-content: center; min-width: 0; }

  /* === Stats row: 2 cols === */
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stats-row .stat { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .stats-row .stat:nth-child(2n) { border-right: none; }
  .stats-row .stat:nth-last-child(-n+2) { border-bottom: none; }
  .stat-value { font-size: 20px; }

  /* === Toolbar: stack === */
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 0; }
  .toolbar > *,
  .toolbar .search-inline,
  .toolbar .filter-chip { width: 100%; max-width: none; min-width: 0; }
  .toolbar .clear { margin-left: 0; text-align: right; }

  /* === Table: horizontal scroll wrapper === */
  table.t {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  table.t thead, table.t tbody, table.t tr { display: table; width: 100%; }
  table.t thead th, table.t tbody td {
    padding: 10px 10px;
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Vistorias list — fixed columns to prevent shift between rows */
  table.t.vistorias-list-t thead, table.t.vistorias-list-t tbody, table.t.vistorias-list-t tr {
    table-layout: fixed;
    min-width: 820px;
  }
  table.t.vistorias-list-t thead th:nth-child(1), table.t.vistorias-list-t tbody td:nth-child(1) { width: 50px; }
  table.t.vistorias-list-t thead th:nth-child(2), table.t.vistorias-list-t tbody td:nth-child(2) { width: 90px; }
  table.t.vistorias-list-t thead th:nth-child(3), table.t.vistorias-list-t tbody td:nth-child(3) { width: 150px; }
  table.t.vistorias-list-t thead th:nth-child(4), table.t.vistorias-list-t tbody td:nth-child(4) { width: 100px; }
  table.t.vistorias-list-t thead th:nth-child(5), table.t.vistorias-list-t tbody td:nth-child(5) { width: 140px; }
  table.t.vistorias-list-t thead th:nth-child(6), table.t.vistorias-list-t tbody td:nth-child(6) { width: 135px; }
  table.t.vistorias-list-t thead th:nth-child(7), table.t.vistorias-list-t tbody td:nth-child(7) { width: 100px; }
  table.t.vistorias-list-t thead th:nth-child(8), table.t.vistorias-list-t tbody td:nth-child(8) { width: 110px; }

  /* === Table footer / pagination === */
  .table-footer { flex-direction: column; align-items: stretch; gap: 8px; }
  .pag { justify-content: center; flex-wrap: wrap; }

  /* === Modal: full screen === */
  .modal-linear .modal-dialog { margin: 0; max-width: 100%; height: 100vh; }
  .modal-linear .modal-content-linear { height: 100vh; max-height: 100vh; border-radius: 0; border: none; }
  .modal-linear .modal-header-linear { padding: 12px 14px; }
  .modal-linear .modal-body-linear { padding: 14px; }
  .modal-linear .modal-footer-linear { padding: 12px 14px; }
  .modal-linear .modal-title-linear { font-size: 14px; }

  /* === Form rows stack === */
  .modal-body-linear .row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }

  /* === Vistoria info grid 1 col === */
  .vistoria-info-grid { grid-template-columns: 1fr !important; }

  /* === Cargas table inside modal: smaller === */
  .cargas-table th, .cargas-table td { padding: 6px 8px; font-size: 11.5px; }

  /* === Anexo actions === */
  .anexo-actions { flex-direction: column; align-items: stretch; gap: 6px; }
  .anexo-actions > * { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .topbar-right .icon-btn { width: 30px; height: 30px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 18px; }
}

.doc-lista { display: flex; flex-direction: column; padding: 0; }
.doc-row { display: flex; flex-direction: column; gap: 5px; padding: 12px 14px; }
.doc-row + .doc-row { border-top: 1px solid var(--border); }
.doc-row-aviso { background: color-mix(in srgb, var(--amber) 7%, var(--surface)); }
.doc-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.doc-row-nome { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.35; }
.doc-row-sub { font-weight: 400; color: var(--muted); }
.doc-row-head .row-actions { flex-shrink: 0; }
.doc-row-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); line-height: 1.4; }
.doc-row-status .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.doc-row-meta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--muted); text-decoration: none; }
a.doc-row-meta:hover { color: var(--accent); }
.doc-row form { width: 100%; margin: 0; }
.doc-row-cta { width: 100%; justify-content: center; padding: 6px 10px; font-size: 12px; margin-top: 3px; }
.doc-row-gerar { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.doc-row-form { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; padding: 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); }
.doc-row-form-label { font-size: 11.5px; color: var(--muted); }
.doc-row-form-linha { display: flex; gap: 6px; width: 100%; }
.doc-row-form-data { flex: 1; min-width: 0; font-size: 12px; padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--text); font-family: inherit; }
.doc-row-form .doc-row-cta { width: auto; white-space: nowrap; margin-top: 0; }
.doc-row .row-action-btn.is-acervo { cursor: help; color: var(--muted); }
.doc-row-form-arquivo { flex: 1; min-width: 0; font-size: 12px; padding: 4px 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--text); font-family: inherit; }
.tel-text .wa-btn { background: none; border: none; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tel-text .wa-btn:disabled { cursor: default; }
.tel-text .wa-papel { position: relative; display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface-2); font-size: 9px; font-weight: 700; line-height: 1; color: var(--text); }
.tel-text .wa-papel::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--bg); background: var(--dim); }
.tel-text .wa-papel--sem-envio { border-style: dashed; background: none; color: var(--dim); }
.tel-text .wa-papel--aguardando::after { background: var(--amber); }
.tel-text .wa-papel--recusado::after,
.tel-text .wa-papel--conferir::after,
.tel-text .wa-papel--falhou::after { background: var(--red); }
.tel-text .wa-papel--falhou { border-color: var(--red); border-style: dashed; }
.tel-text .wa-papel--entregue::after { background: var(--green); }
.tel-text .wa-envio { display: inline-flex; }
.wa-menu { min-width: 190px; padding: 4px; font-size: 12.5px; }
.wa-menu .dropdown-header { padding: 4px 9px 6px; font-size: 11px; color: var(--muted); }
.wa-menu .dropdown-item { padding: 6px 9px; border-radius: var(--radius-md); }

.badge-prop { display: inline-flex; align-items: center; margin-left: 5px; padding: 1px 5px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 10px; font-weight: 600; line-height: 1.5; letter-spacing: .02em; color: var(--muted); text-transform: lowercase; vertical-align: middle; }


.tel-text .wa-btn.is-enviando { cursor: progress; }
.tel-text .wa-btn.is-enviando svg, .tel-text .wa-btn.is-enviando .wa-papel { animation: wa-enviando 1s ease-in-out infinite; }
.tel-text .wa-btn.is-atualizado svg { animation: wa-chegou .45s cubic-bezier(.22, 1, .36, 1); }
.tel-text .wa-btn.is-atualizado .wa-papel { animation: wa-chegou .45s cubic-bezier(.22, 1, .36, 1) .1s both; }
.tel-text .wa-btn.is-falhou svg, .tel-text .wa-btn.is-falhou .wa-papel { animation: wa-falhou .5s; color: var(--red); }
@keyframes wa-enviando { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .3; transform: scale(.78); } }
@keyframes wa-chegou { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes wa-falhou { 0%, 100% { transform: translateX(0); } 25%, 75% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
@media (prefers-reduced-motion: reduce) {
  .tel-text .wa-btn.is-enviando svg, .tel-text .wa-btn.is-enviando .wa-papel, .tel-text .wa-btn.is-atualizado svg, .tel-text .wa-btn.is-atualizado .wa-papel, .tel-text .wa-btn.is-falhou svg, .tel-text .wa-btn.is-falhou .wa-papel { animation: none; }
}
.iti { width: 100%; --iti-border-color: var(--border); --iti-country-selector-bg: var(--surface); --iti-hover-color: var(--surface-2); --iti-icon-color: var(--muted); }
.form-error { color: var(--red); font-size: 11.5px; }
