/* ═══════════════════════════════════════════════════════════════
   STELLA MARIS MEDIA — Admin Panel Styles
   ═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --primary: #0504AA;
  --primary-hover: #03036E;
  --primary-light: #E8F0F5;
  --gold: #D4AF37;
  --gold-hover: #A98A24;
  --gold-light: #FBF7EE;
  --burgundy: #8B1A1A;
  --burgundy-hover: #A52A2A;
  --success: #22c55e;
  --success-hover: #16a34a;
  --warning: #f59e0b;
  --warning-hover: #d97706;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --info: #0504AA;

  --grey-50: #FAFAF9;
  --grey-100: #F5F5F4;
  --grey-200: #E7E5E4;
  --grey-300: #D6D3D1;
  --grey-400: #A8A29E;
  --grey-500: #78716C;
  --grey-600: #57534E;
  --grey-700: #44403C;
  --grey-800: #292524;
  --grey-900: #1C1917;

  --sidebar-width: 260px;
  --sidebar-bg: #03036E;
  --header-height: 56px;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --transition: .2s ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 14px;
  color: var(--grey-800);
  background: var(--grey-100);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Test Banner ────────────────────────────────────────────── */
.test-banner {
  background: var(--warning); color: #000; text-align: center;
  padding: 8px 16px; font-weight: 600; font-size: 13px;
  letter-spacing: .5px; position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
}
body.has-test-banner .sidebar { top: 36px; }
body.has-test-banner .main-content { padding-top: calc(var(--header-height) + 36px); }
body.has-test-banner .admin-header { top: 36px; }

/* ── Login Page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #03036E 0%, #162D3B 50%, #0F1A24 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: var(--radius-lg); padding: 40px;
  width: 100%; max-width: 400px; box-shadow: 0 8px 40px rgba(0,0,0,.25);
}
.login-logo {
  display: block; max-width: 80px; height: auto; margin: 0 auto 12px; border-radius: 50%;
}
.login-card h1 {
  font-size: 22px; text-align: center; color: var(--grey-900);
  font-family: 'Montserrat', sans-serif; font-weight: 600; margin-bottom: 2px;
}
.login-card .subtitle {
  color: var(--grey-500); margin-bottom: 28px; text-align: center; font-size: 13px;
}
.login-error {
  color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; text-align: center;
}

/* ── Password Eye Toggle ───────────────────────────────────── */
.pw-input-wrapper { position: relative; }
.pw-input-wrapper .form-input { padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--grey-400); padding: 4px;
  display: flex; align-items: center; cursor: pointer;
}
.pw-toggle:hover { color: var(--grey-600); }

/* ── MFA ───────────────────────────────────────────────────── */
.mfa-code-input {
  text-align: center; font-size: 24px; letter-spacing: 8px;
  font-weight: 600; font-family: monospace;
}

/* ── Layout ─────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width); background: var(--sidebar-bg); color: #fff;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  overflow-y: auto; transition: transform var(--transition);
  display: flex; flex-direction: column;
}
.sidebar-logo {
  padding: 20px; text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo img { max-width: 56px; height: auto; border-radius: 50%; margin-bottom: 6px; }
.sidebar-logo .sidebar-title {
  display: block; font-size: 15px; color: #fff; font-family: 'Montserrat', sans-serif;
  font-weight: 600; line-height: 1.3;
}
.sidebar-logo .sidebar-subtitle {
  display: block; font-size: 11px; color: var(--gold); text-transform: uppercase;
  letter-spacing: 2px; font-weight: 500; margin-top: 2px;
}
.sidebar-section {
  padding: 16px 20px 4px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 1.5px; color: rgba(255,255,255,.35); font-weight: 600;
}
.sidebar-nav {
  padding: 8px 0; display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.sidebar-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  color: rgba(255,255,255,.7); text-decoration: none; transition: all var(--transition);
  font-size: 14px; border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: rgba(201,168,76,.1); color: var(--gold); text-decoration: none;
}
.sidebar-link.active {
  background: rgba(201,168,76,.12); color: var(--gold);
  border-left-color: var(--gold); font-weight: 500;
}
.sidebar-link svg { flex-shrink: 0; opacity: .7; }
.sidebar-link.active svg { opacity: 1; }
.sidebar-spacer { flex: 1; }
.sidebar-link.sidebar-logout { color: rgba(255,255,255,.4); border-left: none; }
.sidebar-link.sidebar-logout:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ── Header ────────────────────────────────────────────────── */
.admin-header {
  height: var(--header-height); background: #fff; border-bottom: 1px solid var(--grey-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: fixed; top: 0; right: 0;
  left: var(--sidebar-width); z-index: 50;
}
.admin-header .page-title {
  font-size: 18px; font-weight: 600; color: var(--grey-900);
  font-family: 'Montserrat', sans-serif;
}
.admin-header .header-actions { display: flex; align-items: center; gap: 12px; }
.header-btn {
  background: none; border: 1px solid var(--grey-200); border-radius: var(--radius-sm);
  padding: 6px 12px; font-size: 13px; color: var(--grey-600); display: flex;
  align-items: center; gap: 6px; transition: all var(--transition);
}
.header-btn:hover { border-color: var(--grey-300); color: var(--grey-800); }
.sidebar-toggle {
  display: none; background: none; border: none; color: var(--grey-600);
  padding: 4px; margin-right: 8px;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width); padding-top: var(--header-height);
  flex: 1; min-width: 0;
}
.content-body { padding: 24px; max-width: 1400px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  border: none; transition: all var(--transition); line-height: 1;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline {
  background: transparent; border: 1px solid var(--grey-300); color: var(--grey-700);
}
.btn-outline:hover { border-color: var(--grey-400); background: var(--grey-50); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500; color: var(--grey-700);
  margin-bottom: 4px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--grey-300);
  border-radius: var(--radius-sm); font-size: 14px; color: var(--grey-800);
  background: #fff; transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42,80,104,.1);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--grey-500); margin-top: 4px; }
.char-counter { font-size: 12px; color: var(--grey-400); text-align: right; margin-top: 2px; }
.char-counter.near-limit { color: var(--warning); }
.char-counter.at-limit { color: var(--danger); font-weight: 600; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--grey-200);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--grey-200);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2, .card-header h3 {
  font-size: 16px; font-weight: 600; color: var(--grey-900);
}
.card-body { padding: 20px; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 20px;
  border: 1px solid var(--grey-200); box-shadow: var(--shadow);
}
.stat-card .stat-label {
  font-size: 13px; color: var(--grey-500); font-weight: 500; margin-bottom: 4px;
}
.stat-card .stat-value {
  font-size: 28px; font-weight: 700; color: var(--grey-900); line-height: 1.2;
}
.stat-card .stat-icon {
  float: right; width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; color: #fff;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 16px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; color: var(--grey-500);
  border-bottom: 2px solid var(--grey-200);
}
td { padding: 12px 16px; border-bottom: 1px solid var(--grey-100); font-size: 14px; }
tr:hover td { background: var(--grey-50); }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 500; line-height: 1.6;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-gold { background: var(--gold-light); color: var(--gold-hover); }

/* ── Toolbar ───────────────────────────────────────────────── */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-bottom: 20px; padding: 16px 20px; background: #fff;
  border-radius: var(--radius); border: 1px solid var(--grey-200);
}
.toolbar .search-input {
  flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--grey-300);
  border-radius: var(--radius-sm); font-size: 14px;
}
.toolbar .search-input:focus { outline: none; border-color: var(--primary); }
.toolbar .filter-select {
  padding: 8px 12px; border: 1px solid var(--grey-300); border-radius: var(--radius-sm);
  font-size: 14px; background: #fff;
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; transition: all .2s ease;
}
.modal-backdrop.active { opacity: 1; visibility: visible; }
.modal {
  background: #fff; border-radius: var(--radius-lg); max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(20px); transition: transform .2s ease;
}
.modal-backdrop.active .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--grey-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--grey-400); padding: 4px;
  display: flex; cursor: pointer;
}
.modal-close:hover { color: var(--grey-600); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--grey-200);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Toasts ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm); font-size: 14px;
  color: #fff; box-shadow: var(--shadow-md); animation: slideIn .25s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: #000; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Drop Zone ──────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--grey-300); border-radius: var(--radius);
  padding: 40px; text-align: center; cursor: pointer; transition: all var(--transition);
  color: var(--grey-500);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary); background: rgba(42,80,104,.04); color: var(--primary);
}

/* ── Toggle Switch ──────────────────────────────────────────── */
.toggle { position: relative; width: 44px; height: 24px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--grey-300); border-radius: 12px;
  cursor: pointer; transition: all var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; left: 3px; top: 3px;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 20px; }
.pagination button {
  padding: 6px 12px; border: 1px solid var(--grey-300); border-radius: var(--radius-sm);
  background: #fff; font-size: 13px; color: var(--grey-600);
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:hover:not(.active) { background: var(--grey-50); }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--grey-500);
}
.empty-state svg { margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 16px; color: var(--grey-700); margin-bottom: 4px; }

/* ── Drag Handle ────────────────────────────────────────────── */
.drag-handle {
  cursor: grab; color: var(--grey-400); padding: 4px;
  display: flex; align-items: center;
}
.drag-handle:active { cursor: grabbing; }

/* ── Global iOS/touch baseline ─────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, .btn, .sidebar-link { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* ── Dashboard responsive grid ─────────────────────────────── */
/* Two cards side-by-side on desktop, auto-collapse to a single
   column below 640px. Used by Painel → Análises + Visão Geral. */
.dash-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}
.dash-grid-2 > * { min-width: 0; }
@media (max-width: 640px) {
  .dash-grid-2 { grid-template-columns: 1fr; gap: 16px; }
}

/* ── Contato / Pix layout ──────────────────────────────────── */
.contato-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}
.contato-grid > * { min-width: 0; }
@media (max-width: 768px) {
  .contato-grid { grid-template-columns: 1fr; gap: 16px; }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar drawer — bumped width + PWA safe-area insets so the logo,
     title, and nav links aren't hidden under the iPhone notch in
     standalone mode, and aren't clipped by the home indicator below. */
  .sidebar {
    width: min(86vw, 300px);
    transform: translateX(-100%);
    transition: transform 240ms ease;
    z-index: 60;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  /* Backdrop appears when sidebar is open */
  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 55;
    cursor: pointer;
  }
  /* Header also needs safe-area padding so the hamburger sits below
     the notch in standalone mode. */
  .admin-header {
    left: 0;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  }
  .main-content { margin-left: 0; padding-top: calc(var(--header-height) + env(safe-area-inset-top, 0px)); }
  .sidebar-toggle { display: flex; }
  .content-body { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Sidebar typography — touch-friendly sizes so the PWA and
     mobile browser are equally comfortable to read. */
  .sidebar-logo { padding: 22px 18px 20px; }
  .sidebar-logo img { max-width: 64px; margin-bottom: 8px; }
  .sidebar-logo .sidebar-title { font-size: 17px; }
  .sidebar-logo .sidebar-subtitle { font-size: 12px; letter-spacing: 1.8px; }
  .sidebar-section { font-size: 11px; padding: 18px 22px 6px; letter-spacing: 1.6px; }
  .sidebar-link { font-size: 15px; padding: 15px 22px; gap: 14px; }
  .sidebar-link svg { width: 20px; height: 20px; }
  .sidebar-badge { min-width: 22px; height: 22px; font-size: 12px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search-input { min-width: auto; width: 100%; }
  .toolbar .filter-select,
  .toolbar select { width: 100%; }

  /* Header polish */
  .admin-header { padding: 0 14px; }
  .admin-header .page-title { font-size: 15px; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .admin-header .header-actions { gap: 8px; }
  .admin-header .header-actions > span { display: none; }
  .header-btn { padding: 6px 10px; font-size: 12px; }

  /* Prevent iOS zoom on focus */
  input, select, textarea,
  .form-input, .form-select, .form-textarea {
    font-size: 16px !important;
  }
  /* Larger touch targets */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; padding: 8px 12px; font-size: 13px; }

  /* ═══ Tables → card layout ═══ */
  .table-wrapper { overflow: visible; }
  .table-wrapper table,
  .table-wrapper thead,
  .table-wrapper tbody,
  .table-wrapper tr,
  .table-wrapper th,
  .table-wrapper td {
    display: block;
    width: 100%;
  }
  .table-wrapper thead { display: none; }
  .table-wrapper tr {
    margin-bottom: 14px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--grey-200);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }
  .table-wrapper td {
    padding: 7px 0;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    text-align: right;
    max-width: 100% !important;
    white-space: normal !important;
  }
  .table-wrapper td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--grey-700);
    flex-shrink: 0;
    min-width: 90px;
    text-align: left;
  }
  /* Action cell: full-width row, buttons left-aligned, top border */
  .table-wrapper td.cell-actions,
  .table-wrapper td:last-child {
    justify-content: flex-start;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid var(--grey-100);
    text-align: left;
  }
  .table-wrapper td.cell-actions::before,
  .table-wrapper td:last-child::before { display: none; }
  .table-wrapper td.cell-actions > div,
  .table-wrapper td:last-child > div {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    width: 100%;
  }

  /* Forms — full width */
  .form-input, .form-select, .form-textarea { width: 100%; }
  .card { border-radius: var(--radius); }
  .modal { max-width: calc(100vw - 24px); max-height: calc(100vh - 40px); overflow-y: auto; }

  /* Empty-state rows inside tables — keep centered but not broken */
  .table-wrapper td[colspan] { justify-content: center; padding: 28px 0; }
  .table-wrapper td[colspan]::before { display: none; }

  /* ═══ Generic mobile overflow guards ═══ */
  .content-body { max-width: 100%; overflow-x: hidden; }
  .card { padding: 16px; overflow: hidden; }
  img, iframe, video { max-width: 100%; }
  /* Collapse any 2-col grids still using inline styles */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ═══ Notícias: cover on top, info below ═══ */
  .noticia-title-cell {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100%;
  }
  .noticia-title-cell .noticia-thumb {
    width: 100% !important;
    height: 180px !important;
    margin-right: 0 !important;
    border-radius: 8px !important;
  }
  .noticia-title-cell .noticia-title-text { width: 100%; }
  /* Tighter mobile cells for noticias rows (no data-label prefix needed for the title card) */
  .table-wrapper td[data-label="Título"] { justify-content: flex-start; text-align: left; }
  .table-wrapper td[data-label="Título"]::before { display: none; }

  /* ═══ Comentários: title on row 1, chips wrap to row 2 ═══ */
  .com-article-head { flex-wrap: wrap; }
  .com-article-counts {
    flex-basis: 100%;
    order: 10;
    margin-top: 6px;
    gap: 6px;
    flex-wrap: wrap;
    display: flex;
  }

  /* ═══ Newsletter compose ═══ */
  #nlCompose { grid-template-columns: 1fr !important; }
  #nlCompose > div { min-width: 0; max-width: 100%; }
  #nlCompose iframe { width: 100%; max-width: 100%; }
  .nl-editor-wrap { max-width: 100%; min-width: 0; overflow: hidden; }
  .nl-editor-wrap .ProseMirror,
  .ProseMirror { word-break: break-word; overflow-wrap: anywhere; max-width: 100%; }

  /* ═══ Editor toolbars (Tiptap + custom) ═══ */
  .nl-toolbar,
  .editor-toolbar,
  .tiptap-toolbar,
  [class*="editor"] > [class*="toolbar"] { flex-wrap: wrap; gap: 4px; }

  /* ═══ Notícia editor form layout ═══ */
  .editor-form-grid,
  .noticia-editor-grid { grid-template-columns: 1fr !important; gap: 14px; }

  /* ═══ Tiptap article editor (nova-noticia / editar-noticia) ═══ */
  #articleCompose { max-width: 100%; grid-template-columns: 1fr !important; }
  #articleCompose > * { min-width: 0; max-width: 100%; }
  #articleCompose .nl-editor-wrap { max-width: 100% !important; }
  #articleCompose .nl-editor-area { min-height: 480px; }
  #articleCompose .nl-editor-area .tiptap {
    padding: 20px 16px !important;
    min-height: 480px;
    font-size: 15px;
  }
  #articleCompose .nl-editor-area .tiptap h1 { font-size: 24px !important; }
  #articleCompose .nl-editor-area .tiptap h2 { font-size: 20px !important; }
  #articleCompose .nl-editor-area .tiptap h3 { font-size: 17px !important; }
  #articleCompose .nl-tb { top: calc(var(--header-height, 56px) + env(safe-area-inset-top, 0px)); }

  /* History table: breathing room for long subjects */
  #historyTable td { word-break: break-word; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 24px; }
  .content-body { padding: 12px; }
  .admin-header .page-title { font-size: 14px; max-width: 50vw; }
  .admin-header .header-actions .header-btn { padding: 5px 8px; font-size: 11px; }
}

/* ═══════════════════════════════════════════════════════════════
   Password field with eye-toggle
   ═══════════════════════════════════════════════════════════════ */
.pw-wrap {
  position: relative;
  display: block;
}
.pw-wrap .form-input {
  padding-right: 42px;
}
.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  color: var(--grey-500, #6b7280);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.pw-toggle:hover {
  color: var(--primary, #03036E);
  background: var(--grey-100, #f3f4f6);
}

/* ═══════════════════════════════════════════════════════════════
   Sidebar locked link (visible but non-clickable)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-link--locked {
  cursor: not-allowed;
  opacity: 0.45;
  color: rgba(255, 255, 255, 0.55);
}
.sidebar-link--locked:hover {
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
}
.sidebar-link--locked svg:not(.sidebar-link-lock) { opacity: 0.6; }
.sidebar-link-lock {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════
   Sidebar unread badge (used by Comentários nav link)
   ═══════════════════════════════════════════════════════════════ */
.sidebar-link { position: relative; }
.sidebar-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger, #dc2626);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════
   Comentários admin page
   ═══════════════════════════════════════════════════════════════ */
.com-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.com-tab {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--grey-200, #e5e7eb);
  color: var(--grey-600, #4b5563);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
}
.com-tab:hover { background: var(--grey-100, #f3f4f6); }
.com-tab.active {
  background: var(--primary, #03036E);
  color: #fff;
  border-color: var(--primary, #03036E);
}
.com-tab-count {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  background: rgba(255,255,255,.25);
  border-radius: 8px;
  font-size: 11px;
  min-width: 18px;
  text-align: center;
}
.com-tab:not(.active) .com-tab-count {
  background: var(--grey-200, #e5e7eb);
  color: var(--grey-700, #374151);
}

.com-article {
  background: #fff;
  border: 1px solid var(--grey-200, #e5e7eb);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}
.com-article-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  background: var(--grey-50, #f9fafb);
  border-bottom: 1px solid transparent;
  transition: background .15s;
}
.com-article-head:hover { background: var(--grey-100, #f3f4f6); }
.com-article.open .com-article-head {
  border-bottom-color: var(--grey-200, #e5e7eb);
  background: #fff;
}
.com-article-chevron {
  flex-shrink: 0;
  transition: transform .2s;
  color: var(--grey-500, #6b7280);
}
.com-article.open .com-article-chevron { transform: rotate(90deg); }
.com-article-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--grey-200, #e5e7eb);
}
.com-article-title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: var(--grey-900, #111827);
  line-height: 1.3;
}
.com-article-counts {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.com-count-chip {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}
.com-count-chip--pending { background: rgba(234,179,8,.15); color: #854d0e; }
.com-count-chip--flagged { background: rgba(220,38,38,.12); color: #991b1b; }
.com-count-chip--notes { background: rgba(42,80,104,.12); color: var(--primary, #03036E); }
.com-count-chip--done { background: var(--grey-100, #f3f4f6); color: var(--grey-600, #4b5563); }

.com-article-open {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary, #03036E);
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  transition: opacity .15s;
}
.com-article-open:hover { opacity: .85; }

.com-article-body { display: none; padding: 12px 16px 16px; }
.com-article.open .com-article-body { display: block; }

.com-thread { display: flex; flex-direction: column; gap: 12px; }
.com-row {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--grey-200, #e5e7eb);
  border-radius: 6px;
  position: relative;
}
.com-row.has-side {
  grid-template-columns: auto 1fr 260px;
}
.com-row.reply-row {
  margin-left: 32px;
  background: var(--grey-50, #f9fafb);
  border-left: 3px solid var(--primary, #03036E);
}
.com-row.unread {
  border-left: 5px solid #eab308;
  background: #fefce8;
  box-shadow: 0 0 0 1px rgba(234, 179, 8, .45);
}
.com-row.unread::before {
  content: 'NOVO';
  position: absolute;
  top: -9px;
  left: 12px;
  background: #eab308;
  color: #422006;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .6px;
  padding: 2px 8px;
  border-radius: 10px;
}
.com-row.flagged {
  border-left: 5px solid #dc2626;
  background: #fef2f2;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, .35);
}
.com-row.deleted { opacity: .55; font-style: italic; }
.com-row.admin-row { border-left: 3px solid var(--primary, #03036E); background: #eaf0f4; }

.com-side {
  align-self: start;
  min-width: 0;
}

.com-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary, #03036E);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.com-main { flex: 1; min-width: 0; }
.com-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.com-author { font-weight: 600; color: var(--grey-900, #111827); }
.com-email { color: var(--grey-500, #6b7280); font-size: 12px; }
.com-time { color: var(--grey-500, #6b7280); font-size: 12px; }
.com-flag-badge {
  background: rgba(220,38,38,.12);
  color: #991b1b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
}
.com-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #eab308;
  display: inline-block;
}
.com-body {
  font-size: 14px;
  color: var(--grey-800, #1f2937);
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-bottom: 10px;
}
.com-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.com-action {
  padding: 5px 10px;
  background: #fff;
  border: 1px solid var(--grey-200, #e5e7eb);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--grey-700, #374151);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.com-action:hover { background: var(--grey-50, #f9fafb); border-color: var(--grey-300, #d1d5db); }
.com-action.danger { color: var(--danger, #dc2626); }
.com-action.danger:hover { background: #fef2f2; border-color: #fecaca; }
.com-action.active { background: var(--primary, #03036E); color: #fff; border-color: var(--primary, #03036E); }

.com-note-wrap { padding: 10px 12px; background: #fef9c3; border-left: 3px solid #ca8a04; border-radius: 4px; }
.com-note-label { font-size: 11px; font-weight: 700; color: #854d0e; letter-spacing: .5px; text-transform: uppercase; margin-bottom: 4px; }
.com-note-body { font-size: 13px; color: var(--grey-800, #1f2937); white-space: pre-wrap; word-wrap: break-word; }
.com-note-meta { font-size: 11px; color: var(--grey-500, #6b7280); margin-top: 6px; }

/* When the current user is tagged in the note, tint the whole note card
   so the pill is immediately obvious. One-click Resolvido button lives
   at the bottom of the note. */
.com-note-wrap--mentioned {
  background: rgba(234, 179, 8, .18);
  border-left-color: #ca8a04;
}
.com-note-resolve {
  margin-top: 8px;
  display: inline-block;
}

/* Mention status chip inside the note card (visible to everyone) */
.com-mention-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
}
.com-mention-status.pending {
  background: rgba(234, 179, 8, .22);
  color: #854d0e;
}
.com-mention-status.resolved {
  background: rgba(34, 197, 94, .18);
  color: #166534;
}
.com-mention-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ca8a04;
  animation: com-mention-pulse 1.8s ease-in-out infinite;
}
@keyframes com-mention-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(.82); }
}

/* Inline @mention highlight */
.com-mention {
  background: rgba(42, 80, 104, .12);
  color: var(--primary, #0504AA);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
}

/* Floating @ autocomplete picker (attached to body) */
.com-mention-picker {
  position: absolute;
  display: none;
  background: #fff;
  border: 1px solid var(--grey-300, #d1d5db);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  padding: 4px;
  z-index: 9999;
  max-width: 340px;
  max-height: 260px;
  overflow-y: auto;
}
.com-mention-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  cursor: pointer;
  gap: 2px;
}
.com-mention-opt:hover,
.com-mention-opt.active {
  background: rgba(42, 80, 104, .10);
}
.com-mention-opt-handle {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary, #0504AA);
}
.com-mention-opt-name {
  font-size: 11px;
  color: var(--grey-500, #6b7280);
}

/* Handle hint below reply + note textareas */
.com-handle-hint {
  font-size: 11px;
  color: var(--grey-500, #6b7280);
  margin-top: 6px;
  line-height: 1.45;
}
.com-handle-hint code {
  display: inline-block;
  background: var(--grey-100, #f3f4f6);
  color: var(--primary, #0504AA);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: monospace;
  font-weight: 600;
  margin: 0 2px;
}

.com-reply-form {
  margin-top: 10px;
  padding: 10px;
  background: var(--grey-50, #f9fafb);
  border-radius: 4px;
  border: 1px solid var(--grey-200, #e5e7eb);
}
.com-reply-textarea--plain {
  width: 100%;
  min-height: 70px;
  padding: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--grey-900, #111827);
  border: 1px solid var(--grey-300, #d1d5db);
  border-radius: 4px;
  resize: vertical;
  box-sizing: border-box;
  margin: 0;
}

/* Contenteditable note editor (gives us real inline colored mentions) */
.com-note-editor {
  width: 100%;
  min-height: 70px;
  max-height: 260px;
  padding: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--grey-900, #111827);
  border: 1px solid var(--grey-300, #d1d5db);
  border-radius: 4px;
  background: #fff;
  overflow-y: auto;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  outline: none;
}
.com-note-editor:focus {
  border-color: var(--primary, #03036E);
  box-shadow: 0 0 0 3px rgba(30, 61, 79, .12);
}
.com-note-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--grey-400, #9ca3af);
  pointer-events: none;
}
.com-note-editor .com-mention {
  background: rgba(42, 80, 104, .14);
  color: var(--primary, #0504AA);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  /* Keep the span inline with text flow */
  display: inline;
  white-space: nowrap;
}

/* Textarea with inline @mention highlighting via a mirror backdrop.
   The textarea renders transparent text (caret stays visible); the mirror
   sits directly underneath and holds the same text with @handles wrapped
   in a colored span. The two share identical box-model + typography so
   glyphs line up exactly. */
.com-ta-wrap {
  position: relative;
  width: 100%;
  min-height: 70px;
}
.com-ta-wrap .com-ta-mirror,
.com-ta-wrap textarea {
  width: 100%;
  min-height: 70px;
  padding: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: normal;
  box-sizing: border-box;
  border: 1px solid var(--grey-300, #d1d5db);
  border-radius: 4px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin: 0;
}
.com-ta-wrap .com-ta-mirror {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  color: var(--grey-900, #111827);
  background: #fff;
  overflow: hidden;
  border-color: var(--grey-300, #d1d5db);
  z-index: 1;
}
.com-ta-wrap textarea {
  position: relative;
  background: transparent;
  color: transparent;
  caret-color: var(--grey-900, #111827);
  resize: vertical;
  z-index: 2;
}
.com-ta-wrap textarea::selection {
  background: rgba(42, 80, 104, 0.22);
  color: transparent;
}
.com-ta-wrap textarea::-moz-selection {
  background: rgba(42, 80, 104, 0.22);
  color: transparent;
}
/* Inline mention inside the mirror — this is the colored pill the user sees */
.com-ta-mirror .com-mention {
  background: rgba(42, 80, 104, .14);
  color: var(--primary, #0504AA);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
}

/* Delete button on persisted notes */
.com-note-wrap { position: relative; }
.com-note-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  color: var(--grey-500, #6b7280);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 3px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.com-note-delete:hover {
  background: rgba(220, 38, 38, .12);
  color: var(--danger, #dc2626);
}
.com-note-wrap .com-note-label {
  padding-right: 22px;
}
.com-reply-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.com-mention-dropdown {
  position: absolute;
  background: #fff;
  border: 1px solid var(--grey-300, #d1d5db);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  padding: 6px;
  z-index: 100;
  min-width: 180px;
}
.com-mention-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--grey-800, #1f2937);
}
.com-mention-option:hover { background: var(--grey-100, #f3f4f6); }
.com-mention-role {
  float: right;
  font-size: 10px;
  color: var(--grey-500, #6b7280);
  font-weight: 700;
  text-transform: uppercase;
}

.com-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--grey-500, #6b7280);
  background: #fff;
  border: 1px dashed var(--grey-300, #d1d5db);
  border-radius: 8px;
}

@media (max-width: 900px) {
  .com-row.has-side {
    grid-template-columns: auto 1fr;
  }
  .com-row.has-side .com-side {
    grid-column: 1 / -1;
    margin-top: 10px;
  }
}
@media (max-width: 640px) {
  .com-row.reply-row { margin-left: 16px; }
  .com-actions { gap: 2px; }
  .com-action { padding: 4px 8px; font-size: 11px; }
  .com-article-head { padding: 12px; gap: 8px; }
  .com-article-thumb { width: 32px; height: 32px; }
  .com-article-title { font-size: 13px; }
}

/* ── Horizontal scroll on small laptop screens ─────────────────── */
@media (min-width: 769px) {
  body { min-width: calc(var(--sidebar-width) + 860px); }
}

/* ── Editor canvas: parity with public site for embedded iframes ─────── */
#articleCompose .nl-editor-area .tiptap iframe {
  display: block;
  max-width: 100%;
  margin: 16px auto;
  border: 0;
  border-radius: 8px;
}
#articleCompose .nl-editor-area .tiptap iframe[src*="youtube.com"],
#articleCompose .nl-editor-area .tiptap iframe[src*="youtube-nocookie.com"],
#articleCompose .nl-editor-area .tiptap iframe[src*="youtu.be"],
#articleCompose .nl-editor-area .tiptap iframe[src*="player.vimeo.com"] {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
}
