/* ==========================================================================
   Moises Lima Advocacia — Design System
   Fonts: Inter (Google Fonts)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --navy: #0B1F33;
  --navy-mid: #153A56;
  --gold: #C4A35A;
  --gold-light: #E8D5A3;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --text: #1A2332;
  --muted: #5A6A7A;
  --success: #2D6A4F;
  --danger: #9B2226;
  --warning: #B5651D;
  --border: #D8DEE6;
  --border-light: #E8ECF1;
  --shadow-sm: 0 1px 3px rgba(11, 31, 51, 0.06);
  --shadow-md: 0 4px 16px rgba(11, 31, 51, 0.08);
  --shadow-lg: 0 8px 32px rgba(11, 31, 51, 0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --font-display: 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(11, 31, 51, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(21, 58, 86, 0.03) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23153A56' fill-opacity='0.025'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.5em;
  color: var(--navy);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

p { margin: 0 0 1em; }

a {
  color: var(--navy-mid);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover { color: var(--gold); }

img { max-width: 100%; height: auto; display: block; }

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

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  color: #fff;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar.is-open { transform: translateX(0); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 51, 0.5);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.is-visible {
  display: block;
  opacity: 1;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--topbar-h);
}

.sidebar-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
}

.sidebar-brand-text {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--gold-light);
}

.sidebar-brand-text small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  list-style: none;
  margin: 0;
}

.sidebar-nav li { margin: 0; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
}

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--gold);
}

.sidebar-nav a.is-active { background: rgba(196, 163, 90, 0.12); }

.sidebar-nav svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.menu-toggle:hover { background: var(--bg); }

.menu-toggle svg { width: 22px; height: 22px; }

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy);
  display: none;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.topbar-user-name {
  font-weight: 600;
  color: var(--text);
  display: none;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy-mid);
  color: var(--gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
}

.main-content {
  flex: 1;
  padding: 1rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ---- Auth Layout ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--navy);
  background-image:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(21, 58, 86, 0.6) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 100%, rgba(196, 163, 90, 0.08) 0%, transparent 60%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo img {
  width: 80px;
  height: 80px;
  margin: 0 auto 0.75rem;
  object-fit: contain;
}

.auth-logo h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.auth-logo p {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0;
}

.auth-secure-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--navy-mid);
  background: rgba(21, 58, 86, 0.08);
  border: 1px solid rgba(21, 58, 86, 0.12);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  margin: 0 auto 1.25rem;
  width: fit-content;
}

.auth-card .auth-secure-badge {
  display: flex;
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field .form-control {
  padding-right: 5.5rem;
}

.password-toggle {
  position: absolute;
  right: 0.5rem;
  border: none;
  background: transparent;
  color: var(--navy-mid);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
}

.password-toggle:hover {
  background: rgba(21, 58, 86, 0.08);
}

.auth-links {
  margin: 0.5rem 0 0;
  text-align: right;
  font-size: 0.8125rem;
}

.auth-footer {
  font-size: 0.8125rem;
  margin-top: 1rem;
  margin-bottom: 0;
}

.auth-submit:disabled {
  opacity: 0.75;
  cursor: wait;
}

.logout-form {
  display: inline;
  margin: 0;
}

/* ---- Page Header ---- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1 { margin-bottom: 0.125rem; }

.page-subtitle {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}

.btn-primary:hover {
  background: #b8944f;
  border-color: #b8944f;
  color: var(--navy);
}

.btn-navy {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.btn-navy:hover {
  background: var(--navy-mid);
  border-color: var(--navy-mid);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--navy-mid);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--bg);
  border-color: var(--navy-mid);
  color: var(--navy);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #7a1b1e;
  border-color: #7a1b1e;
  color: #fff;
}

.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }

.btn-icon {
  padding: 0.4375rem;
  min-width: 36px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-header h2,
.card-header h3 { margin: 0; font-size: 1rem; }

.card-body { padding: 1.25rem; }

.card-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---- Dashboard Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

a.stat-card-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.stat-card-link:hover {
  border-color: rgba(196, 163, 90, 0.55);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

a.stat-card-link:focus-visible {
  outline: 2px solid var(--gold, #c4a35a);
  outline-offset: 2px;
}

.list-item-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  text-decoration: none;
  color: inherit;
}

.list-item-link:hover .list-item-title {
  color: var(--navy);
  text-decoration: underline;
}

.timeline-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.timeline-link:hover .timeline-title {
  text-decoration: underline;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }

.stat-icon-navy { background: rgba(11, 31, 51, 0.08); color: var(--navy); }
.stat-icon-gold { background: rgba(196, 163, 90, 0.15); color: #8a7340; }
.stat-icon-success { background: rgba(45, 106, 79, 0.1); color: var(--success); }
.stat-icon-danger { background: rgba(155, 34, 38, 0.1); color: var(--danger); }
.stat-icon-warning { background: rgba(181, 101, 29, 0.1); color: var(--warning); }

.stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

label, .form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.375rem;
}

label .required { color: var(--danger); margin-left: 2px; }

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
input[type="search"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(21, 58, 86, 0.12);
}

textarea { min-height: 100px; resize: vertical; }

.form-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--navy-mid);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border-light);
}

.form-section-title {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--navy);
  margin: 1.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.form-section-title:first-child { margin-top: 0; }

.is-invalid { border-color: var(--danger) !important; }

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 0.25rem;
}

/* ---- Tables ---- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.table th,
table.table td {
  padding: 0.75rem 0.875rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

table.table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--bg);
  white-space: nowrap;
}

table.table tbody tr:hover { background: rgba(245, 247, 250, 0.8); }

table.table .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.table-empty {
  text-align: center;
  padding: 2.5rem 1rem !important;
  color: var(--muted);
}

/* Mobile stacked table */
@media (max-width: 639px) {
  table.table-mobile-stack thead { display: none; }

  table.table-mobile-stack tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 0.5rem 0;
  }

  table.table-mobile-stack tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-bottom: none;
    text-align: right;
  }

  table.table-mobile-stack tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    text-align: left;
    flex-shrink: 0;
  }

  table.table-mobile-stack tbody td.actions {
    justify-content: flex-end;
    border-top: 1px solid var(--border-light);
    margin-top: 0.25rem;
    padding-top: 0.75rem;
  }

  table.table-mobile-stack tbody td.actions::before { display: none; }
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.6em;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-ativo, .badge-agendado, .badge-pendente { background: rgba(45, 106, 79, 0.12); color: var(--success); }
.badge-arquivado, .badge-cancelado, .badge-baixado { background: rgba(90, 106, 122, 0.12); color: var(--muted); }
.badge-suspenso, .badge-em_andamento, .badge-parcial { background: rgba(181, 101, 29, 0.12); color: var(--warning); }
.badge-vencido, .badge-danger { background: rgba(155, 34, 38, 0.12); color: var(--danger); }
.badge-cumprido, .badge-pago, .badge-concluido, .badge-concluida { background: rgba(45, 106, 79, 0.15); color: var(--success); }
.badge-info { background: rgba(21, 58, 86, 0.1); color: var(--navy-mid); }
.badge-gold { background: rgba(196, 163, 90, 0.15); color: #7a6530; }
.badge-navy { background: rgba(11, 31, 51, 0.1); color: var(--navy); }
.badge-success { background: rgba(45, 106, 79, 0.12); color: var(--success); }
.badge-warning { background: rgba(181, 101, 29, 0.12); color: var(--warning); }

/* ---- Flash Alerts ---- */
.flash-container {
  margin-bottom: 1rem;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: rgba(45, 106, 79, 0.08); border-color: rgba(45, 106, 79, 0.2); color: var(--success); }
.alert-error { background: rgba(155, 34, 38, 0.08); border-color: rgba(155, 34, 38, 0.2); color: var(--danger); }
.alert-warning { background: rgba(181, 101, 29, 0.08); border-color: rgba(181, 101, 29, 0.2); color: var(--warning); }
.alert-info { background: rgba(21, 58, 86, 0.08); border-color: rgba(21, 58, 86, 0.15); color: var(--navy-mid); }

.alert-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.08);
}

.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  padding: 0;
  color: inherit;
}

.alert-close:hover { opacity: 1; }

/* ---- Profile Header ---- */
.profile-header {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.profile-header-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--gold-light);
  background: var(--bg);
}

.profile-avatar-placeholder {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  border: 3px solid var(--gold-light);
}

.profile-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.profile-details {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.detail-item label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.125rem;
}

.detail-item span {
  font-size: 0.875rem;
  color: var(--text);
  word-break: break-word;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  overflow-x: auto;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}

.tab-btn:hover { color: var(--navy); }

.tab-btn.is-active {
  color: var(--navy);
  border-bottom-color: var(--gold);
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---- Search & Filters ---- */
.search-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar-row {
  display: flex;
  gap: 0.5rem;
}

.search-bar input[type="search"] {
  flex: 1;
}

.search-hint {
  font-size: 0.75rem;
  color: var(--muted);
  min-height: 1rem;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filters-row select { width: auto; min-width: 140px; flex: 1; }

/* ---- List Items (non-card) ---- */
.list-plain {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-plain li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.list-plain li:last-child { border-bottom: none; }

.list-item-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
}

.list-item-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---- Timeline (movimentações) ---- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border-light);
}

.timeline-item {
  position: relative;
  padding: 0 0 1.25rem 1.75rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--navy-mid);
}

.timeline-item.intimacao::before {
  border-color: var(--danger);
  background: rgba(155, 34, 38, 0.15);
}

.timeline-date {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.timeline-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.timeline-desc {
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius);
  color: var(--navy-mid);
  border: 1px solid var(--border-light);
  background: var(--surface);
  transition: all var(--transition);
}

.pagination a:hover {
  background: var(--bg);
  border-color: var(--navy-mid);
}

.pagination .is-active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.pagination .is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.pagination-info {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-right: auto;
}

/* ---- Notification badge ---- */
.notif-badge {
  position: relative;
}

.notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  background: var(--danger);
  color: #fff;
  border-radius: 9px;
}

/* ---- Document preview ---- */
.doc-preview {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  min-height: 300px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.7;
  text-align: justify;
}

.doc-preview h1 {
  text-align: center;
  font-size: 1.125rem;
  margin: 0 0 1.25rem;
}

.doc-preview p {
  margin: 0 0 0.75rem;
  text-align: justify;
}

.doc-preview .doc-local,
.doc-preview .doc-data {
  text-align: right !important;
}

.doc-preview .doc-assinatura {
  text-align: center !important;
  margin-top: 2.5rem;
}

.doc-preview.is-editable {
  cursor: text;
  border-color: rgba(196, 163, 90, 0.55);
  box-shadow: inset 0 0 0 1px rgba(196, 163, 90, 0.2);
}

.doc-preview.is-editable:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.2);
}

.doc-preview .editable-field {
  background: rgba(196, 163, 90, 0.15);
  border-bottom: 2px dashed var(--gold);
  padding: 0 4px;
  cursor: text;
}

.doc-preview .editable-field:focus {
  outline: none;
  background: rgba(196, 163, 90, 0.25);
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  opacity: 0.35;
}

.empty-state p { margin-bottom: 1rem; }

/* ---- Utility ---- */
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.divider {
  height: 1px;
  background: var(--border-light);
  margin: 1rem 0;
}

/* ---- Responsive ---- */
@media (min-width: 640px) {
  .form-row { grid-template-columns: repeat(2, 1fr); }
  .form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search-bar { flex-direction: row; align-items: center; }
  .search-bar input[type="search"] { max-width: 320px; }
  .profile-header-main { flex-direction: row; text-align: left; }
  .profile-details { grid-template-columns: repeat(2, 1fr); }
  .profile-actions { justify-content: flex-start; }
  .topbar-user-name { display: inline; }
}

@media (min-width: 768px) {
  .main-content { padding: 1.5rem; }
  .topbar-title { display: block; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-details { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .sidebar {
    transform: translateX(0);
    position: sticky;
    top: 0;
  }

  .sidebar-overlay { display: none !important; }

  .menu-toggle { display: none; }

  .main-wrapper { margin-left: 0; }

  .stats-grid { grid-template-columns: repeat(4, 1fr); }

  .form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1200px) {
  .dashboard-grid { grid-template-columns: 2fr 1fr; }
}

@media print {
  .sidebar, .topbar, .page-actions, .btn, .tabs { display: none !important; }
  .main-content { padding: 0; max-width: none; }
  body { background: #fff; }
}

/* ---- Auditoria ---- */
.tabs a.tab-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--border-light, #e5e9ef);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 700;
}

.tab-btn.is-active .tab-count {
  background: rgba(196, 163, 90, 0.25);
  color: var(--navy);
}

.audit-filters .form-row { margin-bottom: 0.75rem; }

.form-row.cols-4 {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

.audit-table td.audit-details {
  max-width: 28rem;
  white-space: normal;
  font-size: 0.8125rem;
  word-break: break-word;
}

.badge-muted {
  background: #eef1f5;
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

.mb-2 { margin-bottom: 1rem; }

/* Modal simples */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 1rem;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-dialog {
  background: #fff;
  width: 100%;
  max-width: 32rem;
  border-radius: 0.75rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e8ecf1;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.125rem;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid #e8ecf1;
}

.modal-close {
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.btn-group-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ---- Agenda calendário (tabela) ---- */
.calendar-card {
  overflow: hidden;
}

.agenda-calendar-wrap {
  overflow-x: auto;
}

.agenda-calendar {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--surface);
}

.agenda-calendar th,
.agenda-calendar td {
  border: 1px solid var(--border-light);
  vertical-align: top;
  width: 14.28%;
  padding: 0;
}

.agenda-calendar th {
  background: var(--navy);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  padding: 0.55rem 0.25rem;
}

.agenda-calendar td {
  height: 7.25rem;
  background: var(--surface);
}

.agenda-calendar td.is-empty {
  background: var(--bg);
}

.agenda-calendar td.is-today {
  background: #f3f7fb;
  box-shadow: inset 0 0 0 2px var(--navy-mid);
}

.agenda-calendar .day-num {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--navy);
  padding: 0.35rem 0.4rem 0.15rem;
}

.agenda-calendar .day-items {
  display: block;
  padding: 0 0.3rem 0.35rem;
}

.agenda-calendar .cal-item {
  display: block;
  font-size: 0.6875rem;
  line-height: 1.25;
  padding: 0.2rem 0.3rem;
  margin: 0 0 0.2rem;
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-calendar .cal-item-evento { background: #e8eef5; color: #153a56; }
.agenda-calendar .cal-item-tarefa { background: #fff4e5; color: #8a4b00; }
.agenda-calendar .cal-item-tarefa.is-alta { background: #fde8e8; color: #8b1e1e; }
.agenda-calendar .cal-item-tarefa.is-done { background: #e8f5e9; color: #2e5a32; text-decoration: line-through; }
.agenda-calendar .cal-hora { font-weight: 700; margin-right: 0.15rem; }
.agenda-calendar .cal-more { display: block; font-size: 0.625rem; color: var(--muted); }

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.cal-dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.cal-dot-evento { background: #e8eef5; border: 1px solid #b8c7d6; }
.cal-dot-tarefa { background: #fff4e5; border: 1px solid #e0b87a; }
.cal-dot-alta { background: #fde8e8; border: 1px solid #e0a0a0; }
.cal-dot-done { background: #e8f5e9; border: 1px solid #a5d6a7; }

@media (max-width: 768px) {
  .agenda-calendar td { height: 5.5rem; }
  .agenda-calendar .cal-item { font-size: 0.625rem; }
}

/* ---- Popup tarefas pendentes ---- */
body.tarefa-modal-open {
  overflow: hidden;
}

.tarefa-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.tarefa-modal.is-hiding {
  opacity: 0;
  transition: opacity 0.18s ease;
}

.tarefa-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 31, 51, 0.45);
}

.tarefa-modal-dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: min(80vh, 640px);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(11, 31, 51, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tarefa-modal-header,
.tarefa-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
}

.tarefa-modal-footer {
  border-bottom: 0;
  border-top: 1px solid var(--border-light);
}

.tarefa-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--navy);
}

.tarefa-modal-body {
  padding: 1rem 1.25rem;
  overflow: auto;
}

.tarefa-modal-lead {
  margin: 0 0 0.85rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.tarefa-alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tarefa-alert-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: #fafbfc;
}

.tarefa-alert-item.prioridade-alta {
  border-color: #e8a0a0;
  background: #fff7f7;
}

.tarefa-alert-title {
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
}

.tarefa-alert-title:hover {
  text-decoration: underline;
}

.tarefa-alert-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.tarefa-alert-actions {
  flex-shrink: 0;
}

.badge-pendente,
.badge-em_andamento { background: #fff4e5; color: #8a4b00; }
.badge-concluida { background: #e8f5e9; color: #2e5a32; }
.badge-cancelada { background: #eceff1; color: #546e7a; }
.badge-alta { background: #fde8e8; color: #8b1e1e; }
.badge-media { background: #fff4e5; color: #8a4b00; }
.badge-baixa { background: #e8eef5; color: #153a56; }
.badge-tarefa { background: #fff4e5; color: #8a4b00; }
