@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
  --bg:            #090d18;
  --surface:       #111827;
  --surface-2:     #1a2234;
  --surface-3:     #212d42;
  --surface-hover: #243450;
  --text:          #d0daf0;
  --text-bright:   #eef3ff;
  --muted:         #6b7fa0;
  --line:          #1e2d45;
  --line-bright:   #2d4060;
  --primary:       #e8590c;
  --primary-dark:  #c04a08;
  --primary-light: #ff7a3d;
  --primary-glow:  rgba(232,89,12,0.22);
  --primary-bg:    rgba(232,89,12,0.07);
  --danger:        #ef4444;
  --danger-glow:   rgba(239,68,68,0.22);
  --success:       #10b981;
  --success-glow:  rgba(16,185,129,0.22);
  --warning:       #f59e0b;
  --warning-glow:  rgba(245,158,11,0.22);
  --info:          #3b82f6;
  --info-glow:     rgba(59,130,246,0.22);
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --shadow:        0 4px 24px rgba(0,0,0,0.45), 0 1px 4px rgba(0,0,0,0.3);
  --font-display:  'Sora', system-ui, sans-serif;
  --font-body:     'DM Sans', system-ui, sans-serif;
  --ease:          cubic-bezier(0.4,0,0.2,1);
  --t:             150ms;
}

/* ===== LIGHT THEME ===== */
/*
  Paleta "Sand Stone" (suavizada) — canvas um pouco mais fosco e texto em
  cinza-escuro (nao quase-preto), para reduzir o contraste forte que cansa a
  vista em uso prolongado. Inspirada em paineis profissionais (GitHub, Linear,
  Vercel): nada de branco puro nem preto puro, contraste alto so nos titulos.
  --bg            : #F0E4D4  canvas fosco, sem ofuscar
  --surface        : #F8EFE3  cards elevados — acima do canvas
  --surface-2      : #F2E6D6  camadas internas
  --surface-3      : #EADCCA  inputs e sub-secoes
  --surface-hover  : #E3D3BF  hover com contraste real
  --text           : #3A2D22  marrom-escuro legivel, sem ser preto
  --text-bright    : #1F1610  mais forte, so para titulos
  --muted          : #6B5744  marrom-cinza moderado
  --line           : #D9C7B1  divisores perceptiveis
  --line-bright    : #C7B196  bordas de enfase e inputs
*/
/* Cadastro da estrutura: item pai (codigo so com numero, ou com subitens) nao mostra os campos que so valem nos subitens */
#structureInlineForm.item-pai .campo-filho { display: none; }

/* Icone do calendario (campos de data e mes) em branco no modo escuro */
html:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator,
html:not([data-theme="light"]) input[type="month"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}
html[data-theme="light"] {
  --bg:            #F0E4D4;
  --surface:       #F8EFE3;
  --surface-2:     #F2E6D6;
  --surface-3:     #EADCCA;
  --surface-hover: #E3D3BF;
  --text:          #3A2D22;
  --text-bright:   #1F1610;
  --muted:         #6B5744;
  --line:          #D9C7B1;
  --line-bright:   #C7B196;
  --primary-glow:  rgba(232,89,12,0.20);
  --primary-bg:    rgba(232,89,12,0.10);
  --danger-glow:   rgba(220,38,38,0.16);
  --success-glow:  rgba(16,185,129,0.16);
  --warning-glow:  rgba(245,158,11,0.16);
  --info-glow:     rgba(59,130,246,0.16);
  --shadow:        0 1px 3px rgba(60,35,10,0.12), 0 4px 14px rgba(60,35,10,0.14);
}
html[data-theme="light"] body {
  background-color: #F0E4D4;
  background-image:
    linear-gradient(rgba(60,35,10,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60,35,10,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
}
html[data-theme="light"] ::-webkit-scrollbar-track { background: #EADCCA; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #C7B196; border-radius: 4px; }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #B39C80; }

/* Topbar: surface elevada com sombra definida */
html[data-theme="light"] .topbar {
  background: rgba(248,239,227,0.97);
  border-bottom: 1px solid #C7B196;
  box-shadow: 0 1px 0 #C7B196, 0 2px 10px rgba(60,35,10,0.12);
  backdrop-filter: blur(12px);
}
html[data-theme="light"] .page-overlay         { background: var(--bg); }
html[data-theme="light"] .page-overlay-header  { background: rgba(248,239,227,0.98); border-bottom-color: #C7B196; box-shadow: 0 1px 5px rgba(60,35,10,0.12); }

/* Modal: overlay escuro, card com profundidade real */
html[data-theme="light"] .modal                { background: rgba(60,35,10,0.45); backdrop-filter: blur(4px); }
html[data-theme="light"] .modal-card           { background: #F8EFE3; box-shadow: 0 24px 64px rgba(60,35,10,0.22), 0 0 0 1px #C7B196; }

/* Auth gate */
html[data-theme="light"] .name-gate,
html[data-theme="light"] #clientAuthGate {
  background: #F0E4D4;
  background-image: radial-gradient(ellipse 70% 55% at 50% 35%, rgba(232,89,12,0.08) 0%, transparent 65%);
}
html[data-theme="light"] .name-card {
  background: #F8EFE3;
  box-shadow: 0 8px 32px rgba(60,35,10,0.16), 0 0 0 1px #C7B196;
}

html[data-theme="light"] .toast {
  background: #F8EFE3;
  color: #3A2D22;
  box-shadow: 0 8px 28px rgba(60,35,10,0.18), 0 0 0 1px #C7B196;
}

/* Notice/Aviso */
html[data-theme="light"] .notice {
  background: rgba(245,158,11,0.10);
  border-color: rgba(245,158,11,0.38);
  color: #78350F;
}

/* Status badges */
html[data-theme="light"] .item-status.pending-ok   { background: rgba(59,130,246,0.13);  color: #1D4ED8; }
html[data-theme="light"] .item-status.pending-late { background: rgba(220,38,38,0.12);   color: #B91C1C; }
html[data-theme="light"] .item-status.done         { background: rgba(16,185,129,0.12);  color: #047857; }
html[data-theme="light"] .item-status.partial      { background: rgba(245,158,11,0.12);  color: #92400E; }

html[data-theme="light"] .badge.PENDENTE,
html[data-theme="light"] .pill.danger        { background: rgba(220,38,38,0.11);  color: #B91C1C; border: 1px solid rgba(220,38,38,0.22); }
html[data-theme="light"] .badge.ENTREGUE_PARCIAL,
html[data-theme="light"] .pill.warn          { background: rgba(245,158,11,0.11); color: #92400E; border: 1px solid rgba(245,158,11,0.28); }
html[data-theme="light"] .badge.ENTREGUE_TOTAL,
html[data-theme="light"] .pill.success       { background: rgba(16,185,129,0.11); color: #065F46; border: 1px solid rgba(16,185,129,0.25); }
html[data-theme="light"] .badge.NAO_APLICAVEL,
html[data-theme="light"] .pill.info          { background: rgba(59,130,246,0.11); color: #1D4ED8; border: 1px solid rgba(59,130,246,0.22); }
html[data-theme="light"] .badge.RETIFICACAO  { background: rgba(232,89,12,0.11); color: #C2410C; border: 1px solid rgba(232,89,12,0.25); }

/* Tabs ativas */
html[data-theme="light"] .detail-tab-btn.active { background: rgba(232,89,12,0.11); color: #C2410C; border-color: rgba(232,89,12,0.30); }

/* Cards e painéis: surface sobre canvas — hierarquia real por tom */
html[data-theme="light"] .sol-group-card       { background: #F8EFE3; border: 1px solid #D9C7B1; box-shadow: 0 1px 4px rgba(60,35,10,0.08); }
html[data-theme="light"] .sol-group-card:hover { background: #EEDFCC; border-color: #C7B196; }
html[data-theme="light"] .stat-card            { background: #F8EFE3; border: 1px solid #D9C7B1; box-shadow: 0 1px 4px rgba(60,35,10,0.08); }
html[data-theme="light"] .stat-card::before    { background: linear-gradient(90deg, var(--primary), transparent); opacity: 0.55; }
html[data-theme="light"] .panel,
html[data-theme="light"] .work-panel           { background: #F8EFE3; border: 1px solid #D9C7B1; box-shadow: 0 1px 4px rgba(60,35,10,0.08); }

/* Linhas e hovers */
html[data-theme="light"] .item-row              { border-bottom: 1px solid #D9C7B1; }
html[data-theme="light"] .item-row:hover        { background: #EEDFCC; }
html[data-theme="light"] .tree-row:hover        { background: #E0CFB8; }
html[data-theme="light"] .tree-node             { border-bottom: 1px solid #D9C7B1; }

/* Inputs: levemente mais escuros que o card para distinguir */
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  background: #EADCCA;
  color: #3A2D22;
  border-color: #C7B196;
}
html[data-theme="light"] input::placeholder { color: #B39C80; }
html[data-theme="light"] input:focus,
html[data-theme="light"] select:focus,
html[data-theme="light"] textarea:focus {
  border-color: var(--primary);
  background: #F2E6D6;
  box-shadow: 0 0 0 3px rgba(232,89,12,0.14);
  outline: none;
}

/* Erro de auth */
html[data-theme="light"] .auth-error { color: #DC2626; }

/* Link-btn */
html[data-theme="light"] .link-btn { color: #6B5744; }
html[data-theme="light"] .link-btn:hover { color: #3A2D22; }

/* ===== DATE INPUT — dark mode highlight ===== */
#prorrogacaoDateInput {
  background: var(--surface-3, #212d42);
  color: var(--text-bright);
  box-shadow: 0 0 0 3px rgba(232,89,12,0.18), inset 0 1px 3px rgba(0,0,0,0.25);
  transition: box-shadow 150ms, border-color 150ms;
}
#prorrogacaoDateInput:focus {
  box-shadow: 0 0 0 4px rgba(232,89,12,0.32), inset 0 1px 3px rgba(0,0,0,0.20);
  outline: none;
}
#prorrogacaoDateInput::-webkit-calendar-picker-indicator {
  filter: invert(0.8) sepia(0.3) saturate(4) hue-rotate(340deg);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
}
html[data-theme="light"] #prorrogacaoDateInput {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(13,26,59,0.12), inset 0 1px 2px rgba(13,26,59,0.08);
}
html[data-theme="light"] #prorrogacaoDateInput::-webkit-calendar-picker-indicator {
  filter: none;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 45% at 50% -10%, rgba(232,89,12,0.05) 0%, transparent 55%),
    url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 40V0H40' stroke='%23182033' stroke-width='0.5'/%3E%3C/svg%3E");
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: var(--font-body); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-bright); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
a { color: var(--primary-light); font-weight: 600; text-decoration: none; transition: color var(--t) var(--ease); }
a:hover { color: var(--primary); }

/* ===== BUTTONS ===== */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13px; font-weight: 600; letter-spacing: 0.01em;
  cursor: pointer; white-space: nowrap;
  transition: all var(--t) var(--ease); position: relative;
}
button:disabled { opacity: 0.42; cursor: not-allowed; pointer-events: none; }
button:active:not(:disabled) { transform: scale(0.97) !important; }

button.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-color: var(--primary-dark); color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.12);
}
button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  box-shadow: 0 4px 18px var(--primary-glow); transform: translateY(-1px);
}
button.secondary {
  background: var(--surface-2); border-color: var(--line-bright); color: var(--text);
}
button.secondary:hover:not(:disabled) {
  background: var(--surface-3); border-color: var(--muted); color: var(--text-bright);
}
button.success {
  background: linear-gradient(135deg, var(--success) 0%, #0d9b6e 100%);
  border-color: #0d9b6e; color: #fff;
  box-shadow: 0 2px 10px var(--success-glow);
}
button.success:hover:not(:disabled) { box-shadow: 0 4px 18px var(--success-glow); transform: translateY(-1px); }
button.warning {
  background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
  border-color: #d97706; color: #fff;
  box-shadow: 0 2px 10px var(--warning-glow);
}
button.warning:hover:not(:disabled) { box-shadow: 0 4px 18px var(--warning-glow); transform: translateY(-1px); }
button.danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  border-color: #dc2626; color: #fff;
  box-shadow: 0 2px 10px var(--danger-glow);
}
button.danger:hover:not(:disabled) { box-shadow: 0 4px 18px var(--danger-glow); transform: translateY(-1px); }
button.small { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
button.full { width: 100%; margin-top: 14px; }

a.secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--line-bright); border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13px; font-weight: 600; letter-spacing: 0.01em;
  cursor: pointer; white-space: nowrap;
  transition: all var(--t) var(--ease); position: relative;
  background: var(--surface-2); color: var(--text);
}
a.secondary:hover { background: var(--surface-3); border-color: var(--muted); color: var(--text-bright); }

/* ── Observações não lidas ── */
button.obs-unread {
  background: rgba(0,255,128,0.12);
  border-color: #00e87a;
  color: #00e87a;
  box-shadow: 0 0 8px rgba(0,255,128,0.55), 0 0 20px rgba(0,255,128,0.25);
  animation: obs-pulse 2.2s ease-in-out infinite;
}
button.obs-unread:hover:not(:disabled) {
  background: rgba(0,255,128,0.22);
  box-shadow: 0 0 14px rgba(0,255,128,0.8), 0 0 28px rgba(0,255,128,0.4);
}
@keyframes obs-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0,255,128,0.55), 0 0 20px rgba(0,255,128,0.25); }
  50%       { box-shadow: 0 0 14px rgba(0,255,128,0.85), 0 0 32px rgba(0,255,128,0.45); }
}
.obs-unread-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #00e87a;
  box-shadow: 0 0 6px rgba(0,255,128,0.9);
  margin-left: 4px;
  vertical-align: middle;
  animation: obs-pulse 2.2s ease-in-out infinite;
}
.obs-agg-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(0, 232, 122, 0.6);
  background: rgba(0, 232, 122, 0.12);
  color: #00e87a;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  vertical-align: middle;
  animation: obs-pulse 2.2s ease-in-out infinite;
}
html[data-theme="light"] .obs-agg-badge {
  color: #15803d;
  border-color: rgba(21, 128, 61, 0.55);
  background: rgba(34, 197, 94, 0.16);
}

/* ===== INPUTS ===== */
input, select {
  width: 100%; background: var(--surface); border: 1px solid var(--line-bright);
  border-radius: var(--radius-sm); color: var(--text); padding: 9px 12px; font-size: 14px;
  outline: none; transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
  -webkit-appearance: none; appearance: none;
}
input[type="radio"], input[type="checkbox"] {
  -webkit-appearance: auto; appearance: auto;
  width: auto; padding: 0; border: none; background: transparent;
  box-shadow: none; flex-shrink: 0; cursor: pointer; accent-color: var(--primary);
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
input::placeholder { color: var(--muted); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%236b7fa0' d='M1 3l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
select option { background: var(--surface-2); color: var(--text); }
label {
  display: block; font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em; margin: 12px 0 5px;
}
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  margin: 0 4px;
}

/* ===== APP SHELL ===== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ===== TOPBAR ===== */
.topbar {
  background: rgba(9,13,24,0.97);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  position: sticky; top: 0; z-index: 100; height: 60px; flex-shrink: 0;
}
.brand { display: flex; flex-direction: column; gap: 1px; }
.brand h1 {
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--text-bright); letter-spacing: -0.01em; line-height: 1;
}
.brand h1 .accent { color: var(--primary); }
.brand p { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1; }
.top-actions { display: flex; gap: 6px; align-items: center; }

/* ===== THEME BUTTON ===== */
.theme-btn {
  width: 34px; height: 34px; padding: 0;
  border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-btn svg { pointer-events: none; }
.topbar-divider {
  width: 1px; height: 22px; background: var(--line-bright);
  flex-shrink: 0; align-self: center;
}
#nameGateThemeBtn {
  position: fixed; top: 16px; right: 16px; z-index: 10;
}

/* ===== CONTENT ===== */
.content { flex: 1; max-width: 1760px; width: 100%; margin: 0 auto; padding: 24px 28px; }

/* ===== NOTICE ===== */
.notice {
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.28);
  color: #fbbf24; border-radius: var(--radius); padding: 12px 16px;
  margin-bottom: 16px; font-size: 13px; font-weight: 600;
}

/* ===== PANELS ===== */
.panel, .stat-card, .item-row, .client-card, .modal-card, .name-card, .sync-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.panel { padding: 20px; box-shadow: var(--shadow); }
.panel-title {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.panel-title h2 {
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  color: var(--text-bright); letter-spacing: -0.01em; text-transform: uppercase; letter-spacing: 0.06em;
}

/* ===== STATS ===== */
.stats { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
/* Criacao de solicitacao + contadores na mesma linha */
.solic-overview { display: flex; flex-wrap: wrap; align-items: stretch; gap: 14px; margin-bottom: 20px; }
.solic-overview #solicitationPanel { flex: 1 1 320px; margin-bottom: 0; }
.solic-overview .stats { margin-bottom: 0; align-self: center; }
.stats-compact { display: flex; flex-direction: column; flex: 0 0 auto; gap: 10px; min-width: 210px; }
.stats-compact .stat-card { padding: 12px 16px; display: flex; flex-direction: row; align-items: center; gap: 12px; }
.stats-compact .stat-value { font-size: 28px; }
.stats-compact .stat-label { margin-top: 0; }
.stat-card {
  padding: 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: border-color var(--t) var(--ease), transform var(--t) var(--ease);
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent);
}
.stat-card:hover { border-color: var(--line-bright); transform: translateY(-2px); }
.stat-card-clickable { cursor: pointer; }
.stat-card-clickable:hover { border-color: var(--primary); }
.stat-value {
  font-family: var(--font-display); font-size: 34px; font-weight: 800;
  color: var(--text-bright); line-height: 1; letter-spacing: -0.03em;
}
.stat-label {
  color: var(--muted); margin-top: 6px; font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* ===== GRID ===== */
.grid { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 16px; align-items: start; }
.grid.client-view { grid-template-columns: 1fr; }
.grid.client-view #duePanel { display: none !important; }

/* ===== UNIT SELECTOR ===== */
.unit-selector { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.root-button {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line-bright);
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; padding: 6px 12px; box-shadow: none;
  transition: all var(--t) var(--ease);
}
.root-button.active {
  background: var(--primary-bg); border-color: var(--primary); color: var(--primary-light);
}
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 8px; margin-bottom: 16px; }
.unit-button {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); text-align: left; padding: 12px 14px;
  min-height: 64px; display: flex; flex-direction: column; gap: 4px;
  transition: all var(--t) var(--ease);
}
.unit-button:hover { background: var(--surface-3); border-color: var(--line-bright); transform: translateY(-1px); }
.unit-button.active {
  background: var(--primary-bg); border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-glow);
}
.unit-button strong { display: block; font-size: 13px; font-weight: 700; color: var(--text-bright); line-height: 1.3; }

/* ===== ITEMS ===== */
.client-list, .unit-grid, .item-list, .due-list, .root-list, .compact-list { display: grid; gap: 6px; }
.item-row {
  padding: 12px 14px; display: grid; grid-template-columns: minmax(240px,1fr) auto;
  gap: 12px; align-items: center; box-shadow: none;
  transition: all var(--t) var(--ease);
}
.item-row:hover { border-color: var(--line-bright); background: var(--surface-2); }
.item-row.overdue { border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.04); }
.item-row.solicitation-item { border-left: 3px solid var(--primary); }
.item-row.item-na-disabled {
  background: var(--surface-2);
  border-color: var(--line-bright);
}
.item-row.item-na-disabled > .indent-1,
.item-row.item-na-disabled > .indent-2,
.item-row.item-na-disabled > .indent-3,
.item-row.item-na-disabled > .indent-4,
.item-row.item-na-disabled > .indent-5 {
  opacity: 0.5;
}
.grid.client-view .item-row { grid-template-columns: minmax(0,1fr) minmax(360px,auto); padding: 16px; }
.grid.client-view .item-actions { justify-content: flex-end; }
.item-title { font-size: 13px; font-weight: 600; color: var(--text-bright); line-height: 1.4; }
.item-heading { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item-obs-tip { display: inline-flex; align-items: center; justify-content: center; align-self: center; width: 18px; height: 18px; border-radius: 50%; background: #ffe600; color: #333; font-size: 11px; font-weight: 900; cursor: help; flex-shrink: 0; box-shadow: 0 0 6px #ffe60099; vertical-align: middle; }
.item-path { color: var(--muted); font-size: 11px; margin-top: 3px; letter-spacing: 0.01em; }
.item-tracking {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.item-tracking-col {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  line-height: 1.2;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.item-tracking-col strong {
  color: var(--text);
  font-weight: 700;
}
.item-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.item-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.item-actions input { min-width: 160px; width: 200px; }
.observation-entry { display: inline-grid; grid-template-columns: minmax(180px,220px) auto; gap: 6px; align-items: center; }
.observation-entry input { min-width: 0; width: 100%; }

/* ===== STATUS BADGES ===== */
.item-status {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 6px; padding: 3px 8px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.item-status::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.item-status.pending-ok  { background: rgba(59,130,246,0.1);  color: #60a5fa; }
.item-status.pending-late{ background: rgba(239,68,68,0.1);   color: #f87171; }
.item-status.done        { background: rgba(16,185,129,0.1);  color: #34d399; }
.item-status.partial     { background: rgba(245,158,11,0.1);  color: #fbbf24; }

/* ===== PILLS & BADGES ===== */
.pill, .badge {
  display: inline-flex; align-items: center; border-radius: 6px;
  padding: 3px 8px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--surface-3); color: var(--muted); white-space: nowrap;
}
.badge.PENDENTE,      .pill.danger   { background: rgba(239,68,68,0.1);   color: #f87171; }
.badge.ENTREGUE_PARCIAL,.pill.warn   { background: rgba(245,158,11,0.1);  color: #fbbf24; }
.badge.ENTREGUE_TOTAL,.pill.success  { background: rgba(16,185,129,0.1);  color: #34d399; }
.badge.NAO_APLICAVEL, .pill.info     { background: rgba(59,130,246,0.1);  color: #60a5fa; }
.badge.RETIFICACAO                   { background: rgba(232,89,12,0.1);   color: var(--primary-light); }

/* ===== SELECTED CONTEXT ===== */
.selected-context {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: var(--primary-bg); border: 1px solid rgba(232,89,12,0.22);
  border-left: 3px solid var(--primary); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 14px;
}

/* ===== SYNC PANEL ===== */
.sync-panel {
  border-left: 3px solid var(--primary); padding: 16px;
  margin-bottom: 20px; box-shadow: var(--shadow);
}
.sync-panel.success   { border-left-color: var(--success); }
.sync-panel.error     { border-left-color: var(--danger); }
.sync-panel.cancelled { border-left-color: var(--warning); }
/* #solicitationPanel agora tambem e .modal-card (virou modal); a borda-tarja
   colorida a esquerda precisa vencer o border padrao do modal-card. */
#solicitationPanel.sync-panel { border-left-width: 3px; border-left-color: var(--primary); }
#solicitationPanel.sync-panel.success   { border-left-color: var(--success); }
#solicitationPanel.sync-panel.error     { border-left-color: var(--danger); }
#solicitationPanel.sync-panel.cancelled { border-left-color: var(--warning); }
.sync-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.sync-title { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--text-bright); }
.sync-grid { display: grid; grid-template-columns: repeat(4, minmax(120px,1fr)); gap: 10px; }
.metric {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.metric strong {
  display: block; font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--text-bright); margin-bottom: 3px;
}
.metric span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.sync-bar { height: 3px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.sync-bar-fill {
  height: 100%; width: 40%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  animation: syncMove 1.4s infinite cubic-bezier(0.4,0,0.6,1);
}
.sync-panel.success  .sync-bar-fill { width: 100%; background: var(--success);  animation: none; }
.sync-panel.error    .sync-bar-fill { width: 100%; background: var(--danger);   animation: none; }
.sync-panel.cancelled.sync-bar-fill { width: 100%; background: var(--warning);  animation: none; }
@keyframes syncMove { 0% { transform: translateX(-150%); } 100% { transform: translateX(350%); } }

/* ===== MODALS ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(9,13,24,0.88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; place-items: center; padding: 20px; z-index: 200;
  animation: mFadeIn var(--t) var(--ease);
}
@keyframes mFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: min(780px,100%); max-height: 88vh; overflow: auto; padding: 24px;
  background: var(--surface); border: 1px solid var(--line-bright);
  border-radius: var(--radius-lg);
  box-shadow: 0 28px 72px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.04);
  animation: mSlideUp 200ms cubic-bezier(0.34,1.56,0.64,1);
}
.modal-card.wide { width: min(1000px,100%); }
.modal-card.full { width: min(1380px,100%); max-height: 93vh; }
@keyframes mSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
.modal-head {
  display: flex; justify-content: space-between; gap: 14px; align-items: center;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  color: var(--text-bright); letter-spacing: -0.02em;
}

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(180px,1fr)); gap: 12px; }
.checks {
  max-height: 240px; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface-2); padding: 8px;
  position: relative;
}
.check-row {
  display: flex; gap: 10px; align-items: center; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; font-size: 13px;
  transition: background var(--t) var(--ease);
  margin: 0; color: var(--text); text-transform: none; letter-spacing: normal; font-weight: 500;
}
.check-row:hover { background: var(--surface-3); }
.check-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.top-actions { justify-content: flex-end; }

/* ===== ENTITY & COMPACT CARDS ===== */
.root-item, .compact-item, .link-box, .item-info, .entity-card, .structure-row, .subtle-band {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 12px; word-break: break-word;
}
.entity-list { display: grid; gap: 6px; }
.entity-card { display: grid; gap: 6px; cursor: pointer; transition: all var(--t) var(--ease); }
.entity-card:hover { border-color: var(--line-bright); background: var(--surface-3); }
.entity-card.active {
  border-color: var(--primary); background: var(--primary-bg);
  box-shadow: 0 0 0 1px var(--primary-glow);
}
.subtle-band { margin: 14px 0; }
.subtle-band h3, .structure-layout h3 {
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  color: var(--text-bright); margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.06em;
}
.root-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; }
.structure-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; box-shadow: none; }
.compact-item { cursor: pointer; transition: all var(--t) var(--ease); }
.compact-item:hover { background: var(--surface-3); border-color: var(--line-bright); }

/* ===== NAME GATE ===== */
.name-gate {
  /* Cartão no topo (cerca de 10% da altura da tela), centralizado só na horizontal */
  min-height: 100vh; display: grid; justify-items: center; align-content: start; padding: 10vh 20px 20px;
  background: var(--bg);
  background-image: radial-gradient(ellipse 60% 60% at 50% 40%, rgba(232,89,12,0.07) 0%, transparent 60%);
}
.name-card {
  width: min(460px,100%); padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: 0 32px 72px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
}
.name-card h1 {
  font-family: var(--font-display); font-size: 22px; font-weight: 800;
  color: var(--text-bright); margin-bottom: 8px; letter-spacing: -0.02em;
}

.auth-error {
  color: #f87171; font-size: 12px; margin: 6px 0 2px; font-weight: 500;
}
.link-btn {
  background: none; border: none; color: var(--muted); font-size: 12px;
  cursor: pointer; padding: 6px 0; text-align: center; width: 100%;
  transition: color var(--t) var(--ease);
}
.link-btn:hover { color: var(--text); }

/* ===== TOAST ===== */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 400;
  background: var(--surface-2); color: var(--text-bright);
  border: 1px solid var(--line-bright); border-radius: var(--radius);
  padding: 13px 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  max-width: 440px; font-size: 13px; font-weight: 600;
  animation: toastIn 200ms cubic-bezier(0.4,0,0.2,1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px) translateY(8px); }
  to   { opacity: 1; transform: translateX(0)     translateY(0); }
}

/* ===== VIEW FILES MODAL ===== */
.view-file-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
}
.view-file-row:last-child { border-bottom: none; }
.view-file-row .button-link { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== UPLOAD SPINNER ===== */
.upload-spinner {
  position: fixed; right: 20px; bottom: 20px; z-index: 401;
  background: var(--surface-2); color: var(--text-bright);
  border: 1px solid var(--line-bright); border-radius: var(--radius);
  padding: 13px 18px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  font-size: 13px; font-weight: 600;
  animation: toastIn 200ms cubic-bezier(0.4,0,0.2,1);
}
.spinner-ring {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 2px solid var(--line-bright);
  border-top-color: #f97316;
  border-radius: 50%;
  animation: spinRing 0.7s linear infinite;
}
@keyframes spinRing { to { transform: rotate(360deg); } }

/* ===== CENTER LOADER (overlay centralizado) ===== */
.center-loader {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
  animation: mFadeIn 150ms ease;
}
.center-loader-card {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: var(--surface-2); color: var(--text-bright);
  border: 1px solid var(--line-bright); border-radius: var(--radius);
  padding: 28px 40px; box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  font-size: 14px; font-weight: 600; text-align: center;
}
.center-loader-ring {
  width: 44px; height: 44px; flex-shrink: 0;
  border: 4px solid var(--line-bright);
  border-top-color: #f97316;
  border-radius: 50%;
  animation: spinRing 0.7s linear infinite;
}

/* ===== PAGE OVERLAY ===== */
.page-overlay {
  position: fixed; inset: 0; background: var(--bg);
  z-index: 150; display: flex; flex-direction: column; overflow: hidden;
}
.page-overlay-header {
  background: rgba(9,13,24,0.98); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); padding: 0 24px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; height: 60px;
}
.page-overlay-header h2 {
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--text-bright); flex: 1; letter-spacing: -0.01em;
}
.page-overlay-body { flex: 1; overflow: auto; padding: 24px; }

/* ===== STRUCTURE TREE ===== */
.struct-tree { display: grid; gap: 3px; }
.tree-node {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color var(--t) var(--ease);
}
.tree-node:hover { border-color: var(--line-bright); }
.tree-node.overdue { border-color: rgba(239,68,68,0.28); background: rgba(239,68,68,0.03); }
/* Item marcado como N/A: texto em cinza claro (igual ao painel do cliente) */
.tree-node.tree-na .tree-label { opacity: 0.5; }
.tree-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: default;
  border-radius: calc(var(--radius-sm) - 1px);
  transition: background var(--t) var(--ease);
}
.tree-row:hover { background: var(--surface-2); }
.tree-toggle {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--muted);
  border-radius: 4px; transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.tree-label { flex: 1; font-size: 13px; color: var(--text); line-height: 1.4; }
.tree-label strong { font-weight: 600; color: var(--text-bright); }
.tree-label .tree-tipo {
  font-size: 10px; color: var(--muted); margin-left: 8px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--surface-3); padding: 2px 6px; border-radius: 4px;
}
.tree-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity var(--t) var(--ease); }
.tree-row:hover .tree-actions { opacity: 1; }
.tree-children {
  padding-left: 20px; display: grid; gap: 3px;
  margin: 3px 3px 4px 0; position: relative;
}
.tree-children::before {
  content: ''; position: absolute; left: 9px; top: 0; bottom: 0;
  width: 1px; background: var(--line);
}
.tree-edit-area {
  border-top: 1px solid var(--line); padding: 14px;
  background: var(--surface-2);
  border-radius: 0 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px);
}
.tree-edit-area .form-grid { margin-top: 8px; }
.tree-node.detail-hidden { display: none !important; }

/* ===== SOL GROUP CARDS ===== */
.sol-col { display: grid; gap: 6px; }
.sol-group-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); padding: 12px 14px; cursor: pointer;
  transition: all var(--t) var(--ease);
}
.sol-group-card:hover { border-color: var(--line-bright); background: var(--surface-2); transform: translateX(2px); }
.sol-group-card.concluded { opacity: 0.48; }
.sol-group-card .sg-title { font-size: 13px; font-weight: 700; color: var(--text-bright); margin-bottom: 3px; }
.sol-group-card .sg-meta { color: var(--muted); font-size: 11px; }
.sg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sg-alert-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.65);
  background: rgba(245, 158, 11, 0.22);
  color: #facc15;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  animation: sgWarnPulse 1.1s ease-in-out infinite;
}
@keyframes sgWarnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.28); opacity: 1; }
  50% { box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.04); opacity: 0.78; }
}
.sg-obs-alert-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.65);
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: default;
  animation: sgObsPulse 1.1s ease-in-out infinite;
}
@keyframes sgObsPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.35); opacity: 1; }
  50% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.05); opacity: 0.75; }
}

.deadline-ext-list { display: grid; gap: 8px; }
.deadline-ext-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
}
.deadline-ext-row .title { font-size: 13px; font-weight: 700; color: var(--text-bright); }
.deadline-ext-row .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.deadline-ext-row .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ===== SEND CARDS ===== */
.send-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); padding: 12px 14px;
}
.send-card .send-name { font-weight: 700; font-size: 13px; color: var(--text-bright); }
.send-card .send-meta { color: var(--muted); font-size: 11px; margin-top: 3px; }
.send-card .send-actions { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }

/* ===== INLINE OBS ===== */
.inline-obs { display: flex; gap: 6px; align-items: center; }
.inline-obs input { flex: 1; }
.inline-obs button { flex-shrink: 0; }
.inline-extension { display: flex; gap: 6px; align-items: center; }
.inline-extension input { min-width: 150px; width: 170px; }
.action-point {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin-right: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.deleg-global-dash {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  margin: 12px 0 10px;
}
.deleg-global-header {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 10px 12px;
}
.deleg-global-title { font-size: 12px; font-weight: 800; color: var(--text-bright); text-transform: uppercase; letter-spacing: 0.05em; }
.deleg-global-totals { display: inline-flex; gap: 8px; flex-wrap: wrap; }

.group-ext-alerts {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.group-ext-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
}
.group-ext-card .ext-main { font-size: 13px; color: var(--text-bright); }
.group-ext-card .ext-meta { margin-top: 4px; font-size: 12px; color: var(--muted); }
.group-ext-card .ext-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== ENTITY SOL SECTION ===== */
/* Cada OSS/empresa unica e um bloco separado, com faixa de cabecalho clicavel (recolhe/expande) */
.entity-sol-section {
  margin-bottom: 22px; background: var(--surface-2); border: 1px solid var(--line-bright);
  border-left: 4px solid var(--primary); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.entity-sol-header {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  font-family: var(--font-display); font-size: 16px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  color: #fff; background: var(--surface-3); border: 0; border-bottom: 1px solid var(--line-bright);
  border-radius: 0; padding: 12px 14px;
}
.entity-sol-header:hover { background: var(--surface-hover); }
.entity-sol-header::before { content: '\25BE'; color: var(--primary-light); font-size: 14px; }
.entity-sol-section.collapsed .entity-sol-header { border-bottom: 0; }
.entity-sol-section.collapsed .entity-sol-header::before { content: '\25B8'; }
.entity-sol-body { padding: 10px; }
.entity-sol-section.collapsed .entity-sol-body { display: none; }
html[data-theme="light"] .entity-sol-header { color: var(--text-bright); }

/* ===== DETAIL TABS ===== */
.detail-unit-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.detail-tab-btn {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 6px 14px; font-size: 11px; font-weight: 800;
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.05em;
  transition: all var(--t) var(--ease);
}
.detail-tab-btn:hover { background: var(--surface-3); border-color: var(--line-bright); color: var(--text); }
.detail-tab-btn.active {
  background: var(--primary-bg); color: var(--primary-light);
  border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary-glow);
}
.detail-stats {
  font-size: 11px; color: var(--muted); font-weight: 700; font-family: var(--font-display);
  margin-left: auto; flex-shrink: 0; white-space: nowrap;
  background: var(--surface-3); padding: 3px 8px; border-radius: 6px;
}
.detail-stats-parent { background: var(--info); color: #fff; }
.detail-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.detail-filter-input  { flex: 1 1 180px; min-width: 140px; padding: 7px 10px; font-size: 13px; }
.detail-filter-select { flex: 0 0 auto; width: auto; min-width: 140px; padding: 7px 10px; font-size: 13px; }

/* Selecao/exclusao em massa de itens: visivel apenas ao usuario master logado. */
/* Seleção de itens liberada para todos os admins (retificação em lote);
   apenas o botão de apagar continua restrito ao usuário master. */
.detail-item-check { display: inline-block; }
#groupDetailBulkDeleteBar { display: flex; }
#detailDeleteSelectedBtn { display: none; }
body.is-master-user #detailDeleteSelectedBtn { display: inline-block; }


/* ===== COMPANY DASHBOARD ===== */
.company-dashboard { display: flex; flex-direction: column; margin-bottom: 16px; }
/* Grade das empresas dentro do bloco de cada OSS/empresa unica */
.dashboard-entity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px,1fr)); gap: 8px; align-items: start; }
.dashboard-entity { display: contents; }
.dashboard-unit-item {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px;
  transition: all var(--t) var(--ease);
  cursor: pointer; text-align: left; width: 100%; white-space: normal;
  font: inherit; color: inherit;
}
.dashboard-unit-item:hover { border-color: var(--primary); transform: translateY(-1px); }
.dashboard-unit-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dashboard-unit-name { font-size: 12px; font-weight: 700; color: var(--text-bright); }
.dashboard-unit-pct { font-family: var(--font-display); font-size: 15px; font-weight: 800; }
.dashboard-unit-alerts { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.dashboard-progress-bar { height: 4px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.dashboard-progress-fill { height: 100%; border-radius: 99px; transition: width 0.7s cubic-bezier(0.4,0,0.2,1); }
.dashboard-unit-stats { font-size: 11px; color: var(--muted); }
.dashboard-entity-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); padding: 2px 0 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.dashboard-entity-stats {
  font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: normal;
  color: var(--text);
}

/* ===== CLIENT CARDS ===== */
.client-card { padding: 12px 14px; cursor: pointer; transition: all var(--t) var(--ease); box-shadow: none; }
.client-card.active { border-color: var(--primary); background: var(--primary-bg); box-shadow: 0 0 0 1px var(--primary-glow); }
.client-card:hover { border-color: var(--line-bright); }
.client-name { font-weight: 700; color: var(--text-bright); margin-bottom: 5px; }
.client-access-link {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  display: grid; gap: 6px; cursor: default;
}
.client-access-link span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.client-access-link a { display: block; font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.client-access-link button { justify-self: start; }

/* ===== INDENT ===== */
.indent-1 { padding-left: 0; }
.indent-2 { padding-left: 16px; }
.indent-3 { padding-left: 32px; }
.indent-4 { padding-left: 48px; }
.indent-5 { padding-left: 64px; }

/* ===== DUE ITEM ===== */
.due-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); padding: 10px; font-size: 13px; }

/* ===== STRUCTURE LAYOUT ===== */
.structure-layout { display: grid; grid-template-columns: minmax(320px,.9fr) minmax(420px,1.1fr); gap: 14px; margin-top: 14px; align-items: start; }
.structure-list { display: grid; gap: 6px; }
.struct-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.struct-controls select { width: auto; min-width: 200px; }

/* ===== BUTTON LINK ===== */
.button-link {
  display: inline-flex; align-items: center;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 5px 10px; font-size: 12px; font-weight: 600;
  text-decoration: none; white-space: nowrap; transition: all var(--t) var(--ease);
}
.button-link:hover { background: var(--surface-3); border-color: var(--line-bright); color: var(--text-bright); }
.button-link.small { padding: 4px 8px; font-size: 11px; }

/* ===== COMPANY FILTER BAR ===== */
.company-filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.company-filter-bar select { padding: 6px 8px; font-size: 12px; min-width: 130px; }
@media (max-width: 720px) {
  .company-filter-bar { width: 100%; }
  .company-filter-bar select { flex: 1 1 auto; }
}

/* ===== ITEM FILTER BAR ===== */
.item-filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.item-filter-bar input  { flex: 1 1 180px; min-width: 140px; padding: 7px 10px; font-size: 13px; }
.item-filter-bar select { flex: 0 0 auto; width: auto; min-width: 160px; padding: 7px 10px; font-size: 13px; }
.item-filter-bar #itemFilterStatus { display: none; }
.status-filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.status-filter-btn.active {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary-light);
}
.deleg-resp-dash {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.deleg-resp-card {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: grid;
  gap: 2px;
}
.deleg-resp-card strong {
  color: var(--text-bright);
  font-size: 12px;
}
.filter-count {
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--surface-3); padding: 3px 8px; border-radius: 6px;
  white-space: nowrap; font-family: var(--font-display);
}
.item-new-count {
  font-size: 11px; font-weight: 800; color: #fff;
  background: #16a34a; padding: 3px 9px; border-radius: 999px;
  white-space: nowrap; font-family: var(--font-display);
  box-shadow: 0 0 8px rgba(22,163,74,0.55);
}
.item-novo-badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  color: #052e16; background: #4ade80;
  padding: 1px 7px; border-radius: 999px;
  box-shadow: 0 0 8px rgba(74,222,128,0.7);
  animation: novo-pulse 2s ease-in-out infinite;
}
@keyframes novo-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(74,222,128,0.55); }
  50%      { box-shadow: 0 0 14px rgba(74,222,128,0.95); }
}
@media (max-width: 700px) {
  .item-filter-bar { flex-direction: column; align-items: stretch; }
  .item-filter-bar input,
  .item-filter-bar select,
  .status-filter-group { width: 100%; }
  .status-filter-group .status-filter-btn { flex: 1 1 calc(50% - 6px); }
}

/* ===== OPERADOR + LOGS ===== */
.check-inline {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  margin: 8px 0 4px; cursor: pointer;
}
.check-inline input { width: auto; margin: 0; }
.logs-filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 12px;
}
.logs-filter-bar input[type="text"] { min-width: 160px; }
.logs-date { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.logs-table-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.logs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.logs-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel); text-align: left;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  font-weight: 700; white-space: nowrap;
}
.logs-table tbody td {
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  vertical-align: top; word-break: break-word;
}
.logs-table tbody tr:hover { background: rgba(125,125,125,0.06); }
.logs-table td:first-child { white-space: nowrap; color: var(--muted); font-size: 12px; }
.log-acao {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
  background: rgba(59,130,246,0.12); color: #60a5fa; white-space: nowrap;
}

/* ===== MENUS SUSPENSOS (topbar) ===== */
.menu-group { position: relative; display: inline-block; }
.menu-trigger { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.menu-trigger .caret { font-size: 10px; opacity: 0.85; }
.menu-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  min-width: 230px; display: flex; flex-direction: column; gap: 2px;
  padding: 6px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line-bright);
  box-shadow: 0 14px 32px rgba(0,0,0,0.30);
}
.menu-dropdown.align-right { left: auto; right: 0; }
.menu-dropdown .menu-item {
  width: 100%; text-align: left; justify-content: flex-start;
  background: transparent; border: none; padding: 9px 12px;
  border-radius: 8px; font-size: 14px; color: var(--text); cursor: pointer;
  white-space: nowrap;
}
.menu-dropdown .menu-item:hover { background: rgba(125,125,125,0.14); }

/* ===== DELEGATION STYLES ===== */
.delegation-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.25);
  color: #60a5fa;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 10px;
}
.delegation-banner svg { flex-shrink: 0; }
.delegation-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(59,130,246,0.1);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.2);
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding: 6px 0;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
#delegationItemList .delegation-check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 6px;
  transition: background var(--t);
}
#delegationItemList .delegation-check-row:hover { background: var(--surface-hover); }
#delegationItemList .delegation-check-row label {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  flex: 1;
}
#delegationItemList .delegation-check-row input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
#delegationItemList .indent-1 { padding-left: 0; }
#delegationItemList .indent-2 { padding-left: 16px; }
#delegationItemList .indent-3 { padding-left: 32px; }
#delegationItemList .indent-4 { padding-left: 48px; }
#delegationItemList .indent-5 { padding-left: 64px; }
#delegationItemList .deleg-folder-label { font-weight: 600; color: var(--text); }
#delegationItemList .deleg-leaf-label { color: var(--muted); }
.deleg-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.deleg-form-row input { width: 100%; }
.deleg-selectall-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.deleg-selectall-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px; height: 15px;
  cursor: pointer;
}
.export-filter-group {
  margin-bottom: 16px;
}
.export-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.export-check-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  max-height: 160px;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.export-check-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  background: var(--surface);
}
.export-check-row input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px; height: 14px;
  cursor: pointer;
}
.deleg-link-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface-2);
  flex-wrap: wrap;
}
.deleg-link-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.deleg-link-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  min-width: 0;
}
.deleg-link-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.deleg-link-actions a { text-decoration: none; }
@media (max-width: 600px) {
  .deleg-form-row { grid-template-columns: 1fr; }
}

/* ===== DELEGATION MATRIX (modal "Dividir Tarefas") ===== */
#delegMatrixModal.modal { padding: 10px 6px; }
.deleg-matrix-modal-card {
  display: flex; flex-direction: column; overflow: hidden;
  width: 100%; max-width: 100%; height: 100%; max-height: 100%;
  padding: 16px 10px;
}
.deleg-matrix-toolbar { flex: 0 0 auto; }
.deleg-matrix-toolbar .deleg-form-row { margin: 0 0 10px; }
.deleg-matrix-search-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.deleg-matrix-search-row input[type="search"] {
  flex: 1 1 260px; min-width: 200px;
}
.deleg-matrix-wrap {
  flex: 1 1 auto; min-height: 0; margin-top: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: auto; background: var(--surface);
}
.deleg-matrix-table {
  border-collapse: separate; border-spacing: 0;
  width: max-content; font-size: 13px;
}
.deleg-matrix-table th, .deleg-matrix-table td {
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: 0;
}
.deleg-matrix-table thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2); color: var(--text-bright);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.deleg-matrix-table th.matrix-corner {
  position: sticky; left: 0; top: 0; z-index: 4;
  background: var(--surface-2); text-align: left; padding: 8px 12px;
  width: 280px; max-width: 280px;
}
.deleg-matrix-table th.matrix-unit-col {
  writing-mode: vertical-rl; transform: rotate(180deg);
  text-align: left; height: 120px; white-space: nowrap; padding: 8px 6px;
}
.deleg-matrix-table th.matrix-unit-col label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.deleg-matrix-table .matrix-row-head {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface); text-align: left; padding: 6px 12px;
  width: 280px; max-width: 280px; white-space: normal; overflow-wrap: anywhere;
}
.deleg-matrix-table .matrix-row-head label {
  display: flex; align-items: flex-start; gap: 8px; cursor: pointer; color: var(--text);
}
.deleg-matrix-table .matrix-row-head input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }
.deleg-matrix-table .matrix-cell {
  text-align: center; width: 46px; min-width: 46px; height: 38px; position: relative;
}
.deleg-matrix-table .matrix-cell.disabled { background: var(--surface-2); color: var(--muted); }
.deleg-matrix-table .matrix-cell input[type="checkbox"] {
  accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer;
}
.deleg-matrix-table tr.row-hover td { background: rgba(232,89,12,0.16); }
.deleg-matrix-table td.col-hover, .deleg-matrix-table th.col-hover { background: rgba(232,89,12,0.16); }
.deleg-matrix-table tr.row-hover td.col-hover { background: rgba(232,89,12,0.32); }
.deleg-matrix-table .matrix-cell.other-person::after {
  content: ''; position: absolute; top: 4px; right: 4px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--warning);
}
.deleg-matrix-table.hide-delegated .matrix-cell.other-person {
  opacity: 0.28; pointer-events: none;
}
.deleg-matrix-table.hide-delegated .matrix-cell.other-person input[type="checkbox"] { visibility: hidden; }
#delegMatrixHideDelegatedBtn.active { border-color: var(--primary); background: var(--primary-bg); color: var(--primary-light); }
@media (max-width: 720px) {
  .deleg-matrix-search-row { flex-direction: column; align-items: stretch; }
}

/* ===== PREVIOUS GROUPS ===== */
#previousGroupsSection { margin-top: 16px; }
#previousGroupCards   { margin-top: 8px; }
#togglePreviousBtn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; font-weight: 600; width: 100%; text-align: left;
  padding: 7px 12px; border-radius: var(--radius-sm); justify-content: flex-start;
}
#togglePreviousBtn:hover { background: var(--surface-2); color: var(--text); border-color: var(--line-bright); }
#structureAddRootBtn { margin-bottom: 14px; }
#structurePageMsg    { margin-bottom: 10px; }
#structureEntityPage { min-width: 200px; }

/* ===== AUTH PANEL ===== */
#authPanel.panel { text-align: center; padding: 48px 32px; }
#authPanel h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--text-bright); margin-bottom: 8px; }

/* ===== DETAIL SOL LEAF ===== */
.detail-sol-leaf { padding-left: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .grid { grid-template-columns: minmax(0,1fr); }
  .structure-layout { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr; }
  .grid.client-view .item-row { grid-template-columns: 1fr; }
  .item-actions, .grid.client-view .item-actions { justify-content: flex-start; }
  .item-tracking { gap: 6px; }
}
@media (max-width: 700px) {
  .topbar { height: auto; padding: 12px 16px; align-items: flex-start; flex-direction: column; gap: 10px; }
  .top-actions { justify-content: flex-start; flex-wrap: wrap; }
  .content { padding: 14px 16px; }
  .stats, .form-grid, .sync-grid { grid-template-columns: 1fr; }
  .unit-grid { grid-template-columns: 1fr; }
  .selected-context { align-items: flex-start; flex-direction: column; }
  .root-item, .structure-row { grid-template-columns: 1fr; }
  .item-actions input { width: 100%; }
  .observation-entry { width: 100%; grid-template-columns: 1fr; }
  .modal { padding: 10px; }
  .modal-card { padding: 16px; border-radius: var(--radius); }
  .page-overlay-body { padding: 14px; }
  .detail-toolbar { flex-direction: column; align-items: stretch; }
  .detail-filter-input, .detail-filter-select { width: 100%; }
}

/* ===== MOBILE (celular, ate 700px) ===== */
.menu-toggle-btn { display: none; }
@media (max-width: 700px) {
  /* Blocos de grade precisam poder encolher (causa do estouro lateral) */
  .grid > *, .panel, .panel-title > * { min-width: 0; }

  /* Topo: nome + botao de menu; os botoes abrem em lista vertical */
  .topbar { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; gap: 8px; }
  .brand { flex: 1 1 0; min-width: 0; }
  .brand h1 { font-size: 14px; line-height: 1.2; }
  .brand p { line-height: 1.3; overflow-wrap: anywhere; }
  .menu-toggle-btn { display: inline-flex; flex-shrink: 0; width: 42px; height: 42px; padding: 0; font-size: 20px; }
  .top-actions { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 6px; }
  .topbar.menu-open .top-actions { display: flex; }
  .top-actions > button, .top-actions > a, .menu-trigger { width: 100%; justify-content: flex-start; min-height: 42px; }
  .menu-group { display: block; }
  .menu-dropdown { position: static; min-width: 0; margin-top: 4px; box-shadow: none; }
  .menu-dropdown .menu-item { white-space: normal; min-height: 42px; }
  .topbar-divider { display: none; }
  .theme-btn { width: 100%; }

  /* Administracao: filtros, faixas das OSS e cards das empresas */
  .panel-title { flex-direction: column; align-items: stretch; }
  .company-filter-bar { width: 100%; }
  .company-filter-bar select { flex: 1 1 100%; min-width: 0; font-size: 16px; }
  .entity-sol-header { flex-wrap: wrap; row-gap: 2px; padding: 10px 12px; font-size: 15px; white-space: normal; }
  .dashboard-entity-stats { flex-basis: 100%; font-size: 11px; }
  .entity-sol-body { padding: 8px; }
  .dashboard-entity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .dashboard-unit-item { padding: 10px; }
  .dashboard-unit-name { overflow-wrap: anywhere; }

  /* Cliente: empresas em chips que rolam na horizontal; itens em cartoes */
  .unit-grid { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
  .unit-button { flex: 0 0 auto; min-width: 150px; max-width: 70vw; min-height: 56px; }
  .item-row { padding: 12px; }
  .item-actions { gap: 6px; }
  .item-actions > button, .item-actions > .action-point { flex: 1 1 auto; }
  /* Colunas da lista/itens precisam poder encolher (1fr nao encolhe abaixo do conteudo) */
  .item-list { grid-template-columns: minmax(0, 1fr); }
  .item-row, .grid.client-view .item-row { grid-template-columns: minmax(0, 1fr); }
  .item-row > * { min-width: 0; }
  .item-heading, .item-path, .item-meta { overflow-wrap: anywhere; min-width: 0; }
  .deleg-global-dash { grid-template-columns: minmax(0, 1fr); }

  /* Modais: largura da tela e rolagem interna */
  .modal-card, .modal-card.wide, .modal-card.full { width: 100%; max-height: 92vh; }
  .modal-head { flex-direction: column; align-items: stretch; }
  .modal-head .row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .modal-head .detail-filter-select { max-width: none !important; width: 100%; }

  /* Acompanhamento da solicitacao: filtros e arvore de itens */
  .detail-toolbar > * { flex: 0 0 auto; }
  .tree-row { flex-wrap: wrap; row-gap: 6px; }
  .tree-label { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
  .tree-actions { opacity: 1; } /* no toque nao existe hover */
  .tree-row .detail-filter-select { flex: 1 1 140px; min-width: 0; width: auto; }
  .tree-children { padding-left: 12px; }

  /* Toque: alvos maiores e campos sem zoom automatico no iPhone */
  button { min-height: 40px; }
  button.small { min-height: 36px; }
  input, select, textarea { font-size: 16px; }
}

/* ── Acesso por usuario: vinculos, destinatarios e escolha da solicitacao ── */
.cu-links { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow: auto; padding: 4px 2px; }
.cu-oss { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.cu-oss-head { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.cu-oss-body { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.cu-oss-body label { display: flex; align-items: flex-start; gap: 8px; }
.cu-companies { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0 0 4px; }
.cu-company { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.recipient-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 4px; }
.recipient-pick { display: flex; align-items: center; gap: 10px; cursor: pointer; flex: 1; min-width: 200px; }
.recipient-deleg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.client-access-item { text-align: left; margin-bottom: 8px; padding: 12px 14px; }

/* Meses da tela inicial do cliente: card com barra de progresso */
.month-cards { margin: 12px 0; }
.month-head { margin-bottom: 10px; }
.month-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.month-card { display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: left; padding: 12px 14px; font-size: 13px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px; color: var(--text-bright); cursor: pointer; }
.month-card:hover { border-color: var(--line-bright); }
.month-card.active { border-color: var(--primary); background: var(--primary-bg); }
.month-card strong { font-size: 15px; }
.month-bar { display: block; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.month-bar-fill { display: block; height: 100%; background: #10b981; border-radius: 99px; }
.month-late { color: #ef4444; font-weight: 700; }

/* Card da empresa no painel do administrador: linhas por mes */
.dashboard-unit-card { cursor: default; text-align: left; }
.dashboard-month-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 8px; }
.dashboard-month-row { display: grid; grid-template-columns: 56px minmax(50px, 1fr) auto; align-items: center; gap: 4px 10px; text-align: left; padding: 6px 10px; font-size: 12px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; color: var(--text-bright); cursor: pointer; }
.dashboard-month-row:hover { border-color: var(--line-bright); }
.dashboard-month-row > :nth-child(4) { grid-column: 2; }
.dashboard-month-row > :nth-child(5) { grid-column: 3; text-align: right; }
.dashboard-all-btn { margin-top: 2px; }
