/* AlphaVISTO — app design system
   Reproduz o design system do Visto (design-tokens.css + design-components.css):
   mesma escala tipográfica, mesmos raios/sombras/cores, mesmo cromo de topbar.
   Pre-requisito: tokens.css carregado antes. */

/* ============== Base ============== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background-color: var(--muted);
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--foreground);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--foreground);
  margin: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #2a4d7c; }

label {
  font-weight: 500;
  line-height: 1.4;
  font-family: var(--font-sans);
}

button { font-family: inherit; }

/* ============== Topbar (72px, azul) ============== */

.topbar {
  height: 72px;
  width: 100%;
  flex-shrink: 0;
  background: var(--topbar-bg);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.topbar-indent {
  max-width: 1920px;
  width: 100%;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  padding-right: 16px;
}

/* Logo em "ilha" branca */
.topbar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 100%;
  background-color: #ffffff;
  padding: 0 20px;
  min-width: 150px;
  flex-shrink: 0;
}

.topbar-logo img { height: 32px; width: auto; max-width: 130px; object-fit: contain; }
.topbar-logo img.logo-cliente { padding-left: 14px; border-left: 1px solid var(--border); }

.topbar-menu {
  list-style: none;
  display: flex;
  align-items: center;
  height: 100%;
  margin: 0 0 0 auto;
  padding: 0;
  gap: 4px;
  flex-shrink: 0;
}

.topbar-menu > li {
  display: flex;
  align-items: center;
  height: 100%;
  position: relative;
}

.topbar-menu > li > a,
.topbar-menu > li > .topbar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: color-mix(in srgb, var(--topbar-fg) 85%, transparent);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  background: none;
  border: 0;
}

.topbar-menu > li > a:hover,
.topbar-menu > li > .topbar-link:hover {
  background-color: color-mix(in srgb, var(--topbar-fg) 10%, transparent);
  color: var(--topbar-fg);
}

.topbar-menu .ico { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.topbar-menu .topbarItem { color: inherit; font-size: var(--text-sm); font-weight: 500; }
.topbar-menu .menu-separator {
  color: color-mix(in srgb, var(--topbar-fg) 25%, transparent);
  font-size: 14px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  pointer-events: none;
}

/* Submenu hover */
.topbar-menu > li > .submenu {
  list-style: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 220px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  margin: 4px 0 0;
  padding: 6px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition-fast);
  z-index: var(--z-dropdown);
}

.topbar-menu > li:hover > .submenu,
.topbar-menu > li:focus-within > .submenu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.topbar-menu > li:hover::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 8px;
}

.topbar-menu .submenu li { list-style: none; }
.topbar-menu .submenu li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--foreground);
  font-size: var(--text-sm);
  text-decoration: none;
  width: 100%;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.topbar-menu .submenu li a:hover { background-color: var(--accent); }
.topbar-menu .submenu li a .ico { color: var(--muted-foreground); width: 14px; height: 14px; }
.topbar-menu .submenu li.menu-separator-li { height: 1px; background: var(--border); margin: 6px 0; }

.topbar-menu .notification-bubble {
  position: absolute;
  top: 4px;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--destructive);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============== Conteúdo ============== */

.app-shell { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.content { flex: 1; padding: 24px; width: 100%; }
.content-inner { width: 100%; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title { font-size: var(--text-2xl); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.page-sub { font-size: var(--text-sm); color: var(--muted-foreground); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--muted-foreground); margin-bottom: 10px; }
.breadcrumb a { color: var(--muted-foreground); }
.breadcrumb a:hover { color: var(--primary); }

/* ============== Card / painel ============== */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
}

.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: var(--text-lg); font-weight: 600; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ============== KPIs / dashboard ============== */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi {
  background: var(--card);
  border-radius: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-label { font-size: var(--text-xs); color: var(--muted-foreground); font-weight: 600; letter-spacing: 0; }
.kpi-value { font-size: 30px; font-weight: 800; color: var(--foreground); line-height: 1.1; }
.kpi-value.is-primary { color: var(--primary); }
.kpi-value.is-success { color: var(--visto-success); }
.kpi-value.is-warning { color: var(--warning-icon); }
.kpi-foot { font-size: var(--text-xs); color: var(--muted-foreground); }

.dashboard-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

/* ============== Botões ============== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-size: var(--text-sm);
  font-weight: 400;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:hover { background: var(--muted); border-color: var(--muted-foreground); color: var(--foreground); }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border-color: var(--btn-primary-bg);
}
.btn-primary:hover { background: var(--btn-primary-hover-bg); border-color: var(--btn-primary-hover-bg); color: var(--btn-primary-fg); }

.btn-success { background: var(--visto-success); color: #fff; border-color: var(--visto-success); }
.btn-success:hover { background: #16a34a; border-color: #16a34a; color: #fff; }

.btn-danger { background: var(--destructive); color: #fff; border-color: var(--destructive); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }

.btn-warning { background: var(--warning-icon); color: #fff; border-color: var(--warning-icon); }
.btn-warning:hover { background: #b45309; border-color: #b45309; color: #fff; }

.btn-outline { background: var(--background); color: var(--foreground); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--muted); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--muted); }

.btn-sm { height: 30px; padding: 0 12px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { height: 46px; padding: 0 20px; font-size: var(--text-md); }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-block { width: 100%; }

.btn .ico { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.btn-sm .ico { width: 14px; height: 14px; }

/* ============== Formulários ============== */

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted-foreground);
}
.field-hint { font-size: var(--text-xs); color: var(--muted-foreground); }
.field-req { color: var(--destructive); }

.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input-background);
  color: var(--foreground);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.input:disabled, .select:disabled { background: var(--muted); color: var(--muted-foreground); cursor: not-allowed; }
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; cursor: pointer; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input-ico { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--muted-foreground); stroke: currentColor; fill: none; stroke-width: 1.8; pointer-events: none; }
.input-group .input { padding-left: 38px; }

.check { display: flex; align-items: center; gap: 10px; font-size: var(--text-sm); cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px; }
.form-actions.left { justify-content: flex-start; }

/* ============== Tabela ============== */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  background: var(--table-header-bg);
  color: var(--table-head-text);
  font-size: var(--text-2xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  padding: 12px 24px;
  border-bottom: 1px solid var(--table-border);
  white-space: nowrap;
}
.table td {
  padding: 14px 24px;
  border-bottom: 1px solid var(--table-border);
  color: var(--table-cell-text);
  font-size: var(--text-sm);
  vertical-align: middle;
}
.table tbody tr:hover td { background: var(--table-row-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .acoes { display: flex; gap: 6px; justify-content: flex-end; }
.table .td-strong { font-weight: 500; color: var(--foreground); }
.table .td-sub { font-size: var(--text-xs); color: var(--muted-foreground); }

.empty-state { padding: 48px 24px; text-align: center; color: var(--muted-foreground); font-size: var(--text-sm); }
.empty-state .empty-ico { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--border); stroke: currentColor; fill: none; stroke-width: 1.5; }

/* ============== Badges / status ============== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.no-dot::before { display: none; }

.badge-blue { background: #E3EFED; color: #003F40; }
.badge-sky { background: var(--info-bg); color: var(--info-text); }
.badge-green { background: var(--success-bg); color: var(--success-text); }
.badge-amber { background: var(--warning-bg); color: var(--warning-text); }
.badge-red { background: #FEF2F2; color: #991B1B; }
.badge-gray { background: var(--muted); color: var(--muted-foreground); }
.badge-purple { background: #F5F3FF; color: #5B21B6; }

/* ============== Alertas inline ============== */

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-lg); font-size: var(--text-sm); border: 1px solid transparent; }
.alert .ico { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.alert-info { background: var(--info-bg); color: var(--info-text); }
.alert-info .ico { color: var(--info-icon); }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-success .ico { color: var(--success-icon); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.alert-warning .ico { color: var(--warning-icon); }
.alert-error { background: #FEF2F2; color: #991B1B; }
.alert-error .ico { color: var(--destructive); }

/* ============== Tabs ============== */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted-foreground);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  text-decoration: none;
}
.tab:hover { color: var(--foreground); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============== Filtros ============== */

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 160px; }
.filters .field .input, .filters .field .select { height: 36px; font-size: var(--text-xs); }

/* ============== Login ============== */

.login-banner {
  background: var(--primary);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.login-banner-logo-visto { height: 46px; display: block; }

.login-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  background: var(--muted);
  padding: 40px 24px;
  overflow: auto;
}

.login-columns {
  display: flex;
  gap: 24px;
  align-items: stretch;
  max-width: 1000px;
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
}

.login-card form { margin: 0 0 13.5px; }
.login-card form:last-child { margin-bottom: 13.5px; }

.login-card {
  flex: 1 1 380px;
  max-width: 470px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 28px 32px;
}

.login-title {
  font-size: 28px;
  font-weight: 600;
  line-height: 42px;
  color: var(--foreground);
  margin: 0;
  text-align: left;
}

.login-field { position: relative; margin-bottom: 12px; }
.login-field .login-field-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  font-size: 16px;
  pointer-events: none;
  z-index: 1;
  width: 16px; height: 16px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
}
.login-field .input {
  width: 100%;
  height: 40px;
  padding: 8px 12px 8px 40px;
  font-size: 16px;
  line-height: 22px;
  border-radius: var(--radius-md);
}

.login-forgot { text-align: right; margin: -2px 0 14px; }
.login-forgot a { font-size: 15px; color: var(--primary); text-decoration: none; cursor: pointer; background: none; border: 0; padding: 0; }
.login-forgot a:hover { text-decoration: underline; }

.login-submit .btn { width: 100%; height: 48px; font-size: 16px; font-weight: 400; padding: 0 15px; border-radius: var(--radius-md); }

.login-promo {
  flex: 1 1 380px;
  max-width: 470px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  background: linear-gradient(135deg, #003F40 0%, #005D59 62%, #0FA98F 130%);
  color: #fff;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-promo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  width: fit-content;
  margin-bottom: 20px;
}
.login-promo-badge .ico { width: 13px; height: 13px; stroke: var(--visto-blue); fill: none; stroke-width: 2; }
.login-promo-headline { font-size: 24px; font-weight: 700; line-height: 1.25; margin: 0 0 16px; color: #fff; }
.login-promo-headline strong { color: #7FE3C8; }
.login-promo-detail { display: flex; align-items: center; gap: 8px; font-size: 13px; color: rgba(255, 255, 255, 0.8); margin-bottom: 20px; }
.login-promo-detail .ico { width: 14px; height: 14px; stroke: #7FE3C8; fill: none; stroke-width: 2; }
.login-promo .btn-promo { background: #fff; color: var(--primary); border-color: #fff; font-weight: 400; width: fit-content; height: 38px; margin-bottom: 13.5px; padding: 0 15px; font-size: var(--text-sm); border-radius: var(--radius-md); }
.login-promo .btn-promo:hover { background: #E3EFED; color: var(--primary); }

.login-demo { text-align: center; font-size: 14px; color: var(--muted-foreground); margin: 32px 0 24px; }
.login-demo a { color: var(--primary); font-weight: 500; }
.login-demo a:hover { text-decoration: underline; }

.login-footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted-foreground);
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  background: var(--card);
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-shrink: 0;
}
.login-footer a { color: var(--primary); }
.login-footer a:hover { color: var(--primary-hover); text-decoration: underline; }

/* ============== Modal / dialog ============== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 24px;
  z-index: var(--z-modal);
  overflow: auto;
}
.modal {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  border: 1px solid var(--border);
}
.modal.modal-lg { max-width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: var(--text-lg); font-weight: 600; }
.modal-close { background: none; border: 0; cursor: pointer; color: var(--muted-foreground); padding: 4px; display: flex; }
.modal-close:hover { color: var(--foreground); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ============== Utilidades ============== */

.row { display: flex; gap: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 16px; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.muted { color: var(--muted-foreground); }
.small { font-size: var(--text-xs); }
.strong { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.hidden { display: none !important; }

/* ============== Responsivo ============== */

@media (max-width: 1024px) {
  .form-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .content { padding: 16px; }
  .form-grid, .form-grid.cols-3, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; }
  .page-title { font-size: var(--text-xl); }
  .topbar { height: 64px; }
  .topbar-logo { min-width: 0; padding: 0 14px; }
  .topbar-menu > li > a { padding: 8px; }
  .topbar-menu .label-item { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* ============== Rodapé do app ============== */
.app-footer { margin-top: 8px; padding: 16px 24px 24px; }
.app-footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; font-size: var(--text-sm); color: var(--muted-foreground);
}
.app-footer-brand { flex: 0 0 auto; }
.app-footer-links { display: flex; align-items: center; gap: 10px; }
.app-footer-links a { color: var(--muted-foreground); }
.app-footer-links a:hover { color: var(--primary); }
.app-footer-sep { color: var(--border); }
.app-footer-copy { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; text-align: right; font-size: var(--text-xs); }
.app-footer-copy a { color: var(--primary); }

/* item ativo do menu */
.topbar-menu > li > .topbar-link.is-active { background-color: color-mix(in srgb, var(--topbar-fg) 12%, transparent); color: var(--topbar-fg); }

/* ============== Home (espelha inicio.faces) ============== */
.home-greeting { margin-bottom: 4px; }
.home-sub { color: var(--muted-foreground); font-size: var(--text-base); margin: 0 0 24px; }
.home-section-title { font-size: var(--text-lg); font-weight: 600; margin: 0 0 12px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.home-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 24px; }
.home-kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-height: 104px;
  box-shadow: var(--shadow-xs);
}
.home-kpi .num { font-size: 28px; font-weight: 700; line-height: 1.1; }
.home-kpi .lbl { font-size: var(--text-sm); color: var(--muted-foreground); line-height: 1.35; }
.home-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); }
.home-card-head { padding: 18px 20px 0; }
.home-card-title { font-size: var(--text-lg); font-weight: 600; }
.home-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 20px; }
.home-filters .lbl { font-size: var(--text-sm); color: var(--foreground); }
.home-filters .select, .home-filters .input { height: 38px; width: auto; min-width: 150px; font-size: var(--text-sm); }
.home-chart { margin: 0 20px 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 12px 8px; }
.home-chart-title { text-align: center; font-size: var(--text-md); font-weight: 500; margin-bottom: 6px; }
.home-chart-legend { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: var(--text-xs); color: var(--muted-foreground); padding: 6px 0 4px; }
.home-chart-legend .swatch { width: 26px; height: 10px; border: 1.5px solid var(--primary); background: color-mix(in srgb, var(--primary) 12%, white); border-radius: 2px; }
.home-map { padding: 18px 20px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--text-md); }
.home-map .ico { color: #dc2626; }
.home-news { padding: 16px 20px; }
.home-news-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.home-news-item:last-child { border-bottom: 0; }
.home-news-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.home-news-date { font-size: var(--text-xs); color: var(--muted-foreground); }
.home-news-title { font-size: var(--text-md); font-weight: 600; margin: 0 0 4px; }
.home-news-desc { font-size: var(--text-sm); color: var(--muted-foreground); margin: 0; line-height: 1.45; }

@media (max-width: 1100px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-kpis { grid-template-columns: 1fr; }
}

/* ============== Acordeão do detalhe (Laudo de Vistoria) ============== */
.acc { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); overflow: hidden; box-shadow: var(--shadow-xs); }
.acc > details { border-bottom: 1px solid var(--border); }
.acc > details:last-child { border-bottom: 0; }
.acc > details > summary {
  list-style: none; cursor: pointer; padding: 16px 20px;
  font-size: var(--text-md); font-weight: 600; color: var(--foreground);
  display: flex; align-items: center; gap: 8px;
}
.acc > details > summary::-webkit-details-marker { display: none; }
.acc > details > summary::before {
  content: ""; width: 0; height: 0;
  border-left: 5px solid var(--muted-foreground);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform var(--transition-fast);
}
.acc > details[open] > summary::before { transform: rotate(90deg); }
.acc-body { padding: 4px 20px 20px; }
.acc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
.acc-sub { display: flex; align-items: center; gap: 8px; font-size: var(--text-md); font-weight: 600; margin: 12px 0 14px; }
.acc-sub .ico { width: 18px; height: 18px; }
.acc-field { margin-bottom: 12px; }
.acc-field .lbl { display: block; font-size: var(--text-xs); color: var(--muted-foreground); margin-bottom: 2px; }
.acc-field .val { font-size: var(--text-sm); color: var(--foreground); }
.acc-field .val.strong { font-weight: 600; text-transform: uppercase; }
.action-bar {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 20px 0 4px; flex-wrap: wrap;
}
@media (max-width: 900px) { .acc-grid { grid-template-columns: 1fr; gap: 8px; } }

/* ============== Consultar Vistoria (lista) ============== */
.list-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; margin-bottom: 8px; }
.list-filters .field { min-width: 0; }
.list-periodo { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: end; }
.list-periodo .a { padding-bottom: 10px; font-size: var(--text-sm); color: var(--muted-foreground); }
.list-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 8px 0 20px; }
.list-result { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 14px 20px; }
.list-result-txt { font-size: var(--text-sm); color: var(--foreground); }
.list-code-line { font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.table th:first-child, .table td:first-child { min-width: 210px; }
.list-code-pill {
  display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 999px;
  background: #E3EFED; color: #003F40; font-size: var(--text-xs); font-weight: 600;
}
.list-sub { font-size: var(--text-xs); color: var(--muted-foreground); }
.list-integ { font-size: var(--text-xs); color: var(--warning-icon); }
.list-acoes { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.list-acoes .btn { width: 28px; height: 28px; padding: 0; border-color: transparent; background: transparent; }
.list-acoes .btn:hover { background: var(--muted); border-color: var(--border); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-info { font-size: var(--text-xs); color: var(--muted-foreground); }
.pager-pages { display: flex; align-items: center; gap: 4px; }
.pager-pages a, .pager-pages span {
  min-width: 28px; height: 28px; padding: 0 6px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); color: var(--foreground); text-decoration: none;
}
.pager-pages a:hover { background: var(--muted); }
.pager-pages .is-active { background: var(--primary); color: #fff; }
@media (max-width: 900px) { .list-filters { grid-template-columns: 1fr; } }

/* ============== Agenda (calendário mensal) ============== */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 8px 0 12px; flex-wrap: wrap; }
.cal-title { font-size: var(--text-lg); font-weight: 600; }
.cal-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.cal-seg a { padding: 6px 14px; font-size: var(--text-sm); color: var(--foreground); text-decoration: none; }
.cal-seg a.is-active { background: var(--primary); color: #fff; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--card); }
.cal-head { background: var(--table-header-bg); color: var(--table-head-text); font-size: var(--text-2xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 132px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; overflow: hidden; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-day { font-size: var(--text-xs); color: var(--muted-foreground); text-align: right; margin-bottom: 4px; }
.cal-ev { display: block; font-size: 10px; line-height: 1.5; padding: 1px 6px; border-radius: 3px; margin-bottom: 3px; color: #fff; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev:hover { filter: brightness(1.08); }
@media (max-width: 900px) { .cal-cell { min-height: 84px; } }

/* ============== Arquivos da vistoria (fotos) ============== */
.foto-thumb {
  width: 176px; height: 235px; border-radius: var(--radius-lg);
  background: var(--muted); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-foreground); overflow: hidden; flex-shrink: 0;
}
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; }
.foto-card { display: flex; gap: 16px; align-items: flex-start; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.foto-card:last-child { border-bottom: 0; padding-bottom: 0; }
.foto-acoes { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ============== Caixa postal ============== */
.cp-card { display: flex; gap: 16px; align-items: flex-start; padding: 20px; }
.cp-ico {
  width: 44px; height: 44px; border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--primary) 12%, white);
  color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cp-titulo { font-size: var(--text-lg); font-weight: 600; margin: 0 0 4px; }
.cp-legenda { display: flex; gap: 16px; align-items: center; font-size: var(--text-xs); color: var(--muted-foreground); }
.cp-legenda .ponto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* ── Linha de vistoria: expansão + menu de ações ── */
.row-toggle {
  background: none; border: 0; padding: 2px; cursor: pointer; color: var(--muted-foreground);
  display: inline-flex; align-items: center; border-radius: 4px;
}
.row-toggle:hover { background: var(--muted); color: var(--foreground); }
tr.is-open > td { background: #FAFBFF; }

.vrow-dd { position: relative; display: inline-block; }
.vrow-dd > summary { list-style: none; cursor: pointer; }
.vrow-dd > summary::-webkit-details-marker { display: none; }
.vrow-dd[open] > summary { background: var(--muted); }
.vrow-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 60; width: 260px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 6px; text-align: left;
}
.vrow-menu a, .vrow-menu button, .vrow-menu .vrow-off {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  font-size: var(--text-sm); color: var(--foreground); background: none; border: 0;
  border-radius: var(--radius-md); cursor: pointer; text-decoration: none; text-align: left;
}
.vrow-menu a:hover, .vrow-menu button:hover { background: var(--muted); }
.vrow-menu .vrow-off { color: var(--muted-foreground); cursor: not-allowed; opacity: .6; }
.vrow-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.vrow-menu svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--muted-foreground); }

.row-exp > td { background: #FAFBFF; border-top: 0 !important; padding: 4px 16px 18px 44px !important; }
.row-exp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.row-exp-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.row-exp-title {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted-foreground); margin-bottom: 10px;
}
.row-exp-line {
  display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--foreground);
  padding: 3px 0;
}
.row-exp-line svg { width: 14px; height: 14px; color: var(--muted-foreground); flex-shrink: 0; }
.row-exp-line .badge { font-size: 10px; padding: 2px 7px; }
.row-exp-foot {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: var(--text-xs); color: var(--muted-foreground);
}
.row-exp-foot svg { width: 13px; height: 13px; }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--primary); font-size: var(--text-sm);
  cursor: pointer; text-decoration: underline;
}

/* ── Análise com IA ── */
.ia-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; background: #FBFCFE;
}
.ia-achados { margin: 10px 0 0; padding-left: 18px; font-size: var(--text-sm); }
.ia-achados li { margin-bottom: 4px; }
.ia-critico { color: var(--destructive); }
.ia-atencao { color: var(--warning-icon); }
.ia-info { color: var(--muted-foreground); }

/* ── Blocos de código (documentação de API) ── */
.code-block {
  margin: 0 0 12px; padding: 12px 14px; border-radius: var(--radius-md);
  background: #0B1F33; color: #E2E8F0; font-size: 11.5px; line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; white-space: pre;
}
.code-block:last-child { margin-bottom: 0; }
.card-body code, p code, span code {
  background: var(--muted); padding: 1px 5px; border-radius: 4px;
  font-size: 11.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Modais (padrão Visto) ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 200;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px 24px; overflow-y: auto;
}
.modal {
  background: var(--card); border-radius: 8px; box-shadow: 0 24px 60px rgba(15,23,42,.28);
  width: 100%; max-width: 620px; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.2; }
.modal-x {
  background: none; border: 0; cursor: pointer; color: var(--muted-foreground);
  display: inline-flex; align-items: center; justify-content: center; padding: 4px; border-radius: 4px;
}
.modal-x:hover { background: var(--muted); color: var(--foreground); }
.modal-body { padding: 22px 24px; }
.modal-intro { font-size: var(--text-sm); font-weight: 600; margin: 0 0 18px; }
.modal-foot {
  display: flex; align-items: center; gap: 10px; padding: 16px 24px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.modal-foot .btn { height: 40px; padding: 0 18px; }
.modal-foot-4 .btn-primary { margin-right: auto; }
@media (max-width: 640px) { .modal-foot-4 .btn { flex: 1 1 45%; } }

/* tile de IA na tabela */
.ia-tile {
  width: 34px; height: 34px; border-radius: 8px; background: #E5E7EB; color: #9CA3AF;
  display: inline-flex; align-items: center; justify-content: center;
}
.ia-tile.ok { background: #DCFCE7; color: #047857; }

/* toast de sucesso das ações */
.toast-ok {
  position: fixed; right: 24px; bottom: 24px; z-index: 300;
  background: #065F46; color: #fff; padding: 12px 16px; border-radius: var(--radius-lg);
  font-size: var(--text-sm); box-shadow: 0 12px 30px rgba(6,95,70,.35); max-width: 380px;
}

/* ── Configurações de Vistoria (TipoEditor) ── */
.tipo-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 32px; }
@media (max-width: 900px) { .tipo-grid { grid-template-columns: 1fr; gap: 16px; } }
.breadcrumb-link { font-size: var(--text-xs); color: var(--primary); text-decoration: none; }
.breadcrumb-link:hover { text-decoration: underline; }
.save-bar {
  position: sticky; bottom: 0; z-index: 30; display: flex; gap: 10px; justify-content: center;
  padding: 14px; background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
  border-top: 1px solid var(--border); margin: 0 -24px -24px;
}
.save-bar .btn { min-width: 130px; height: 40px; }

/* switch */
.switch {
  width: 44px; height: 24px; border-radius: 999px; background: #D1D5DB; border: 0; padding: 2px;
  cursor: pointer; position: relative; transition: background .15s; display: inline-flex;
}
.switch.on { background: #22C55E; }
.switch-knob {
  width: 20px; height: 20px; border-radius: 50%; background: #fff; display: block;
  transform: translateX(0); transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch.on .switch-knob { transform: translateX(20px); }

/* acessórios */
.acessorios-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 18px;
  max-height: 420px; overflow-y: auto; padding-right: 8px;
}
.acessorios-grid .check { font-size: var(--text-sm); }

/* roteiro */
.tipo-roteiro td { padding: 6px 8px !important; }
.roteiro-row {
  display: grid; align-items: center; gap: 6px;
  grid-template-columns: 56px 100px 70px 74px 104px 140px minmax(160px, 1fr) 150px;
  padding: 4px 8px;
}
.roteiro-row .input, .roteiro-row .select { height: 34px; font-size: 12.5px; }
.roteiro-ordem { text-align: center; }
.roteiro-cabecalho { padding-top: 0; padding-bottom: 0; }
/* a grade das linhas já define as colunas: sem a largura mínima geral das tabelas do painel */
.app-shell .table.tipo-roteiro { min-width: 0; }
.roteiro-cabecalho > span { white-space: normal; line-height: 1.2; min-width: 0; }
.roteiro-cabecalho .right { text-align: right; }
.roteiro-check { justify-content: center; }
.roteiro-acoes { display: flex; gap: 2px; justify-content: flex-end; }
@media (max-width: 1100px) {
  .roteiro-row { grid-template-columns: 54px 1fr; grid-auto-rows: auto; }
  .roteiro-cabecalho { display: none; }
  .roteiro-row > *:not(:nth-child(8)) { grid-column: span 1; }
}

/* modais com 3/4 botões */
.modal-foot-3 .btn-danger { margin-right: auto; }
.btn-danger { background: var(--destructive); border-color: var(--destructive); color: #fff; }
.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; }

/* WhatsApp na linha da vistoria */
.list-acoes .vrow-wa,
.vrow-wa {
  background: #25D366; border-color: #25D366; color: #fff;
  width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 10px;
}
.list-acoes .vrow-wa:hover,
.vrow-wa:hover { background: #1EBE5A; border-color: #1EBE5A; color: #fff; }
.list-acoes .vrow-wa.is-off,
.vrow-wa.is-off { background: #E5E7EB; border-color: #E5E7EB; color: #9CA3AF; cursor: not-allowed; }
.vrow-danger { color: var(--destructive) !important; }
.vrow-danger svg { color: var(--destructive) !important; }

/* ações compactas na lista de vistorias (caber WhatsApp + menu) */
.table-wrap .list-acoes .btn { width: 30px; height: 30px; padding: 0; justify-content: center; }
.table-wrap .list-acoes .vrow-wa { width: 30px; height: 30px; border-radius: 8px; }
.table-wrap .list-acoes > * { flex-shrink: 0; }

/* ── Moldes da câmera (master, #1062): o desenho é traço branco transparente, então o fundo é escuro ── */
.moldes-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.molde-quadro { aspect-ratio: 3 / 4; border-radius: 10px; background: linear-gradient(160deg, #3c4a4f, #1d2427);
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: rgba(255,255,255,0.7); }
.molde-quadro img { width: 100%; height: 100%; object-fit: contain; }
.molde-quadro.is-mini { width: 100%; }
.molde-opcoes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.molde-opcao { display: flex; flex-direction: column; gap: 4px; align-items: center; padding: 4px; border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px; background: #fff; cursor: pointer; font: inherit; }
.molde-opcao:hover { border-color: var(--brand, #0f7a63); }
.molde-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.text-danger { color: #b91c1c; }
