/* The outer Hub owns screen insets; modules fill the remaining iframe. */
:root {
  --renge-safe-top: env(safe-area-inset-top, 0px);
  --renge-safe-bottom: env(safe-area-inset-bottom, 0px);
  --renge-safe-left: env(safe-area-inset-left, 0px);
  --renge-safe-right: env(safe-area-inset-right, 0px);
}
:root.renge-embedded {
  --renge-safe-top: 0px;
  --renge-safe-bottom: var(--renge-frame-safe-bottom, 0px);
  --renge-safe-left: 0px;
  --renge-safe-right: 0px;
}
html { -webkit-text-size-adjust: 100%; }
button, a, input, select, textarea { touch-action: manipulation; }

:root[data-renge-layout="shell"] { --renge-bar-height: 48px; height:var(--renge-app-height,100%); overflow:hidden; }
[data-renge-layout="shell"] body {
  display: flex;
  flex-direction: column;
  position: absolute;
  inset: var(--renge-app-top, 0px) 0 auto;
  height: var(--renge-app-height, 100%);
  min-height: 0;
  padding: 0 var(--renge-safe-right) 0 var(--renge-safe-left);
  overflow: hidden;
}
:root.renge-embedded { height: var(--renge-module-height, 100%); }
.mobile-module-select { display: none; }
[data-renge-layout="shell"] .top {
  position: relative;
  inset: auto;
  flex: 0 0 auto;
  width: 100%;
  height: calc(var(--renge-bar-height) + var(--renge-safe-top));
  padding: var(--renge-safe-top) 10px 0;
  align-items: center;
}
[data-renge-layout="shell"] .viewport {
  position: relative;
  inset: auto;
  flex: 1 1 0;
  height: auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}
[data-renge-layout="shell"] .gate {
  top: var(--renge-app-top, 0px);
  bottom: auto;
  height: var(--renge-app-height, 100%);
  padding: calc(16px + var(--renge-safe-top)) max(16px, var(--renge-safe-right)) calc(16px + var(--renge-safe-bottom)) max(16px, var(--renge-safe-left));
  overflow-y: auto;
}
[data-renge-layout="shell"] .auth { min-height: 0; max-height: 100%; overflow-y: auto; }
[data-renge-layout="shell"] .accountMenu,
[data-renge-layout="shell"] .update-status {
  top: calc(var(--renge-app-top, 0px) + var(--renge-safe-top) + var(--renge-bar-height) + 8px);
}
[data-renge-layout="shell"] .module { height: 100%; }

@media screen and (max-width: 720px), screen and (max-width: 1100px) and (max-height: 550px) and (pointer: coarse) {
  :root[data-renge-layout="shell"] { --renge-bar-height: 52px; }
  [data-renge-layout="shell"] .brand { display: none; }
  [data-renge-layout="shell"] .top { gap: 6px; }
  [data-renge-layout="shell"] .tabs { align-items: center; height: 100%; flex: 1; }
  [data-renge-layout="shell"] .tab { min-width: 116px; max-width: none; height: 44px; font-size: 12px; padding: 0 10px; flex: 0 0 auto; }
  [data-renge-layout="shell"] .account { width: 44px; height: 44px; flex: 0 0 44px; font-size: 0; padding: 0; }
  [data-renge-layout="shell"] .account::after { content: 'Conta'; font-size: 11px; }
  [data-renge-layout="shell"] .app-update { height: 44px; flex: 0 0 auto; padding: 0 8px; font-size: 11px; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px !important; }

  /* A single compact header and one scrolling surface in the module. */
  html[data-renge-layout="gestao"], [data-renge-layout="gestao"] body { height: 100%; overflow: hidden !important; }
  [data-renge-layout="gestao"] .app { display: flex; flex-direction: column; height: 100% !important; min-height: 0 !important; padding: 0; overflow: hidden; }
  [data-renge-layout="gestao"] .main { order: 1; flex: 1 1 0; height: auto; min-height: 0; width: 100%; overflow-y: auto; overflow-x: hidden; padding: 0 !important; scrollbar-gutter: auto; }
  [data-renge-layout="gestao"] .topbar {
    position: sticky; top: 0; display: grid;
    grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto;
    height: auto !important; min-height: 0; gap: 8px;
    padding: calc(8px + var(--renge-safe-top)) 12px 8px !important;
    background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  [data-renge-layout="gestao"] .top-actions { grid-column: 2; grid-row: 1; margin-left: 0; justify-content: flex-end; min-width: 0; gap: 6px; }
  [data-renge-layout="gestao"] .top-actions .btn { padding: 9px 10px; white-space: nowrap; }
  [data-renge-layout="gestao"] .search { grid-column: 1; grid-row: 1; order: initial; width: 100%; min-width: 0; max-width: none; }
  [data-renge-layout="gestao"] .search input { min-height: 44px; width: 100%; }
  [data-renge-layout="gestao"] .search::before { top: 11px; }
  [data-renge-layout="gestao"] .page { padding: 14px 12px 24px; }
  [data-renge-layout="gestao"] .page-head { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  [data-renge-layout="gestao"] .page-title { font-size: 24px; line-height: 1.2; margin: 0; }
  [data-renge-layout="gestao"] .head-actions { margin: 0; }
  [data-renge-layout="gestao"] .sidebar { order: 2; display: flex; flex: 0 0 auto; position: relative; width: 100%; height: calc(68px + var(--renge-safe-bottom)); min-height: 0; padding: 0 0 var(--renge-safe-bottom); gap: 0; border-right: 0; border-top: 1px solid #292720; }
  [data-renge-layout="gestao"] .sidebar > :not(.nav), [data-renge-layout="gestao"] .sidebar .nav-sep { display: none; }
  [data-renge-layout="gestao"] .nav { display: flex; flex-direction: row; align-items: stretch; gap: 0; padding: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scrollbar-gutter: auto; }
  [data-renge-layout="gestao"] .nav::-webkit-scrollbar { display: none; }
  [data-renge-layout="gestao"] .nav-btn { flex: 1 0 25%; min-width: 0; height: 68px; border-radius: 0; flex-direction: column; justify-content: center; gap: 5px; padding: 8px 4px; font-size: 11px; line-height: 1.15; text-align: center; }
  [data-renge-layout="gestao"] .nav-btn span { display: block; }
  [data-renge-layout="gestao"] .nav-btn.active { box-shadow: inset 0 3px 0 var(--accent); }
  [data-renge-layout="gestao"] .btn, [data-renge-layout="gestao"] .icon-btn, [data-renge-layout="gestao"] .modal-close { min-height: 44px; }
  [data-renge-layout="gestao"] .icon-btn, [data-renge-layout="gestao"] .modal-close { min-width: 44px; }
  [data-renge-layout="gestao"] .modal-backdrop { padding: 8px 8px calc(8px + var(--renge-safe-bottom)); align-items: center; }
  [data-renge-layout="gestao"] .modal { max-height: calc(100dvh - 16px - var(--renge-safe-bottom)) !important; }
  [data-renge-layout="gestao"] .notif-panel { top: calc(64px + var(--renge-safe-top)); left: 12px; right: 12px; width: auto; max-height: calc(100dvh - 150px); }
  [data-renge-layout="gestao"] .toast-wrap { left: 12px; right: 12px; bottom: calc(80px + var(--renge-safe-bottom)); }
  [data-renge-layout="gestao"] .toast { min-width: 0; max-width: 100%; }

  /* Give the color recipe most of the screen instead of two large search blocks. */
  [data-renge-layout="gestao"] #page-colors .page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-bottom: 12px; }
  [data-renge-layout="gestao"] #page-colors .page-title { font-size: 22px; }
  [data-renge-layout="gestao"] #page-colors .page-sub { font-size: 12px; line-height: 1.35; margin-top: 5px; }
  [data-renge-layout="gestao"] #page-colors .head-actions .btn { padding: 9px 10px; font-size: 12px; white-space: nowrap; }
  [data-renge-layout="gestao"] #page-colors > .card > .card-body { padding: 10px; }
  [data-renge-layout="gestao"] #colorSearch { min-height: 44px; }
  [data-renge-layout="gestao"] #colorsList { gap: 12px; margin-top: 12px; }
  [data-renge-layout="gestao"] .color-card { padding: 16px; }
  [data-renge-layout="gestao"] .color-header { margin-bottom: 10px; }
  [data-renge-layout="gestao"] .color-header h3 { font-size: 18px; line-height: 1.3; }
  [data-renge-layout="gestao"] .recipe-table { font-size: 14px; line-height: 1.4; }
  [data-renge-layout="gestao"] .recipe-table td, [data-renge-layout="gestao"] .recipe-table th { padding-top: 8px; padding-bottom: 8px; }
  [data-renge-layout="gestao"] .recipe-notes { font-size: 14px; }

  [data-renge-layout="finance"] body { padding-bottom: 0; }
  [data-renge-layout="finance"] .shell { padding-bottom: calc(76px + var(--renge-safe-bottom)) !important; }
  [data-renge-layout="finance"] .sidebar { height: calc(76px + var(--renge-safe-bottom)) !important; padding-bottom: var(--renge-safe-bottom) !important; }
  [data-renge-layout="finance"] .sidebar .nav { flex-wrap: nowrap !important; }
  [data-renge-layout="finance"] .sidebar .nav button { flex: 1 0 25% !important; width: 25% !important; min-width: 0; }
  [data-renge-layout="finance"] .page { padding-bottom: 28px !important; }
  [data-renge-layout="finance"] .modal-bg { padding-bottom: 0 !important; }
  [data-renge-layout="finance"] .modal-foot { padding-bottom: calc(12px + var(--renge-safe-bottom)) !important; }
  [data-renge-layout="hub"] .main { padding-left: max(18px, var(--renge-safe-left)); padding-right: max(18px, var(--renge-safe-right)); padding-bottom: calc(108px + var(--renge-safe-bottom)) !important; }
  [data-renge-layout="hub"] .bottomNav { height: calc(84px + var(--renge-safe-bottom)); padding-bottom: var(--renge-safe-bottom); }
  [data-renge-layout="hub"] .sheetBox { padding-bottom: calc(24px + var(--renge-safe-bottom)); }
}

/* Operacional: eight sections must never create a second row. */
@media screen and (max-width: 899px) {
  :root[data-renge-layout="hub"] { --renge-hub-nav-height: 64px; }
  [data-renge-layout="hub"] #bottomNav {
    display: flex; flex-wrap: nowrap; align-items: stretch; justify-content: flex-start;
    width: 100%; gap: 0; height: calc(var(--renge-hub-nav-height) + var(--renge-safe-bottom));
    padding: 0 0 var(--renge-safe-bottom); overflow-x: auto; overflow-y: hidden;
    overscroll-behavior-x: contain; scrollbar-width: none;
  }
  [data-renge-layout="hub"] #bottomNav .navBtn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex: 1 0 25%; min-width: 0; max-width: none; height: calc(var(--renge-hub-nav-height) - 1px);
    padding: 6px 4px; margin: 0; gap: 4px; font-size: 11px; line-height: 1.15;
  }
  [data-renge-layout="hub"] #bottomNav .navIco { height: 20px; line-height: 20px; font-size: 18px; }
  [data-renge-layout="hub"] #bottomNav .navLabel { min-height: 25px; max-width: 100%; white-space: normal; }
  [data-renge-layout="hub"] .main { padding-bottom: calc(var(--renge-hub-nav-height) + 24px + var(--renge-safe-bottom)) !important; }
  [data-renge-layout="hub"] .syncStatus, [data-renge-layout="hub"] .toast { top: auto; bottom: calc(var(--renge-hub-nav-height) + 12px + var(--renge-safe-bottom)); }
  [data-renge-layout="hub"] .syncStatus { max-width: calc(100% - 24px); }
}

.layout-diagnostics { width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto; border: 1px solid #c9b98d; border-radius: 14px; padding: 18px; background: #fff; color: #191a18; }
.layout-diagnostics::backdrop { background: #0008; }
.layout-diagnostics h2 { font-size: 18px; margin: 0 0 8px; }
.layout-diagnostics p { font-size: 13px; line-height: 1.4; }
.layout-diagnostics pre { font: 12px/1.5 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.layout-diagnostics-actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; background: #fff; padding-top: 10px; }
.layout-diagnostics button { min-height: 44px; border: 1px solid #dedbd2; border-radius: 8px; padding: 8px 12px; background: #f4f2ec; color: #191a18; }
/* The bottom safe area belongs to navigation, not an empty strip outside the app. */
[data-renge-layout="shell"] .profiles-page { padding-bottom:calc(16px + var(--renge-safe-bottom)); }
:root.renge-embedded body { height:100%; }
:root.renge-embedded .shell { min-height:100%; }
@media screen and (max-width:720px), screen and (max-width:1100px) and (max-height:550px) and (pointer:coarse) {
 :root[data-renge-layout="shell"] { --renge-bar-height:48px; }
 [data-renge-layout="shell"] .top { gap:8px;padding-left:10px;padding-right:10px; }
 [data-renge-layout="shell"].renge-module-picker #tabs { display:none; }
 [data-renge-layout="shell"] .brand { display:none; }
 [data-renge-layout="shell"] .top { background:#20201f;backdrop-filter:none;-webkit-backdrop-filter:none;filter:none;opacity:1; }
 [data-renge-layout="shell"] .mobile-module-select { display:block;appearance:none;-webkit-appearance:none;flex:1 1 0;min-width:0;max-width:100%;height:40px;border:1px solid #524b3a;border-radius:10px;background:#111315;color:#fff;padding:0 9px;font-size:16px!important;font-weight:650;backdrop-filter:none;-webkit-backdrop-filter:none;filter:none;opacity:1; }
 [data-renge-layout="shell"] .account { flex:0 0 44px;width:44px;height:40px;padding:0;font-size:0; }
 [data-renge-layout="shell"] .account::after { content:'Conta';font-size:11px; }
 [data-renge-layout="shell"] .app-update { height:40px;flex:0 0 auto;font-size:11px;padding:0 8px; }
 [data-renge-layout="gestao"] .modal { max-height:calc(var(--renge-module-height,100dvh) - 16px)!important; }
 [data-renge-layout="finance"] .modal { max-height:calc(var(--renge-module-height,100dvh) - 12px)!important; }
}
@media screen and (max-width:899px), screen and (max-width:1100px) and (max-height:550px) and (pointer:coarse) {
 html[data-renge-layout="hub"], [data-renge-layout="hub"] body { height:100%;min-height:0;overflow:hidden; }
 [data-renge-layout="hub"] body { display:flex;flex-direction:column; }
 [data-renge-layout="hub"] .shell { display:flex;flex-direction:column;flex:1 1 0;height:auto;min-height:0!important;overflow:hidden; }
 [data-renge-layout="hub"] .sidebar { display:none!important; }
 [data-renge-layout="hub"] .main { flex:1 1 0;min-height:0;width:100%;max-width:none;overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;padding:16px 16px 24px!important; }
 :root[data-renge-layout="hub"] { --renge-hub-nav-height:64px; }
 [data-renge-layout="hub"] #bottomNav { position:relative;inset:auto;flex:0 0 calc(64px + var(--renge-safe-bottom));display:flex;width:100%;height:calc(64px + var(--renge-safe-bottom));padding:0 0 var(--renge-safe-bottom);gap:0;overflow-x:auto;overflow-y:hidden;flex-wrap:nowrap; }
 [data-renge-layout="hub"] #bottomNav .navBtn { display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1 0 25%;min-width:0;max-width:none;height:63px;padding:6px 4px;gap:4px;font-size:11px;line-height:1.15; }
 [data-renge-layout="hub"] #bottomNav .navIco { height:20px;line-height:20px;font-size:18px; }
 [data-renge-layout="hub"] #bottomNav .navLabel { min-height:25px;max-width:100%;white-space:normal; }
 [data-renge-layout="hub"] .metrics { gap:10px;margin-top:12px; }
 [data-renge-layout="hub"] .metric { padding:14px;box-shadow:0 4px 14px #191a1805; }
 [data-renge-layout="hub"] h1 { font-size:28px;line-height:1.1; }
 [data-renge-layout="hub"] .syncStatus { bottom:calc(72px + var(--renge-safe-bottom));padding:4px 8px;font-size:10px;pointer-events:none; }
 [data-renge-layout="hub"] .syncStatus[data-kind="ok"] { display:none; }
 [data-renge-layout="hub"] .sheetBox { max-height:calc(var(--renge-module-height,100dvh) - 12px); }
}

@media screen and (max-width:720px), screen and (max-width:1100px) and (max-height:550px) and (pointer:coarse) {
 :root.renge-embedded[data-renge-layout="finance"] .shell { min-height:100%!important; }
}
@media screen and (min-width:951px) and (max-width:1100px) and (max-height:550px) and (pointer:coarse) {
 [data-renge-layout="finance"] .shell { display:block!important; }
 [data-renge-layout="finance"] .main { width:100%!important;margin:0!important;min-width:0; }
 [data-renge-layout="finance"] .sidebar { position:fixed!important;top:auto!important;bottom:0!important;left:0!important;right:0!important;width:100%!important;z-index:120!important;display:block!important;overflow:hidden;border-top:1px solid #292720; }
 [data-renge-layout="finance"] .sidebar > :not(.nav) { display:none!important; }
 [data-renge-layout="finance"] .sidebar .nav { display:flex!important;flex-direction:row;height:76px;overflow-x:auto;overflow-y:hidden;padding:0;gap:0; }
 [data-renge-layout="finance"] .sidebar .nav button { display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;height:76px;padding:7px 4px;border-radius:0;font-size:11px; }
 [data-renge-layout="finance"] .sidebar .nav .nav-sep { display:none; }
}

/* 10.40.37 · iPhone: folga abaixo da barra de status.
   No iOS 26 o sistema desfoca o que fica colado ao topo da tela; descer o cabeçalho evita o desfoque e dá respiro.
   Só vale quando há área segura no topo (aparelhos com notch / Dynamic Island). */
:root { --renge-top-gap: min(var(--renge-safe-top), 14px); }
:root.renge-embedded { --renge-top-gap: 0px; }
[data-renge-layout="shell"] .top {
  height: calc(var(--renge-bar-height) + var(--renge-safe-top) + var(--renge-top-gap));
  padding-top: calc(var(--renge-safe-top) + var(--renge-top-gap));
  padding-bottom: 6px;
  background: #20201f;
}
[data-renge-layout="shell"] .gate {
  padding-top: calc(16px + var(--renge-safe-top) + var(--renge-top-gap));
}
[data-renge-layout="shell"] .accountMenu,
[data-renge-layout="shell"] .update-status {
  top: calc(var(--renge-app-top, 0px) + var(--renge-safe-top) + var(--renge-top-gap) + var(--renge-bar-height) + 8px);
}
