/* =============================================
   TouchBase CRM — Stylesheet
   Lightweight, no framework dependency
   ============================================= */

:root {
  --primary:    #2563eb;
  --primary-d:  #1d4ed8;
  --success:    #16a34a;
  --danger:     #dc2626;
  --warning:    #d97706;
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #0f172a;
  --muted:      #64748b;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --nav-h:      56px;
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Navbar ── */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: var(--nav-h);
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.navbar-brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: #fff;
  letter-spacing: -.3px;
  flex-shrink: 0;
}
.navbar-brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: .25rem; flex: 1; }
.nav-links a {
  color: rgba(255,255,255,.85);
  padding: .4rem .75rem;
  border-radius: var(--radius);
  font-size: .9rem;
  transition: background .15s;
  white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,.2);
  color: #fff;
  text-decoration: none;
}
.navbar-right { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }

/* Hamburger */
.hamburger-btn {
  display: none;
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 6px;
  width: 36px; height: 36px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: rgba(255,255,255,.28); }
.hamburger-btn span {
  display: block;
  width: 18px; height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .22s, opacity .22s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .75rem;
  color: var(--text);
}

/* ── Stat grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
a.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  transform: translateY(-2px);
  border-color: var(--primary);
  text-decoration: none;
}
a.stat-card:hover .label { color: var(--primary); }
.stat-card .num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.stat-card .label {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .3rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .9rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: filter .15s, opacity .15s;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.92); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-secondary { background: var(--border);  color: var(--text); }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-icon { padding: .3rem; width: 32px; height: 32px; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
  color: var(--text);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: .25rem; }
.invalid-feedback { font-size: .78rem; color: var(--danger); margin-top: .25rem; display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Table ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
th {
  background: var(--bg);
  text-align: left;
  padding: .65rem .85rem;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .75rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f1f5f9; }

/* ── Alerts / Flash ── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.alert-success  { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info     { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning  { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ── Notification Bell ── */
.bell-wrap { position: relative; }
.bell-btn {
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 50%;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 1.1rem;
  transition: background .15s;
}
.bell-btn:hover { background: rgba(255,255,255,.3); }
.bell-badge {
  position: absolute;
  top: -3px; right: -3px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--primary);
}
.bell-badge.hidden { display: none; }

/* Notification dropdown */
.notif-dropdown {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
  display: none;
}
.notif-dropdown.open { display: block; }
.notif-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eff6ff; }
.notif-item.unread:hover { background: #dbeafe; }
.notif-item-title { font-size: .875rem; font-weight: 500; }
.notif-item-meta  { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.notif-actions { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.notif-footer {
  padding: .6rem 1rem;
  text-align: center;
  font-size: .8rem;
  border-top: 1px solid var(--border);
}
.notif-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .875rem;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-birthday    { background: #fce7f3; color: #9d174d; }
.badge-anniversary { background: #fef3c7; color: #92400e; }
.badge-visit       { background: #d1fae5; color: #065f46; }
.badge-custom      { background: #ede9fe; color: #5b21b6; }

/* ── Calendar ── */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: .5rem;
}
.calendar-title { font-size: 1.25rem; font-weight: 700; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-day-name {
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  padding: .5rem 0;
  text-transform: uppercase;
}
.cal-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-height: 80px;
  padding: .4rem;
  vertical-align: top;
  cursor: pointer;
  transition: background .1s;
}
.cal-cell:hover { background: #f1f5f9; }
.cal-cell.today { border-color: var(--primary); border-width: 2px; }
.cal-cell.empty { background: var(--bg); cursor: default; }
.cal-date {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .25rem;
}
.cal-cell.today .cal-date { color: var(--primary); }
.cal-event {
  display: block;
  font-size: .7rem;
  padding: .1rem .3rem;
  border-radius: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
a.cal-event { text-decoration: none; cursor: pointer; }
a.cal-event:hover { opacity: .85; text-decoration: underline; }

/* ── Client profile header ── */
.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.profile-header-info { flex: 1; min-width: 0; }
.profile-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.profile-name { font-size: 1.2rem; font-weight: 700; }
.profile-meta { font-size: .875rem; color: var(--muted); margin-top: .15rem; }

/* ── 2-column grid that collapses ── */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Sidebar grid: main content + fixed-width panel ── */
.grid-sidebar {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}
.sticky-panel { position: sticky; top: 1rem; }

/* ── Admin sub-nav ── */
.admin-sub-nav {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: .75rem;
}

/* ── Update Alerts button state ── */
#btn-update-alerts.loading { opacity: .7; pointer-events: none; }
#alert-result { display: none; margin-top: .75rem; }

/* ── Misc utilities ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: .75rem;
  flex-wrap: wrap;
}
.page-title { font-size: 1.25rem; font-weight: 700; }
.text-muted { color: var(--muted); }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.d-flex { display: flex; }
.gap-2  { gap: .5rem; }
.flex-1 { flex: 1; }
.section-title {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--border);
}
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: .1rem .3rem;
}
.modal-close:hover { color: var(--text); }

/* Interaction status badges */
.badge-reached     { background: #dbeafe; color: #1e40af; }
.badge-no-response { background: #f1f5f9; color: #475569; }
.badge-responded   { background: #dcfce7; color: #166534; }
.badge-followup    { background: #fef3c7; color: #92400e; }
.badge-secondary   { background: #f1f5f9; color: #475569; }

/* Status semantic badge colors (account status, ticket status, activity log) */
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* Banner-style status block (wider padding than pill badge) */
.status-banner {
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .9rem;
}

/* Announcement preview box inside dashboard */
.announcement-preview {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.announcement-preview-title { font-weight: 600; font-size: .85rem; color: #92400e; margin-bottom: .2rem; }
.announcement-preview-body  { font-size: .9rem; color: #78350f; }
.announcement-preview-meta  { font-size: .75rem; color: #92400e; margin-top: .2rem; }

/* Inline text color utilities */
.text-warning-muted { color: #92400e; }
.text-danger-muted  { color: #991b1b; }

/* Renewal days chip */
.renewal-days-warning { background: #fef3c7; color: #92400e; font-size: .75rem; padding: .15rem .5rem; border-radius: 10px; white-space: nowrap; }
.renewal-days-danger  { background: #fee2e2; color: #991b1b; font-size: .75rem; padding: .15rem .5rem; border-radius: 10px; white-space: nowrap; }

/* ── Auth layout ── */
.auth-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2rem 1.5rem;
}
.auth-title { font-size: 1.35rem; font-weight: 700; margin-bottom: .25rem; }
.auth-subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-switch { text-align: center; margin-top: 1.25rem; font-size: .875rem; color: var(--muted); }
.form-control.is-error { border-color: var(--danger); }

/* ── User menu ── */
.user-menu-wrap { position: relative; }
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: var(--radius);
  padding: .3rem .6rem;
  cursor: pointer;
  color: #fff;
  font-size: .875rem;
  transition: background .15s;
}
.user-menu-btn:hover { background: rgba(255,255,255,.25); }
.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.user-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-dropdown {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
  display: none;
}
.user-dropdown.open { display: block; }
.user-dropdown-header { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.user-dropdown-item {
  display: block;
  padding: .6rem 1rem;
  font-size: .875rem;
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: background .1s;
  width: 100%;
  text-align: left;
}
.user-dropdown-item:hover { background: var(--bg); text-decoration: none; }
.user-dropdown-item--danger { color: var(--danger); }
.user-dropdown-divider { border-top: 1px solid var(--border); margin: .25rem 0; }

/* Pagination */
.pagination { display: flex; gap: .35rem; list-style: none; margin-top: 1rem; flex-wrap: wrap; }
.page-link {
  padding: .3rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--primary);
}
.page-item.active .page-link { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-item.disabled .page-link { color: var(--muted); pointer-events: none; }

/* Search bar */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search-bar .form-control { flex: 1; min-width: 160px; max-width: 340px; }

/* ── Responsive card-table (used on wide tables for mobile) ── */
.table-cards { width: 100%; }


/* ══════════════════════════════════════════════
   RESPONSIVE
   Breakpoints: tablet ≤ 900px  |  mobile ≤ 640px
   ══════════════════════════════════════════════ */

/* ── Tablet ── */
@media (max-width: 900px) {
  .user-name { display: none; }

  .notif-dropdown {
    width: 300px;
  }

  .grid-2col {
    grid-template-columns: 1fr;
  }

  .grid-sidebar {
    grid-template-columns: 1fr;
  }
  .sticky-panel { position: static; }

  .cal-cell { min-height: 60px; }
  .cal-event { font-size: .65rem; }

  /* Super-admin sub-nav: scroll horizontally at tablet rather than wrapping to 2 rows */
  .admin-sub-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .admin-sub-nav::-webkit-scrollbar { display: none; }
}

/* ── Mobile ── */
@media (max-width: 640px) {
  /* Navbar — hamburger mode */
  .navbar {
    padding: 0 1rem;
    flex-wrap: wrap;
    height: auto;
    min-height: var(--nav-h);
  }
  .navbar > .navbar-brand { line-height: var(--nav-h); }
  .navbar-spacer { flex: 1; }

  .hamburger-btn { display: flex; }

  .nav-links {
    display: none;
    order: 10;          /* push below the main row */
    width: 100%;
    flex-direction: column;
    gap: .2rem;
    padding: .5rem 0 .75rem;
    border-top: 1px solid rgba(255,255,255,.15);
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    padding: .55rem .75rem;
    border-radius: var(--radius);
  }
  /* keep text visible on mobile (was hidden at 700px) */
  .nav-links a span { display: inline !important; }

  /* Compact right side */
  .navbar-right { gap: .5rem; }

  /* Container */
  .container { padding: 1rem .75rem; }

  /* Page header */
  .page-title { font-size: 1.1rem; }

  /* Profile header: stack avatar+info, then actions below */
  .profile-header { flex-direction: column; gap: .75rem; }
  .profile-header-actions { width: 100%; }

  /* 2-col grid → single column */
  .grid-2col { grid-template-columns: 1fr; }

  /* Form row → single column */
  .form-row { grid-template-columns: 1fr; }

  /* Search bar full-width */
  .search-bar .form-control { max-width: 100%; }

  /* Notification dropdown — fixed just below navbar, spans viewport */
  .notif-dropdown {
    position: fixed;
    top: var(--nav-h);
    left: .75rem;
    right: .75rem;
    width: auto;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 300;
  }
  .notif-list { max-height: unset; }

  /* Calendar */
  .cal-cell { min-height: 44px; padding: .2rem; }
  .cal-date { font-size: .7rem; }
  .cal-day-name { font-size: .65rem; padding: .3rem 0; }
  .cal-event { font-size: .6rem; padding: .05rem .2rem; }
  .calendar-title { font-size: 1rem; }

  /* Stat cards */
  .stat-card .num { font-size: 1.6rem; }

  /* Stats grid: 2 columns on mobile */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Auth card */
  .auth-card { padding: 1.5rem 1.25rem 1.25rem; }

  /* Modal */
  .modal-box { margin: 0; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  /* Card-table: stack rows as cards on mobile */
  .table-cards thead { display: none; }
  .table-cards tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .75rem;
    background: var(--surface);
  }
  .table-cards tbody tr:hover td { background: unset; }
  .table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
    padding: .55rem .85rem;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
  }
  .table-cards td:last-child { border-bottom: none; }
  .table-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    flex-shrink: 0;
    min-width: 80px;
    padding-top: .1rem;
  }
  .table-cards td:empty { display: none; }

  /* Regular table-wrap: hint that content scrolls */
  .table-wrap { position: relative; }
}

/* ── Sortable table headers ─────────────────────────── */
.sort-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.sort-link:hover { color: var(--primary); text-decoration: none; }
.sort-link.sort-active { color: var(--primary); }
.sort-arrow { font-size: .75rem; opacity: .5; }
.sort-link.sort-active .sort-arrow { opacity: 1; }

/* ── Tag / Label chip input ─────────────────────────── */
.tag-input-box {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 42px;
  cursor: text;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.tag-input-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem .5rem;
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 500;
}
.tag-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: #7c3aed;
  font-size: .9rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
}
.tag-chip button:hover { color: var(--danger); }
.tag-text {
  border: none;
  outline: none;
  flex: 1;
  min-width: 80px;
  font-size: .875rem;
  font-family: inherit;
  background: transparent;
  color: var(--text);
  padding: .1rem 0;
}
.tag-badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .5rem;
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
  line-height: 1.4;
}
.tag-badge:hover { background: #ddd6fe; text-decoration: none; }

/* ── Announcement banner ─────────────────────────────── */
.announcement-banner {
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fbbf24;
  padding: .45rem 1rem;
  text-align: center;
  font-size: .875rem;
}

/* ── Auth icon circles ───────────────────────────────── */
.icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px; height: 52px;
  border-radius: 50%;
  margin-bottom: .75rem;
}
.icon-circle-info   { background: #dbeafe; }
.icon-circle-danger { background: #fee2e2; }

/* ── Ticket submitted flash card ─────────────────────── */
.ticket-submitted-card {
  border-left: 4px solid var(--success);
  background: #f0fdf4;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.ticket-submitted-note { color: #166534; font-size: .9rem; }

/* ── Free-trial offer card (register-payment) ───────── */
.trial-offer-card {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.25rem 1.1rem;
  margin-bottom: 1.25rem;
}
.trial-offer-title { font-size: 1rem;  font-weight: 700; color: #1e3a8a; margin-bottom: .25rem; }
.trial-offer-desc  { font-size: .85rem; color: #1e40af; line-height: 1.5; }
.trial-offer-sub   { font-size: .78rem; color: #2563eb; }
.trial-offer-price { font-size: 1.5rem; font-weight: 800; color: #2563eb; white-space: nowrap; }

/* ── Plan row: trial (superadmin) ────────────────────── */
.plan-row-trial {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem .75rem;
  background: #eff6ff;
  border-radius: var(--radius);
  border: 1px solid #bfdbfe;
}
.plan-row-trial-label { font-weight: 600; font-size: .9rem;  color: #1e40af; }
.plan-row-trial-sub   { font-size: .78rem; color: #3b82f6; }
.plan-row-trial-count { font-size: 1.4rem; font-weight: 700; line-height: 1; color: #2563eb; }

/* ── Dark mode toggle button ─────────────────────────── */
.theme-toggle-btn {
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 50%;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 1.1rem;
  transition: background .15s;
  flex-shrink: 0;
}
.theme-toggle-btn:hover { background: rgba(255,255,255,.3); }

/* ══════════════════════════════════════════════
   DARK MODE  — [data-theme="dark"] on <html>
   ══════════════════════════════════════════════ */

[data-theme="dark"] {
  --primary:   #3b82f6;
  --primary-d: #2563eb;
  --success:   #22c55e;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --bg:        #0f172a;
  --surface:   #1e293b;
  --border:    #334155;
  --text:      #f1f5f9;
  --muted:     #94a3b8;
  --shadow:    0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
}

[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] a { color: #60a5fa; }

/* Forms */
[data-theme="dark"] .form-control { background: #1e293b; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .form-control:focus { border-color: var(--primary); }
[data-theme="dark"] .tag-input-box { background: #1e293b; }
[data-theme="dark"] .tag-text { color: var(--text); }

/* Tables */
[data-theme="dark"] th { background: #161f2e; color: var(--muted); border-color: var(--border); }
[data-theme="dark"] td { border-color: var(--border); }
[data-theme="dark"] tr:hover td { background: #263245; }
[data-theme="dark"] tr:last-child td { border-bottom: none; }

/* Notification dropdown */
[data-theme="dark"] .notif-item:hover { background: #263245; }
[data-theme="dark"] .notif-item.unread { background: #1e3a5f; }
[data-theme="dark"] .notif-item.unread:hover { background: #1a3560; }

/* User dropdown */
[data-theme="dark"] .user-dropdown-item:hover { background: #263245; }

/* Calendar */
[data-theme="dark"] .cal-cell:hover { background: #263245; }
[data-theme="dark"] .cal-cell.empty { background: #131c2e; }
[data-theme="dark"] .cal-cell.today { border-color: var(--primary); }

/* Alerts */
[data-theme="dark"] .alert-success  { background: #14532d; color: #bbf7d0; border-color: #166534; }
[data-theme="dark"] .alert-danger   { background: #450a0a; color: #fecaca; border-color: #991b1b; }
[data-theme="dark"] .alert-info     { background: #1e3a5f; color: #bfdbfe; border-color: #1d4ed8; }
[data-theme="dark"] .alert-warning  { background: #451a03; color: #fde68a; border-color: #92400e; }

/* Tags */
[data-theme="dark"] .tag-chip  { background: #312e81; color: #c4b5fd; }
[data-theme="dark"] .tag-chip button { color: #a78bfa; }
[data-theme="dark"] .tag-badge { background: #312e81; color: #c4b5fd; }
[data-theme="dark"] .tag-badge:hover { background: #3730a3; }

/* Buttons */
[data-theme="dark"] .btn-secondary { background: #334155; color: var(--text); }

/* Announcement banner */
[data-theme="dark"] .announcement-banner { background: #451a03; color: #fbbf24; border-color: #92400e; }

/* Auth card */
[data-theme="dark"] .auth-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .auth-body { background: var(--bg); }

/* Mobile card-table rows */
@media (max-width: 640px) {
  [data-theme="dark"] .table-cards tbody tr { background: var(--surface); border-color: var(--border); }
  [data-theme="dark"] .table-cards td { border-color: var(--border); }
}

/* Badges */
[data-theme="dark"] .badge-birthday    { background: #831843; color: #fbcfe8; }
[data-theme="dark"] .badge-anniversary { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-visit       { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .badge-custom      { background: #3730a3; color: #c4b5fd; }
[data-theme="dark"] .badge-secondary   { background: #1e293b; color: #94a3b8; border: 1px solid var(--border); }
[data-theme="dark"] .badge-reached     { background: #1e3a5f; color: #bfdbfe; }
[data-theme="dark"] .badge-no-response { background: #1e293b; color: #94a3b8; }
[data-theme="dark"] .badge-responded   { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .badge-followup    { background: #78350f; color: #fde68a; }

/* Inputs / selects */
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #64748b; }
[data-theme="dark"] select.form-control option { background: #1e293b; color: var(--text); }

/* Dropdown shadows */
[data-theme="dark"] .notif-dropdown,
[data-theme="dark"] .user-dropdown { box-shadow: 0 8px 24px rgba(0,0,0,.55); }

[data-theme="dark"] .notif-footer { border-top: 1px solid var(--border); background: var(--surface); }
[data-theme="dark"] .notif-footer a { color: #60a5fa; }

/* Bell & theme-toggle on navbar (navbar stays primary-blue) */
[data-theme="dark"] .bell-btn { color: #fff; }

/* Scrollbars */
[data-theme="dark"] * { scrollbar-color: #334155 #1e293b; }

/* HR */
[data-theme="dark"] hr { border-color: var(--border); }

/* Code / pre */
[data-theme="dark"] pre, [data-theme="dark"] code { background: #1e293b; color: #e2e8f0; border-color: var(--border); }

/* Status badge semantic colors (used on .badge pills) */
[data-theme="dark"] .badge-warning { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-success { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .badge-danger  { background: #450a0a; color: #fecaca; }
[data-theme="dark"] .badge-info    { background: #1e3a5f; color: #bfdbfe; }
[data-theme="dark"] .badge-neutral { background: #1e293b; color: #94a3b8; }

/* Status banner */
[data-theme="dark"] .status-banner.badge-warning { background: #78350f; color: #fde68a; }
[data-theme="dark"] .status-banner.badge-success { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .status-banner.badge-danger  { background: #450a0a; color: #fecaca; }
[data-theme="dark"] .status-banner.badge-info    { background: #1e3a5f; color: #bfdbfe; }
[data-theme="dark"] .status-banner.badge-neutral { background: #1e293b; color: #94a3b8; }

/* Announcement preview box */
[data-theme="dark"] .announcement-preview       { background: #451a03; border-color: #92400e; color: #fde68a; }
[data-theme="dark"] .announcement-preview-title { color: #fde68a; }
[data-theme="dark"] .announcement-preview-body  { color: #fde68a; }
[data-theme="dark"] .announcement-preview-meta  { color: #fbbf24; }

/* Inline text color utilities */
[data-theme="dark"] .text-warning-muted { color: #fde68a; }
[data-theme="dark"] .text-danger-muted  { color: #fca5a5; }

/* Renewal days pill */
[data-theme="dark"] .renewal-days-warning { background: #78350f; color: #fde68a; }
[data-theme="dark"] .renewal-days-danger  { background: #450a0a; color: #fecaca; }

/* Auth icon circles */
[data-theme="dark"] .icon-circle-info   { background: #1e3a5f; }
[data-theme="dark"] .icon-circle-danger { background: #450a0a; }

/* Ticket submitted flash card */
[data-theme="dark"] .ticket-submitted-card { background: #14532d; }
[data-theme="dark"] .ticket-submitted-note { color: #bbf7d0; }

/* Free-trial offer card */
[data-theme="dark"] .trial-offer-card  { background: linear-gradient(135deg, #1e3a5f, #1a2e4a); border-color: var(--primary); }
[data-theme="dark"] .trial-offer-title { color: #bfdbfe; }
[data-theme="dark"] .trial-offer-desc  { color: #93c5fd; }
[data-theme="dark"] .trial-offer-sub   { color: #60a5fa; }
[data-theme="dark"] .trial-offer-price { color: #60a5fa; }

/* Plan row: trial (superadmin) */
[data-theme="dark"] .plan-row-trial             { background: #1e3a5f; border-color: #1d4ed8; }
[data-theme="dark"] .plan-row-trial-label        { color: #bfdbfe; }
[data-theme="dark"] .plan-row-trial-sub,
[data-theme="dark"] .plan-row-trial-count        { color: #93c5fd; }
