/* ==========================================================================
   1. VARIABLES & BASE STYLES
   ========================================================================== */

:root {
  --bg-main: #334058;
  --bg-card: #bcc8df;
  --bg-surface: #ffffff;
  --bg-disabled: #f8fafc;

  --text-dark: #111827;
  --text-main: #1f2937;
  --text-muted: #374151;
  --text-light: #64748b;

  --border-default: #5f6b7a; /* 3:1+ on white and on --bg-card (form/control borders) */
  --border-light: #cbd5e1; /* dividers inside white surfaces */
  --border-subtle: #f1f5f9;

  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --success: #15803d;
  --success-text: #14532d;

  --border-width: 1.7px;
  --line-on-card: rgba(
    51,
    64,
    88,
    0.4
  ); /* rules drawn directly on the blue card */
  --btn-fill: #334058; /* primary filled buttons (same navy as the page) */
  --btn-fill-hover: #1f2937;
  --blue: #2563eb; /* Edit buttons and the active page number */
  --blue-hover: #1d4ed8;

  --radius-sm: 12px;
  --radius-md: 12px;
  --radius-pill: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

body {
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   2. CARDS & CONTAINERS
   ========================================================================== */

/* Auth pages card (index.html & register.html) */
.auth-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  padding: 2rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 420px;
  margin: auto;
}

.auth-card h1 {
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1.75rem;
  color: var(--text-dark);
}

.auth-link {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-link a {
  color: var(--primary-hover);
  font-weight: 600;
  text-decoration: none;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* Dashboard container (contacts.html) */
.dashboard-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  padding: 1.5rem;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  border-radius: 0;
  box-sizing: border-box;
}

/* ==========================================================================
   3. FORM CONTROLS & UNIFIED INPUTS
   ========================================================================== */

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-group {
  margin-bottom: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-group input,
.search-group input,
.card-field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-pill);
  outline: none;
  font-size: 0.9rem;
  background-color: var(--bg-surface);
  color: var(--text-dark);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.form-group input:focus,
.search-group input:focus,
.card-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.25);
}

.card-field input {
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  border-color: var(--border-default);
}

.card-field input:disabled {
  background-color: var(--bg-disabled);
  color: var(--text-muted);
}

.input-with-copy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-with-copy input {
  flex: 1;
}

.form-error {
  font-size: 0.85rem;
  color: #991b1b;
  margin-bottom: 1rem;
  text-align: center;
}

.form-error:empty {
  margin-bottom: 0;
}

.form-error.form-success {
  color: var(--success-text);
}

/* ==========================================================================
   4. UNIFIED CUSTOM DROPDOWN SELECTS
   ========================================================================== */

.custom-select-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.custom-select-wrapper label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.custom-select {
  position: relative;
  user-select: none;
  width: 100%;
}

.compact-select {
  min-width: 140px;
  width: auto;
}

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem;
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  color: var(--text-dark);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.compact-select .select-trigger {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.custom-select:focus .select-trigger,
.custom-select.open .select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.25);
}

.select-trigger .arrow {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  margin-left: 0.5rem;
  transition: transform 0.15s ease;
}

.custom-select.open .select-trigger .arrow {
  transform: rotate(180deg);
}

.custom-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
  display: none;
  overflow: hidden;
  z-index: 100;
}

.custom-select.open .custom-options {
  display: block;
}

.custom-option {
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.compact-select .custom-option {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.custom-option:hover {
  background: var(--primary);
  color: var(--bg-surface);
}

.custom-option.selected {
  background: #eff6ff;
  color: var(--primary-hover);
  font-weight: 600;
}

/* ==========================================================================
   5. DASHBOARD HEADER & CONTROL BAR
   ========================================================================== */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: var(--border-width) solid var(--line-on-card);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-section h1 {
  font-size: 1.75rem;
  color: var(--text-dark);
}

.user-section {
  font-weight: 600;
  color: var(--text-main);
}

.badge {
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.badge-admin {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-user {
  background: #e0e7ff;
  color: #1d4ed8;
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.search-group {
  flex: 1;
}

.admin-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.4);
  border: var(--border-width) solid var(--line-on-card);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
}

/* ==========================================================================
   6. CONTACT CARDS & DYNAMIC GRID
   ========================================================================== */

.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 0.94rem;
  width: 100%;
  flex: 1;
  align-content: start;
  margin-bottom: 1rem;
}

.contact-card {
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.card-top h3 {
  font-size: 1.1rem;
  color: var(--text-dark);
}

.card-id {
  font-size: 0.75rem;
  color: var(--text-light);
}

.owner-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: var(--border-width) solid var(--border-light);
}

.card-field {
  margin-bottom: 0.75rem;
}

.card-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

/* ==========================================================================
   7. BUTTONS, ACTIONS & LINKS
   ========================================================================== */

button {
  width: 100%;
  padding: 0.65rem 1.25rem;
  background: var(--btn-fill);
  color: var(--bg-surface);
  border: var(--border-width) solid var(--btn-fill);
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.1s ease;
}

button:hover {
  background: var(--btn-fill-hover);
  border-color: var(--btn-fill-hover);
}

button:active {
  transform: scale(0.98);
}

.btn-primary-pill {
  width: auto;
}

.btn-secondary-pill {
  width: auto;
  background: var(--bg-surface);
  color: var(--text-main);
  border: var(--border-width) solid var(--border-default);
}

.btn-secondary-pill:hover {
  background: #f3f4f6;
  border-color: var(--btn-fill);
}

.btn-full-width {
  width: 100%;
  margin-top: 0.5rem;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: var(--border-width) solid var(--border-light);
}

.btn-card-action {
  width: auto;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-pill);
  line-height: 1.2;
}

.btn-edit {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--bg-surface);
}

.btn-edit:hover {
  background: var(--blue-hover);
  border-color: var(--blue-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--bg-surface);
}

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

.btn-copy-inline {
  width: 42px;
  height: 38px;
  padding: 0;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-copy-inline:hover {
  background: var(--bg-disabled);
  color: var(--text-dark);
  border-color: var(--btn-fill);
}

.btn-copy-inline .icon-copy {
  display: block;
}

.btn-copy-inline .icon-check {
  display: none;
}

.btn-copy-inline.copied {
  background: #f0fdf4;
  color: var(--success);
  border-color: var(--success);
}

.btn-copy-inline.copied .icon-copy {
  display: none;
}

.btn-copy-inline.copied .icon-check {
  display: block;
  animation: scaleIn 0.15s ease-out;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  border-radius: var(--radius-pill);
  width: auto;
}

/* ==========================================================================
   8. MODALS & ADMIN USER MANAGEMENT
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: var(--bg-surface);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 440px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.user-modal-card {
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-header h2 {
  font-size: 1.25rem;
  color: var(--text-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: auto;
}

.modal-close:hover {
  color: var(--text-dark);
  background: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.user-form-section {
  background: var(--bg-disabled);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--border-default);
  margin-bottom: 1rem;
}

.user-form-section h3,
.user-list-section h3 {
  font-size: 0.95rem;
  color: var(--text-dark);
  margin-bottom: 0.75rem;
}

.user-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.user-list-header h3 {
  margin: 0;
}

.modal-divider {
  border: none;
  border-top: var(--border-width) solid var(--border-light);
  margin: 1.25rem 0;
}

.table-container {
  overflow-x: auto;
}

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

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

.users-table th {
  background: #f1f5f9;
  color: var(--text-muted);
  font-weight: 600;
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-active {
  background: #dcfce7;
  color: #166534;
}

.status-disabled {
  background: #fee2e2;
  color: #b91c1c;
}

.table-actions {
  display: flex;
  gap: 0.35rem;
}

/* Custom Scrollbar for Modals and Dropdowns */
.user-modal-card::-webkit-scrollbar,
.contact-modal-card::-webkit-scrollbar,
.custom-options::-webkit-scrollbar,
.tag-suggestions::-webkit-scrollbar {
  width: 14px;
}

.user-modal-card::-webkit-scrollbar-track,
.contact-modal-card::-webkit-scrollbar-track,
.custom-options::-webkit-scrollbar-track,
.tag-suggestions::-webkit-scrollbar-track {
  background: transparent;
}

.user-modal-card::-webkit-scrollbar-thumb,
.contact-modal-card::-webkit-scrollbar-thumb,
.custom-options::-webkit-scrollbar-thumb,
.tag-suggestions::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-pill);
}

.user-modal-card,
.contact-modal-card,
.custom-options,
.tag-suggestions {
  scrollbar-color: var(--border-default) transparent;
}

/* ==========================================================================
   10. CONTACT CARDS AT 75% SIZE
   ========================================================================== */
.contacts-grid {
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 0.94rem;
}
.contact-card {
  padding: 0.94rem;
}
.card-top h3 {
  font-size: 0.825rem;
}
.card-id {
  font-size: 0.56rem;
}
.owner-tag {
  font-size: 0.6rem;
  margin-bottom: 0.56rem;
  padding-bottom: 0.38rem;
}
.card-field {
  margin-bottom: 0.56rem;
}
.card-field label {
  font-size: 0.56rem;
}
.card-field input {
  font-size: 0.64rem;
  padding: 0.34rem 0.8rem;
}
.btn-copy-inline {
  width: 32px;
  height: 28px;
}
.btn-copy-inline svg {
  width: 11px;
  height: 11px;
}
.card-actions {
  margin-top: 0.56rem;
  padding-top: 0.38rem;
  gap: 0.38rem;
}
.btn-card-action {
  font-size: 0.56rem;
  padding: 0.23rem 0.56rem;
}

/* ==========================================================================
   11. PAGINATION
   ========================================================================== */
.contacts-pagination {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.pagination-footer {
  display: flex;
  align-items: flex-end; /* page info sits on the same bottom edge as Log Out */
  justify-content: space-between;
  width: 100%;
  padding: 0;
}

.page-info {
  text-align: center;
  color: var(--text-main);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}

/* Left balancer to keep center buttons perfectly centered */
.pagination-spacer {
  flex: 1;
}

/* Middle pagination controls */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

/* Right side action container */
.pagination-actions {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.btn-logout {
  width: auto;
  background: #fef2f2;
  color: var(--danger);
  border: var(--border-width) solid var(--danger);
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
}

.btn-logout:hover {
  background: var(--danger);
  color: var(--bg-surface);
  border-color: var(--danger);
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.page-btn {
  width: auto;
  min-width: 2.25rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-main);
  border: var(--border-width) solid var(--border-default);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.page-btn:hover {
  background: #f3f4f6;
  border-color: var(--btn-fill);
}

.page-btn.active {
  background: radial-gradient(circle at center, var(--blue) 0%, #3b82f6 100%);
  color: var(--bg-surface);
  border-color: var(--blue-hover);
}

.page-ellipsis {
  color: var(--text-muted);
  padding: 0 0.25rem;
}
/* ==========================================================================
   12. SINGLE-ROW TOOLBAR & HEADER MANAGE BUTTON
   ========================================================================== */
.user-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.toolbar {
  align-items: center;
}
.toolbar .custom-select-wrapper label {
  white-space: nowrap;
}
.toolbar .custom-select {
  min-width: 200px;
}
.toolbar .btn-primary-pill {
  white-space: nowrap;
}

/* ==========================================================================
   13. HEIGHT-CONSTRAINED DASHBOARD LAYOUT
   The grid wrapper gets its height from the viewport (not from its cards),
   so JS can measure how many rows actually fit.
   ========================================================================== */
.dashboard-card {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.contacts-grid-wrapper {
  flex: 1;
  min-height: 0; /* lets a flex child shrink below its content size */
  overflow: hidden;
}

.contacts-grid {
  margin-bottom: 0; /* margin would skew the row math */
}

/* In normal flow (was position: fixed) so it reserves its own space
   instead of overlapping the grid. */
.contacts-pagination {
  position: static;
  flex-shrink: 0;
  padding-top: 0.5rem;
}

/* ==========================================================================
   14. TAGS
   ========================================================================== */
.contact-modal-card {
  max-height: 90vh;
  overflow-y: auto;
}

/* Pills on contact cards (fixed height so card heights stay uniform) */
.card-tags {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 1rem;
  margin-bottom: 0.56rem;
  overflow: hidden;
}

.tag-pill {
  display: inline-block;
  max-width: 48px;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  font-size: 0.56rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.tag-pill-more {
  background: var(--border-light);
  color: var(--text-muted);
}

/* Modal tag editor */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-chips:not(:empty) {
  margin-bottom: 0.5rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.3rem 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: var(--border-width) solid transparent;
}

.tag-chip.editing {
  border-color: var(--text-dark);
}

.tag-chip-label {
  cursor: pointer;
}

.tag-chip .tag-chip-remove {
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: none;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.18);
  color: inherit;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tag-chip .tag-chip-remove svg {
  display: block;
  pointer-events: none;
}

.tag-chip .tag-chip-remove:hover {
  background: rgba(0, 0, 0, 0.4);
}

.tag-editor {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tag-editor #tag-input {
  flex: 1;
  min-width: 0;
}

.tag-editor input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 44px;
  padding: 3px;
  border-radius: 50%;
  cursor: pointer;
  flex: none;
  overflow: hidden;
}

/* Mask the swatch itself to a circle so no square corners show through */
.tag-editor input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.tag-editor input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.tag-editor input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.tag-editor .tag-hex {
  width: 5.5rem;
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.tag-suggestions {
  margin-top: 0.35rem;
  max-height: 140px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-md);
}

.tag-suggestion {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
}

.tag-suggestion:hover {
  background: var(--primary);
  color: var(--bg-surface);
}

.tag-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.45);
}

.tag-cancel-edit {
  width: auto;
  align-self: flex-start;
  margin-top: 0.35rem;
  padding: 0;
  background: none;
  color: var(--primary);
  font-size: 0.75rem;
  border: none;
}

.tag-cancel-edit:hover {
  background: none;
  text-decoration: underline;
}

.tag-hint {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-light);
}

.tag-group .form-error {
  margin: 0.35rem 0 0;
  text-align: left;
}

/* Shown to admins when editing another user's contact */
.admin-edit-note {
  background: #fef3c7;
  border: var(--border-width) solid #fcd34d;
  color: #92400e;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* ==========================================================================
   15. TAG FILTER DROPDOWN
   ========================================================================== */
#tag-filter .custom-options,
#owner-filter .custom-options {
  max-height: 240px;
  overflow-y: auto;
}

#tag-filter .custom-option,
#owner-filter .custom-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ==========================================================================
   16. ACCESSIBILITY ADDITIONS
   ========================================================================== */
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Hint directly under the "Tags" label, above the chips */
.tag-group label + .tag-hint {
  margin: 0 0 0.5rem;
}

/* ==========================================================================
   17. COMPACT CONTACT CARDS
   Short, wide cards so two full rows of four fit on a laptop-height screen.
   Layout: name + ID / tags / inline Email / inline Phone / owner + actions.
   ========================================================================== */
.contacts-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.contact-card {
  padding: 0.75rem 0.7rem;
  gap: 0.5rem; /* vertical breathing room between the card's rows */
}

.card-top {
  margin-bottom: 0;
  align-items: baseline;
  gap: 0.4rem;
}

.card-top h3 {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-id {
  flex-shrink: 0;
}

.card-tags {
  height: 0.9rem;
  margin-bottom: 0;
}

/* Label sits to the left of the input instead of above it */
.card-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0;
}

.card-field label {
  flex: 0 0 2.1rem;
  margin: 0;
  font-size: 0.6rem;
}

.card-field .input-with-copy {
  flex: 1;
  min-width: 0;
  gap: 0.35rem;
}

.card-field input {
  padding: 0.3rem 0.8rem;
  min-width: 0;
}

.btn-copy-inline {
  width: 30px;
  height: 24px;
}

/* Bottom row: owner on the left, Edit / Delete on the right, no divider */
.card-actions {
  justify-content: space-between;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  gap: 0.5rem;
}

.card-actions .owner-tag {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-action-buttons {
  display: flex;
  gap: 0.38rem;
  flex-shrink: 0;
}

/* Reclaim vertical space above the grid */
.dashboard-header {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
}

.toolbar {
  margin-bottom: 1rem;
}
