:root {
  color-scheme: light;
  --app-primary: #7b1e2b;
  --app-secondary: #f1d6dc;
  --app-bg: #f8f3f4;
  --app-paper: #ffffff;
  --app-text: #1f1417;
  --app-text-secondary: #736166;
  --app-active-bg: #7b1e2b;
  --app-active-color: #ffffff;
  --app-border: rgba(123,30,43,.10);
  --app-muted-border: rgba(123,30,43,.08);
}
* { box-sizing: border-box; }
html, body, #root { min-height: 100%; width: 100%; }
body { margin: 0; overflow-x: hidden; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, rgba(241,214,220,.62), transparent 32%), linear-gradient(135deg, #3c0711, #7b1e2b 55%, #f1d6dc); }
.login-card { width: min(480px, 100%); padding: 18px; }
.brand-mark { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: #7b1e2b; color: #f8e9ed; font-weight: 900; font-size: 20px; }
.app-shell { min-height: 100vh; width: 100%; max-width: 100%; display: flex; background: var(--app-bg); color: var(--app-text); overflow-x: hidden; }
.app-shell[data-theme="vinho"] { --app-primary: #7b1e2b; --app-secondary: #f1d6dc; --app-bg: #f8f3f4; --app-paper: #ffffff; --app-text: #1f1417; --app-text-secondary: #736166; --app-active-bg: #7b1e2b; --app-active-color: #ffffff; --app-border: rgba(123,30,43,.10); --app-muted-border: rgba(123,30,43,.08); }
.app-shell[data-theme="azul"] { --app-primary: #0b77b7; --app-secondary: #aee9ff; --app-bg: #f3f9fd; --app-paper: #ffffff; --app-text: #13202a; --app-text-secondary: #64748b; --app-active-bg: #0b77b7; --app-active-color: #ffffff; --app-border: rgba(11,119,183,.10); --app-muted-border: rgba(11,119,183,.08); }
.app-shell[data-theme="claro"] { --app-primary: #7b1e2b; --app-secondary: #f1d6dc; --app-bg: #f8fafc; --app-paper: #ffffff; --app-text: #1e293b; --app-text-secondary: #64748b; --app-active-bg: #f4e6e9; --app-active-color: #7b1e2b; --app-border: rgba(123,30,43,.12); --app-muted-border: rgba(123,30,43,.08); }
.app-shell[data-theme="escuro"] { color-scheme: dark; --app-primary: #f1b7c2; --app-secondary: #4d1320; --app-bg: #160b10; --app-paper: #211018; --app-text: #f8eef0; --app-text-secondary: #d2b6bd; --app-active-bg: #f1b7c2; --app-active-color: #2d0710; --app-border: rgba(255,255,255,.08); --app-muted-border: rgba(255,255,255,.07); }
.side-drawer { width: 250px; flex: 0 0 250px; }
.side-paper { width: 250px; border-right: 0 !important; background: var(--app-paper) !important; padding: 14px 14px 18px; }
.side-brand { height: 54px; display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand-dot { width: 25px; height: 25px; border-radius: 50%; background: conic-gradient(var(--app-secondary) 0 75%, var(--app-primary) 0); box-shadow: 0 0 0 5px color-mix(in srgb, var(--app-secondary) 35%, transparent); }
.menu-caption { font-size: 11px !important; font-weight: 900 !important; letter-spacing: .06em !important; color: var(--app-text-secondary); margin: 12px 8px 6px !important; }
.side-paper .MuiListItemButton-root { border-radius: 8px; margin: 3px 0; color: var(--app-text) !important; }
.side-paper .MuiListItemIcon-root { min-width: 34px; color: inherit; }
.side-paper .menu-active { background: var(--app-active-bg) !important; color: var(--app-active-color) !important; border: 1px solid color-mix(in srgb, var(--app-primary) 28%, transparent); }
.side-paper .menu-active .MuiListItemIcon-root,
.side-paper .menu-active .MuiListItemText-primary { color: inherit !important; }
.side-help { margin-top: 16px; padding: 14px; text-align: center; background: color-mix(in srgb, var(--app-primary) 6%, transparent) !important; }
.main-area { flex: 1 1 calc(100% - 250px); width: calc(100% - 250px); max-width: calc(100% - 250px); min-width: 0; padding-left: 0; display: flex; flex-direction: column; }
.topbar { backdrop-filter: blur(10px); background: color-mix(in srgb, var(--app-bg) 88%, transparent) !important; border-bottom: 1px solid var(--app-muted-border); }
.content-wrap { flex: 1 1 auto; padding: 26px 28px; max-width: 100%; width: 100%; min-width: 0; margin: 0; }
.hero-grid { display: grid; grid-template-columns: 1.55fr 1.2fr .9fr; gap: 20px; }
.mini-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.sales-card { min-height: 190px; position: relative; overflow: hidden; }
.mini-line { position: absolute; right: 20px; bottom: 12px; width: 46%; color: var(--app-primary); }
.stat-card { min-height: 150px; }
.stat-dark { background: var(--app-primary) !important; color: #fff7f8 !important; }
.stat-lime { background: var(--app-secondary) !important; color: #3a0b14 !important; }
.mini-bars { display: flex; align-items: end; gap: 18px; height: 210px; padding: 18px 8px 0; }
.bar-wrap { flex: 1; height: 100%; display: grid; grid-template-rows: 1fr auto; align-items: end; justify-items: center; gap: 8px; color: var(--app-text-secondary); font-size: 11px; }
.bar-wrap span { width: 22px; min-height: 20px; border-radius: 12px; background: linear-gradient(180deg, var(--app-secondary), var(--app-primary)); display: block; }
.page-title-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.page-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; background: color-mix(in srgb, var(--app-primary) 14%, transparent); color: var(--app-primary); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-top: 8px; }
.form-grid.four-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-span-2 { grid-column: span 2; }
.field-span-all { grid-column: 1 / -1; }
.report-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, .85fr); gap: 20px; align-items: start; }
.report-preview { padding: 18px; min-height: 320px; background: color-mix(in srgb, var(--app-primary) 5%, transparent) !important; }
.preview-table { margin-top: 18px; overflow: auto; }
.drag-row { padding: 10px 12px; display: flex; gap: 8px; align-items: center; cursor: grab; border: 1px dashed rgba(127,127,127,.35); }
.saved-model { padding: 10px 12px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.upload-box { padding: 10px 12px; border: 1px dashed rgba(127,127,127,.36); background: rgba(127,127,127,.04) !important; }
.upload-box.compact { padding: 8px; }
.MuiTableHead-root .MuiTableCell-root { font-weight: 900; color: var(--app-text); background: color-mix(in srgb, var(--app-primary) 8%, transparent); }
.MuiTextField-root .MuiInputLabel-root { background: var(--app-paper); padding: 0 4px; }

/* Aproveitamento horizontal total das páginas e painéis */
.content-wrap > .MuiStack-root,
.content-wrap > .MuiBox-root { width: 100%; max-width: 100%; min-width: 0; }
.content-wrap .MuiCard-root,
.content-wrap .MuiPaper-root { width: 100%; max-width: 100%; min-width: 0; }
.content-wrap .MuiCardContent-root { width: 100%; min-width: 0; overflow-x: auto; }
.content-wrap .MuiTable-root { width: 100%; min-width: 100%; }
.content-wrap .MuiTextField-root,
.content-wrap .MuiFormControl-root { min-width: 0; }
.MuiDialog-paper { max-width: calc(100vw - 48px) !important; }
.MuiDialog-paperWidthXl { width: min(1540px, calc(100vw - 48px)); }
.MuiDialog-paperWidthLg { width: min(1280px, calc(100vw - 48px)); }

@media (max-width: 1300px) {
  .form-grid.four-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .builder-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .hero-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .mini-grid, .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-grid.four-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .side-paper { width: 78px; padding: 12px 8px; }
  .side-drawer { width: 78px; }
  .main-area { flex-basis: calc(100% - 78px); width: calc(100% - 78px); max-width: calc(100% - 78px); padding-left: 0; }
  .side-brand h6, .menu-caption, .side-paper .MuiListItemText-root, .side-help { display: none; }
  .side-paper .MuiListItemIcon-root { min-width: 0; margin: auto; }
  .content-wrap { padding: 16px; }
  .MuiDialog-paper { max-width: calc(100vw - 20px) !important; width: calc(100vw - 20px) !important; }
  .page-title-row { align-items: flex-start; flex-direction: column; }
  .mini-grid, .report-grid, .form-grid, .form-grid.four-cols { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: span 1; }
}
.orgao-emblem { display: flex; align-items: center; gap: 12px; text-align: left; }
.permission-group { padding: 14px; border: 1px solid var(--app-muted-border); }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
@media (max-width: 820px) { .permission-grid { grid-template-columns: 1fr; } }

/* Modais amplos e formulários adaptáveis */
.modal-80 .MuiDialog-paper,
.MuiDialog-paper.modal-80 { width: 80vw !important; max-width: 80vw !important; }
.form-grid.adaptive-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.form-grid .field-span-2 { grid-column: span 2; }
.form-grid .field-span-3 { grid-column: span 3; }
.form-grid .field-span-all { grid-column: 1 / -1; }
.form-grid .MuiTextField-root,
.form-grid .MuiFormControl-root,
.form-grid .upload-box { width: 100%; }

.dialog-content-scroll { max-height: min(72vh, 720px); overflow-y: auto !important; }
.modal-80 .MuiDialog-paper { max-height: calc(100vh - 48px); }
.form-grid .field-date { max-width: 190px; }
.form-grid .field-small { max-width: 170px; }
.form-grid .field-medium { max-width: 260px; }
.form-grid .field-span-2.field-date,
.form-grid .field-span-2.field-small,
.form-grid .field-span-2.field-medium,
.form-grid .field-span-all.field-date,
.form-grid .field-span-all.field-small,
.form-grid .field-span-all.field-medium { max-width: none; }
.form-grid.docs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .modal-80 .MuiDialog-paper,
  .MuiDialog-paper.modal-80 { width: 94vw !important; max-width: 94vw !important; }
  .form-grid.adaptive-cols, .form-grid.docs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .field-span-2, .form-grid .field-span-3 { grid-column: span 2; }
}
@media (max-width: 720px) {
  .modal-80 .MuiDialog-paper,
  .MuiDialog-paper.modal-80 { width: calc(100vw - 20px) !important; max-width: calc(100vw - 20px) !important; }
  .form-grid.adaptive-cols, .form-grid.docs-grid { grid-template-columns: 1fr; }
  .form-grid .field-span-2, .form-grid .field-span-3 { grid-column: 1 / -1; }
  .form-grid .field-date, .form-grid .field-small, .form-grid .field-medium { max-width: none; }
}

/* Login institucional no padrão da referência enviada */
.login-page.soft-login {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(22px, 4vw, 56px);
  color: #ffffff;
  background:
    radial-gradient(circle at 97% 17%, rgba(154, 190, 78, .30) 0 0, transparent 15%),
    radial-gradient(circle at 7% 88%, rgba(22, 154, 166, .28) 0 0, transparent 18%),
    linear-gradient(120deg, #09243f 0%, #0b2d45 43%, #113d36 100%);
}
.login-page.soft-login::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 58px 58px;
  mask-image: linear-gradient(90deg, rgba(0,0,0,.75), rgba(0,0,0,.95), rgba(0,0,0,.72));
  pointer-events: none;
}
.login-lines { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.login-lines span { position: absolute; width: 54vw; height: 1px; border-radius: 999px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent); animation: softLine 9s ease-in-out infinite alternate; }
.login-lines span:nth-child(1) { top: 16%; left: -8%; transform: rotate(-16deg); }
.login-lines span:nth-child(2) { top: 55%; right: -12%; transform: rotate(-16deg); animation-delay: 1.1s; }
.login-lines span:nth-child(3) { bottom: 18%; left: 14%; transform: rotate(-16deg); animation-delay: 2.2s; }
.login-lines i { position: absolute; display: block; width: 190px; height: 190px; border-radius: 50%; filter: blur(24px); opacity: .44; background: #8bbf45; animation: glowPulse 7s ease-in-out infinite alternate; }
.login-lines i:nth-of-type(1) { right: 4%; top: 5%; }
.login-lines i:nth-of-type(2) { left: -2%; bottom: 10%; background: #168da6; animation-delay: 1.8s; }
.login-shell { position: relative; z-index: 1; width: min(1060px, 100%); display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, 390px); gap: clamp(28px, 6vw, 92px); align-items: center; }
.login-hero { padding: 10px 0; background: transparent; border: 0; box-shadow: none; }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22); color: #d7f58a; margin-bottom: 24px; }
.login-kicker { color: #c8f06e; font-weight: 900 !important; letter-spacing: .22em !important; font-size: .72rem !important; margin-bottom: 8px !important; }
.login-headline { max-width: 610px; margin: 0 !important; font-size: clamp(2.35rem, 5.1vw, 4.35rem) !important; line-height: .95 !important; letter-spacing: -.06em !important; font-weight: 950 !important; color: #ffffff; text-shadow: 0 18px 40px rgba(0,0,0,.24); }
.login-subtitle { max-width: 660px; margin-top: 22px !important; font-size: 1.02rem !important; color: rgba(255,255,255,.75); line-height: 1.72 !important; }
.login-tags .MuiChip-root { color: #fff; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.13); font-weight: 850; backdrop-filter: blur(10px); border-radius: 14px; }
.login-tags .MuiChip-icon { color: #ffffff !important; font-size: 18px; }
.modern-login-card { width: 100%; padding: 18px; border-radius: 18px !important; overflow: hidden; box-shadow: 0 28px 70px rgba(0,0,0,.26) !important; border: 1px solid rgba(255,255,255,.55); background: rgba(248,250,252,.94) !important; backdrop-filter: blur(15px); position: relative; }
.modern-login-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 5px; background: linear-gradient(90deg, #1ab8b8, #b7e35d); }
.login-card-head { display: grid; grid-template-columns: 42px 1fr; gap: 14px; align-items: start; margin-bottom: 22px; padding-top: 8px; }
.login-card-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #d8f176; background: linear-gradient(135deg, #0b4c76, #0b6b97); box-shadow: 0 10px 22px rgba(11,76,118,.28); }
.login-card-subtitle { font-size: .92rem !important; line-height: 1.55 !important; }
.modern-login-card .MuiTextField-root .MuiInputBase-root { border-radius: 9px !important; background: rgba(255,255,255,.72); }
.modern-login-card .MuiInputLabel-root { background: rgba(248,250,252,.94); }
.modern-login-card .MuiButton-contained { border-radius: 16px !important; min-height: 46px; font-weight: 850; text-transform: none; background: linear-gradient(135deg, #0d63a5, #0a4d84) !important; box-shadow: 0 14px 28px rgba(10,77,132,.24); }
.modern-login-card .MuiButton-text { text-transform: none; font-weight: 800; color: #0a4d84; }
.animated-mark { animation: floatMark 4.8s ease-in-out infinite; box-shadow: 0 16px 32px rgba(0,0,0,.20); }
@keyframes softLine { from { opacity: .30; transform: translateX(-18px) rotate(-16deg); } to { opacity: .88; transform: translateX(34px) rotate(-16deg); } }
@keyframes glowPulse { from { transform: scale(.92); opacity: .30; } to { transform: scale(1.08); opacity: .52; } }
@keyframes floatMark { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; gap: 28px; }
  .login-hero { padding-top: 8px; }
  .modern-login-card { max-width: 440px; justify-self: center; }
}
@media (max-width: 560px) {
  .login-page.soft-login { padding: 16px; place-items: start center; }
  .login-headline { font-size: 2.35rem !important; }
  .login-card-head { grid-template-columns: 1fr; }
}
