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

:root {
  --bg: #f5f7fa;
  --fg: #1a2030;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-light: rgba(37,99,235,.1);
  --muted: #64748b;
  --border: #e2e8f0;
  --destructive: #ef4444;
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,.15);
  --radius: 0.5rem;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* Header */
.header { background: var(--card); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 1rem; }
.header-left { display: flex; align-items: center; gap: .5rem; }
.header-left h1 { font-size: 1.25rem; font-weight: 700; }
.icon-primary { color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .5rem 1rem; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; transition: .15s;
}
.btn-sm { padding: .375rem .75rem; }
.btn-outline { border-color: var(--border); background: transparent; color: var(--fg); }
.btn-outline:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: transparent; border: none; color: var(--fg); padding: .375rem; border-radius: var(--radius); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { color: var(--destructive); }
.btn-danger:hover { background: rgba(239,68,68,.08); }
.btn-destructive { background: var(--destructive); color: #fff; border: none; }
.btn-destructive:hover { opacity: .9; }

/* Search */
.search-box { position: relative; max-width: 28rem; margin-bottom: 1rem; }
.search-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .875rem; outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.search-input { padding-left: 2.25rem; }

/* Table */
.table-wrapper { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td { padding: .75rem 1rem; text-align: left; white-space: nowrap; }
.table thead { background: var(--bg); }
.table th { font-weight: 600; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--fg); }
.sort-icon { margin-left: .25rem; opacity: .4; font-size: .75rem; }
.active-sort .sort-icon { opacity: 1; }
.table tbody tr { border-top: 1px solid var(--border); transition: background .1s; }
.table tbody tr:hover { background: #f8fafc; }
.table .font-medium { font-weight: 500; }

/* Badges & Links */
.badge-setor {
  display: inline-block; padding: .125rem .625rem; border-radius: 9999px;
  font-size: .75rem; font-weight: 500; background: var(--primary-light); color: var(--primary);
}
.badge-birthday {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .125rem .625rem; border-radius: 9999px;
  font-size: .75rem; font-weight: 600; background: var(--warning-bg); color: var(--warning);
}
a.link-phone { color: var(--primary); text-decoration: none; }
a.link-phone:hover { text-decoration: underline; }
a.link-email { color: var(--muted); text-decoration: none; }
a.link-email:hover { color: var(--primary); text-decoration: underline; }

.record-count { font-size: .875rem; color: var(--muted); margin-top: .75rem; }

/* Sticky actions column */
.table th.col-actions,
.table td.col-actions {
  position: sticky;
  right: 0;
  background: var(--card);
  box-shadow: -4px 0 6px -4px rgba(0,0,0,.1);
  width: 100px;
}
.table thead th.col-actions { background: var(--bg); }
.table tbody tr:hover td.col-actions { background: #f8fafc; }
.main-content { padding-top: 1.5rem; padding-bottom: 2rem; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 100; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--card); border-radius: var(--radius); padding: 1.5rem;
  width: 90%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal h2 { font-size: 1.125rem; font-weight: 700; margin-bottom: 1rem; }
.modal .form-group { margin-bottom: .75rem; }
.modal label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .25rem; }
.modal-footer { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.25rem; }

/* Login page */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card {
  background: var(--card); border-radius: var(--radius); padding: 2rem;
  width: 100%; max-width: 24rem; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.login-card .icon-circle {
  width: 3rem; height: 3rem; border-radius: 50%; background: var(--primary-light);
  display: flex; align-items: center; justify-content: center; margin: 0 auto .75rem;
  color: var(--primary);
}
.login-card h2 { text-align: center; font-size: 1.125rem; font-weight: 700; margin-bottom: 1.25rem; }
.login-card .form-group { margin-bottom: 1rem; }
.login-card label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .25rem; }

/* Toast */
.toast {
  position: fixed; top: 1rem; right: 1rem; padding: .75rem 1.25rem;
  border-radius: var(--radius); font-size: .875rem; font-weight: 500;
  z-index: 200; transform: translateX(120%); transition: transform .3s;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.toast.show { transform: translateX(0); }
.toast-success { background: #16a34a; color: #fff; }
.toast-error { background: var(--destructive); color: #fff; }

/* Admin header */
.admin-actions { display: flex; gap: .5rem; align-items: center; }
.actions-cell { display: flex; gap: .25rem; }

/* Empty */
.empty-row td { text-align: center; padding: 2rem; color: var(--muted); }

@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; gap: .5rem; }
  .table { font-size: .8rem; }
  .table th, .table td { padding: .5rem .625rem; }
}
