/* ─── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ─── Tokens — QualisCS Design System (espelho exato do qualiscs.com.br) ───── */
:root {
  /* ── Tipografia ── */
  --font:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* ── Marca / Brand ── */
  --blue:       #0F3D91;
  --navy:       #0A1F44;
  --navy-mid:   #152d62;
  --steel:      #5F6B7A;
  --light-gray: #D9E1EA;

  /* ── Cor de acento extra ── */
  --indigo:        #4338ca;
  --indigo-bg:     rgba(67,56,202,.07);
  --indigo-border: rgba(67,56,202,.20);

  /* ── Status semânticos — texto / bg / borda ── */
  --blue-dim:    rgba(15,61,145,.08);
  --blue-border: rgba(15,61,145,.22);

  --approval:        #0d5e40;
  --approval-bg:     rgba(13,94,64,.08);
  --approval-border: rgba(13,94,64,.22);

  --caution:        #7a3b00;
  --caution-bg:     rgba(122,59,0,.08);
  --caution-border: rgba(122,59,0,.22);

  --critical:        #8b1a1a;
  --critical-bg:     rgba(139,26,26,.08);
  --critical-border: rgba(139,26,26,.22);

  /* ── Superfícies ── */
  --canvas:    #F4F7FC;
  --surface-1: #FFFFFF;
  --surface-2: #F4F7FC;
  --surface-3: #EBF0F8;

  /* ── Texto — 4 níveis ── */
  --text-1: #0A1F44;
  --text-2: #5F6B7A;
  --text-3: #8C9BAB;
  --text-4: #B5C0CC;

  /* ── Bordas ── */
  --border-1: rgba(217,225,234,.55);
  --border-2: #D9E1EA;
  --border-3: rgba(95,107,122,.28);

  /* ── Raios (design sóbrio — cantos retos) ── */
  --r-xs: 2px;
  --r-sm: 3px;
  --r:    4px;
  --r-lg: 6px;
  --r-xl: 8px;

  /* ── Layout ── */
  --sidebar-w: 228px;
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text-1);
  font-size: 0.9375rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App Shell ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,.06);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: var(--blue);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: #fff; font-weight: 800;
  flex-shrink: 0;
}
.sidebar-brand-logo {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  object-fit: cover;
}
.sidebar-brand-name {
  font-weight: 800;
  font-size: 0.9375rem;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: 0.65rem;
  color: rgba(217,225,234,.45);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.sidebar-section {
  padding: 16px 12px 8px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.sidebar-section::-webkit-scrollbar { width: 4px; }
.sidebar-section::-webkit-scrollbar-track { background: transparent; }
.sidebar-section::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
.sidebar-section::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }
.sidebar-section-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(217,225,234,.3);
  padding: 0 8px;
  margin-bottom: 4px;
  margin-top: 16px;
}
.sidebar-collapse-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  border-radius: 4px;
  padding: 4px 8px;
  transition: background .15s;
}
.sidebar-collapse-toggle:hover { background: rgba(255,255,255,.05); }
.sidebar-chevron {
  width: 12px; height: 12px;
  transition: transform .2s;
  opacity: .4;
  flex-shrink: 0;
}
.sidebar-collapse-toggle.is-collapsed .sidebar-chevron {
  transform: rotate(-90deg);
}
.sidebar-collapsible {
  overflow: hidden;
  max-height: 600px;
  transition: max-height .25s ease, opacity .2s;
  opacity: 1;
}
.sidebar-collapsible.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}
.sidebar-nav { list-style: none; }
.sidebar-nav li + li { margin-top: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: rgba(217,225,234,.65);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.14s, color 0.14s;
  text-decoration: none;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.92);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: rgba(15,61,145,.55);
  color: #fff;
  font-weight: 600;
}
.sidebar-nav .nav-icon {
  width: 16px; height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}
.sidebar-nav a.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: #c0392b;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}
.nav-badge.nav-badge-warn { background: #d97706; }
.nav-badge.nav-badge-blue { background: #2563eb; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 0.72rem;
  color: rgba(217,225,234,.25);
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* ─── App Body ───────────────────────────────────────────────────────────────── */
.app-body {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Top bar dentro do conteúdo ────────────────────────────────────────────── */
.topbar-inner {
  height: 56px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner .page-title {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text-1);
  letter-spacing: -0.01em;
}
.topbar-inner .topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── Main content ───────────────────────────────────────────────────────────── */
.main-content {
  padding: 28px 32px;
  max-width: 1100px;
  width: 100%;
}

/* ─── Flash ──────────────────────────────────────────────────────────────────── */
.flash {
  background: #edf7f1;
  border: 1px solid rgba(13,94,64,.25);
  color: var(--approval);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* ─── Page heading ───────────────────────────────────────────────────────────── */
h1 {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}
h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 20px 0 10px;
}

/* ─── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  margin-bottom: 16px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  transition: background 0.13s, border-color 0.13s;
  text-decoration: none;
}
.btn:hover { background: var(--navy-mid); border-color: var(--navy-mid); text-decoration: none; color: #fff; }
.btn.secondary {
  background: var(--surface-1);
  color: var(--text-2);
  border-color: var(--border-2);
}
.btn.secondary:hover { border-color: var(--border-3); background: var(--surface-3); color: var(--text-1); }
.btn.danger { background: var(--critical); border-color: var(--critical); }
.btn.danger:hover { background: #700; border-color: #700; }
.btn.small { padding: 5px 10px; font-size: 0.8rem; }

/* ─── Filters / toolbar ──────────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filters select {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--text-1);
  font-family: inherit;
  font-size: 0.85rem;
}
.filters select:focus { outline: 2px solid rgba(15,61,145,.35); border-color: var(--blue); }

/* ─── Table ──────────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border-2); }
th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-3);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-1);
  color: var(--text-1);
  font-size: 0.875rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  gap: 5px;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge.draft    { background: var(--caution-bg);    border: 1px solid var(--caution-border);  color: var(--caution);  }
.badge.draft::before    { background: var(--caution); }
.badge.approved { background: var(--blue-dim);      border: 1px solid var(--blue-border);     color: var(--blue);     }
.badge.approved::before { background: var(--blue); }
.badge.reminded { background: var(--indigo-bg);     border: 1px solid var(--indigo-border);   color: var(--indigo);   }
.badge.reminded::before { background: var(--indigo); }
.badge.done     { background: var(--approval-bg);   border: 1px solid var(--approval-border); color: var(--approval); }
.badge.done::before     { background: var(--approval); }
.badge.reprovado { background: var(--critical-bg);  border: 1px solid var(--critical-border); color: var(--critical); }
.badge.reprovado::before { background: var(--critical); }
.badge.critical { background: var(--critical-bg);   border: 1px solid var(--critical-border); color: var(--critical); }
.badge.critical::before { background: var(--critical); }
.badge.em_correcao  { background: #fff4e6; border: 1px solid #f5a623; color: #b36a00; }
.badge.em_correcao::before  { background: #f5a623; }
.badge.em_publicacao { background: #e6f7f5; border: 1px solid #1abc9c; color: #0e7862; }
.badge.em_publicacao::before { background: #1abc9c; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
form .field { margin-bottom: 16px; }
form label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
form input[type=text],
form input[type=email],
form input[type=password],
form input[type=datetime-local],
form textarea,
form select,
form input[type=number] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface-3);
  color: var(--text-1);
  transition: border-color 0.13s, box-shadow 0.13s;
}
form input[type=email]:focus,
form input[type=password]:focus,
form input:focus,
form textarea:focus,
form select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(15,61,145,.12);
  background: var(--surface-1);
}
form textarea { min-height: 90px; resize: vertical; }
.checkbox-group label,
.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-1);
  margin-right: 18px;
  cursor: pointer;
}
.checkbox-group input,
.radio-group input { width: auto; }

/* ─── Thumb row ──────────────────────────────────────────────────────────────── */
.thumb-row { display: flex; gap: 6px; }
.thumb-row img {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: var(--r-xs);
  border: 1px solid var(--border-2);
}

/* ─── Media grid ─────────────────────────────────────────────────────────────── */
.media-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.media-item {
  position: relative;
  width: 160px;
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface-1);
  cursor: grab;
}
.media-item img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  background: var(--surface-3);
  transition: opacity 0.13s;
}
.media-item img:hover { opacity: 0.85; }
.media-item video {
  width: 100%;
  display: block;
  background: #000;
}
.media-item .download-link {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 0;
  background: var(--surface-3);
  color: var(--blue);
  text-decoration: none;
  border-top: 1px solid var(--border-1);
}
.media-item .download-link:hover { background: var(--surface-2); }
.media-item .order-num {
  position: absolute;
  top: 6px; left: 6px;
  background: rgba(10,31,68,.7);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
}
.media-item .remove-btn {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(139,26,26,.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 22px;
  text-align: center;
  display: flex; align-items: center; justify-content: center;
}
.media-item .remove-btn:hover { background: var(--critical); }

/* ─── Actions row ────────────────────────────────────────────────────────────── */
.actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; align-items: center; }

/* ─── Helpers ────────────────────────────────────────────────────────────────── */
.muted { color: var(--text-3); font-size: 0.85rem; }
.empty-state { text-align: center; padding: 48px 0; color: var(--text-3); font-size: 0.9rem; }

/* ─── QR ─────────────────────────────────────────────────────────────────────── */
.qr-box { text-align: center; margin: 8px 0; }
.qr-box img { max-width: 240px; border: 1px solid var(--border-2); border-radius: var(--r); padding: 8px; }

/* ─── Guide / ol / ul ────────────────────────────────────────────────────────── */
ol, ul { padding-left: 20px; }
li { margin-bottom: 6px; font-size: 0.9rem; color: var(--text-1); }
p { margin-bottom: 10px; font-size: 0.9rem; }
code {
  font-family: var(--font-mono);
  background: var(--surface-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-xs);
  padding: 1px 5px;
  font-size: 0.82em;
  color: var(--navy);
}

/* ─── Sidebar user block ─────────────────────────────────────────────────────── */
.sidebar-user {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.sidebar-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(15,61,145,.7);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  line-height: 1.2;
}
.sidebar-user-role {
  font-size: 0.7rem;
  color: rgba(217,225,234,.35);
  font-family: monospace;
}
.btn-logout {
  width: 100%;
  padding: 6px 0;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-sm);
  color: rgba(217,225,234,.6);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
}
.btn-logout:hover { background: rgba(255,255,255,.12); color: rgba(255,255,255,.9); }

/* ─── Flash error variant ────────────────────────────────────────────────────── */
.flash-error {
  background: rgba(139,26,26,.08);
  border-color: rgba(139,26,26,.2);
  color: var(--critical);
}

/* ─── Permission label (checkbox card) ──────────────────────────────────────── */
.perm-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.perm-label:hover { border-color: var(--blue); background: var(--blue-dim); }
.perm-label.checked { border-color: var(--blue-border); background: var(--blue-dim); }

/* ─── Login page ─────────────────────────────────────────────────────────────── */
body.login-page {
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-shell {
  width: 100%;
  max-width: 400px;
  padding: 24px 16px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}
.login-brand-icon {
  width: 40px; height: 40px;
  background: var(--blue);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  font-weight: 900;
  flex-shrink: 0;
}
.login-brand-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.login-brand-sub {
  font-size: 0.68rem;
  color: rgba(217,225,234,.4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.login-card {
  background: var(--surface-1);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  border: 1px solid rgba(255,255,255,.06);
}
.login-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}
.login-btn {
  width: 100%;
  justify-content: center;
  padding: 10px 0;
  font-size: 0.9375rem;
  margin-top: 4px;
}
.login-footer {
  text-align: center;
  color: rgba(217,225,234,.25);
  font-size: 0.72rem;
  margin-top: 24px;
}

/* ─── Form grid helpers ──────────────────────────────────────────────────────── */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}
.reminder-add-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.reminder-add-row .field { margin-bottom: 0; }
.reminder-add-row select,
.reminder-add-row input[type=datetime-local] { width: 100%; }

/* ─── Mobile topbar (oculto no desktop) ─────────────────────────────────────── */
.mobile-topbar {
  display: none;
}
.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mobile-topbar-logo {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  object-fit: cover;
  flex-shrink: 0;
}
.mobile-topbar-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.mobile-topbar-name {
  font-weight: 700;
  font-size: .88rem;
  color: var(--text-1);
  letter-spacing: -.01em;
}
.mobile-topbar-sub {
  font-size: .62rem;
  color: var(--text-4);
  font-weight: 500;
  letter-spacing: .02em;
}

/* ─── Sidebar overlay (oculto no desktop) ───────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,31,68,.45);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ─── Task detail layout 2 colunas ────────────────────────────────────────── */
.task-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.task-col-main {
  min-width: 0;
}
.task-col-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Filtros estilizados */
.filter-sep {
  width: 1px;
  height: 22px;
  background: var(--border-2);
  margin: 0 2px;
}

/* ─── Responsive — tablet e mobile ─────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Layout shell */
  .app-body {
    margin-left: 0;
  }

  /* Sidebar vira drawer deslizante */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    z-index: 200;
    width: 272px;
    height: 100vh;
    height: 100dvh;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(10,31,68,.35);
  }

  /* Overlay ativo */
  .sidebar-overlay.active {
    display: block;
  }

  /* Topbar mobile */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 52px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-2);
    position: sticky;
    top: 0;
    z-index: 50;
  }

  /* Hamburger */
  .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--r-sm);
    flex-shrink: 0;
  }
  .hamburger:hover { background: var(--surface-3); }
  .hamburger span {
    display: block;
    height: 2px;
    width: 20px;
    background: var(--text-2);
    border-radius: 2px;
    transition: transform .2s;
  }

  /* Content area */
  .main-content {
    padding: 16px;
  }

  h1 {
    font-size: 1.15rem;
    margin-bottom: 14px;
  }

  /* Cards */
  .card {
    padding: 16px;
    border-radius: var(--r);
    margin-bottom: 12px;
  }

  /* Botões — toque mais fácil */
  .btn {
    padding: 10px 18px;
    font-size: 0.9rem;
  }
  .btn.small {
    padding: 7px 12px;
    font-size: 0.82rem;
  }

  /* Actions em coluna em telas pequenas */
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .actions .btn,
  .actions form { width: 100%; }
  .actions form .btn { width: 100%; justify-content: center; }
  .actions > a.btn { justify-content: center; }

  /* Filtros */
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  .filters select { width: 100%; padding: 10px 12px; font-size: .9rem; }

  /* Forms */
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
  form input[type=text],
  form input[type=email],
  form input[type=password],
  form input[type=datetime-local],
  form textarea,
  form select,
  form input[type=number] {
    font-size: 1rem;   /* evita zoom automático no iOS */
    padding: 10px 12px;
  }
  form textarea { min-height: 110px; }

  /* Reminder row vira coluna */
  .reminder-add-row {
    flex-direction: column;
  }
  .reminder-add-row > div { width: 100% !important; flex: none !important; }
  .reminder-add-row .btn { width: 100%; justify-content: center; }

  /* Tabela → cards em mobile */
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tbody tr {
    background: var(--surface-1);
    border: 1px solid var(--border-2);
    border-radius: var(--r);
    margin-bottom: 10px;
    padding: 12px 14px;
    position: relative;
  }
  tbody tr:hover td { background: none; }
  td {
    border: none;
    padding: 3px 0;
    font-size: 0.875rem;
  }
  /* Coluna # */
  td:first-child {
    font-size: .72rem;
    color: var(--text-4);
    font-weight: 700;
    margin-bottom: 4px;
  }
  /* Coluna de miniaturas */
  td:nth-child(2) { margin-bottom: 6px; }
  /* Coluna de ações — alinha à direita */
  td:last-child {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-1);
    flex-wrap: wrap;
  }
  td:last-child .btn,
  td:last-child form { flex: 1; }
  td:last-child .btn,
  td:last-child form .btn { width: 100%; justify-content: center; }

  /* Thumbs maiores em mobile */
  .thumb-row img { width: 52px; height: 52px; }

  /* Media grid — itens menores */
  .media-grid { gap: 8px; }
  .media-item {
    width: calc(50% - 4px);
  }
  .media-item img { height: 130px; }

  /* Badge em texto curto */
  .badge {
    font-size: .68rem;
    padding: 3px 7px;
  }

  /* QR */
  .qr-box img { max-width: 200px; }

  /* ── Dashboard ── */
  .dashboard-week-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }

  /* ── Calendário ── */
  .cal-grid {
    grid-template-columns: repeat(7, 1fr) !important;
    font-size: .65rem;
  }
  .cal-grid > div[style*="min-height:100px"] {
    min-height: 52px !important;
    padding: 3px !important;
  }
  .cal-grid > div[style*="padding:8px"] {
    padding: 4px !important;
  }

  /* ── Task layout mobile ── */
  .task-layout { grid-template-columns: 1fr !important; }

  .filter-sep { display: none; }

  /* ── Kanban ── */
  .kanban-board {
    grid-template-columns: repeat(5, minmax(180px, 1fr)) !important;
    -webkit-overflow-scrolling: touch;
  }
  .kanban-col { min-width: 180px !important; }

  /* ── Métricas: barras e grids ── */
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Hashtags: form inline → stack ── */
  .hashtag-form {
    grid-template-columns: 1fr !important;
  }

  /* ── Campanhas cards ── */
  [style*="grid-template-columns:repeat(auto-fill,minmax(300px,1fr))"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Biblioteca de mídias ── */
  .media-lib-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* ── Guia WhatsApp ── */
  .wg-section h2 { font-size: .95rem; }
  .wg-table { font-size: .68rem; display: block; overflow-x: auto; }
  .wg-table th, .wg-table td { padding: 5px 6px; white-space: nowrap; }
  .wg-table td:last-child { white-space: normal; }
  .wg-flow { padding: 12px 14px; }
  .wg-option { padding: 8px 10px; }
  .wg-step { font-size: .8rem; }
  .wg-tip { font-size: .78rem; }

  /* ── Aprovação externa (página pública) ── */
  .review-wrap { padding: 0 !important; }
  .review-card { padding: 16px !important; }
  .review-title { font-size: 1.1rem !important; }
  .media-grid-review { grid-template-columns: repeat(2, 1fr) !important; }
  .btn-approve, .btn-reject { padding: 10px 20px !important; font-size: .9rem !important; }

  /* ── Ações rápidas no dashboard ── */
  [style*="display:flex;gap:10px;flex-wrap:wrap;margin-top:20px"] {
    flex-direction: column;
  }
  [style*="display:flex;gap:10px;flex-wrap:wrap;margin-top:20px"] .btn {
    text-align: center;
    justify-content: center;
  }

  /* ── Calendário legenda ── */
  [style*="display:flex;gap:16px;flex-wrap:wrap;margin-top:14px"] {
    gap: 8px !important;
    font-size: .68rem !important;
  }
}

/* ─── iPhone 15 Pro Max e similares (≥ 430px ainda mobile) ─────────────────── */
@media (min-width: 430px) and (max-width: 768px) {
  .media-item {
    width: calc(33.333% - 6px);
  }
  .actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .actions .btn,
  .actions form { width: auto; flex: none; }
  .actions > a.btn { justify-content: initial; }
}

/* ─── Safe area (iPhone com notch/Dynamic Island) ────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .main-content {
      padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
    .mobile-topbar {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }
  }
}
