/* ══════════════════════════════════════════════════════════════════════
   GiacoCalc Admin CMS – Styles
══════════════════════════════════════════════════════════════════════ */
:root {
  --red:       #C00000;
  --red-dark:  #8C0000;
  --red-grad:  linear-gradient(135deg,#C00000,#8C0000);
  --sidebar-bg:#F8FAFC;
  --sidebar-w: 240px;
  --white:     #FFFFFF;
  --bg:        #F3F5F9;
  --border:    #E4E8EF;
  --font:      'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  --shadow-md: 0 4px 16px rgba(0,0,0,.07),0 1px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 32px rgba(0,0,0,.10),0 2px 8px rgba(0,0,0,.06);
  --r-md:      10px;
  --r-lg:      14px;
}
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: #111827;
  display: flex;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  box-shadow: 1px 0 0 rgba(16,24,40,.02);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid #E9EDF3;
}
.sidebar-logo-mark {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--red-grad);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900;
  flex-shrink: 0;
}
.sidebar-logo-name { font-size: 15px; font-weight: 800; color: #0F172A; line-height: 1.2; }
.sidebar-logo-sub  { font-size: 10px; color: #64748B; margin-top: 2px; }
.sidebar-logo-name-large { font-size: 26px; font-weight: 800; color: #0F172A; text-align: center; padding: 20px 0; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* ── Navegação: botões com relevo, acento e resposta ao cursor/toque ───────── */
.snav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border: 1px solid #E7EBF1;
  background: #FFFFFF;
  color: #475569;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  border-radius: 11px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  /* relevo subtil sobre fundo claro */
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  transition: background .18s, color .18s, border-color .18s,
              transform .12s cubic-bezier(.2,.8,.2,1), box-shadow .18s;
}
/* barra de acento à esquerda (aparece ao passar / no ativo) */
.snav-item::before {
  content: ''; position: absolute; left: -1px; top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px; height: 58%; border-radius: 0 3px 3px 0;
  background: #C00000; transition: transform .2s;
}
.snav-item:hover {
  background: #F1F4F9;
  color: #0F172A;
  border-color: #D7DEE9;
  transform: translateX(3px);
  box-shadow: 0 8px 18px -10px rgba(16,24,40,.30);
}
.snav-item:hover::before { transform: translateY(-50%) scaleY(1); }
.snav-item:active { transform: translateX(3px) scale(.985);
  box-shadow: inset 0 2px 4px rgba(16,24,40,.08); }
/* selecionado: gradiente Giacomini com relevo e brilho */
.snav-item.active {
  background: linear-gradient(135deg, #C00000, #8C0000);
  color: #fff; font-weight: 700;
  border-color: rgba(192,0,0,.5);
  box-shadow: 0 8px 20px -7px rgba(192,0,0,.5), inset 0 1px 0 rgba(255,255,255,.18);
}
.snav-item.active::before { background: #fff; transform: translateY(-50%) scaleY(1); }
.snav-item.active:hover { transform: none; }   /* o ativo não desliza */
/* ícone num "selo" com profundidade */
.snav-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px; font-size: 15px; flex-shrink: 0;
  background: #EEF1F6;
  box-shadow: inset 0 0 0 1px rgba(16,24,40,.04);
  transition: background .18s, box-shadow .18s, transform .18s;
}
.snav-item:hover .snav-icon { background: #E2E8F1; transform: scale(1.05); }
.snav-item.active .snav-icon {
  background: rgba(255,255,255,.22);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.30), 0 2px 6px -2px rgba(0,0,0,.25);
}
.snav-badge {
  margin-left: auto;
  background: #E9EDF3;
  color: #64748B;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
  box-shadow: inset 0 0 0 1px rgba(16,24,40,.03);
}
.snav-item.active .snav-badge { background: rgba(255,255,255,.22); color: #fff; box-shadow: none; }
@media (prefers-reduced-motion: reduce) {
  .snav-item, .snav-item:hover, .snav-item:active, .snav-icon { transform: none !important; }
}
@media (pointer: coarse) {
  .snav-item { padding: 13px 14px; }   /* alvo de toque confortável em tablet */
}

/* ── Hard Config (super-admin) ───────────────────────────────────────────── */
.sidebar-hardconfig {
  padding: 10px 12px 6px;           /* fica acima do LKCOM (nav tem flex:1) */
  border-top: 1px dashed #E4E8EF;
}
.snav-hardconfig {
  background: #FEF6E7;
  border: 1px solid #F0D48A;
  color: #92400E !important;
}
.snav-hardconfig:hover { background: #FDECC8; }
.snav-hardconfig.active { background: #FDE7BC; color: #7C3A06 !important; box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 8px 20px -8px rgba(217,119,6,.4); }
/* acento e selo do Hard Config em âmbar (não no vermelho da base) */
.snav-hardconfig::before { background: #D97706; }
.snav-hardconfig .snav-icon { background: #FBE6BF; }
.snav-hardconfig.active .snav-icon { background: rgba(217,119,6,.20); box-shadow: inset 0 0 0 1px rgba(217,119,6,.4); }
.snav-hc-tag {
  margin-left: auto;
  font-size: 9px; font-weight: 800; letter-spacing: 1px;
  background: #D97706; color: #1a1205;
  padding: 2px 6px; border-radius: 5px;
}

/* Painel de toggles (Hard Config) */
.hc-grid { display: flex; flex-direction: column; gap: 10px; }
.hc-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; background: #fff;
  border: 1px solid #E5E7EB; border-radius: 10px;
}
.hc-row.off { background: #F9FAFB; opacity: .85; }
.hc-row-icon { width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.hc-row-icon svg { width: 18px; height: 18px; }
.hc-ic-dashboard { color: #2563EB; background: color-mix(in srgb, #2563EB 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, #2563EB 24%, transparent); }
.hc-ic-users     { color: #C00000; background: color-mix(in srgb, #C00000 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, #C00000 24%, transparent); }
.hc-ic-calcs     { color: #059669; background: color-mix(in srgb, #059669 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, #059669 24%, transparent); }
.hc-ic-admins    { color: #7C3AED; background: color-mix(in srgb, #7C3AED 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, #7C3AED 24%, transparent); }
.hc-ic-mail      { color: #D97706; background: color-mix(in srgb, #D97706 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, #D97706 24%, transparent); }
.hc-ic-prices    { color: #0E7490; background: color-mix(in srgb, #0E7490 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, #0E7490 24%, transparent); }
.hc-ic-images    { color: #DB2777; background: color-mix(in srgb, #DB2777 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, #DB2777 24%, transparent); }
.hc-ic-bot       { color: #4F46E5; background: color-mix(in srgb, #4F46E5 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, #4F46E5 24%, transparent); }
.hc-row-info { flex: 1; min-width: 0; }
.hc-row-label { font-weight: 700; color: #1F2937; font-size: 14px; }
.hc-row-desc  { font-size: 12px; color: #6B7280; margin-top: 2px; }
.hc-row-state { font-size: 11px; font-weight: 800; letter-spacing: .5px; min-width: 64px; text-align: right; }
.hc-row.on  .hc-row-state { color: #059669; }
.hc-row.off .hc-row-state { color: #9CA3AF; }
/* switch */
.hc-switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.hc-switch input { opacity: 0; width: 0; height: 0; }
.hc-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #CBD5E1; border-radius: 26px; transition: background .2s;
}
.hc-slider::before {
  content: ''; position: absolute; height: 20px; width: 20px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.hc-switch input:checked + .hc-slider { background: #059669; }
.hc-switch input:checked + .hc-slider::before { transform: translateX(20px); }
.hc-switch input:disabled + .hc-slider { opacity: .5; cursor: wait; }

/* ── Design da Frente (Hard Config): 2 seletores, computador vs toque ──────── */
.hc-design-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .hc-design-grid { grid-template-columns: 1fr; } }
.hc-design-card {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: #fff; border: 1px solid #E5E7EB; border-radius: 10px;
}
.hc-design-ic { font-size: 22px; flex: 0 0 auto; }
.hc-design-lbl { flex: 1; min-width: 0; font-weight: 700; color: #1F2937; font-size: 13.5px; }
.hc-design-select {
  flex: 0 0 auto; height: 38px; border-radius: 8px; border: 1px solid #D1D5DB;
  background: #F9FAFB; padding: 0 10px; font-size: 13px; font-weight: 600; color: #1F2937; cursor: pointer;
}
.hc-design-select:focus { outline: none; border-color: #C00000; }

/* ── LKCOM branding ──────────────────────────────────────────────────────── */
.sidebar-lkcom {
  padding: 14px 20px 10px;
  border-top: 1px solid #E9EDF3;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.lkcom-label {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #94A3B8;
  margin-bottom: 8px;
  line-height: 1.4;
}
.lkcom-logo-link {
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: .85;
  transition: opacity .2s, transform .2s;
  text-decoration: none;
}
.lkcom-logo-link:hover {
  opacity: 1;
  transform: scale(1.04);
}
.lkcom-svg {
  /* Wordmark novo (rácio ~3.8:1) — o logótipo antigo era compacto e 45px
     chegavam; a esta largura o wordmark ficaria com ~12px de altura. */
  width: 108px;
  height: auto;
  display: block;
}

/* ── Sidebar footer ──────────────────────────────────────────────────────── */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #E9EDF3;
}
.sf-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--red-grad);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.sf-info { flex: 1; min-width: 0; }
.sf-name  { font-size: 12px; font-weight: 700; color: #0F172A; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-email { font-size: 10px; color: #94A3B8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Power/logout icon button */
.sf-logout {
  background: #F1F4F9;
  border: 1px solid #E4E8EF;
  color: #94A3B8;
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
  padding: 0;
}
.sf-logout svg { width: 16px; height: 16px; }
.sf-logout:hover {
  background: #FEE2E2;
  border-color: #FBB4B4;
  color: #DC2626;
}

/* ── Main area ───────────────────────────────────────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;          /* deixa o item flex encolher → tabelas largas fazem scroll dentro do cartão */
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;    /* nada transborda para fora do ecrã */
}
.admin-topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.atb-left  { display: flex; align-items: center; gap: 14px; }
.atb-title { display: inline-flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 700; color: #111827; }
/* Ícone do cabeçalho — o mesmo da barra lateral, em badge vermelho suave */
.atb-title-ico { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: color-mix(in srgb, var(--red, #C00000) 12%, #fff); color: var(--red, #C00000); flex: 0 0 auto; }
.atb-title-ico svg { width: 18px; height: 18px; display: block; }
.atb-title-txt { line-height: 1; }
.atb-date  { font-size: 12px; color: #9CA3AF; }
.atb-right { display: flex; align-items: center; gap: 10px; }
.atb-refresh {
  background: linear-gradient(180deg, #FFFFFF, #F4F5F8);
  border: 1.5px solid var(--border);
  border-radius: 10px; padding: 8px 15px;
  font-size: 12.5px; font-weight: 600; color: #374151;
  cursor: pointer; font-family: var(--font);
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
  transition: border-color .15s, color .15s, box-shadow .18s, transform .1s;
}
.atb-refresh:hover {
  border-color: var(--red); color: var(--red);
  box-shadow: 0 4px 12px -4px rgba(192,0,0,.28);
  transform: translateY(-1px);
}
.atb-refresh:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.atb-export {
  background: linear-gradient(135deg, #C00000, #A00000);
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  font-family: var(--font);
  transition: box-shadow .15s, transform .1s;
}
.atb-export:hover {
  box-shadow: 0 4px 12px rgba(192,0,0,.25);
  transform: translateY(-1px);
}
.atb-export:active { transform: translateY(0); }
.atb-app-link {
  font-size: 12.5px; font-weight: 600; color: var(--red);
  text-decoration: none; padding: 7px 14px;
  border: 1.5px solid rgba(192,0,0,.3); border-radius: 8px;
  transition: background .15s;
}
.atb-app-link:hover { background: #FFF0F0; }

.admin-content {
  padding: 24px 28px 40px;
  flex: 1;
  min-width: 0;
  max-width: 1600px; /* cap width on ultra-wide screens */
}

/* ── Loading ─────────────────────────────────────────────────────────────── */
.loading-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px; color: #9CA3AF; gap: 14px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #E5E7EB;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dashboard KPI row ───────────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
  min-width: 0;
}
.adm-kpi {
  --ak: #C00000;                       /* cor de acento (redefinida por cartão) */
  position: relative;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7F8FB 100%);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 20px 18px 16px;
  overflow: hidden;
  /* Profundidade em camadas (elevação tipo "3D") */
  box-shadow: 0 1px 2px rgba(16,24,40,.05),
              0 10px 24px -10px rgba(16,24,40,.22),
              inset 0 1px 0 rgba(255,255,255,.8);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
}
/* Barra de acento em gradiente no topo */
.adm-kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--ak), color-mix(in srgb, var(--ak) 45%, #fff));
}
/* Brilho suave de canto (dá volume ao cartão) */
.adm-kpi::after {
  content: ''; position: absolute; top: -46%; right: -18%;
  width: 170px; height: 170px; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--ak) 14%, transparent), transparent 70%);
}
.adm-kpi:hover {
  transform: translateY(-5px);
  box-shadow: 0 2px 4px rgba(16,24,40,.06),
              0 22px 40px -12px rgba(16,24,40,.30),
              inset 0 1px 0 rgba(255,255,255,.9);
}
.adm-kpi.red          { --ak: #C00000; }
.adm-kpi:nth-child(2) { --ak: #2563EB; }
.adm-kpi:nth-child(3) { --ak: #059669; }
.adm-kpi:nth-child(4) { --ak: #D97706; }
.adm-kpi:nth-child(5) { --ak: #7C3AED; }
.adm-kpi:nth-child(6) { --ak: #DB2777; }
/* Ícone num "selo" arredondado com a cor do cartão */
.ak-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 14px; font-size: 23px;
  margin-bottom: 14px; position: relative;
  color: var(--ak);
  background: color-mix(in srgb, var(--ak) 12%, #fff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ak) 24%, transparent),
              0 4px 10px -4px color-mix(in srgb, var(--ak) 45%, transparent);
}
.ak-icon svg { width: 23px; height: 23px; display: block; }
.ak-value {
  font-size: 30px; font-weight: 800; color: #0F172A; line-height: 1;
  margin-bottom: 5px; letter-spacing: -.6px; font-variant-numeric: tabular-nums;
}
.ak-label {
  font-size: 11px; color: #64748B; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
}

/* ── Charts ──────────────────────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  min-width: 0; /* allow grid to shrink */
}
.charts-row:last-child { grid-template-columns: 1fr 1fr; }
.chart-card {
  background: linear-gradient(180deg, #FFFFFF 0%, #FCFCFE 100%);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16,24,40,.04),
              0 12px 28px -14px rgba(16,24,40,.20);
  padding: 20px 22px;
  min-width: 0;       /* critical: allows flex/grid child to shrink */
  overflow: hidden;   /* prevents canvas overflow */
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
}
.chart-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(16,24,40,.05),
              0 20px 38px -14px rgba(16,24,40,.28);
}
.chart-card canvas {
  max-width: 100%;    /* canvas never wider than its container */
}
.chart-title {
  font-size: 13px; font-weight: 700; color: #374151;
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
/* Pequeno acento em gradiente por baixo do título */
.chart-title::after {
  content: ''; position: absolute; left: 0; bottom: -1px;
  width: 46px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--red), #F19999);
}
canvas { max-height: 280px; }

/* ── Admin card / table ──────────────────────────────────────────────────── */
.adm-card {
  background: white;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16,24,40,.04),
              0 12px 28px -14px rgba(16,24,40,.18);
  overflow: hidden;
  min-width: 0; /* allows grid/flex to shrink */
}
.adm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 700; color: #374151;
  flex-wrap: wrap;
  gap: 10px;
}
.adm-search {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: var(--font);
  color: #374151;
  background: #F9FAFB;
  width: min(240px, 100%);
  transition: border-color .15s;
}
.adm-search:focus { outline: none; border-color: var(--red); background: white; }

.adm-table-wrap { overflow-x: auto; }
.adm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 700px;
}
.adm-table thead tr { background: linear-gradient(135deg,#1F2937,#374151); }
.adm-table th[data-sort] { user-select: none; }
.adm-table th[data-sort]:hover { background: rgba(255,255,255,.08); }
.adm-table th .sort-ind { font-size: 10px; opacity: .95; }
.adm-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,.85);
  letter-spacing: .3px;
  white-space: nowrap;
}
.adm-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #F3F4F6;
  color: #374151;
  vertical-align: middle;
}
.adm-table tbody tr:nth-child(even) td { background: #FAFBFD; }
.adm-table tbody tr:hover td { background: #FFF8F8; }
.adm-email-link { color: var(--red); text-decoration: none; font-weight: 500; }
.adm-email-link:hover { text-decoration: underline; }
.adm-badge {
  display: inline-flex; align-items: center;
  background: #EFF6FF; color: #1D4ED8;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.adm-act-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #C00000;
  font-size: 11.5px; font-weight: 600;
  cursor: pointer; font-family: var(--font);
  transition: background .15s, color .15s, box-shadow .15s;
  background: white; color: #C00000;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
.adm-act-btn:hover {
  background: #C00000; color: white;
  box-shadow: 0 2px 8px rgba(192,0,0,0.25);
}
/* Botões só com ícone (coluna de Ações compacta) */
.adm-act-btn.icon {
  padding: 0; width: 30px; height: 28px; gap: 0;
  justify-content: center; flex-shrink: 0;
}

/* Coluna de Ações fixa à direita — sempre visível mesmo com scroll horizontal */
.adm-table th.col-actions,
.adm-table td.col-actions {
  position: sticky; right: 0;
  width: 1%; white-space: nowrap;
}
.adm-table td.col-actions {
  background: #fff; z-index: 2;
  box-shadow: -8px 0 10px -8px rgba(0,0,0,.18);
}
.adm-table tbody tr:nth-child(even) td.col-actions { background: #FAFBFD; }
.adm-table tbody tr:hover td.col-actions { background: #FFF8F8; }
.adm-table th.col-actions {
  background: #374151; z-index: 3;
  box-shadow: -8px 0 10px -8px rgba(0,0,0,.18);
}

/* ── Calc detail modal ───────────────────────────────────────────────────── */
.cdm-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.cdm-backdrop.hidden { display: none; }
.cdm-dialog {
  background: white;
  border-radius: var(--r-lg);
  width: 100%; max-width: 560px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.cdm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700; color: #111827;
}
.cdm-close {
  background: transparent; border: none;
  font-size: 18px; color: #9CA3AF;
  cursor: pointer; padding: 2px 6px; border-radius: 4px;
  transition: background .15s, color .15s;
}
.cdm-close:hover { background: #F3F4F6; color: #374151; }
.cdm-body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.cdm-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.cdm-btn-results {
  background: linear-gradient(135deg, #0369A1, #0284C7); color: white;
  border: none; border-radius: 8px;
  padding: 9px 20px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: var(--font);
  transition: box-shadow .15s, transform .1s;
}
.cdm-btn-results:hover {
  box-shadow: 0 4px 12px rgba(3,105,161,.25);
  transform: translateY(-1px);
}
.cdm-btn-pdf {
  background: var(--red-grad); color: white;
  border: none; border-radius: 8px;
  padding: 9px 20px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: var(--font);
}
.cdm-btn-close {
  background: white; border: 1.5px solid var(--border);
  border-radius: 8px; padding: 8px 20px;
  font-size: 13px; font-weight: 600; color: #374151;
  cursor: pointer; font-family: var(--font);
}
.cdm-section { margin-bottom: 4px; }
.cdm-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid #F3F4F6;
  font-size: 13px;
}
.cdm-row span { color: #6B7280; }
.cdm-row strong { color: #111827; }
.cdm-row a { color: var(--red); text-decoration: none; }
.cdm-row a:hover { text-decoration: underline; }
.cdm-divider {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--red);
  margin: 18px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.cdm-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.cdm-zonas { display: flex; flex-direction: column; gap: 4px; }
.cdm-zona  {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  background: #F9FAFB;
  border-radius: 6px;
  font-size: 12.5px;
}
.cz-piso { background: #E5E7EB; color: #374151; padding: 1px 7px; border-radius: 4px; font-weight: 700; font-size: 11px; }
.cz-nome { flex: 1; color: #374151; font-weight: 600; }
.cz-area { color: #6B7280; font-size: 12px; }

/* ── Map container ───────────────────────────────────────────────────────── */
.map-card {
  background: white;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  grid-column: 1 / -1; /* full width */
}
.map-card .chart-title { padding: 16px 20px; margin-bottom: 0; }
#admin-map {
  height: 420px;
  width: 100%;
  border-top: 1px solid var(--border);
}
.map-bubble-popup .leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}

/* Marcador individual — círculo pequeno vermelho com número */
.map-pin-icon {
  width: 28px; height: 28px;
  background: #C00000;
  border: 2px solid #8C0000;
  border-radius: 50%;
  color: white;
  font-family: Inter, sans-serif;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  cursor: pointer;
  transition: transform .15s;
}
.map-pin-icon:hover { transform: scale(1.15); }

/* Cluster — círculo maior com total */
.map-cluster-icon {
  width: 36px; height: 36px;
  background: #C00000;
  border: 3px solid rgba(255,255,255,.85);
  border-radius: 50%;
  color: white;
  font-family: Inter, sans-serif;
  font-size: 13px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(192,0,0,.5);
  cursor: pointer;
}

/* ── Tipologia charts row: 3 columns ─────────────────────────────────────── */
.charts-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  min-width: 0;
}
.charts-row-3 canvas { max-height: 220px; max-width: 100%; }

/* ── Configuration Section ───────────────────────────────────────────────── */
.config-section { }
.config-field {
  margin-bottom: 20px;
}
.config-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #1F2937;
  font-size: 13px;
}
.config-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.config-field input:focus {
  outline: none;
  border-color: #C00000;
  box-shadow: 0 0 0 3px rgba(192, 0, 0, 0.1);
}
.config-field small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #9CA3AF;
}
.config-save-btn, .config-test-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  font-family: var(--font);
}
.config-save-btn {
  background: linear-gradient(135deg, #C00000 0%, #A00000 100%);
  color: white;
}
.config-save-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(192, 0, 0, 0.25);
}
.config-test-btn {
  background: white;
  color: #1F2937;
  border: 1px solid #D1D5DB;
}
.config-test-btn:hover {
  background: #F9FAFB;
  border-color: #9CA3AF;
}

/* ── Hamburger button (mobile only) ─────────────────────────────────────── */
.btn-menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 8px; color: #374151;
  transition: background .15s;
}
.btn-menu-toggle:hover { background: #F3F4F6; }
.btn-menu-toggle svg { display: block; }

/* ── Sidebar overlay (mobile) ───────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}
.sidebar-overlay.open { display: block; }

/* ── Responsive — Tablet ≤ 1024px ──────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .admin-content { padding: 20px 20px 40px; }

  /* Dashboard */
  .charts-row { grid-template-columns: 1fr 1fr; }
  .charts-row:last-child { grid-template-columns: 1fr 1fr; }
  .charts-row-3 { grid-template-columns: 1fr 1fr; }

  /* Tables – always scrollable */
  .adm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Modal */
  .cdm-dialog { max-width: 95vw; }
}

/* ── Responsive — Mobile ≤ 768px ───────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed; left: -100%; top: 0; bottom: 0;
    z-index: 200; transition: left .25s ease;
    width: 260px !important;
  }
  .sidebar.open { left: 0; }
  .admin-main { margin-left: 0; }

  /* Topbar */
  .btn-menu-toggle { display: flex; align-items: center; justify-content: center; }
  .admin-topbar { padding: 0 16px; gap: 10px; }
  .atb-date { display: none; }
  .atb-export { display: none; }
  .atb-app-link { padding: 6px 10px; font-size: 11.5px; }
  .atb-refresh { padding: 6px 10px; font-size: 11.5px; }

  /* Content */
  .admin-content { padding: 16px 14px 40px; }

  /* KPIs */
  .kpi-row { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .ak-value { font-size: 22px; }

  /* Charts */
  .charts-row   { grid-template-columns: 1fr; }
  .charts-row:last-child { grid-template-columns: 1fr; }
  .charts-row-3 { grid-template-columns: 1fr; }
  .chart-card   { padding: 16px; }

  /* Map */
  #admin-map { height: 300px; }

  /* Tables – all sections */
  .adm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .results-table-wrap, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Card header wraps nicely */
  .adm-card-header { flex-direction: column; align-items: flex-start; }
  .adm-search { width: 100%; }

  /* Config / Prices */
  .config-section { padding: 0; }
  .cdm-dialog { max-width: 95vw; }
  .cdm-body { padding: 14px 16px; }
  .cdm-footer { flex-wrap: wrap; }
}

/* ── Responsive — Small mobile ≤ 480px ─────────────────────────────────── */
@media (max-width: 480px) {
  /* Dashboard KPIs */
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
  .adm-kpi { padding: 14px 12px 10px; }
  .ak-icon  { font-size: 18px; margin-bottom: 6px; }
  .ak-value { font-size: 20px; }
  .atb-title { font-size: 15px; }

  /* Tables */
  .adm-table { font-size: 11.5px; }
  .adm-table th, .adm-table td { padding: 8px 10px; }

  /* Table action buttons */
  .adm-act-btn { font-size: 10.5px; padding: 4px 8px; }

  /* Modal */
  .cdm-dialog { border-radius: 12px; }
  .cdm-header { padding: 14px 16px; font-size: 14px; }
  .cdm-footer { padding: 12px 16px; }
  .cdm-btn-pdf, .cdm-btn-close, .cdm-btn-results { padding: 8px 14px; font-size: 12px; }

  /* Map */
  #admin-map { height: 240px; }

  /* Config buttons */
  .config-save-btn, .config-test-btn { width: 100%; margin-bottom: 8px; }
}

/* ── Mostrar/ocultar password (ver js/ui-enhance.js) ────────────────────────── */
.pass-wrap { position: relative; display: block; }
.pass-wrap > input { padding-right: 42px !important; }
.pass-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  padding: 6px; border-radius: 6px; color: #9CA3AF;
}
.pass-toggle:hover { color: var(--red, #C00000); }
.pass-toggle svg { width: 18px; height: 18px; display: block; }
.pass-toggle .eye-off { display: none; }
.pass-toggle.is-on .eye-on { display: none; }
.pass-toggle.is-on .eye-off { display: block; }

/* ── Legenda/nota de campo (obrigatoriedades e contexto) ────────────────────── */
.field-hint {
  display: block; margin-top: 5px; font-size: 12px; line-height: 1.4; color: #6B7280;
}
.field-hint.req::before { content: '• '; color: var(--red, #C00000); font-weight: 700; }

/* ── Revelação de conteúdo (entrada escalonada + ao fazer scroll) ────────────
   Aplicada por applyReveal() em admin.js. Só entra em efeito quando o JS marca
   .reveal (senão o conteúdo fica sempre visível). */
.reveal    { opacity: 0; transform: translateY(16px); will-change: opacity, transform; }
.reveal.in {
  opacity: 1; transform: none;
  transition: opacity .55s cubic-bezier(.16,1,.3,1), transform .55s cubic-bezier(.16,1,.3,1);
  transition-delay: var(--reveal-delay, 0ms);
}
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal.in { opacity: 1 !important; transform: none !important; transition: none !important; }
}
/* Variante para linhas de tabela/grelhas densas (utilizadores, cálculos,
   administradores, galeria de produtos, Hard Config): só fade (sem transform,
   para não criar costuras nas bordas das linhas), stagger mais curto — usada
   por _staggerItems() SÓ no carregamento inicial da secção (não em cada
   filtro/ordenação, para a pesquisa continuar instantânea). */
.reveal-row    { opacity: 0; }
.reveal-row.in {
  opacity: 1;
  transition: opacity .4s cubic-bezier(.16,1,.3,1);
  transition-delay: var(--reveal-delay, 0ms);
}
@media (prefers-reduced-motion: reduce) {
  .reveal-row, .reveal-row.in { opacity: 1 !important; transition: none !important; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Cabeçalho de marca, ícones SVG, menu da conta e biblioteca de produtos
══════════════════════════════════════════════════════════════════════════ */

/* ── Marca no topo da sidebar (logo Giacomini + nome da app) ────────────────── */
.sidebar-logo { flex-direction: column; align-items: flex-start; gap: 11px; }
.sidebar-brand-logo { width: 150px; height: auto; display: block; }
.sidebar-brand-app { display: flex; flex-direction: column; line-height: 1.15; }
.brand-app-name { font-size: 18px; font-weight: 800; color: #0F172A; letter-spacing: -.3px; }
.brand-app-accent { color: #C00000; }
.brand-app-sub { font-size: 10px; color: #94A3B8; font-weight: 600; letter-spacing: .3px; margin-top: 2px; }

/* ── Ícones SVG na navegação (traço, cor de marca; brancos sobre o ativo) ───── */
.snav-icon svg { width: 18px; height: 18px; display: block; }
.snav-icon { color: #C00000; }
.snav-item:hover .snav-icon { color: #A00000; }
.snav-item.active .snav-icon { background: #fff; color: #C00000; box-shadow: 0 2px 6px -2px rgba(0,0,0,.25); }
/* Hard Config em âmbar (sobrepõe as regras gerais acima) */
.snav-hardconfig .snav-icon { color: #B45309; }
.snav-hardconfig.active .snav-icon { background: #fff; color: #B45309; box-shadow: 0 2px 6px -2px rgba(0,0,0,.2); }

/* ── Menu da conta (rodapé clicável) ───────────────────────────────────────── */
.sidebar-userbar { position: relative; }
.sidebar-footer {
  width: 100%; background: transparent; border: none; cursor: pointer;
  border-top: 1px solid #E9EDF3; text-align: left; font-family: var(--font);
  transition: background .15s;
}
.sidebar-footer:hover { background: #F1F4F9; }
.sf-caret { margin-left: auto; color: #94A3B8; display: flex; transition: transform .2s; }
.sf-caret svg { width: 16px; height: 16px; }
#btn-user-menu[aria-expanded="true"] .sf-caret { transform: rotate(180deg); }
.user-menu {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% - 2px);
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 30px -8px rgba(16,24,40,.28); padding: 6px; z-index: 120;
  display: flex; flex-direction: column; gap: 2px;
}
.user-menu[hidden] { display: none; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: none; background: transparent; cursor: pointer;
  border-radius: 8px; font-size: 13px; font-weight: 600; color: #334155;
  font-family: var(--font); text-align: left; transition: background .14s, color .14s;
}
.user-menu-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.user-menu-item:hover { background: #F1F4F9; color: #0F172A; }
.user-menu-item.danger { color: #B91C1C; }
.user-menu-item.danger:hover { background: #FEE2E2; color: #991B1B; }

/* ── Biblioteca de imagens de produtos ─────────────────────────────────────── */
.prod-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.prod-card {
  display: flex; flex-direction: column; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; padding: 0; font-family: var(--font);
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s, border-color .18s;
}
.prod-card:hover { transform: translateY(-4px); border-color: #D7DEE9;
  box-shadow: 0 16px 30px -14px rgba(16,24,40,.28); }
.prod-thumb {
  aspect-ratio: 4 / 3; background: #F8FAFC; display: flex; align-items: center;
  justify-content: center; border-bottom: 1px solid #EEF1F6; overflow: hidden;
}
.prod-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.prod-thumb.no-img::after { content: 'sem imagem'; color: #CBD5E1; font-size: 12px; }
.prod-meta { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.prod-code { font-size: 12px; font-weight: 800; color: #C00000; letter-spacing: .2px; }
.prod-name {
  font-size: 12.5px; color: #334155; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.prod-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; }
.prod-fam {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
  background: #EEF1F6; color: #64748B;
}
.prod-fam.fam-tubo    { background: #DBEAFE; color: #1D4ED8; }
.prod-fam.fam-placa   { background: #D1FAE5; color: #047857; }
.prod-fam.fam-coletor { background: #EDE9FE; color: #6D28D9; }
.prod-fam.fam-termo   { background: #FEF3C7; color: #92400E; }
.prod-fam.fam-valv    { background: #FFE4E6; color: #BE123C; }
.prod-price { font-size: 12.5px; font-weight: 800; color: #0F172A; white-space: nowrap; }
.prod-price em { font-style: normal; font-weight: 600; color: #94A3B8; font-size: 11px; }
.prod-price.muted { color: #94A3B8; font-weight: 600; font-size: 11px; }

/* Detalhe do produto (modal) */
.prod-modal {
  position: fixed; inset: 0; z-index: 1000; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.prod-modal-box {
  position: relative; background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: 0 30px 70px rgba(0,0,0,.35); overflow: hidden;
  display: grid; grid-template-columns: 220px 1fr;
}
.prod-modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 30px; height: 30px; border-radius: 8px; border: none; cursor: pointer;
  background: rgba(255,255,255,.9); color: #475569; font-size: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.prod-modal-img { background: #F8FAFC; display: flex; align-items: center; justify-content: center; padding: 16px; }
.prod-modal-img img { max-width: 100%; max-height: 260px; object-fit: contain; }
.prod-modal-info { padding: 20px 22px; min-width: 0; }
.prod-modal-code { font-size: 13px; font-weight: 800; color: #C00000; }
.prod-modal-name { font-size: 15px; font-weight: 700; color: #0F172A; margin: 2px 0 14px; line-height: 1.3; }
.prod-modal-table { width: 100%; border-collapse: collapse; }
.prod-modal-table th, .prod-modal-table td {
  text-align: left; padding: 7px 0; border-bottom: 1px solid #EEF1F6;
  font-size: 12.5px; vertical-align: top;
}
.prod-modal-table th { color: #94A3B8; font-weight: 600; width: 42%; padding-right: 10px; }
.prod-modal-table td { color: #1F2937; font-weight: 600; }
@media (max-width: 560px) {
  .prod-modal-box { grid-template-columns: 1fr; max-width: 420px; }
  .prod-modal-img { max-height: 200px; }
}
