:root {
  --mb-bg: #e4e8e5;
  --mb-surface: #f0f2f0;
  --mb-surface-2: #ffffff;
  --mb-ink: #1c1916;
  --mb-muted: #6f6a62;
  --mb-line: rgba(28, 25, 22, 0.1);
  --mb-line-strong: rgba(28, 25, 22, 0.16);
  --mb-brand: #0d5c4d;
  --mb-brand-2: #094438;
  --mb-accent: #c45c26;
  --mb-ok: #1f7a4c;
  --mb-warn: #a86a00;
  --mb-danger: #b42318;
  --mb-sidebar: #132821;
  --mb-sidebar-text: #d7e6e1;
  --mb-sidebar-muted: #8eaaa2;
  --mb-radius: 12px;
  --mb-shadow: 0 1px 2px rgba(28, 25, 22, 0.04), 0 6px 20px rgba(28, 25, 22, 0.05);
  --mb-shadow-sm: 0 1px 2px rgba(28, 25, 22, 0.05);
  --mb-font: "Segoe UI", "Source Sans 3", system-ui, sans-serif;
  --mb-display: Georgia, "Fraunces", serif;
  --mb-mono: Consolas, "IBM Plex Mono", monospace;
  --sidebar-w: 250px;
  --topbar-h: 64px;
  --mb-checkbox-size: 1.25rem;
  --mb-checkbox-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.2l2.8 2.8 6.2-7' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

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

html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: var(--mb-font);
  color: var(--mb-ink);
  background: var(--mb-bg);
}

a { color: var(--mb-brand); text-decoration: none; }
a:hover { color: var(--mb-brand-2); }

.muted { color: var(--mb-muted); }
.mono { font-family: var(--mb-mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

[hidden] {
  display: none !important;
}

/* —— Login —— */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(13, 92, 77, 0.18), transparent 45%),
    radial-gradient(ellipse at 90% 90%, rgba(196, 92, 38, 0.14), transparent 40%),
    linear-gradient(160deg, #e7e1d5, var(--mb-surface));
}
.login-card {
  width: min(100%, 420px);
  background: var(--mb-surface-2);
  border: 1px solid var(--mb-line);
  border-radius: 16px;
  padding: 2rem 1.6rem;
  box-shadow: var(--mb-shadow);
}
.login-card .brand { font-family: var(--mb-display); font-size: 1.7rem; margin: 0; color: var(--mb-brand); }
.login-card h1 { font-family: var(--mb-display); font-size: 1.35rem; margin: 0.4rem 0 0.2rem; }
.login-card .login-links { margin: 1rem 0 0; text-align: center; font-size: 0.9rem; }
.login-card .login-links a { color: var(--mb-brand); }
.stack { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.2rem; }
.stack label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.92rem; }
.stack input {
  min-height: 44px; border: 1px solid var(--mb-line); border-radius: 8px;
  padding: 0.55rem 0.8rem; font: inherit; background: #fff;
}
.stack input:focus { outline: 2px solid var(--mb-brand); outline-offset: 1px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.55rem 1rem; border-radius: 8px;
  border: 1px solid transparent; font: inherit; cursor: pointer;
}
.btn-primary { background: var(--mb-brand); color: #fff; }
.btn-primary:hover { background: var(--mb-brand-2); }

.alert { padding: 0.7rem 0.85rem; border-radius: 8px; margin: 0 0 1rem; transition: opacity .3s ease, transform .3s ease; }
.alert:empty { display: none; }
.alert.is-dismissing {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}
.alert-danger { background: #f8e4e2; color: var(--mb-danger); border: 1px solid #e8b4ae; }
.alert-ok { background: #e5f3ea; color: var(--mb-ok); border: 1px solid #b7dcc5; }

/* —— App shell (fixed sidebar) —— */
.app-shell {
  position: relative;
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  overflow: hidden;
  background: var(--mb-bg);
}

.app-sidebar {
  height: 100vh;
  background: linear-gradient(180deg, #16352c 0%, var(--mb-sidebar) 55%, #0e1f1a 100%);
  color: var(--mb-sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  max-height: var(--topbar-h);
  padding: 0 1rem;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #1f8f78, #c45c26);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2);
}
.sidebar-brand .brand {
  font-family: var(--mb-display);
  font-size: 1.2rem;
  margin: 0;
  color: #fff;
  line-height: 1.1;
}
.brand-sub { margin: 0.15rem 0 0; font-size: 0.75rem; color: var(--mb-sidebar-muted); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.65rem 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.22);
  border-radius: 99px;
}

.nav-group-label {
  margin: 0.95rem 0.55rem 0.35rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mb-sidebar-muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.62rem 0.7rem;
  margin: 0.12rem 0;
  border-radius: 8px;
  color: var(--mb-sidebar-text);
  font-size: 0.94rem;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.is-active {
  background: rgba(31, 143, 120, 0.28);
  color: #fff;
  box-shadow: inset 3px 0 0 #2bb896;
}
.nav-item.nav-disabled { opacity: 0.38; pointer-events: none; }
.nav-ico { width: 1.1rem; text-align: center; opacity: 0.85; }

.app-main {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--mb-surface);
}

.app-topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  max-height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--mb-surface-2);
  border-bottom: 1px solid var(--mb-line);
  box-sizing: border-box;
  z-index: 4;
}
.topbar-start {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}
.topbar-start .topbar-title {
  flex-shrink: 0;
}
.topbar-end {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}
.btn-icon.sidebar-toggle {
  display: none;
  flex-shrink: 0;
}
.topbar-title {
  font-family: var(--mb-display);
  font-size: 1.15rem;
  margin: 0;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(12, 28, 24, 0.45);
}
.sidebar-backdrop.is-open { display: block; }
@media (min-width: 901px) {
  .btn-icon.sidebar-toggle,
  .sidebar-backdrop,
  .sidebar-backdrop.is-open {
    display: none !important;
  }
}
.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  font-size: 0.84rem;
  padding-right: 0.15rem;
}
.user-chip strong {
  font-size: 0.88rem;
  font-weight: 600;
}
.user-chip .muted {
  font-size: 0.76rem;
}
.inline-form { display: inline; margin: 0; }

.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.1rem 1.35rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.app-content > .alert { margin-bottom: 0; }
.app-content > .page-head { margin-bottom: 0; }
.app-content > .toolbar { margin-bottom: 0; }
.app-content > .kpi-row { margin-top: 0; }
.content-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}
.content-section > h2,
.content-section > .page-title {
  margin: 0;
  font-family: var(--mb-display);
  font-size: 1.12rem;
}

/* —— Scrollbars (consistent with sidebar) —— */
.mb-scroll,
.app-content,
.modal-body,
.table-wrap,
.pos-grid,
.cart-lines,
.typeahead-menu,
.rbac-roles-list,
.rbac-perms-body {
  scrollbar-width: thin;
  scrollbar-color: #b9b1a4 transparent;
}
.mb-scroll::-webkit-scrollbar,
.app-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.pos-grid::-webkit-scrollbar,
.cart-lines::-webkit-scrollbar,
.typeahead-menu::-webkit-scrollbar,
.rbac-roles-list::-webkit-scrollbar,
.rbac-perms-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.mb-scroll::-webkit-scrollbar-thumb,
.app-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.pos-grid::-webkit-scrollbar-thumb,
.cart-lines::-webkit-scrollbar-thumb,
.typeahead-menu::-webkit-scrollbar-thumb,
.rbac-roles-list::-webkit-scrollbar-thumb,
.rbac-perms-body::-webkit-scrollbar-thumb {
  background: #c5beb2;
  border-radius: 99px;
}
.mb-scroll::-webkit-scrollbar-thumb:hover,
.app-content::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.table-wrap::-webkit-scrollbar-thumb:hover,
.pos-grid::-webkit-scrollbar-thumb:hover,
.cart-lines::-webkit-scrollbar-thumb:hover,
.typeahead-menu::-webkit-scrollbar-thumb:hover,
.rbac-roles-list::-webkit-scrollbar-thumb:hover,
.rbac-perms-body::-webkit-scrollbar-thumb:hover {
  background: #a9a195;
}
.mb-scroll::-webkit-scrollbar-track,
.app-content::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track,
.pos-grid::-webkit-scrollbar-track,
.cart-lines::-webkit-scrollbar-track,
.typeahead-menu::-webkit-scrollbar-track,
.rbac-roles-list::-webkit-scrollbar-track,
.rbac-perms-body::-webkit-scrollbar-track {
  background: transparent;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-head > p.muted,
.page-head > .muted {
  margin: 0;
  flex: 1;
  min-width: 12rem;
  font-size: 0.92rem;
  line-height: 1.45;
}
.page-title {
  font-family: var(--mb-display);
  font-size: 1.55rem;
  margin: 0 0 0.25rem;
}
.page-actions { display: flex; gap: 0.45rem; flex-shrink: 0; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid var(--mb-line); background: var(--mb-surface-2);
  color: var(--mb-ink); cursor: pointer; text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.btn-icon:hover { border-color: var(--mb-line-strong); background: var(--mb-surface); color: var(--mb-brand); }
.btn-icon-primary {
  background: var(--mb-brand); border-color: var(--mb-brand); color: #fff;
}
.btn-icon-primary:hover { background: var(--mb-brand-2); color: #fff; }
.btn-icon svg { width: 18px; height: 18px; fill: currentColor; }
.col-actions .btn-icon {
  border: none;
  background: rgba(13, 92, 77, 0.07);
}
.col-actions .btn-icon:hover {
  background: rgba(13, 92, 77, 0.14);
  color: var(--mb-brand);
}

.toolbar {
  display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem;
}
.search-field {
  flex: 1; display: flex; align-items: center; gap: 0.5rem;
  min-height: 40px; padding: 0 0.8rem;
  background: var(--mb-surface-2);
  border: 1px solid var(--mb-line);
  border-radius: 8px;
  transition: border-color 0.15s ease;
}
.search-field:focus-within {
  border-color: var(--mb-line-strong);
}
.search-field input {
  border: 0; outline: 0; background: transparent; width: 100%; font: inherit;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 1rem 0 1.25rem;
}
.kpi-row-dash {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0.75rem 0 1.35rem;
}
.dash-intro { margin: 0 0 0.35rem; }
.kpi, .panel {
  background: var(--mb-surface-2);
  border: none;
  border-radius: var(--mb-radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--mb-shadow-sm);
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--mb-display);
  font-size: 1.1rem;
}
.panel h2 { font-family: var(--mb-display); font-size: 1.1rem; margin: 0 0 0.5rem; }
.kpi {
  position: relative;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--mb-line);
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(26, 24, 20, 0.08);
}
.kpi-money::before { background: var(--mb-brand); }
.kpi-brand::before { background: #2a7a68; }
.kpi-accent::before { background: var(--mb-accent); }
.kpi-warn {
  border-color: #e6c98a;
  background: linear-gradient(180deg, #fffdf8, #fff8ea);
}
.kpi-warn::before { background: var(--mb-warn); }
.kpi-danger {
  border-color: #e8b4ae;
  background: linear-gradient(180deg, #fffafa, #fdf1ef);
}
.kpi-danger::before { background: var(--mb-danger); }
.kpi-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.kpi-ico {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: inline-grid; place-items: center;
  background: var(--mb-surface);
  color: var(--mb-brand);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.kpi-money .kpi-ico { background: #e7f3ef; color: var(--mb-brand); }
.kpi-accent .kpi-ico { background: #f8ebe3; color: var(--mb-accent); }
.kpi-warn .kpi-ico { background: #fff1d6; color: var(--mb-warn); }
.kpi-danger .kpi-ico { background: #f8e4e2; color: var(--mb-danger); }
.kpi-label { margin: 0; color: var(--mb-muted); font-size: 0.84rem; }
.kpi-value {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.kpi-currency {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--mb-muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}
.kpi-hint { margin: 0.35rem 0 0; font-size: 0.78rem; }
.chart-placeholder { min-height: 180px; }

.dash-charts {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.dash-bottom {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.chart-panel { min-width: 0; }
.chart-frame {
  position: relative;
  height: 240px;
  margin-top: 0.35rem;
}
.chart-frame-donut { height: 250px; }
.chart-frame canvas { width: 100% !important; height: 100% !important; }

.table-wrap {
  background: var(--mb-surface-2);
  border: none;
  border-radius: var(--mb-radius);
  overflow: auto;
  box-shadow: var(--mb-shadow-sm);
  max-width: 100%;
  min-width: 0;
}
.table-wrap > .empty-state {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--mb-muted);
  font-size: 0.92rem;
}
.table-enhanced {
  overflow: auto;
}
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--mb-line);
  background: var(--mb-surface-2);
  flex-shrink: 0;
}
.table-toolbar .table-search {
  flex: 1;
  min-width: 180px;
  margin: 0;
  min-height: 38px;
  padding: 0 0.75rem;
  background: var(--mb-surface);
  border: 1px solid transparent;
  border-radius: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.table-toolbar .table-search:focus-within {
  background: var(--mb-surface-2);
  border-color: var(--mb-line-strong);
}
.table-toolbar .table-search input {
  font-size: 0.9rem;
}
.table-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
  padding: 0 0.7rem;
  border: 1px solid var(--mb-line);
  border-radius: 8px;
  background: var(--mb-surface-2);
  color: var(--mb-muted);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-export:hover {
  border-color: var(--mb-line-strong);
  color: var(--mb-ink);
}
.btn-export:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-export svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex-shrink: 0;
}
.table-meta { margin: 0; font-size: 0.82rem; color: var(--mb-muted); }
.table-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--mb-line);
  background: var(--mb-surface-2);
  flex-shrink: 0;
}
.table-page-label { font-size: 0.84rem; min-width: 5.5rem; text-align: center; color: var(--mb-muted); }
.table-pager .btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}
.data-table th,
.data-table td {
  padding: 0.78rem 1rem;
  text-align: left;
  vertical-align: middle;
}
.data-table thead th {
  background: var(--mb-surface);
  color: var(--mb-muted);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--mb-line);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.data-table tbody td {
  border-bottom: 1px solid var(--mb-line);
  color: var(--mb-ink);
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}
.data-table tbody tr {
  transition: background-color 0.12s ease;
  background: var(--mb-surface-2);
}
.data-table tbody tr:hover {
  background: rgba(13, 92, 77, 0.03);
}
.data-table td.mono,
.data-table td.num-right {
  font-variant-numeric: tabular-nums;
}
.col-actions {
  width: 52px;
  text-align: right;
  padding-right: 0.85rem !important;
}
.col-actions .btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border-color: transparent;
  background: transparent;
}
.col-actions .btn-icon:hover {
  background: var(--mb-surface);
  border-color: var(--mb-line);
}

/* Mobile: stacked “column” cards */
@media (max-width: 760px) {
  .table-wrap,
  .table-enhanced {
    overflow: hidden;
    max-width: 100%;
  }
  .table-enhanced .data-table thead { display: none; }
  .table-enhanced .data-table,
  .table-enhanced .data-table tbody {
    display: block;
    width: 100%;
    max-width: 100%;
  }
  .table-enhanced .data-table tbody {
    padding: 0.65rem;
    box-sizing: border-box;
  }
  .table-enhanced .data-table tr {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 0.65rem;
    padding: 0;
    border: 1px solid var(--mb-line);
    border-radius: var(--mb-radius);
    background: var(--mb-surface-2);
    box-shadow: var(--mb-shadow-sm);
    box-sizing: border-box;
  }
  .table-enhanced .data-table tr:last-child {
    margin-bottom: 0;
  }
  .table-enhanced .data-table td {
    display: grid;
    grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
    gap: 0.65rem;
    align-items: start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border-bottom: 1px solid var(--mb-line);
    padding: 0.55rem 0.75rem;
    text-align: right;
    word-break: break-word;
  }
  .table-enhanced .data-table td:last-child { border-bottom: 0; }
  .table-enhanced .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--mb-muted);
    text-align: left;
    min-width: 0;
    justify-self: start;
  }
  .table-enhanced .data-table td > * {
    justify-self: end;
    width: max-content;
    max-width: 100%;
  }
  .table-enhanced .data-table td.col-actions {
    grid-template-columns: minmax(0, 40%) auto;
    justify-items: end;
  }
  .table-enhanced .data-table td.col-actions::before { content: "Acções"; }
  .table-enhanced .data-table td.num-right { text-align: right; }

  .table-toolbar {
    padding: 0.65rem 0.75rem;
  }
  .table-toolbar .table-search {
    flex: 1 1 100%;
    min-width: 0;
  }
  .table-toolbar-actions {
    flex: 1 1 100%;
    justify-content: space-between;
    min-width: 0;
  }
  .table-pager {
    padding: 0.55rem 0.75rem;
  }
}
.thumb {
  width: 42px; height: 42px; border-radius: 8px; object-fit: cover;
  background: #efe9df; border: 1px solid var(--mb-line);
}
.thumb-placeholder {
  width: 42px; height: 42px; border-radius: 8px;
  background: linear-gradient(135deg, #e8e1d4, #d9d1c2);
  display: inline-grid; place-items: center; color: var(--mb-muted); font-size: 0.75rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-ok { background: rgba(31, 122, 76, 0.1); color: var(--mb-ok); }
.badge-warn { background: rgba(168, 106, 0, 0.1); color: var(--mb-warn); }
.badge-danger { background: rgba(180, 35, 24, 0.1); color: var(--mb-danger); }
.badge-muted { background: rgba(28, 25, 22, 0.06); color: var(--mb-muted); }
.empty-state { padding: 2rem; text-align: center; color: var(--mb-muted); font-size: 0.92rem; }

/* —— Modal —— */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 18, 14, 0.45);
  display: none; align-items: center; justify-content: center;
  padding: 1rem; z-index: 80;
}
.modal-backdrop.is-open { display: flex; }
.modal-backdrop.is-locked { background: rgba(20, 18, 14, 0.62); }
.modal-backdrop.is-locked .modal { box-shadow: 0 28px 70px rgba(0, 0, 0, 0.35); }
.modal {
  width: min(100%, 720px);
  max-height: min(92vh, 900px);
  overflow: hidden;
  background: var(--mb-surface-2);
  border-radius: 16px;
  border: 1px solid var(--mb-line);
  box-shadow: 0 24px 60px rgba(0,0,0,0.22);
  display: flex;
  flex-direction: column;
}
.modal-sm { width: min(100%, 480px); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--mb-line);
  position: sticky; top: 0; background: var(--mb-surface-2); z-index: 1;
  flex-shrink: 0;
}
.modal-head h2 { margin: 0; font-family: var(--mb-display); font-size: 1.2rem; }
.modal-body {
  padding: 1.1rem 1.15rem 1.3rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

@media (max-width: 768px) {
  .modal-backdrop {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }
  /* Higher specificity than per-modal widths (.modal-payment, .modal-receipt, …) defined later */
  .modal-backdrop > .modal {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }
  .modal-head {
    padding: 0.9rem 1rem;
  }
  .modal-body {
    padding: 1rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem;
}
.form-grid label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  min-height: 40px; padding: 0.5rem 0.7rem; border: 1px solid var(--mb-line);
  border-radius: 8px; background: #fff; font: inherit; width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.pos-cart label input:focus,
.filters-bar input:focus,
.filters-bar select:focus,
.toolbar .search-field:focus-within {
  border-color: var(--mb-brand);
  box-shadow: 0 0 0 2px rgba(13, 92, 77, 0.12);
  outline: none;
}
.form-grid select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.25rem;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%216a645a' d='M1.4.6L6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 8px;
}
.form-grid textarea { min-height: 72px; resize: vertical; }
.form-grid input[type="checkbox"],
.form-grid input[type="radio"] {
  width: var(--mb-checkbox-size);
  min-width: var(--mb-checkbox-size);
  min-height: var(--mb-checkbox-size);
  padding: 0;
  flex: 0 0 var(--mb-checkbox-size);
}
.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-start !important;
  gap: 0.6rem !important;
  width: auto;
  max-width: 100%;
  align-self: start;
  cursor: pointer;
  user-select: none;
  line-height: 1.35;
  font-size: 0.92rem;
}
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* —— Checkboxes —— */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: var(--mb-checkbox-size);
  height: var(--mb-checkbox-size);
  min-width: var(--mb-checkbox-size);
  min-height: var(--mb-checkbox-size);
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  border: 2px solid #b0a89c;
  border-radius: 5px;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0 0;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, background-size 0.1s;
}
input[type="checkbox"]:hover:not(:disabled) { border-color: var(--mb-brand); }
input[type="checkbox"]:checked {
  background-color: var(--mb-brand);
  border-color: var(--mb-brand);
  background-image: var(--mb-checkbox-check);
  background-size: 13px 13px;
}
input[type="checkbox"]:focus-visible {
  outline: 2px solid rgba(13, 92, 77, 0.35);
  outline-offset: 2px;
}
input[type="checkbox"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
input[type="checkbox"]:indeterminate {
  background-color: var(--mb-brand);
  border-color: var(--mb-brand);
  background-image: none;
}
input[type="checkbox"]:indeterminate::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  background: #fff;
  border: 0;
  border-radius: 1px;
  transform: translate(-50%, -50%);
}

/* —— Custom file / image picker —— */
.image-picker {
  position: relative;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.9rem;
  align-items: stretch;
}
.image-picker-preview {
  width: 120px; height: 120px; border-radius: 14px;
  border: 1px dashed var(--mb-line);
  background:
    linear-gradient(135deg, rgba(13,92,77,0.08), rgba(196,92,38,0.08)),
    var(--mb-surface);
  display: grid; place-items: center; overflow: hidden; position: relative;
}
.image-picker-preview img {
  width: 100%; height: 100%; object-fit: cover; display: none;
}
.image-picker-preview.has-image img { display: block; }
.image-picker-preview.has-image .image-picker-fallback { display: none; }
.image-picker-fallback { text-align: center; color: var(--mb-muted); font-size: 0.78rem; padding: 0.5rem; }
.image-picker-drop {
  border: 1px dashed #b7cfc7;
  border-radius: 14px;
  background: #f4faf8;
  padding: 0.9rem 1rem;
  display: flex; flex-direction: column; justify-content: center; gap: 0.35rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.image-picker-drop:hover, .image-picker-drop.is-dragover {
  border-color: var(--mb-brand); background: #eaf6f2;
}
.image-picker-drop strong { color: var(--mb-brand); font-size: 0.95rem; }
.image-picker-drop span { color: var(--mb-muted); font-size: 0.82rem; }
.image-picker input[type="file"] {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

/* —— POS / Vendas —— */
.pos-page .app-content {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  overflow: hidden;
}
/* Modo normal: scroll na página, POS com altura confortável */
body.pos-page:not(.pos-focus) .app-content {
  overflow-y: auto;
  overflow-x: hidden;
}
body.pos-page:not(.pos-focus) .pos-layout {
  flex: 0 0 auto;
  min-height: min(500px, 62vh);
  overflow: visible;
}
body.pos-page:not(.pos-focus) .pos-catalog,
body.pos-page:not(.pos-focus) .pos-cart {
  height: auto;
  min-height: 440px;
  max-height: min(56vh, 540px);
}
body.pos-page:not(.pos-focus) .pos-recent {
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
}
body.pos-page:not(.pos-focus) .pos-recent .table-wrap {
  overflow: visible;
}
.pos-page .pos-layout {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.pos-page .pos-catalog,
.pos-page .pos-cart {
  height: 100%;
  min-height: 0;
  max-height: none;
}
.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
  gap: 0.85rem;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}
.pos-catalog {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  overflow: hidden;
}
.pos-catalog .toolbar { margin: 0; flex-shrink: 0; }
.pos-search-field {
  width: 100%;
  flex: 0 0 auto;
}
.pos-search-field.is-scan-ok {
  animation: pos-scan-flash-ok 0.35s ease;
}
.pos-search-field.is-scan-error {
  animation: pos-scan-flash-error 0.35s ease;
}
@keyframes pos-scan-flash-ok {
  0% { box-shadow: 0 0 0 0 rgba(13, 92, 77, 0.45); border-color: var(--mb-brand); }
  100% { box-shadow: 0 0 0 8px rgba(13, 92, 77, 0); }
}
@keyframes pos-scan-flash-error {
  0% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.4); border-color: var(--mb-danger); }
  100% { box-shadow: 0 0 0 8px rgba(180, 35, 24, 0); }
}
.pos-catalog .search-field,
.pos-catalog .pos-search-field {
  flex: 0 0 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  padding: 0.3rem 0.65rem;
  background: var(--mb-surface);
  border-color: var(--mb-line);
}
.pos-catalog .search-field input {
  min-height: 0;
  height: 1.35rem;
  line-height: 1.35;
  padding: 0;
  font-size: 0.9rem;
}
.pos-catalog .search-field:focus-within {
  border-color: var(--mb-brand);
  box-shadow: 0 0 0 2px rgba(13, 92, 77, 0.15);
}
.pos-catalog-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  position: relative;
}
.pos-catalog > .empty-state,
.pos-catalog-body > .empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  border: none;
  border-radius: 12px;
  background: rgba(13, 92, 77, 0.04);
}
.pos-catalog-body > .empty-state {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: auto;
  gap: 0.7rem;
  align-content: start;
  padding: 0.35rem 0.3rem 0.5rem 0.35rem;
}
.pos-product {
  text-align: left;
  border: none;
  background: var(--mb-surface);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font: inherit;
  color: inherit;
  min-height: 0;
  height: auto;
  width: 100%;
  box-sizing: border-box;
  transition: background .15s, transform .12s, box-shadow .15s;
  box-shadow: var(--mb-shadow-sm);
}
.pos-product.is-filtered {
  display: none !important;
}
.pos-product:hover {
  background: #eef7f3;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(13, 92, 77, 0.1);
}
.pos-product:focus-visible {
  outline: 2px solid var(--mb-brand);
  outline-offset: 2px;
}
.pos-product-name {
  font-size: 0.92rem;
  line-height: 1.25;
  font-weight: 600;
  display: block;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.pos-product .muted {
  font-size: 0.76rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.pos-product em {
  font-style: normal;
  font-weight: 700;
  color: var(--mb-brand);
  margin-top: auto;
  font-variant-numeric: tabular-nums;
}

.pos-cart {
  position: relative;
  top: auto;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: var(--mb-surface-2);
  overflow: hidden;
}
.pos-catalog h2,
.pos-cart h2 {
  margin: 0;
  font-family: var(--mb-display);
  font-size: 1.2rem;
  flex-shrink: 0;
}
#sale-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
  min-height: 0;
}
.pos-cart .cart-lines {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 80px;
  max-height: none;
  overflow-y: auto;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0.15rem 0.1rem;
}
.pos-cart .empty-state {
  padding: 1.25rem 0.85rem;
  border: none;
  border-radius: 12px;
  background: rgba(13, 92, 77, 0.04);
  margin: 0;
  text-align: center;
  color: var(--mb-muted);
  font-size: 0.9rem;
}
.cart-line {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.8rem;
  border: none;
  border-radius: 12px;
  background: var(--mb-surface);
  box-shadow: var(--mb-shadow-sm);
}
.cart-line-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.cart-line-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1; }
.cart-line-info strong { font-size: 0.92rem; line-height: 1.3; }
.cart-line-info .muted { font-size: 0.78rem; }
.cart-line-qty {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.cart-line-qty button {
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: rgba(13, 92, 77, 0.08);
  cursor: pointer; font: inherit; color: var(--mb-ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.cart-line-qty button:hover { background: rgba(13, 92, 77, 0.15); color: var(--mb-brand); }
.cart-line-qty button svg { width: 16px; height: 16px; fill: currentColor; }
.cart-line-qty input {
  width: 3.6rem; text-align: center; border: 1px solid var(--mb-line);
  border-radius: 8px; padding: 0.3rem; font: inherit; min-height: 32px;
  background: #fff;
}
.cart-remove { color: var(--mb-danger) !important; background: rgba(180, 35, 24, 0.08) !important; }
.cart-remove:hover { background: rgba(180, 35, 24, 0.15) !important; color: var(--mb-danger) !important; }
.cart-line-sum {
  font-weight: 700;
  min-width: 4.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--mb-brand);
  font-size: 1rem;
  flex-shrink: 0;
  padding-top: 0.1rem;
}
.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.7rem 0.9rem;
  margin: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #e8f4f0, var(--mb-surface));
  border: none;
  font-size: 1rem;
  flex-shrink: 0;
}
.cart-total strong {
  font-size: 1.4rem;
  color: var(--mb-brand);
  font-variant-numeric: tabular-nums;
}
.pos-cart label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--mb-muted);
}
.pos-cart label input {
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--mb-line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--mb-ink);
}
.pos-cart label input:focus {
  outline: 2px solid var(--mb-brand);
  outline-offset: 1px;
}
.btn-confirm {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--mb-brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(13, 92, 77, 0.22);
  margin-top: auto;
}
.btn-confirm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}
#sale-form .btn-confirm {
  flex-shrink: 0;
  margin-top: 0.2rem;
}
.btn-confirm:not(:disabled):hover { background: var(--mb-brand-2); }

/* —— Contas abertas (POS) —— */
.pos-tabs.panel {
  flex: 0 0 auto;
  padding: 0.7rem 0.9rem;
}
.pos-tabs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.pos-tabs-head h2 {
  margin: 0;
  font-family: var(--mb-display);
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.pos-tabs-count {
  min-width: 1.6rem;
  padding: 0.05rem 0.45rem;
  border-radius: 99px;
  background: #eef7f3;
  color: var(--mb-brand);
  font: 600 0.8rem var(--mb-font);
  text-align: center;
}
.pos-tabs-new,
.cart-tab-actions .btn,
.cart-open-tab {
  min-height: 38px;
  padding: 0.4rem 0.85rem;
  border: 1px solid #c5ddd5;
  background: #fff;
  color: var(--mb-brand);
  font-weight: 600;
  border-radius: 10px;
}
.pos-tabs-new:hover,
.cart-tab-actions .btn:hover,
.cart-open-tab:not(:disabled):hover { background: #eef7f3; }
.cart-open-tab:disabled,
.pos-tabs-new:disabled { opacity: 0.45; cursor: not-allowed; }
.pos-tabs-list {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.6rem 0 0.15rem;
  scrollbar-width: thin;
}
.pos-tabs-list:empty { display: none; }
.pos-tabs-empty { margin: 0.45rem 0 0; font-size: 0.88rem; }
.pos-tab-chip {
  flex: 0 0 auto;
  display: grid;
  gap: 0.1rem;
  min-width: 150px;
  max-width: 220px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--mb-line-strong);
  border-radius: 12px;
  background: var(--mb-surface);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.pos-tab-chip:hover { border-color: var(--mb-brand); }
.pos-tab-chip.is-active {
  border-color: var(--mb-brand);
  background: #eef7f3;
  box-shadow: inset 0 0 0 1px rgba(13, 92, 77, 0.2);
}
.pos-tab-code { font: 700 0.95rem var(--mb-mono); color: var(--mb-brand); }
.pos-tab-label {
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pos-tab-meta { font-size: 0.78rem; color: var(--mb-muted); }
.pos-tab-meta strong { color: var(--mb-ink); font-variant-numeric: tabular-nums; }

.cart-tab-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #c5ddd5;
  border-radius: 12px;
  background: #eef7f3;
  flex-shrink: 0;
}
.cart-tab-bar[hidden] { display: none; }
.cart-tab-info {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}
.cart-tab-info strong { font: 700 1rem var(--mb-mono); color: var(--mb-brand); }
.cart-tab-label {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  color: var(--mb-ink);
  text-decoration: underline dotted;
  cursor: pointer;
}
.cart-tab-status { font-size: 0.78rem; color: var(--mb-muted); }
.cart-tab-status[data-kind="ok"] { color: var(--mb-ok); }
.cart-tab-status[data-kind="error"] { color: var(--mb-danger); font-weight: 600; }
.cart-tab-actions { display: flex; gap: 0.4rem; }
.cart-tab-actions .cart-tab-cancel { color: var(--mb-danger); border-color: #e8b4ae; }
.cart-tab-actions .cart-tab-cancel:hover { background: #f8e4e2; }
.cart-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  flex-shrink: 0;
  margin-top: 0.2rem;
}
.cart-buttons .cart-open-tab { min-height: 48px; border-radius: 12px; flex: 0 0 auto; }
.cart-buttons .btn-confirm { flex: 1; margin-top: 0 !important; }

.pos-recent {
  margin-top: 0;
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 0;
}
.pos-recent.panel {
  padding: 0.85rem 1rem 0.65rem;
}
.pos-recent .table-wrap {
  border: 0;
  box-shadow: none;
  background: transparent;
  border-radius: 8px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  max-height: none;
}
.pos-recent .data-table thead th {
  position: static;
  top: auto;
}
.pos-recent h2 {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
}

/* —— Relatórios —— */
.report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1.1rem;
}
.report-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--mb-line);
  background: var(--mb-surface-2);
  color: var(--mb-ink);
  font-size: 0.9rem;
}
.report-tabs a:hover { border-color: var(--mb-brand); color: var(--mb-brand); }
.report-tabs a.is-active {
  background: var(--mb-brand);
  border-color: var(--mb-brand);
  color: #fff;
}
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  align-items: flex-end;
  margin-bottom: 0;
  padding: 0.5rem 0.7rem;
  background: var(--mb-surface-2);
  border: none;
  border-radius: var(--mb-radius);
  box-shadow: var(--mb-shadow-sm);
  flex-shrink: 0;
}
.filters-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--mb-muted);
  min-width: 0;
  flex: 1 1 108px;
}
.filters-bar input,
.filters-bar select {
  min-height: 34px;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--mb-line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 0.88rem;
  color: var(--mb-ink);
  width: 100%;
}
.filters-bar .btn {
  min-height: 34px;
  padding: 0.35rem 0.9rem;
  background: var(--mb-brand);
  color: #fff;
  border-color: var(--mb-brand);
  flex: 0 0 auto;
}

/* —— Relatórios: filtros compactos + tabela com scroll —— */
.reports-page .app-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  overflow: hidden;
}
.reports-page .report-tabs {
  flex-shrink: 0;
  margin-bottom: 0;
}
.reports-page .filters-bar {
  padding: 0.4rem 0.65rem;
  gap: 0.4rem 0.55rem;
}
.reports-page .filters-bar label {
  flex: 1 1 96px;
  font-size: 0.74rem;
}
.reports-page .summary-row {
  flex-shrink: 0;
  margin-bottom: 0;
  gap: 0.55rem;
}
.reports-page .summary-row .kpi {
  padding: 0.55rem 0.7rem;
}
.reports-page .summary-row .kpi-label {
  font-size: 0.76rem;
  margin-bottom: 0.1rem;
}
.reports-page .summary-row .kpi-value {
  font-size: 1.05rem;
}
.reports-page .table-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}
.summary-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.summary-row .kpi { padding: 0.85rem 0.95rem; }
.num-right { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .btn-icon.sidebar-toggle { display: inline-flex; }
  .app-sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; width: min(86vw, 280px);
    transform: translateX(-105%); transition: transform .2s ease;
  }
  .app-sidebar.is-open { transform: translateX(0); }
  body.sidebar-open { overflow: hidden; }
  .kpi-row, .form-grid, .image-picker, .summary-row { grid-template-columns: 1fr 1fr; }
  .pos-layout { grid-template-columns: 1fr; }
  .pos-page .pos-layout {
    flex: 1 1 0;
    min-height: 0;
  }
  .pos-catalog,
  .pos-cart { height: auto; min-height: 0; }
  .pos-catalog-body {
    min-height: 180px;
    max-height: none;
  }
  .pos-catalog-body > .empty-state { flex: none; min-height: 8rem; }
  .pos-cart { position: static; }
  .btn-confirm { margin-top: 0; }
  .dash-charts, .dash-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .app-content {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
  .kpi-row, .summary-row, .image-picker { grid-template-columns: 1fr; }
  .kpi-row-dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* —— Loadings —— */
.spinner {
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid rgba(13, 92, 77, 0.2);
  border-top-color: var(--mb-brand);
  border-radius: 50%;
  display: inline-block;
  animation: mb-spin 0.7s linear infinite;
}
@keyframes mb-spin { to { transform: rotate(360deg); } }

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(250, 247, 241, 0.72);
  backdrop-filter: blur(4px);
}
.page-loader.is-visible { display: flex; }
.page-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: var(--mb-surface-2);
  border: 1px solid var(--mb-line);
  border-radius: 14px;
  box-shadow: var(--mb-shadow);
  min-width: 160px;
}
.page-loader-card p { margin: 0; color: var(--mb-muted); font-size: 0.92rem; }
.page-loader .spinner {
  width: 1.6rem;
  height: 1.6rem;
  border-width: 3px;
}

button.is-loading,
.btn.is-loading,
.btn-icon.is-loading,
.btn-confirm.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
button.is-loading::after,
.btn.is-loading::after,
.btn-icon.is-loading::after,
.btn-confirm.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.05rem;
  height: 1.05rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mb-spin 0.7s linear infinite;
}
.btn-icon.is-loading::after {
  border-color: rgba(13, 92, 77, 0.2);
  border-top-color: var(--mb-brand);
}

/* —— Definições —— */
.settings-stack {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.settings-panel[hidden] {
  display: none !important;
}
.settings-panel.is-active {
  display: block;
}
.settings-save-row {
  margin-top: 1.1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--mb-line);
}
.btn-icon-on-brand {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}
.btn-icon-on-brand:hover {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
  border-color: #fff;
}
.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.field-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--mb-muted);
  font-weight: 400;
}
.user-resend-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--mb-line);
}
.user-resend-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
}
.btn-block {
  width: 100%;
  justify-content: center;
}

/* —— RBAC / Funções —— */
.rbac-section {
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}
.rbac-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1rem;
  align-items: stretch;
}
.rbac-roles.panel,
.rbac-perms.panel {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 520px;
  height: 100%;
}
.rbac-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--mb-brand);
  color: #fff;
}
.rbac-panel-head h2 {
  margin: 0;
  color: #fff;
  font-size: 1.05rem;
}
.rbac-slug {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.75);
}
.rbac-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.btn-ghost {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #fff;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 0.75rem;
  cursor: pointer;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn-accent {
  border: 0;
  background: #e6b422;
  color: #1a1814;
  font-weight: 600;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 0.9rem;
  cursor: pointer;
}
.btn-accent:hover { filter: brightness(0.96); }
.btn-accent:disabled { opacity: 0.55; cursor: not-allowed; }
.rbac-roles-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem;
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.rbac-role-card {
  text-align: left;
  border: 1px solid var(--mb-line);
  background: var(--mb-surface-2);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  display: grid;
  gap: 0.2rem;
}
.rbac-role-card:hover { border-color: var(--mb-brand); }
.rbac-role-card.is-active {
  border-color: var(--mb-brand);
  box-shadow: inset 3px 0 0 var(--mb-brand);
  background: #f3faf7;
}
.rbac-role-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.rbac-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #ece7df;
  color: #4a453c;
}
.rbac-badge-accent {
  background: #d9f0e8;
  color: var(--mb-brand);
}
.rbac-code {
  display: block;
  font-family: var(--mb-mono);
  font-size: 0.78rem;
  color: var(--mb-danger);
}
.rbac-meta {
  font-size: 0.8rem;
  color: var(--mb-muted);
}
.rbac-perms-body {
  padding: 0.9rem 1rem 1.1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rbac-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.85rem;
}
.rbac-search { flex: 1 1 220px; }
.rbac-select-all { margin: 0; white-space: nowrap; }
.rbac-note {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  background: #e8f4f0;
  color: var(--mb-brand-2);
  font-size: 0.9rem;
}
.rbac-perm-tree {
  display: grid;
  gap: 1rem;
  flex: 1;
  overflow: auto;
  padding-right: 0.25rem;
  min-height: 0;
}
#sec-utilizadores {
  margin-top: 1.5rem;
}
.users-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.users-head h2 { margin: 0; }
.rbac-section-title {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--mb-muted);
}
.rbac-group {
  border: 1px solid var(--mb-line);
  border-radius: 10px;
  margin-bottom: 0.55rem;
  overflow: hidden;
  background: var(--mb-surface);
}
.rbac-group-head {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  padding: 0.65rem 0.8rem;
  background: var(--mb-surface-2);
  font-weight: 600;
  margin: 0;
  cursor: pointer;
}
.rbac-group-body {
  display: grid;
  gap: 0.15rem;
  padding: 0.35rem 0.55rem 0.55rem 1.6rem;
}
.rbac-perm-item {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0.35rem;
  border-radius: 8px;
  margin: 0;
  cursor: pointer;
}
.rbac-perm-item:hover { background: rgba(13, 92, 77, 0.06); }
.rbac-perm-item strong {
  display: block;
  font-size: 0.92rem;
}
.rbac-perm-item .rbac-code { margin-top: 0.1rem; }

@media (max-width: 900px) {
  .rbac-layout { grid-template-columns: 1fr; }
  .rbac-roles.panel,
  .rbac-perms.panel { min-height: 0; height: auto; }
}

/* —— Typeahead / pesquisa —— */
.typeahead {
  position: relative;
  width: 100%;
}
.typeahead-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 42px;
  padding: 0 0.55rem 0 0.75rem;
  border: 1px solid var(--mb-line);
  border-radius: 10px;
  background: #fff;
}
.typeahead-field:focus-within {
  border-color: var(--mb-brand);
  box-shadow: 0 0 0 3px rgba(13, 92, 77, 0.12);
}
.typeahead-input {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  min-height: 38px !important;
  padding: 0.35rem 0 !important;
  width: 100%;
  font: inherit;
}
.typeahead-clear {
  border: 0;
  background: transparent;
  color: var(--mb-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}
.typeahead-clear:hover { color: var(--mb-ink); background: #f0ebe3; }
.typeahead-menu {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--mb-surface-2);
  border: 1px solid var(--mb-line);
  border-radius: 10px;
  box-shadow: var(--mb-shadow);
  max-height: 260px;
  overflow: auto;
  padding: 0.35rem;
}
.typeahead-option {
  display: grid;
  gap: 0.1rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.typeahead-option:hover,
.typeahead-option.is-active { background: #eef7f3; }
.typeahead-option strong { font-size: 0.92rem; }
.typeahead-meta {
  font-size: 0.78rem;
  color: var(--mb-muted);
}
.typeahead-empty {
  padding: 0.7rem 0.75rem;
  color: var(--mb-muted);
  font-size: 0.88rem;
}
.modal-sm .modal-body { padding-bottom: 1rem; }

/* —— Flatpickr (brand) —— */
.flatpickr-calendar {
  border-radius: 12px !important;
  border: 1px solid var(--mb-line) !important;
  box-shadow: var(--mb-shadow) !important;
  font-family: var(--mb-font) !important;
}
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--mb-brand) !important;
  border-color: var(--mb-brand) !important;
}
.flatpickr-day:hover {
  background: #e8f4f0 !important;
}
.js-flatpickr {
  min-height: 40px;
}

/* —— POS focus / fullsize —— */
body.pos-focus.app-shell {
  grid-template-columns: 1fr !important;
}
body.pos-focus .app-sidebar,
body.pos-focus #sidebar {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}
body.pos-focus .app-main {
  width: 100%;
  max-width: 100%;
}
body.pos-focus .app-content {
  padding: 0.65rem 0.85rem 0.85rem;
  overflow: hidden;
}
body.pos-focus .pos-page .app-content {
  overflow: hidden;
}
body.pos-focus .pos-page .pos-layout {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}
body.pos-focus .pos-page .pos-catalog,
body.pos-focus .pos-page .pos-cart {
  min-height: 0;
  max-height: none;
  height: 100%;
}
body.pos-focus .pos-recent {
  display: none !important;
}
body.pos-focus .pos-layout {
  min-height: 0;
  gap: 0.75rem;
}
body.pos-focus .pos-grid {
  gap: 0.75rem;
  padding: 0.4rem 0.35rem 0.55rem;
}
body.pos-focus .pos-catalog,
body.pos-focus .pos-cart {
  min-height: 0;
}
body.pos-focus .user-chip span {
  display: none;
}
#pos-focus-toggle .pos-focus-exit { display: none; }
#pos-focus-toggle[aria-pressed="true"] .pos-focus-enter { display: none; }
#pos-focus-toggle[aria-pressed="true"] .pos-focus-exit { display: block; }

.pos-cash-strip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: #fff4e8;
  border: 1px solid #e8c9a8;
  color: #8a4b12;
  font-size: 0.82rem;
  white-space: nowrap;
}
.pos-cash-strip.is-open {
  background: #e8f4f0;
  border-color: #c5ddd5;
  color: #0d5c4d;
}
.pos-cash-strip.is-open .pos-cash-dot {
  background: #0d5c4d;
}
.pos-cash-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c45c26;
  flex-shrink: 0;
}
.pos-cash-strip a {
  color: var(--mb-brand);
  font-weight: 600;
  text-decoration: none;
}
.pos-cash-strip a:hover { text-decoration: underline; }

/* —— Payment modal —— */
.modal-payment .modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.payment-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0;
  font-size: 0.88rem;
  color: var(--mb-muted);
}
.payment-field input[type="text"] {
  min-height: 40px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--mb-line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--mb-ink);
}
.payment-field .typeahead-field {
  min-height: 40px;
}
/* Inside the scrollable payment modal the menu must push content down, not overlay/clip it */
.modal-payment .typeahead-menu {
  position: static;
  margin-top: 4px;
  max-height: 168px;
  box-shadow: none;
}
.modal-payment {
  width: min(96vw, 540px);
}
.modal-receipt {
  width: min(96vw, 440px);
}
.modal-receipt .modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.receipt-frame {
  width: 100%;
  height: min(62vh, 560px);
  border: 1px solid var(--mb-line);
  border-radius: 10px;
  background: #f2efe9;
}
.receipt-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
}
.receipt-actions .btn { white-space: nowrap; }
.receipt-actions .btn-confirm { flex: 1; }
.payment-extra {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-top: 0.15rem;
  border-top: 1px solid rgba(13, 92, 77, 0.1);
}
.payment-total-box {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, #e8f4f0, var(--mb-surface));
  border: none;
}
.payment-total-box span { color: var(--mb-muted); font-size: 0.9rem; }
.payment-total-box strong {
  font-size: 1.45rem;
  color: var(--mb-brand);
  font-variant-numeric: tabular-nums;
}
.payment-methods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}
@media (max-width: 360px) {
  .payment-methods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.payment-method-btn {
  min-height: 42px;
  border: 1px solid var(--mb-line);
  border-radius: 10px;
  background: var(--mb-surface);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.payment-method-btn:hover {
  border-color: var(--mb-brand);
  color: var(--mb-brand);
}
.payment-method-btn.is-active {
  background: #eef7f3;
  border-color: var(--mb-brand);
  color: var(--mb-brand);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(13, 92, 77, 0.15);
}
.payment-cash-panel {
  display: grid;
  gap: 0.55rem;
}
.payment-cash-panel label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--mb-muted);
}
.payment-cash-panel input {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--mb-line);
  border-radius: 10px;
  font: inherit;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
.payment-change-box {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: var(--mb-surface);
  border: 1px dashed var(--mb-line);
}
.payment-change-box strong {
  font-size: 1.2rem;
  color: var(--mb-brand);
  font-variant-numeric: tabular-nums;
}
.payment-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-top: 0.15rem;
}
.payment-actions .btn-confirm {
  flex: 1;
  margin-top: 0;
}

/* —— Caixa —— */
.cash-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 0.85rem;
  margin-bottom: 0.85rem;
  align-items: stretch;
}
.cash-status-card,
.cash-summary-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  height: auto;
}
.cash-status-card .cash-meta {
  flex: 0 0 auto;
}
.cash-status-top {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.cash-status-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  background: #f8e4e2;
  color: #b42318;
  border: 1px solid #e8b4ae;
  flex-shrink: 0;
}
.cash-status-icon.is-open {
  background: #e8f4f0;
  color: var(--mb-brand);
  border-color: #c5ddd5;
}
.cash-status-copy h2 {
  margin: 0 0 0.35rem;
  font-family: var(--mb-display);
  font-size: 1.15rem;
}
.cash-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.cash-status-pill.is-open {
  background: #e4f3ea;
  color: var(--mb-ok);
}
.cash-status-pill.is-closed {
  background: var(--mb-surface);
  color: var(--mb-muted);
}
.cash-summary-card h2,
.cash-history h2 {
  margin: 0;
  font-family: var(--mb-display);
  font-size: 1.15rem;
}
.cash-meta {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  background: rgba(13, 92, 77, 0.04);
  border: none;
}
.cash-meta > div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}
.cash-meta dt {
  margin: 0;
  color: var(--mb-muted);
  font-size: 0.86rem;
}
.cash-meta dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.cash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: auto;
}
.cash-actions .btn-confirm {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
}
.cash-actions-row {
  flex-direction: row;
}
.cash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
}
.cash-kpi {
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 12px;
  background: var(--mb-surface);
  box-shadow: var(--mb-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.cash-kpi span { color: var(--mb-muted); font-size: 0.8rem; }
.cash-kpi strong { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.cash-kpi-brand {
  background: linear-gradient(135deg, #e8f4f0, var(--mb-surface));
}
.cash-kpi-brand strong { color: var(--mb-brand); }
.cash-kpi-in strong { color: var(--mb-ok); }
.cash-kpi-out strong { color: var(--mb-danger); }
.cash-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  min-width: 0;
}
.cash-split .table-wrap {
  min-width: 0;
  padding: 0.55rem 0.65rem 0.7rem;
  overflow: auto;
}
.cash-split .data-table {
  font-size: 0.86rem;
}
.cash-split .data-table th,
.cash-split .data-table td {
  padding: 0.45rem 0.5rem;
}
.cash-split .data-table td:last-child {
  max-width: 9rem;
  overflow-wrap: anywhere;
  white-space: normal;
}
.cash-movement-hint {
  margin: 0;
  font-size: 0.84rem;
  grid-column: 1 / -1;
}
.cash-movement-hint strong {
  color: var(--mb-brand);
  font-variant-numeric: tabular-nums;
}
.cash-page .cash-layout {
  align-items: start;
}
.cash-split h3 {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  color: var(--mb-muted);
}
.cash-history { margin-top: 0; }
.modal-cash .form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}
.modal-cash .form-actions .btn-confirm {
  flex: 1;
  margin-top: 0;
}
.btn-confirm-outline {
  background: transparent;
  color: var(--mb-brand);
  border: 1px solid #c5ddd5;
  box-shadow: none;
}
.btn-confirm-outline:hover { background: #eef7f3; }

@media (max-width: 960px) {
  .cash-layout,
  .cash-split { grid-template-columns: 1fr; }
  .pos-cash-strip { display: none; }
}

/* —— Ajuda / manual —— */
.help-search {
  min-width: 16rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--mb-line-strong);
  border-radius: 10px;
  background: #fff;
  font: inherit;
}
.help-no-results { margin: 0; color: var(--mb-muted); }
.help-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.help-toc {
  position: sticky;
  top: 0;
  max-height: calc(100vh - var(--topbar-h) - 2.5rem);
  overflow-y: auto;
}
.help-toc-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: default;
}
.help-toc-title {
  font-family: var(--mb-display);
  font-size: 1.05rem;
}
.help-toc-current,
.help-toc-chevron { display: none; }
.help-toc ol { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.15rem; }
.help-toc a {
  display: block;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  color: var(--mb-ink);
  text-decoration: none;
  font-size: 0.9rem;
}
.help-toc a:hover { background: rgba(13, 92, 77, 0.07); }
.help-toc a.is-active { background: rgba(13, 92, 77, 0.12); color: var(--mb-brand); font-weight: 600; }
.help-body { display: flex; flex-direction: column; gap: 0.85rem; min-width: 0; }
.help-section { line-height: 1.6; font-size: 0.95rem; scroll-margin-top: 0.5rem; }
.help-section h2 { font-size: 1.3rem; margin-bottom: 0.75rem; }
.help-section h3 {
  margin: 1.1rem 0 0.35rem;
  font-size: 1rem;
  color: var(--mb-brand);
  scroll-margin-top: 0.5rem;
}
.help-section p { margin: 0.35rem 0; }
.help-section ol,
.help-section ul { margin: 0.35rem 0; padding-left: 1.4rem; }
.help-section li { margin: 0.2rem 0; }
.help-section a { color: var(--mb-brand); }
.help-steps li { margin: 0.45rem 0; }
.help-section kbd {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--mb-line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fff;
  font-family: var(--mb-mono);
  font-size: 0.82rem;
}
.help-note,
.help-warn {
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border-left: 3px solid var(--mb-brand);
  background: rgba(13, 92, 77, 0.06);
}
.help-warn { border-left-color: var(--mb-danger); background: rgba(180, 35, 24, 0.06); }
.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}
.help-table th,
.help-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--mb-line);
  text-align: left;
  vertical-align: top;
}
.help-table th { background: rgba(28, 25, 22, 0.04); font-weight: 600; }
.help-faq dt,
.help-glossary dt { font-weight: 600; margin-top: 0.8rem; }
.help-faq dd,
.help-glossary dd { margin: 0.2rem 0 0; color: var(--mb-ink); }
.help-glossary dt { margin-top: 0.5rem; }

@media (max-width: 900px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-toc {
    position: sticky;
    top: -1.1rem;
    z-index: 5;
    max-height: none;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }
  .help-toc-toggle { margin: 0; cursor: pointer; }
  .help-section,
  .help-section h3 { scroll-margin-top: 3.5rem; }
  .help-toc-current {
    display: block;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--mb-brand);
    font-size: 0.88rem;
    font-weight: 600;
  }
  .help-toc-current:not(:empty)::before { content: "· "; color: var(--mb-muted); }
  .help-toc-chevron {
    display: inline-block;
    margin-left: auto;
    transition: transform .15s ease;
  }
  .help-toc.is-open .help-toc-chevron { transform: rotate(180deg); }
  .help-toc:not(.is-open) ol { display: none; }
  .help-toc.is-open ol {
    margin-top: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
  }
  .help-search { min-width: 0; width: 100%; }
  .help-head .page-head-actions { width: 100%; flex-wrap: nowrap; }
  .help-table { display: block; overflow-x: auto; }
}

@media print {
  .help-page .app-sidebar,
  .help-page .app-topbar,
  .help-page .help-head,
  .help-page #page-loader { display: none !important; }
  .help-page .help-toc { position: static; max-height: none; box-shadow: none; border: 0; }
  .help-page .help-toc ol { display: grid !important; max-height: none !important; overflow: visible !important; }
  .help-page .help-toc-current,
  .help-page .help-toc-chevron { display: none !important; }
  .help-page.app-shell { display: block; }
  .help-page .app-main,
  .help-page .app-content { height: auto; overflow: visible; display: block; padding: 0; background: #fff; }
  .help-page .help-layout { display: block; }
  .help-page .help-section { box-shadow: none; border: 0; page-break-inside: auto; break-before: page; }
  .help-page .help-section:first-child { break-before: auto; }
}
