/* ============================================================
   SINNC Assistência Social — Gestão Integrada do SUAS
   Design system conforme mockups oficiais (verde-oliva + laranja)
   ============================================================ */
:root {
  --primary: #33421A;        /* verde-oliva institucional (sidebar / títulos) */
  --primary-dark: #26321A;
  --primary-light: #4B5E28;
  --primary-50: #EEF2E6;
  --primary-100: #DCE5CC;
  --accent: #E07B12;         /* laranja de ação */
  --accent-dark: #C4660A;
  --accent-light: #F59A3A;
  --accent-50: #FDF1E4;
  --accent-100: #FBE0C2;

  --success: #2F7D3A; --success-50: #E6F4E8;
  --warning: #C76A08; --warning-50: #FDF0E0;
  --danger: #C62828;  --danger-50: #FDECEC;
  --info: #2F6FB3;    --info-50: #E8F1FB;

  --white: #FFFFFF;
  --gray-50: #FAFAF8; --gray-100: #F4F4F1; --gray-200: #E7E7E2; --gray-300: #D5D5CE;
  --gray-400: #A3A39A; --gray-500: #74746C; --gray-600: #56564F; --gray-700: #3C3C37; --gray-800: #25251F; --gray-900: #161613;

  --sidebar-w: 236px;
  --sidebar-w-collapsed: 72px;
  --header-h: 64px;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(30,30,20,.06), 0 1px 3px rgba(30,30,20,.05);
  --shadow-md: 0 4px 14px rgba(30,30,20,.08);
  --shadow-lg: 0 14px 32px rgba(30,30,20,.16);
  --t: .2s cubic-bezier(.4,0,.2,1);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
html, body { height: 100%; }
body { font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--gray-100); color: var(--gray-800); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { color: var(--accent); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
h1,h2,h3 { color: var(--gray-900); }

/* ── LOGIN ─────────────────────────────────────────────── */
.login-wrapper { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--white); }
.login-hero { position: relative; overflow: hidden; background: #1c2412; display: flex; flex-direction: column; justify-content: flex-end; padding: 3rem; min-height: 100vh; color: #fff; }
.login-hero img.login-hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.login-hero::before { content: ''; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(35,48,20,.35) 0%, rgba(35,48,20,.45) 50%, rgba(22,30,12,.9) 100%); }
.login-hero-content { position: relative; z-index: 2; max-width: 560px; }
.login-hero-tagline { font-size: 2.3rem; font-weight: 800; line-height: 1.2; margin-bottom: 1rem; color: #fff; }
.login-hero-sub { font-size: 1.02rem; color: rgba(255,255,255,.93); border-left: 3px solid var(--accent); padding-left: .7rem; }
.login-hero-badge { position: absolute; top: 2rem; left: 2rem; z-index: 2; display: inline-flex; align-items: center; gap: .5rem; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28); padding: .4rem .9rem; border-radius: 30px; font-size: .7rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; backdrop-filter: blur(4px); }
.login-hero-badge i { color: var(--accent-light); }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem; background: linear-gradient(180deg, #fff 0%, #FBFBF9 100%); }
.login-card { width: 100%; max-width: 400px; }
.login-logo { height: 84px; width: auto; display: block; margin-bottom: 1.6rem; }
.login-title { font-size: 1.45rem; font-weight: 800; color: var(--primary); margin-bottom: .15rem; }
.login-sub { font-size: .85rem; color: var(--gray-500); margin-bottom: 1.4rem; }
.input-icon { position: relative; }
.input-icon > i.field-icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: .85rem; pointer-events: none; }
.input-icon > .form-control { padding-left: 2.2rem; }
.input-icon .toggle-visibility { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--gray-400); padding: .25rem; }
.login-extra-row { display: flex; align-items: center; justify-content: space-between; margin: -.2rem 0 1.2rem; font-size: .8rem; }
.login-remember { display: flex; align-items: center; gap: .4rem; color: var(--gray-600); cursor: pointer; }
.login-remember input { accent-color: var(--accent); }
.login-forgot { color: var(--primary); font-weight: 700; }
.login-btn { width: 100%; padding: .85rem; border: none; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--accent), var(--accent-dark)); color: #fff; font-weight: 700; font-size: .95rem; box-shadow: 0 6px 14px rgba(224,123,18,.3); display: flex; align-items: center; justify-content: center; gap: .5rem; }
.login-btn:hover { filter: brightness(1.05); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; }
.login-error { background: var(--danger-50); color: var(--danger); border-left: 3px solid var(--danger); padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .82rem; margin-bottom: 1rem; }
.login-disclaimer { display: flex; gap: .45rem; font-size: .72rem; color: var(--gray-500); margin-top: 1rem; }
.login-divider { border: none; border-top: 1px solid var(--gray-200); margin: 1.2rem 0; }
.login-tagline-row { display: flex; align-items: center; gap: .5rem; font-size: .75rem; color: var(--gray-600); margin-bottom: .7rem; }
.login-tagline-row i { color: var(--primary-light); }
.login-footer-text { font-size: .7rem; color: var(--gray-400); text-align: center; }
@media (max-width: 860px) { .login-wrapper { grid-template-columns: 1fr; } .login-hero { display: none; } .login-panel { min-height: 100vh; } }

/* ── SHELL ─────────────────────────────────────────────── */
.app-wrapper { display: grid; grid-template-areas: "sidebar header" "sidebar content"; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--header-h) 1fr; height: 100vh; overflow: hidden; transition: grid-template-columns var(--t); }
.app-wrapper.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.app-sidebar { grid-area: sidebar; background: var(--primary); color: #fff; display: flex; flex-direction: column; overflow: hidden; z-index: 200; }
.sidebar-logo { background: #fff; padding: .4rem .8rem; height: var(--header-h); display: flex; align-items: center; justify-content: flex-start; flex-shrink: 0; border-bottom: 1px solid var(--gray-200); }
.sidebar-logo img.logo-full { height: 54px; width: auto; max-width: 100%; }
.sidebar-logo img.logo-icon { display: none; height: 40px; }
.app-wrapper.collapsed .sidebar-logo { justify-content: center; padding: .5rem; }
.app-wrapper.collapsed .sidebar-logo img.logo-full { display: none; }
.app-wrapper.collapsed .sidebar-logo img.logo-icon { display: block; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .9rem .6rem; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }
.sidebar-item { display: flex; align-items: center; gap: .85rem; padding: .68rem .8rem; border-radius: 8px; margin-bottom: 2px; cursor: pointer; color: rgba(255,255,255,.88); font-size: .9rem; font-weight: 500; white-space: nowrap; transition: background var(--t); text-decoration: none; }
.sidebar-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-item.active { background: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 4px 10px rgba(0,0,0,.18); }
.sidebar-item i { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.sidebar-footer { padding: .6rem; border-top: 1px solid rgba(255,255,255,.12); }
.app-wrapper.collapsed .sidebar-item span { display: none; }
.app-wrapper.collapsed .sidebar-item { justify-content: center; }

.app-header { grid-area: header; background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; z-index: 100; }
.header-toggle { width: 36px; height: 36px; border: none; background: transparent; border-radius: 8px; color: var(--gray-600); font-size: 1rem; flex-shrink: 0; }
.header-toggle:hover { background: var(--gray-100); }
.header-search { position: relative; flex: 1; max-width: 480px; }
.header-search i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--gray-500); }
.header-search input { width: 100%; padding: .62rem .9rem .62rem 2.4rem; border: 1px solid var(--gray-200); border-radius: 8px; background: var(--gray-50); font-size: .88rem; }
.header-search input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-50); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--gray-200); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; display: none; z-index: 300; }
.search-results.open { display: block; }
.search-group { padding: .4rem 0; border-bottom: 1px solid var(--gray-100); }
.search-group-title { font-size: .68rem; font-weight: 700; text-transform: uppercase; color: var(--gray-500); padding: .3rem .9rem; letter-spacing: .4px; }
.search-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .9rem; cursor: pointer; font-size: .85rem; }
.search-item:hover { background: var(--accent-50); }
.search-item i { color: var(--accent); width: 16px; }
.search-item small { color: var(--gray-500); margin-left: auto; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.header-unit { display: flex; align-items: center; gap: .55rem; padding: .55rem .9rem; border: 1px solid var(--gray-200); border-radius: 8px; background: #fff; font-size: .88rem; font-weight: 500; color: var(--gray-800); min-width: 190px; }
.header-unit i.fa-location-dot { color: var(--primary); }
.header-unit .fa-chevron-down { margin-left: auto; font-size: .7rem; color: var(--gray-500); }
.header-bell { position: relative; width: 38px; height: 38px; border: none; background: transparent; border-radius: 8px; color: var(--gray-700); font-size: 1.1rem; }
.header-bell:hover { background: var(--gray-100); }
.header-bell .dot { position: absolute; top: 6px; right: 7px; min-width: 16px; height: 16px; padding: 0 3px; background: var(--accent); color: #fff; border-radius: 10px; font-size: .6rem; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.header-user { display: flex; align-items: center; gap: .6rem; background: none; border: none; padding: .3rem .4rem; border-radius: 8px; font-size: .9rem; font-weight: 600; color: var(--gray-800); }
.header-user:hover { background: var(--gray-100); }
.header-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.dropdown { position: absolute; top: calc(100% + 8px); right: 0; background: #fff; border: 1px solid var(--gray-200); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 280px; z-index: 400; display: none; overflow: hidden; }
.dropdown.open { display: block; }
.dropdown-head { padding: .8rem 1rem; border-bottom: 1px solid var(--gray-100); font-weight: 700; font-size: .85rem; }
.dropdown-item { display: flex; align-items: center; gap: .65rem; padding: .65rem 1rem; font-size: .85rem; color: var(--gray-700); cursor: pointer; }
.dropdown-item:hover { background: var(--gray-50); }
.dropdown-item i { width: 16px; color: var(--accent); }
.dropdown-empty { padding: 1.2rem 1rem; font-size: .82rem; color: var(--gray-500); text-align: center; }
.rel { position: relative; }

.app-content { grid-area: content; overflow-y: auto; min-height: 0; background: var(--gray-100); }
.page { padding: 1.4rem 1.6rem 1rem; max-width: 1480px; margin: 0 auto; }
.page-footer { font-size: .72rem; color: var(--gray-500); padding: 1rem 0 .4rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumb { font-size: .8rem; color: var(--gray-600); display: flex; align-items: center; gap: .4rem; margin-bottom: .5rem; }
.breadcrumb a { color: var(--gray-600); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb i.fa-house { color: var(--gray-600); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-title { font-size: 1.85rem; font-weight: 800; color: var(--gray-900); letter-spacing: -.4px; line-height: 1.15; }
.page-sub { font-size: .92rem; color: var(--gray-600); margin-top: .2rem; }
.page-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* ── CARDS ─────────────────────────────────────────────── */
.card { background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 1rem; }
.card-head { padding: 1rem 1.2rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; border-bottom: 1px solid var(--gray-100); }
.card-title { font-size: 1.08rem; font-weight: 700; color: var(--gray-900); display: flex; align-items: center; gap: .5rem; }
.card-title i { color: var(--gray-700); }
.card-sub { font-size: .82rem; color: var(--gray-600); margin-top: .15rem; }
.card-body { padding: 1.1rem 1.2rem; }
.card-foot { padding: .9rem 1.2rem; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: .6rem; align-items: center; }
.link-action { font-size: .84rem; font-weight: 600; color: var(--accent-dark); display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; background: none; border: none; }
.link-action:hover { color: var(--accent); }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.layout-side-lg { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1rem; align-items: start; }
.mb-1 { margin-bottom: 1rem; } .mt-1 { margin-top: 1rem; } .mb-h { margin-bottom: .5rem; }

.kpi { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow-sm); }
.kpi-icon { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; background: var(--primary-50); color: var(--primary); }
.kpi-icon.orange { background: var(--accent-50); color: var(--accent); }
.kpi-label { font-size: .85rem; color: var(--gray-700); }
.kpi-value { font-size: 1.75rem; font-weight: 800; color: var(--gray-900); line-height: 1.1; }

.quick-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .8rem; margin: 1rem 0; }
.quick { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: .9rem 1rem; display: flex; align-items: center; gap: .7rem; cursor: pointer; font-size: .87rem; font-weight: 500; color: var(--gray-800); box-shadow: var(--shadow-sm); transition: all var(--t); }
.quick:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.quick i { font-size: 1.15rem; color: var(--accent); }
.quick i.green { color: var(--primary); }

/* ── BOTÕES ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .62rem 1.1rem; border-radius: 8px; font-size: .88rem; font-weight: 600; border: 1px solid transparent; transition: all var(--t); white-space: nowrap; line-height: 1.2; }
.btn-lg { padding: .78rem 1.4rem; font-size: .95rem; }
.btn-sm { padding: .38rem .7rem; font-size: .78rem; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 3px 8px rgba(224,123,18,.25); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: #fff; color: var(--accent-dark); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent-50); }
.btn-green { background: var(--primary); color: #fff; }
.btn-green:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-ghost:hover { background: var(--gray-50); }
.btn-danger { background: #fff; color: var(--danger); border-color: #EFB3B3; }
.btn-danger:hover { background: var(--danger-50); }
.btn-soft { background: var(--accent-50); color: var(--accent-dark); }
.btn-icon { width: 34px; height: 34px; padding: 0; border: 1px solid var(--gray-300); background: #fff; color: var(--gray-700); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled, .btn-icon:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ── FORM ─────────────────────────────────────────────── */
.form-group { margin-bottom: .9rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--gray-800); margin-bottom: .35rem; }
.req { color: var(--danger); }
.form-control { width: 100%; padding: .6rem .8rem; border: 1px solid var(--gray-300); border-radius: 8px; font-size: .88rem; color: var(--gray-800); background: #fff; }
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-50); }
.form-control[readonly], .form-control:disabled { background: var(--gray-50); color: var(--gray-700); }
textarea.form-control { min-height: 84px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2356564F' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }
.input-icon > select.form-control { padding-left: 2.2rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; }
.form-hint { font-size: .72rem; color: var(--gray-500); margin-top: .25rem; text-align: right; }
.filters { display: grid; gap: .9rem; align-items: end; }
.check { display: flex; align-items: center; gap: .45rem; font-size: .85rem; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ── TABELAS ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.table th { text-align: left; padding: .7rem .9rem; background: var(--gray-50); color: var(--gray-800); font-weight: 700; font-size: .8rem; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
table.table td { padding: .72rem .9rem; border-bottom: 1px solid var(--gray-100); color: var(--gray-800); vertical-align: middle; }
table.table tbody tr.clickable { cursor: pointer; }
table.table tbody tr.clickable:hover { background: var(--gray-50); }
table.table tbody tr.selected { background: var(--accent-50); box-shadow: inset 3px 0 0 var(--accent); }
table.table td .sub { display: block; font-size: .76rem; color: var(--gray-500); }
table.table td.num { font-weight: 700; }
.cell-actions { display: flex; gap: .4rem; align-items: center; }
.cell-actions button { background: none; border: none; color: var(--gray-700); padding: .25rem .3rem; font-size: .95rem; border-radius: 6px; }
.cell-actions button:hover { color: var(--accent); background: var(--accent-50); }

/* ── Pesquisa de registros relacionados / grids padronizados ── */
.sr-only, .lookup-native { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip-path: inset(50%); white-space: nowrap; border: 0 !important; }
.lookup-control { display: flex; align-items: stretch; position: relative; min-width: 0; width: 100%; border: 1px solid var(--gray-300); background: white; border-radius: 8px; transition: border-color var(--t), box-shadow var(--t); }
.lookup-control:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-50); }
.lookup-control.has-selection { border-color: #9BAC85; background: #F8FAF5; }
.lookup-control .lookup-input { min-width: 0; border: 0; background: transparent; box-shadow: none; padding: .65rem .75rem; text-overflow: ellipsis; }
.lookup-control .lookup-input:focus { box-shadow: none; }
.lookup-control:has(input:disabled) { background: var(--gray-100); }
.lookup-browse, .lookup-clear { border: 0; background: transparent; color: var(--gray-600); flex-shrink: 0; min-width: 36px; border-radius: 6px; }
.lookup-clear[hidden] { display: none; }
.lookup-browse { min-width: 42px; border-left: 1px solid var(--gray-200); color: var(--primary); background: var(--primary-50); border-radius: 0 7px 7px 0; }
.lookup-browse:hover:not(:disabled), .lookup-clear:hover:not(:disabled) { background: var(--accent-50); color: var(--accent-dark); }
.lookup-browse:disabled, .lookup-clear:disabled { opacity: .4; cursor: not-allowed; }
.input-icon:has(> .lookup-control) > .field-icon { display: none; }
.lookup-popover { position: fixed; margin: 0; padding: 0; inset: auto; background: white; border: 1px solid var(--gray-200); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 1600; overflow-y: auto; color: var(--gray-800); }
.lookup-popover[hidden] { display: none; }
.lookup-status { padding: .8rem 1rem; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); font-size: .8rem; color: var(--gray-600); }
.lookup-option { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; border-bottom: 1px solid var(--gray-100); cursor: pointer; }
.lookup-option:hover, .lookup-option[aria-selected=true] { background: var(--primary-50); box-shadow: inset 3px 0 0 var(--primary-light); }
.lookup-option > span:nth-child(2) { min-width: 0; flex: 1; }
.lookup-option strong { display: block; font-size: .88rem; overflow-wrap: anywhere; }
.lookup-option small { display: block; margin-top: .18rem; color: var(--gray-600); font-size: .75rem; overflow-wrap: anywhere; }
.lookup-option > i { color: var(--gray-400); font-size: .75rem; }
.lookup-avatar { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: var(--primary-50); color: var(--primary); flex-shrink: 0; }
.lookup-keyboard { padding: .5rem 1rem; color: var(--gray-600); font-size: .7rem; background: var(--gray-50); }
.lookup-dialog .modal-header { background: var(--primary-50); color: var(--primary); border-radius: 14px 14px 0 0; }
.lookup-description { margin-bottom: 1rem; color: var(--gray-600); font-size: .88rem; line-height: 1.6; }
.lookup-search { display: flex; gap: .6rem; padding: .85rem; border: 1px solid var(--gray-200); border-radius: 10px; background: var(--gray-50); }
.lookup-search input { flex: 1; min-width: 0; }
.lookup-summary { padding: .9rem 0; color: var(--gray-600); font-size: .8rem; }
.lookup-table td:last-child { color: var(--gray-600); font-size: .8rem; }
.lookup-results { min-height: 160px; }
.lookup-footer-hint { margin-right: auto; color: var(--gray-600); font-size: .75rem; align-self: center; }
.table-wrap { max-width: 100%; isolation: isolate; }
.table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.action-grid .grid-actions { position: sticky; left: 0; z-index: 1; width: 1%; white-space: nowrap; background: #fff; border-right: 1px solid var(--gray-200); text-align: left; }
.action-grid th.grid-actions { background: var(--primary-50); color: var(--primary); z-index: 2; }
.action-grid tr:hover > td { background: var(--gray-50); }
.action-grid tr.selected > td { background: var(--accent-50); }
.action-grid .grid-actions .cell-actions { justify-content: flex-start; flex-wrap: nowrap; }
.action-grid .grid-actions button:not(.btn):not([data-v]), .action-grid .grid-actions a:not(.btn) { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 34px; min-width: 34px; padding: .35rem .55rem; border: 1px solid var(--gray-200); border-radius: 7px; background: #fff; }
.action-grid .grid-actions button:hover, .action-grid .grid-actions a:hover { border-color: var(--accent); color: var(--accent-dark); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 3px; }
.grid > *, .filters > *, .layout-side > *, .layout-side-lg > * { min-width: 0; }
@media (max-width: 640px) {
  .page { padding: 1rem .75rem; }
  .grid-2, .grid-3, .grid-4, .filters { grid-template-columns: 1fr !important; }
  .modal-backdrop { padding: .5rem; }
  .modal-box { max-height: 95dvh; }
  .modal-body { padding: 1rem; }
  .lookup-search { flex-wrap: wrap; }
  .lookup-search input { flex-basis: 100%; }
  .lookup-search .btn { flex: 1; }
  .lookup-footer-hint { display: none; }
  .lookup-keyboard { display: none; }
  .lookup-browse, .lookup-clear { min-height: 42px; }
  .action-grid td, .action-grid th { padding: .6rem; }
  .action-grid .grid-actions { max-width: 45vw; white-space: normal; }
}
@media print { .action-grid .grid-actions { display: none; } .lookup-popover { display: none !important; } }

/* ── BADGES ─────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .7rem; border-radius: 20px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--success-50); color: var(--success); }
.badge-orange { background: var(--warning-50); color: var(--warning); }
.badge-blue { background: var(--info-50); color: var(--info); }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }
.badge-red { background: var(--danger-50); color: var(--danger); }
.badge-olive { background: var(--primary-50); color: var(--primary); }

/* ── TABS ─────────────────────────────────────────────── */
.tabs { display: flex; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); overflow-x: auto; margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: .55rem; padding: .95rem 1rem; background: none; border: none; border-right: 1px solid var(--gray-100); border-bottom: 3px solid transparent; font-size: .9rem; font-weight: 500; color: var(--gray-700); white-space: nowrap; }
.tab:last-child { border-right: none; }
.tab i { font-size: 1rem; }
.tab:hover { color: var(--accent-dark); }
.tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 700; background: linear-gradient(180deg, #fff 60%, var(--accent-50)); }
.tabs.compact { display: inline-flex; }
.tabs.compact .tab { flex: 0 0 auto; padding: .8rem 1.4rem; }
.pills { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.pill { padding: .6rem 1.3rem; border-radius: 8px; border: 1px solid var(--gray-300); background: #fff; font-size: .88rem; font-weight: 500; color: var(--gray-800); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ── DETALHE (painel lateral) ─────────────────────────────── */
.detail-row { display: flex; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--gray-100); align-items: flex-start; }
.detail-row:last-child { border-bottom: none; }
.detail-row > i { width: 18px; color: var(--gray-700); margin-top: .15rem; text-align: center; }
.detail-label { font-size: .8rem; color: var(--gray-700); font-weight: 600; }
.detail-value { font-size: .86rem; color: var(--gray-800); }
.detail-kv { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--gray-100); font-size: .85rem; }
.detail-kv .k { display: flex; gap: .6rem; align-items: center; color: var(--gray-700); }
.detail-kv .k i { width: 18px; text-align: center; }
.detail-kv .v { font-weight: 500; text-align: right; }
.avatar-circle { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-50); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; }
.avatar-circle.green { background: var(--primary-50); color: var(--primary); }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; flex-shrink: 0; background: var(--primary-50); color: var(--primary); }
.avatar-sm.orange { background: var(--accent-50); color: var(--accent); }
.icon-circle { width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary); flex-shrink: 0; font-size: 1rem; }
.icon-circle.orange { background: var(--accent-50); color: var(--accent); }
.icon-circle.gray { background: var(--gray-100); color: var(--gray-700); }

.alert { border-radius: var(--radius); padding: .9rem 1rem; display: flex; gap: .8rem; align-items: flex-start; font-size: .85rem; }
.alert-orange { background: var(--accent-50); border: 1px solid var(--accent-100); color: var(--gray-800); }
.alert-orange .alert-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 800; }
.alert-green { background: var(--success-50); border: 1px solid #C7E5CB; }
.alert-gray { background: var(--gray-50); border: 1px solid var(--gray-200); color: var(--gray-700); }
.note { font-size: .76rem; color: var(--gray-600); display: flex; gap: .4rem; align-items: center; justify-content: center; }
.steps { list-style: none; }
.steps li { display: flex; gap: .7rem; align-items: flex-start; margin-bottom: .7rem; font-size: .85rem; }
.steps .n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; flex-shrink: 0; }
.bullets { list-style: none; font-size: .82rem; color: var(--gray-700); }
.bullets li { padding-left: 1rem; position: relative; margin-bottom: .25rem; }
.bullets li::before { content: ''; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; position: absolute; left: 0; top: .5rem; }

.list-row { display: flex; align-items: center; gap: .8rem; padding: .75rem 0; border-bottom: 1px solid var(--gray-100); cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.list-row:hover .list-title { color: var(--accent-dark); }
.list-title { font-size: .88rem; font-weight: 600; color: var(--gray-800); }
.list-sub { font-size: .77rem; color: var(--gray-500); }
.list-row .right { margin-left: auto; text-align: right; font-size: .78rem; color: var(--gray-600); }
.list-row .count { margin-left: auto; font-weight: 800; color: var(--accent-dark); font-size: 1.05rem; }
.progress { height: 12px; background: var(--gray-200); border-radius: 10px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 10px; }

.member-card { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1rem .7rem; text-align: center; background: #fff; cursor: pointer; transition: all var(--t); }
.member-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.member-avatar { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto .6rem; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 700; color: #fff; }
.member-name { font-weight: 700; font-size: .9rem; }
.member-meta { font-size: .76rem; color: var(--gray-600); }

.timeline-list .tl { display: flex; gap: .8rem; padding: .6rem 0; position: relative; }
.timeline-list .tl:not(:last-child)::after { content: ''; position: absolute; left: 17px; top: 44px; bottom: -6px; width: 2px; background: var(--gray-200); }
.timeline-list .tl .icon-circle { width: 36px; height: 36px; font-size: .85rem; }
.timeline-list .tl .right { margin-left: auto; text-align: right; font-size: .76rem; color: var(--gray-600); white-space: nowrap; }

.seg { display: inline-flex; gap: .4rem; }
.seg button { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--gray-300); background: #fff; font-size: .8rem; font-weight: 500; color: var(--gray-700); }
.seg button.on-present { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg button.on-absent { background: var(--accent); border-color: var(--accent); color: #fff; }

.file-row { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border: 1px solid var(--gray-200); border-radius: 8px; margin-bottom: .5rem; font-size: .82rem; }
.file-row i.fa-file, .file-row i.fa-image, .file-row i.fa-file-pdf { font-size: 1.1rem; color: var(--gray-700); }
.file-row .right { margin-left: auto; }

.empty-state { text-align: center; padding: 2.2rem 1rem; color: var(--gray-500); font-size: .88rem; }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; color: var(--gray-400); }
.loading-state { text-align: center; padding: 2rem; color: var(--gray-500); }
.muted { color: var(--gray-500); font-size: .8rem; }
.text-right { text-align: right; }
.bold { font-weight: 700; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1.2rem; border-top: 1px solid var(--gray-100); font-size: .84rem; gap: 1rem; flex-wrap: wrap; }
.pagination .pg { display: flex; gap: .6rem; align-items: center; }

/* ── MODAL / TOAST ─────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,22,14,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal-box { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 600px; max-height: 92vh; display: flex; flex-direction: column; }
.modal-box.lg { max-width: 860px; }
.modal-box.sm { max-width: 440px; }
.modal-header { padding: 1rem 1.3rem; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 1.02rem; }
.modal-header i { color: var(--accent); margin-right: .4rem; }
.modal-body { padding: 1.2rem 1.3rem; overflow-y: auto; }
.modal-footer { padding: .9rem 1.3rem; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: .6rem; }
.modal-close { background: none; border: none; font-size: 1.3rem; color: var(--gray-500); }
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; }
.toast { min-width: 280px; max-width: 380px; background: #fff; border-radius: 8px; box-shadow: var(--shadow-lg); padding: .8rem 1rem; border-left: 4px solid var(--primary); font-size: .85rem; animation: toast-in .25s ease-out; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.autocomplete { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--gray-200); border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 1200; max-height: 240px; overflow-y: auto; display: none; }
.ac-list.open { display: block; }
.ac-item { padding: .55rem .8rem; font-size: .85rem; cursor: pointer; }
.ac-item:hover { background: var(--accent-50); }
.ac-item small { display: block; color: var(--gray-500); font-size: .74rem; }

@media print {
  .app-sidebar, .app-header, .page-actions, .no-print { display: none !important; }
  .app-wrapper { display: block; height: auto; }
  .app-content { overflow: visible; }
}
@media (max-width: 1200px) {
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .layout-side, .layout-side-lg { grid-template-columns: 1fr; }
  .grid-5, .grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .app-wrapper { grid-template-columns: 0 1fr; }
  .app-sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform var(--t); }
  .app-wrapper.mobile-open .app-sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .header-unit { min-width: 0; }
  .header-unit span, .header-user span { display: none; }
  .page-title { font-size: 1.45rem; }
}

/* ── Compatibilidade com views legadas (usuários, unidades, auditoria, pessoas) ── */
.page-content { padding: 0; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-header .page-title { font-size: 1.3rem; }
.page-breadcrumb { font-size: .82rem; color: var(--gray-600); }
table.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data-table th { text-align: left; padding: .7rem .9rem; background: var(--gray-50); font-weight: 700; font-size: .8rem; border-bottom: 1px solid var(--gray-200); }
table.data-table td { padding: .7rem .9rem; border-bottom: 1px solid var(--gray-100); }
table.data-table tbody tr:hover { background: var(--gray-50); cursor: pointer; }
.badge-primary { background: var(--primary-50); color: var(--primary); }
.badge-success { background: var(--success-50); color: var(--success); }
.badge-warning { background: var(--warning-50); color: var(--warning); }
.badge-danger { background: var(--danger-50); color: var(--danger); }
.card-header { padding: .9rem 1.2rem; border-bottom: 1px solid var(--gray-100); display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.card-footer { padding: .8rem 1.2rem; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: .5rem; }
.btn-secondary { background: var(--primary-light); color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card { background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); border-left: 4px solid var(--primary); padding: 1rem; }
.stat-card-label { font-size: .75rem; color: var(--gray-600); } .stat-card-value { font-size: 1.6rem; font-weight: 800; }
.tabs-inline { display: flex; gap: .25rem; border-bottom: 2px solid var(--gray-200); margin-bottom: 1rem; }
.tabs-inline .tab-btn { padding: .55rem 1rem; font-size: .82rem; font-weight: 600; color: var(--gray-500); background: none; border: none; border-bottom: 2px solid transparent; }
.tabs-inline .tab-btn.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
