/* Minha Vida Organizada — shell global: sidebar, topbar, conteúdo.
   Depende de tokens.css já estar carregado antes.
   Sem linhas dividindo a tela: as áreas se separam por fundo e sombra, não por borda. */

:root { --sb-w: 240px; --topbar-h: 56px; }
html.sb-collapsed { --sb-w: 72px; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sb-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 180ms;
}

.body-split { display: grid; grid-template-columns: 1fr 300px; gap: var(--space-4); align-items: start; }
@media (max-width: 1100px) { .body-split { grid-template-columns: 1fr; } }

/* ---------- Sidebar (clara; recolhe pra só ícones; no celular vira gaveta) ---------- */
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-3);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 30;
}
.sb-brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-2) var(--space-5); margin-bottom: var(--space-2); border-bottom: 1px solid var(--sidebar-line); }
.sb-brand .mark { width: 28px; height: 28px; background: var(--brand); border-radius: var(--radius-sm); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--on-brand); }
.sb-brand .mark svg { width: 16px; height: 16px; }
.sb-brand .name { font-size: 14px; font-weight: 700; line-height: 1.2; white-space: nowrap; }

.sb-sec { font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; padding: var(--space-4) var(--space-2) var(--space-2); white-space: nowrap; }
.sb-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--sidebar-ink-soft);
  text-decoration: none;
  margin-bottom: var(--space-1);
  white-space: nowrap;
  transition: background-color 150ms, color 150ms;
}
.sb-item svg { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 2; }
.sb-item:hover { background: var(--surface-2); color: var(--text-primary); }
.sb-item.on { background: var(--sidebar-active); color: var(--brand-ink); }
.sb-item.on:not([data-mod]) svg { color: var(--brand); }
.sb-item.soon { opacity: 0.45; cursor: default; }
.sb-item.soon:hover { background: transparent; color: var(--sidebar-ink-soft); }
.sb-spacer { flex: 1; }
/* Troca de contexto (Minha casa <-> Gestão do MVO): só existe pra quem acumula os dois papéis. */
.sb-switch { border-top: 1px solid var(--sidebar-line); padding-top: var(--space-2); margin-top: var(--space-2); }
.sb-switch a { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: var(--sidebar-ink-soft); text-decoration: none; white-space: nowrap; }
.sb-switch a:hover { background: var(--surface-2); color: var(--text-primary); }
.sb-switch a svg { width: 14px; height: 14px; flex-shrink: 0; stroke-width: 2; }
.sb-user { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-2); border-top: 1px solid var(--sidebar-line); margin-top: var(--space-2); cursor: pointer; }
.sb-user .avatar { width: 28px; height: 28px; font-size: 11px; }
.sb-user .un { font-size: 12.5px; font-weight: 600; }
.sb-user .ue { font-size: 11.5px; color: var(--sidebar-ink-soft); }
.sb-user .chev { margin-left: auto; color: var(--sidebar-ink-soft); width: 14px; height: 14px; }

html.sb-collapsed .sidebar .lbl { display: none; }
html.sb-collapsed .sb-item, html.sb-collapsed .sb-brand { justify-content: center; padding-left: 0; padding-right: 0; }
html.sb-collapsed .sb-sec { padding: var(--space-2) 0; margin-top: var(--space-2); border-top: 1px solid var(--sidebar-line); }
html.sb-collapsed .sb-brand + .sb-sec { border-top: none; margin-top: 0; }

.sb-backdrop { display: none; }
@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform 180ms; box-shadow: var(--shadow-floating); }
  html.sb-collapsed .sidebar .lbl { display: revert; }
  html.sb-collapsed .sb-item, html.sb-collapsed .sb-brand { justify-content: flex-start; padding-left: var(--space-3); padding-right: var(--space-3); }
  html.sb-collapsed .sb-sec { padding: var(--space-4) var(--space-2) var(--space-2); border-top: none; margin-top: 0; }
  body.sb-open .sidebar { transform: none; }
  body.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 25; }
}

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--space-3); height: var(--topbar-h); padding: 0 var(--space-8); background: var(--bg); }
@media (max-width: 780px) { .topbar { padding: 0 var(--space-4); } .top-user-name { display: none; } .kbd { display: none; } }
.icon-btn { width: 32px; height: 32px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; background: transparent; border: none; color: var(--text-secondary); cursor: pointer; flex-shrink: 0; transition: background-color 150ms, color 150ms, box-shadow 150ms; }
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.icon-btn svg { width: 16px; height: 16px; stroke-width: 2; }
.theme-seg { margin-left: auto; display: inline-flex; gap: var(--space-1); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: var(--space-1); }
.theme-seg button { width: 32px; height: 28px; border: none; background: transparent; border-radius: var(--radius-pill); color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background-color 150ms, color 150ms, box-shadow 150ms; }
.theme-seg button svg { width: 14px; height: 14px; stroke-width: 2; }
.theme-seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.search { position: relative; display: flex; align-items: center; gap: var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); color: var(--text-faint); font-size: 14px; max-width: 320px; flex: 1; min-width: 0; }
.search svg { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 2; }
.search input { border: none; background: none; outline: none; font-family: var(--font-sans); font-size: 14px; color: var(--text-primary); flex: 1; min-width: 0; box-shadow: none; }
.search input::placeholder { color: var(--text-faint); }
.kbd { margin-left: auto; font-size: 11px; color: var(--text-faint); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 var(--space-1); }
.top-icon-wrap { position: relative; }
.top-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); cursor: pointer; }
.top-icon svg { width: 16px; height: 16px; stroke-width: 2; }
.top-dot { position: absolute; top: var(--space-2); right: var(--space-2); width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.notif-empty { font-size: 12.5px; color: var(--text-faint); padding: var(--space-3); text-align: center; white-space: nowrap; }
.top-user-wrap { position: relative; }
.top-user { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; font-weight: 600; cursor: pointer; }
.top-user .avatar { width: 30px; height: 30px; font-size: 12px; }
.top-user svg { width: 14px; height: 14px; color: var(--text-faint); stroke-width: 2; }
.account-menu { display: none; position: absolute; top: calc(100% + 8px); right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2); min-width: 160px; box-shadow: var(--shadow-floating); z-index: 50; }
.account-menu.open { display: block; }
.account-menu a { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; color: var(--text-primary); text-decoration: none; cursor: pointer; }
.account-menu a:hover { background: var(--surface-2); }
.account-menu a svg { width: 16px; height: 16px; color: var(--text-faint); stroke-width: 2; }

/* ---------- Main content ---------- */
.main-col { min-width: 0; }
.content { padding: var(--space-8) var(--space-8) calc(var(--space-10) * 2); max-width: 1440px; margin: 0 auto; }
@media (max-width: 780px) { .content { padding: var(--space-5) var(--space-4) calc(var(--space-10) * 2); } .page-title { font-size: 26px; } }

.page-hd { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-6); flex-wrap: wrap; }
.page-title { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.15; }
.page-sub { font-size: 16px; font-weight: 400; color: var(--text-secondary); margin-top: var(--space-2); }
.date-chip { display: flex; align-items: center; gap: var(--space-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.date-chip svg { width: 14px; height: 14px; stroke-width: 2; }

.sec-lbl { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: var(--space-4); }
.sec-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); }

/* ---------- Context cards (Em destaque) ---------- */
.hl-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-bottom: var(--space-6); }
@media (max-width: 900px) { .hl-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .hl-row { grid-template-columns: 1fr; } }
.hl-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--card-accent, var(--border)); border-radius: var(--radius-md); padding: var(--space-4); box-shadow: var(--shadow-card); transition: box-shadow 150ms, transform 150ms, border-color 150ms; text-decoration: none; color: inherit; }
a.hl-card:hover { box-shadow: var(--shadow-floating); transform: translateY(-1px); }
.hl-top { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.hl-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hl-icon svg { width: 18px; height: 18px; stroke-width: 2; }
.hl-label { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.hl-sub { font-size: 12.5px; color: var(--text-secondary); }
.hl-val { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.3; margin-top: var(--space-2); color: var(--text-primary); padding-right: var(--space-8); }   /* espaço pra seta, que fica no canto */
.hl-val .num { font-family: var(--font-mono); font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.hl-arrow { position: absolute; bottom: var(--space-3); right: var(--space-3); width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.hl-arrow svg { width: 14px; height: 14px; stroke-width: 2; }
.hl-empty { color: var(--text-faint); font-size: 11.5px; margin-top: var(--space-2); }

/* ---------- Module grid ---------- */
.mod-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
@media (max-width: 900px) { .mod-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .mod-grid { grid-template-columns: 1fr; } }
.mod-tile { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--card-accent, var(--border)); border-radius: var(--radius-md); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); text-decoration: none; color: inherit; box-shadow: var(--shadow-card); transition: box-shadow 150ms, transform 150ms, border-color 150ms; }
a.mod-tile:hover { box-shadow: var(--shadow-floating); transform: translateY(-1px); }
.mod-icon-lg { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.mod-icon-lg svg { width: 18px; height: 18px; stroke-width: 2; }
.mod-label { font-size: 15px; font-weight: 600; }
.mod-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; min-height: 32px; }
.mod-foot { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-1); }
.mod-foot svg { width: 14px; height: 14px; color: var(--text-faint); stroke-width: 2; }

/* ---------- Right side column ---------- */
.home-side { display: flex; flex-direction: column; gap: var(--space-4); }
.side-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); box-shadow: var(--shadow-card); }
.side-hd { display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: 600; margin-bottom: var(--space-3); }
.side-hd a { font-size: 12.5px; font-weight: 600; color: var(--brand); text-decoration: none; cursor: pointer; }
.side-caption { font-size: 11.5px; color: var(--text-faint); margin-top: var(--space-2); }
.side-list { display: flex; flex-direction: column; gap: var(--space-3); }
.side-row { display: flex; align-items: center; gap: var(--space-3); }
.side-row svg { width: 14px; height: 14px; stroke-width: 2; color: var(--text-secondary); margin-left: auto; flex-shrink: 0; }
.sr-nm { font-size: 14px; font-weight: 600; }
.sr-sub { font-size: 11.5px; color: var(--text-faint); margin-top: var(--space-1); font-family: var(--font-mono); }
.mini-flag { width: 38px; height: 38px; border-radius: var(--radius-sm); color: var(--on-brand); font-size: 12px; font-weight: 800; letter-spacing: -0.2px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.side-go { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); margin-left: auto; flex-shrink: 0; }
.side-go svg { width: 12px; height: 12px; margin-left: 0; stroke-width: 2; }

/* ---------- Sugestões de melhoria (janela aberta pelo ícone da lâmpada no topo) ---------- */
.fb-modal-bg { display: none; position: fixed; inset: 0; background: var(--overlay); z-index: 201; align-items: center; justify-content: center; padding: var(--space-4); }
.fb-modal-bg.open { display: flex; }
.fb-modal { background: var(--surface); border-radius: var(--radius-lg); width: 460px; max-width: 92vw; max-height: min(88vh, calc(100dvh - var(--space-8))); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-floating); }
.fb-modal-body { padding: var(--space-6); overflow-y: auto; min-height: 0; }
.fb-modal h3 { font-size: 16px; font-weight: 700; margin-bottom: var(--space-1); }
.fb-modal .sub { font-size: 12.5px; color: var(--text-secondary); margin-bottom: var(--space-4); }
.fb-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: var(--space-4); }
.fb-tab { font-size: 12.5px; font-weight: 600; color: var(--text-faint); padding: var(--space-2) var(--space-1); margin-right: var(--space-5); border: none; background: none; border-bottom: 2px solid transparent; cursor: pointer; font-family: var(--font-sans); }
.fb-tab.on { color: var(--brand-ink); border-color: var(--brand); }
.fb-textarea { width: 100%; background: var(--surface); color: var(--text-primary); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: var(--space-3); font-family: var(--font-sans); font-size: 13px; resize: vertical; min-height: 70px; }
.fb-item { padding: var(--space-3) 0; border-bottom: 1px solid var(--border-soft); }
.fb-item:last-child { border-bottom: none; }
.fb-item-title { font-size: 13px; font-weight: 600; }
.fb-item-desc { font-size: 12px; color: var(--text-secondary); margin-top: var(--space-1); }
.fb-item-status { margin-top: var(--space-1); }


/* ---------- Menu da busca global ---------- */
.search-menu { display: none; position: absolute; top: calc(100% + 8px); left: 0; width: 380px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2); box-shadow: 0 12px 32px rgba(20,25,22,0.14); z-index: 60; }
.search-menu.open { display: block; }
.sm-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius:  var(--radius-sm); text-decoration: none; color: var(--text-primary); }
.sm-item:hover { background: var(--surface-2); }
.sm-ic { width: 28px; height: 28px; border-radius:  var(--radius-sm); background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sm-ic svg { width: 16px; height: 16px; }
.sm-tx { display: flex; flex-direction: column; min-width: 0; }
.sm-t { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-s { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Sino de notificações ---------- */
.notif-menu { width: 340px; max-width: 92vw; padding: var(--space-2); }
.nf-sec { font-size:11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); padding: var(--space-2) var(--space-3) var(--space-1); }
.nf-item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius:  var(--radius-sm); text-decoration: none; color: var(--text-primary); }
a.nf-item:hover { background: var(--surface-2); }
.nf-foot { display: block; margin-top: var(--space-2); padding: var(--space-2) var(--space-3); border-top: 1px solid var(--border-soft); font-size: 12px; font-weight: 600; color: var(--brand-ink); text-decoration: none; }
.nf-foot:hover { text-decoration: underline; }
.nf-ic { width: 28px; height: 28px; border-radius:  var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nf-ic svg { width: 14px; height: 14px; }
.nf-tx { display: flex; flex-direction: column; min-width: 0; }
.nf-t { font-size: 12.5px; line-height: 1.35; font-weight: 500; }
.nf-t b { font-weight: 700; }
.nf-s { font-size: 11.5px; color: var(--text-faint); margin-top: var(--space-1); }

.fb-prints { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-2); }
.fb-prints:empty { display: none; }
.fb-print { position: relative; width: 96px; height: 72px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.fb-print img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fb-print .icon-btn { position: absolute; top: var(--space-1); right: var(--space-1); width: 24px; height: 24px; background: var(--surface); box-shadow: var(--shadow-card); }
.fb-detalhes { margin-bottom: var(--space-4); font-size: 12.5px; color: var(--text-secondary); }
.fb-detalhes summary { cursor: pointer; font-weight: 600; color: var(--brand-ink); }
.fb-detalhes .hint { margin-top: var(--space-2); line-height: 1.55; }
.fb-apontado { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.fb-apontado:empty { display: none; }
body.fb-apontando, body.fb-apontando * { cursor: crosshair !important; }
.fb-apontar-alvo { outline: 2px solid var(--brand) !important; outline-offset: 2px; }
.fb-apontar-banner { position: fixed; top: var(--space-4); left: 50%; transform: translateX(-50%); z-index: 250; background: var(--text-primary); color: var(--bg); font-size: 13px; font-weight: 600; padding: var(--space-3) var(--space-4); border-radius: var(--radius-pill); display: flex; align-items: center; gap: var(--space-3); box-shadow: var(--shadow-floating); }
.fb-apontar-banner .btn { cursor: pointer; }

/* ---------- Pular para o conteúdo (só aparece quando recebe o foco do teclado) ---------- */
.skip-link { position: absolute; left: var(--space-4); top: calc(var(--space-10) * -2); z-index: 500; background: var(--surface); color: var(--brand-ink); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); font-weight: 600; text-decoration: none; box-shadow: var(--shadow-floating); }
.skip-link:focus { top: var(--space-3); }

/* ---------- Toque e celular ---------- */
@media (max-width: 780px) {
  .input, select.input, textarea.input, .search input { font-size: 16px !important; }   /* o iPhone não dá zoom ao tocar no campo (vale mesmo com ajuste local da tela) */
  .input, select.input { min-height: 40px; }
  .top-user { min-height: 40px; }
  .view-tab { min-width: 40px; }
  .mod-pill { min-height: 40px; }
  .ag-item a { display: inline-flex; align-items: center; min-height: 40px; }
  .topbar { gap: var(--space-2); }
  .icon-btn, .top-icon { width: 40px; height: 40px; }
  .theme-seg button { width: 36px; height: 36px; }
  .btn-sm { height: 40px; }
  .sb-item { min-height: 44px; }
  .tab, .view-tab, .fb-tab, .chip, .p-chip, .seg button { min-height: 40px; }
  .side-hd a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--space-2); }
  .row-item.clickable, .ag-item { min-height: 48px; }
  /* A busca vira só a lupa; ao tocar, abre por cima da barra do topo, na largura toda. */
  .search { flex: 0 0 auto; width: 40px; height: 40px; padding: 0; justify-content: center; cursor: pointer; }
  .search input { width: 0; flex: 0; opacity: 0; padding: 0; }
  .search:focus-within { position: absolute; left: var(--space-4); right: var(--space-4); top: 50%; transform: translateY(-50%); width: auto; height: 44px; padding: 0 var(--space-3); justify-content: flex-start; cursor: text; z-index: 30; box-shadow: var(--shadow-floating); }
  .search:focus-within input { width: auto; flex: 1; opacity: 1; }
}
