/* Altify SMS — minimal responsive app shell */
:root {
  --af-bg: #f4f7fb;
  --af-surface: #ffffff;
  --af-border: #e8eef5;
  --af-text: #0f172a;
  --af-muted: #64748b;
  --af-primary: #3b6ef5;
  --af-primary-soft: #e8effe;
  --af-primary-dark: #2a56d4;
  --af-success: #059669;
  --af-success-soft: #d1fae5;
  --af-danger: #dc2626;
  --af-danger-soft: #fee2e2;
  --af-warning: #d97706;
  --af-warning-soft: #ffedd5;
  --af-purple: #7c3aed;
  --af-purple-soft: #ede9fe;
  --af-sidebar-bg: #eef2f7;
  --af-sidebar-link: #475569;
  --af-sidebar-hover: rgba(255, 255, 255, 0.7);
  --af-input-bg: #ffffff;
  --af-input-border: #dbe3ef;
  --af-table-stripe: #f8fafc;
  --af-sidebar-w: 248px;
  --af-sidebar-collapsed: 72px;
  --af-radius: 12px;
  --af-radius-sm: 8px;
  --af-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  /* Brand type stack — mirrors altifysolutions.com */
  --af-font-sans: "Nunito Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --af-font-display: "Nunito Sans", ui-sans-serif, system-ui, sans-serif;
  --af-font-poppins: Poppins, "Nunito Sans", ui-sans-serif, system-ui, sans-serif;
  --af-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --af-font: var(--af-font-sans);
  --af-space-1: 4px;
  --af-space-2: 8px;
  --af-space-3: 12px;
  --af-space-4: 16px;
  --af-space-5: 20px;
  --af-space-6: 24px;
  --af-pad-x: clamp(12px, 2.2vw, 28px);
  --af-pad-y: clamp(10px, 1.6vw, 20px);
  --af-fs-xs: 0.6875rem;   /* 11 */
  --af-fs-sm: 0.8125rem;   /* 13 */
  --af-fs-base: 0.875rem;  /* 14 */
  --af-fs-md: 0.9375rem;   /* 15 */
  --af-fs-lg: clamp(1.05rem, 0.9rem + 0.4vw, 1.25rem);
  --af-fs-xl: clamp(1.2rem, 1rem + 0.55vw, 1.4rem);
  --af-lh: 1.45;
  color-scheme: light;
}

html.af-dark {
  --af-bg: #0b1220;
  --af-surface: #111827;
  --af-border: #1f2a3d;
  --af-text: #f1f5f9;
  --af-muted: #94a3b8;
  --af-primary-soft: #1e2f55;
  --af-success-soft: #064e3b;
  --af-danger-soft: #450a0a;
  --af-warning-soft: #451a03;
  --af-purple-soft: #2e1065;
  --af-sidebar-bg: #0f172a;
  --af-sidebar-link: #cbd5e1;
  --af-sidebar-hover: rgba(255, 255, 255, 0.06);
  --af-input-bg: #0f172a;
  --af-input-border: #243247;
  --af-table-stripe: #0f172a;
  --af-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

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

body.af-app {
  margin: 0;
  font-family: var(--af-font-sans) !important;
  font-size: var(--af-fs-base);
  line-height: var(--af-lh);
  background: var(--af-bg) !important;
  color: var(--af-text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.af-font-display,
.font-display {
  font-family: var(--af-font-display) !important;
}

.af-font-poppins,
.font-poppins {
  font-family: var(--af-font-poppins) !important;
}

.af-font-mono,
.font-mono {
  font-family: var(--af-font-mono) !important;
}

body.af-app h1,
body.af-app h2,
body.af-app h3,
body.af-app h4,
body.af-app .af-topbar__titles h1,
body.af-app .af-chart-card h3,
body.af-app .af-metric__value,
body.af-app .af-sidebar__brand-name,
body.af-app .content-header h1,
body.af-app .card-title {
  font-family: var(--af-font-display);
  letter-spacing: -0.02em;
}

body.af-app .btn,
body.af-app .form-control,
body.af-app .custom-select,
body.af-app .select2-container,
body.af-app .dropdown-menu,
body.af-app .nav-link,
body.af-app .table,
body.af-app input,
body.af-app select,
body.af-app textarea,
body.af-app button {
  font-family: inherit;
}

body.af-auth .btn,
body.af-auth .form-control,
body.af-auth input,
body.af-auth select,
body.af-auth textarea,
body.af-auth button {
  font-family: inherit;
}

body.af-app .wrapper {
  display: flex !important;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--af-bg) !important;
}

/* —— Sidebar —— */
.af-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--af-sidebar-w);
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--af-sidebar-bg);
  border-right: 1px solid var(--af-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1040;
  transition: width 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.af-sidebar__brand {
  margin: 14px 14px 8px;
  padding: 12px 14px;
  background: var(--af-surface);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  text-decoration: none !important;
  box-shadow: var(--af-shadow);
  border: 1px solid var(--af-border);
}

.af-sidebar__logo-full {
  height: 28px;
  width: auto;
  max-width: 132px;
  flex-shrink: 0;
  display: block;
}

.af-sidebar__logo-mark {
  display: none;
  width: 36px;
  height: 32px;
  flex-shrink: 0;
  object-fit: contain;
}

/* Legacy square mark (kept for any residual markup) */
.af-sidebar__logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
  overflow: hidden;
}

.af-sidebar__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.af-sidebar__brand-text {
  min-width: 0;
}

.af-sidebar__brand-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--af-text);
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.af-sidebar__brand-sub {
  display: block;
  font-size: 11px;
  color: var(--af-muted);
  margin-top: 0;
  line-height: 1.3;
}

.af-sidebar__nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding: 8px 12px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.45) transparent;
}

.af-sidebar__nav::-webkit-scrollbar {
  width: 6px;
}

.af-sidebar__nav::-webkit-scrollbar-track {
  background: transparent;
}

.af-sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.4);
  border-radius: 999px;
}

.af-nav-group {
  margin-bottom: 14px;
}

.af-nav-group__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--af-muted);
  padding: 4px 10px 6px;
  margin: 0;
}

.af-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--af-radius-sm);
  color: var(--af-sidebar-link) !important;
  text-decoration: none !important;
  font-size: var(--af-fs-sm);
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.af-nav-link:hover {
  background: var(--af-sidebar-hover);
  color: var(--af-text) !important;
}

.af-nav-link.is-active {
  background: var(--af-primary-soft) !important;
  color: var(--af-primary) !important;
  font-weight: 700;
}

.af-icon,
.af-nav-link svg,
.af-topbar__toggle svg,
.af-chip svg,
.af-icon-btn svg,
.af-sidebar__logout svg,
.af-nav-caret svg {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  min-height: 18px;
  flex-shrink: 0;
  display: block;
  stroke: currentColor !important;
  fill: none !important;
  color: inherit;
  overflow: visible;
}

.af-chip svg {
  width: 15px !important;
  height: 15px !important;
  min-width: 15px;
  min-height: 15px;
  color: var(--af-muted);
}

.af-icon-btn .af-theme-moon,
.af-icon-btn .af-theme-sun {
  display: grid;
  place-items: center;
  line-height: 0;
}

.af-topbar__toggle,
.af-icon-btn {
  color: var(--af-sidebar-link) !important;
}

.af-topbar__toggle:hover,
.af-icon-btn:hover {
  color: var(--af-primary) !important;
}

.af-nav-link .af-badge-count {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--af-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.af-nav-sub {
  display: none;
  padding: 2px 0 6px 28px;
}

.af-nav-item.is-open > .af-nav-sub {
  display: block;
}

.af-nav-sub .af-nav-link {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 450;
}

.af-nav-caret {
  margin-left: auto;
  transition: transform 0.15s ease;
  opacity: 0.55;
}

.af-nav-item.is-open > .af-nav-link .af-nav-caret {
  transform: rotate(90deg);
}

.af-sidebar__profile {
  margin: 8px 14px 14px;
  padding: 10px 12px;
  background: var(--af-surface);
  border-radius: 14px;
  border: 1px solid var(--af-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  box-shadow: var(--af-shadow);
}

.af-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 999px;
  background: var(--af-primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  line-height: 1;
}

.af-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.af-sidebar__profile-meta {
  min-width: 0;
  flex: 1;
}

.af-sidebar__profile-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--af-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.af-sidebar__profile-role {
  font-size: 11px;
  color: var(--af-muted);
}

.af-sidebar__logout {
  color: var(--af-muted);
  display: grid;
  place-items: center;
  padding: 6px;
  border-radius: 8px;
}

.af-sidebar__logout:hover {
  background: var(--af-danger-soft);
  color: var(--af-danger);
}

/* —— Main column —— */
.af-main {
  margin-left: var(--af-sidebar-w);
  flex: 1 1 auto;
  min-width: 0;
  width: calc(100% - var(--af-sidebar-w));
  display: flex;
  flex-direction: column;
  /* Do not force 100vh here — stacks with topbar/footer and causes blank scroll */
  min-height: 0;
  position: relative;
  transition: margin-left 0.2s ease, width 0.2s ease;
}

@media (min-width: 993px) {
body.af-sidebar-collapsed .af-sidebar {
  width: var(--af-sidebar-collapsed);
}

body.af-sidebar-collapsed .af-main {
  margin-left: var(--af-sidebar-collapsed);
  width: calc(100% - var(--af-sidebar-collapsed));
}

body.af-sidebar-collapsed .af-sidebar__brand-text,
body.af-sidebar-collapsed .af-sidebar__logo-full,
body.af-sidebar-collapsed .af-nav-group__label,
body.af-sidebar-collapsed .af-nav-link span:not(.af-badge-count),
body.af-sidebar-collapsed .af-nav-caret,
body.af-sidebar-collapsed .af-sidebar__profile-meta,
body.af-sidebar-collapsed .af-sidebar__brand-sub {
  display: none;
}

body.af-sidebar-collapsed .af-sidebar__logo-mark {
  display: block;
}

body.af-sidebar-collapsed .af-nav-link {
  justify-content: center;
  padding: 10px;
}

body.af-sidebar-collapsed .af-sidebar__brand,
body.af-sidebar-collapsed .af-sidebar__profile {
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
}

/* Collapsed profile: avatar only, centered in the rail */
body.af-sidebar-collapsed .af-sidebar__profile {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 8px 12px 14px;
  padding: 10px 8px;
  min-width: 0;
  overflow: hidden;
}

body.af-sidebar-collapsed .af-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
}

body.af-sidebar-collapsed .af-sidebar__logout {
  padding: 5px;
  margin-top: 2px;
}

body.af-sidebar-collapsed .af-sidebar__logout svg {
  width: 15px;
  height: 15px;
}

/* Collapsed rail expands on hover so the full menu stays reachable */
  body.af-sidebar-collapsed .af-sidebar:hover,
  body.af-sidebar-collapsed .af-sidebar:focus-within {
    width: var(--af-sidebar-w);
    box-shadow: 8px 0 28px rgba(15, 23, 42, 0.14);
  }

  body.af-sidebar-collapsed .af-sidebar:hover .af-sidebar__brand-text,
  body.af-sidebar-collapsed .af-sidebar:hover .af-sidebar__logo-full,
  body.af-sidebar-collapsed .af-sidebar:hover .af-nav-group__label,
  body.af-sidebar-collapsed .af-sidebar:hover .af-nav-link span:not(.af-badge-count),
  body.af-sidebar-collapsed .af-sidebar:hover .af-nav-caret,
  body.af-sidebar-collapsed .af-sidebar:hover .af-sidebar__profile-meta,
  body.af-sidebar-collapsed .af-sidebar:hover .af-sidebar__brand-sub,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-sidebar__brand-text,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-sidebar__logo-full,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-nav-group__label,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-nav-link span:not(.af-badge-count),
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-nav-caret,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-sidebar__profile-meta,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-sidebar__brand-sub {
    display: block;
  }

  body.af-sidebar-collapsed .af-sidebar:hover .af-sidebar__logo-mark,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-sidebar__logo-mark {
    display: none;
  }

  body.af-sidebar-collapsed .af-sidebar:hover .af-nav-link,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-nav-link {
    justify-content: flex-start;
    padding: 8px 10px;
  }

  body.af-sidebar-collapsed .af-sidebar:hover .af-sidebar__brand,
  body.af-sidebar-collapsed .af-sidebar:hover .af-sidebar__profile,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-sidebar__brand,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-sidebar__profile {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    margin-left: 14px;
    margin-right: 14px;
    padding: 10px 12px;
    overflow: visible;
  }

  body.af-sidebar-collapsed .af-sidebar:hover .af-nav-caret,
  body.af-sidebar-collapsed .af-sidebar:focus-within .af-nav-caret {
    display: inline-flex;
    margin-left: auto;
  }
}

/* —— Topbar —— */
.af-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(244, 247, 251, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--af-border);
  padding: var(--af-space-3) var(--af-pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--af-space-3);
  min-height: 56px;
}

.af-topbar__left {
  display: flex;
  align-items: center;
  gap: var(--af-space-3);
  min-width: 0;
  flex: 1 1 auto;
}

.af-topbar__toggle {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--af-radius-sm);
  border: 1px solid var(--af-border);
  background: var(--af-surface);
  color: var(--af-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.af-topbar__toggle:hover {
  color: var(--af-primary);
  border-color: var(--af-primary-soft);
}

.af-topbar__titles {
  min-width: 0;
}

.af-topbar__titles h1 {
  margin: 0;
  font-size: var(--af-fs-lg);
  font-weight: 700;
  color: var(--af-text);
  letter-spacing: -0.02em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(52vw, 420px);
}

.af-topbar__titles p {
  margin: 2px 0 0;
  font-size: var(--af-fs-xs);
  color: var(--af-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: min(56vw, 480px);
}

.af-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--af-space-2);
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.af-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--af-surface);
  border: 1px solid var(--af-border);
  font-size: var(--af-fs-xs);
  font-weight: 600;
  color: var(--af-text);
  white-space: nowrap;
}

.af-chip--role {
  background: var(--af-primary-soft);
  border-color: transparent;
  color: var(--af-primary);
}

.af-chip--ghost {
  background: transparent;
}

.af-chip--action {
  text-decoration: none !important;
  color: var(--af-muted);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.af-chip--action:hover {
  color: var(--af-primary);
  border-color: rgba(59, 110, 245, 0.35);
  background: var(--af-primary-soft);
}

.af-chip--action svg {
  color: inherit;
}

.af-chip select {
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  outline: none;
  cursor: pointer;
  padding: 0;
}

.af-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--af-border);
  background: var(--af-surface);
  color: var(--af-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.af-icon-btn:hover {
  color: var(--af-primary);
}

/* —— Content —— */
.af-content {
  flex: 1 1 auto;
  min-height: 0;
}

.af-content .content-header {
  display: none !important;
}

/* Soft-restyle common AdminLTE cards inside new shell.
   Kill AdminLTE Layout.js / adminlte.css min-height so pages don't scroll into blank space. */
body.af-app .content-wrapper,
body.af-app .af-content.content-wrapper,
body.af-app .wrapper .content-wrapper {
  background: transparent !important;
  margin: 0 !important;
  margin-left: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding: var(--af-space-3) var(--af-pad-x) var(--af-space-6) !important;
  padding-bottom: var(--af-space-6) !important;
  min-height: 0 !important;
  height: auto !important;
  overflow: visible !important;
  overflow-y: visible !important;
  flex: 1 1 auto;
  max-width: 100%;
}

html.af-app,
html:has(body.af-app) {
  height: auto;
  overflow-x: hidden;
}

body.af-app .card {
  border: 1px solid var(--af-border) !important;
  border-radius: var(--af-radius) !important;
  box-shadow: none !important;
  background: var(--af-surface) !important;
  margin-bottom: var(--af-space-4) !important;
}

body.af-app .card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--af-border) !important;
  border-radius: var(--af-radius) var(--af-radius) 0 0 !important;
  padding: var(--af-space-3) var(--af-space-4) !important;
}

body.af-app .card-body {
  padding: var(--af-space-4) !important;
}

body.af-app .card-header h1,
body.af-app .card-header h2,
body.af-app .card-header h3,
body.af-app .card-header h4,
body.af-app .card-title {
  font-size: var(--af-fs-md) !important;
  font-weight: 700 !important;
  margin: 0 !important;
  letter-spacing: -0.01em;
}

body.af-app .btn-primary {
  background: var(--af-primary) !important;
  border-color: var(--af-primary) !important;
  border-radius: 999px !important;
  font-weight: 600;
  box-shadow: none !important;
}

body.af-app .btn-primary:hover {
  background: var(--af-primary-dark) !important;
  border-color: var(--af-primary-dark) !important;
}

body.af-app .table thead th {
  border-top: none !important;
  border-bottom: 1px solid var(--af-border) !important;
  color: #94a3b8 !important;
  font-size: var(--af-fs-xs) !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: transparent !important;
  padding: 10px 12px !important;
  white-space: nowrap;
}

body.af-app .table td {
  border-top: 1px solid var(--af-border) !important;
  vertical-align: middle !important;
  padding: 10px 12px !important;
  font-size: var(--af-fs-sm) !important;
}

body.af-app .table-body,
body.af-app .dataTables_wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Action dropdown lifted out of the table so the full list stays usable */
body > .dropdown-menu.af-action-menu {
  position: fixed !important;
  z-index: 1080 !important;
  min-width: 180px;
  max-height: min(360px, calc(100vh - 16px));
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.45) transparent;
}

body > .dropdown-menu.af-action-menu::-webkit-scrollbar {
  width: 6px;
}

body > .dropdown-menu.af-action-menu::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.45);
  border-radius: 999px;
}

/* Keep footer in normal document flow at the bottom of the main column.
   Overrides AdminLTE / custom.css position:fixed rules that pull it over content. */
body.af-app .main-footer,
body.af-app footer.main-footer,
body.af-app .af-footer {
  position: static !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  float: none !important;
  clear: both !important;
  z-index: 1 !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: auto 0 0 0 !important;
  margin-left: 0 !important;
  background: transparent !important;
  border: none !important;
  border-top: 1px solid var(--af-border) !important;
  color: var(--af-muted);
  font-size: var(--af-fs-xs);
  line-height: 1.5;
  padding: var(--af-space-3) var(--af-pad-x) var(--af-space-5) !important;
  transform: none !important;
}

body.af-app .main-footer .float-right {
  float: none !important;
  text-align: left;
}

/* Metric / badge utilities */
.af-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--af-space-3);
  margin-bottom: var(--af-space-4);
}

.af-metric {
  background: var(--af-surface);
  border: 1px solid var(--af-border);
  border-radius: var(--af-radius);
  box-shadow: none;
  padding: var(--af-space-3) var(--af-space-4);
}

.af-metric__label {
  font-size: var(--af-fs-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--af-muted);
  margin-bottom: 6px;
}

.af-metric__value {
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--af-text);
  line-height: 1.15;
}

.af-metric__value.is-success { color: var(--af-success); }
.af-metric__value.is-danger { color: var(--af-danger); }
.af-metric__value.is-warning { color: var(--af-warning); }

.af-chart-card {
  background: var(--af-surface);
  border: 1px solid var(--af-border);
  border-radius: var(--af-radius);
  box-shadow: none;
  padding: var(--af-space-4);
  margin-bottom: var(--af-space-4);
  color: var(--af-text);
}

.af-chart-card h3 {
  margin: 0 0 2px;
  font-size: var(--af-fs-md);
  font-weight: 700;
  color: var(--af-text);
}

.af-chart-card p {
  margin: 0 0 var(--af-space-3);
  font-size: var(--af-fs-xs);
  color: var(--af-muted);
}

.af-chart-wrap {
  position: relative;
  height: clamp(200px, 40vw, 280px);
}

.af-single-card {
  max-width: 860px;
}

.af-hide-mobile { display: inline-flex; }
.af-hide-tablet { display: inline-flex; }

.af-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.af-pill--gray { background: #f1f5f9; color: #64748b; }
.af-pill--green { background: var(--af-success-soft); color: var(--af-success); }
.af-pill--orange { background: var(--af-warning-soft); color: var(--af-warning); }
.af-pill--purple { background: var(--af-purple-soft); color: var(--af-purple); }
.af-pill--blue { background: var(--af-primary-soft); color: var(--af-primary); }
.af-pill--red { background: var(--af-danger-soft); color: var(--af-danger); }

.af-pill__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.af-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.af-filter {
  border: 1px solid var(--af-border);
  background: var(--af-table-stripe);
  color: var(--af-text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
}

.af-filter.is-active {
  background: var(--af-primary);
  border-color: var(--af-primary);
  color: #fff !important;
}

/* —— Tablet —— */
@media (max-width: 1100px) {
  .af-hide-tablet { display: none !important; }

  .af-topbar__titles p { display: none; }

  .af-metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }
}

/* —— Tablet / small laptop: off-canvas sidebar —— */
@media (max-width: 992px) {
  .af-sidebar {
    transform: translateX(-105%);
    width: min(280px, 86vw);
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.12);
  }

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

  .af-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  body.af-sidebar-collapsed .af-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .af-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 1035;
  }

  body.af-sidebar-open .af-backdrop {
    display: block;
  }

  .af-topbar {
    padding: var(--af-space-2) var(--af-pad-x);
    gap: var(--af-space-2);
  }

  .af-chip--action span { display: none; }
  .af-chip--action { padding: 8px; width: 36px; height: 36px; justify-content: center; }

  body.af-app .card-body { padding: var(--af-space-3) !important; }
  body.af-app .card-header { padding: var(--af-space-3) !important; }

  .af-footer,
  body.af-app .main-footer {
    padding: var(--af-space-3) var(--af-pad-x) !important;
    font-size: var(--af-fs-xs) !important;
  }
}

/* —— Phone —— */
@media (max-width: 640px) {
  .af-hide-mobile { display: none !important; }

  :root {
    --af-radius: 10px;
  }

  .af-topbar {
    align-items: center;
    min-height: 52px;
  }

  .af-topbar__titles h1 {
    max-width: 46vw;
    font-size: 1.05rem;
  }

  .af-topbar__right {
    gap: 6px;
  }

  .af-chip {
    padding: 5px 8px;
    font-size: 11px;
  }

  .af-icon-btn,
  .af-topbar__toggle {
    width: 36px;
    height: 36px;
  }

  .af-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--af-space-2);
  }

  .af-metric {
    padding: var(--af-space-3);
  }

  .af-metric__value {
    font-size: 1.2rem;
  }

  .af-chart-wrap {
    height: 200px;
  }

  .af-single-card {
    padding: var(--af-space-4) !important;
    border-radius: var(--af-radius) !important;
  }

  .af-compose-wrap {
    grid-template-columns: 1fr !important;
    gap: var(--af-space-4) !important;
  }

  .af-compose-preview { display: none !important; }

  body.af-app .btn,
  body.af-app .btn-sm {
    min-height: 36px;
  }

  body.af-app .table thead th,
  body.af-app .table td {
    padding: 8px 10px !important;
  }

  /* DataTables controls stack cleanly */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: left !important;
    width: 100%;
    margin-bottom: 8px;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: min(100%, 220px) !important;
    margin-left: 0 !important;
  }
}

/* —— Large desktop —— */
@media (min-width: 1400px) {
  .af-metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .af-topbar__titles h1 { max-width: 560px; }
  .af-topbar__titles p { max-width: 640px; }
}

/* —— Dark mode: app-wide AdminLTE / Bootstrap overrides —— */
html.af-dark body.af-app,
html.af-dark body.af-app .wrapper,
html.af-dark body.af-app .af-main {
  background: var(--af-bg) !important;
  color: var(--af-text);
}

html.af-dark body.af-app .card-title,
html.af-dark body.af-app .card-header h1,
html.af-dark body.af-app .card-header h2,
html.af-dark body.af-app .card-header h3,
html.af-dark body.af-app .card-header h4,
html.af-dark body.af-app h1,
html.af-dark body.af-app h2,
html.af-dark body.af-app h3,
html.af-dark body.af-app h4,
html.af-dark body.af-app h5,
html.af-dark body.af-app h6,
html.af-dark body.af-app .text-dark,
html.af-dark body.af-app label,
html.af-dark body.af-app .form-group > label {
  color: var(--af-text) !important;
}

html.af-dark body.af-app .text-muted,
html.af-dark body.af-app .text-secondary,
html.af-dark body.af-app small,
html.af-dark body.af-app .breadcrumb-item,
html.af-dark body.af-app .page-link {
  color: var(--af-muted) !important;
}

html.af-dark body.af-app .card-body,
html.af-dark body.af-app .card-footer,
html.af-dark body.af-app .list-group-item,
html.af-dark body.af-app .modal-content,
html.af-dark body.af-app .dropdown-menu,
html.af-dark body.af-app .popover,
html.af-dark body.af-app .info-box,
html.af-dark body.af-app .small-box,
html.af-dark body.af-app .direct-chat-messages {
  background: var(--af-surface) !important;
  color: var(--af-text) !important;
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app .modal-header,
html.af-dark body.af-app .modal-footer,
html.af-dark body.af-app .card-footer {
  border-color: var(--af-border) !important;
  background: var(--af-surface) !important;
}

html.af-dark body.af-app .close,
html.af-dark body.af-app .modal-header .close {
  color: var(--af-text);
  text-shadow: none;
  opacity: 0.75;
}

html.af-dark body.af-app .form-control,
html.af-dark body.af-app .custom-select,
html.af-dark body.af-app select.form-control,
html.af-dark body.af-app textarea.form-control,
html.af-dark body.af-app input.form-control,
html.af-dark body.af-app .input-group-text,
html.af-dark body.af-app .custom-file-label {
  background-color: var(--af-input-bg) !important;
  border-color: var(--af-input-border) !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-app .form-control::placeholder,
html.af-dark body.af-app textarea::placeholder {
  color: var(--af-muted) !important;
  opacity: 0.85;
}

html.af-dark body.af-app .form-control:focus,
html.af-dark body.af-app .custom-select:focus {
  background-color: var(--af-input-bg) !important;
  border-color: var(--af-primary) !important;
  color: var(--af-text) !important;
  box-shadow: 0 0 0 0.15rem rgba(59, 110, 245, 0.25) !important;
}

html.af-dark body.af-app .table,
html.af-dark body.af-app .table td,
html.af-dark body.af-app .table th,
html.af-dark body.af-app .dataTables_wrapper {
  color: var(--af-text) !important;
}

html.af-dark body.af-app .table,
html.af-dark body.af-app .table-bordered,
html.af-dark body.af-app .table-bordered td,
html.af-dark body.af-app .table-bordered th {
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app .table-striped tbody tr:nth-of-type(odd),
html.af-dark body.af-app .table-hover tbody tr:hover {
  background-color: var(--af-table-stripe) !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-app .table thead th,
html.af-dark body.af-app table.dataTable thead th,
html.af-dark body.af-app thead tr {
  color: var(--af-muted) !important;
  background: var(--af-surface) !important;
  background-color: var(--af-surface) !important;
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app .dropdown-item {
  color: var(--af-text) !important;
}

html.af-dark body.af-app .dropdown-item:hover,
html.af-dark body.af-app .dropdown-item:focus {
  background: var(--af-sidebar-hover) !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-app .dropdown-divider {
  border-top-color: var(--af-border) !important;
}

html.af-dark body.af-app .page-link {
  background: var(--af-surface) !important;
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app .page-item.active .page-link {
  background: var(--af-primary) !important;
  border-color: var(--af-primary) !important;
  color: #fff !important;
}

html.af-dark body.af-app .page-item.disabled .page-link {
  background: var(--af-surface) !important;
  border-color: var(--af-border) !important;
  color: var(--af-muted) !important;
}

html.af-dark body.af-app .nav-tabs {
  border-bottom-color: var(--af-border) !important;
}

html.af-dark body.af-app .nav-tabs .nav-link {
  color: var(--af-muted) !important;
}

html.af-dark body.af-app .nav-tabs .nav-link.active,
html.af-dark body.af-app .nav-pills .nav-link.active {
  background: var(--af-primary-soft) !important;
  color: var(--af-primary) !important;
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app .alert-light,
html.af-dark body.af-app .bg-light,
html.af-dark body.af-app .bg-white {
  background-color: var(--af-surface) !important;
  color: var(--af-text) !important;
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app .alert-info {
  background-color: rgba(59, 110, 245, 0.14) !important;
  color: var(--af-text) !important;
  border-color: rgba(59, 110, 245, 0.35) !important;
}

html.af-dark body.af-app .alert-info a {
  color: var(--af-primary) !important;
}

html.af-dark body.af-app .border,
html.af-dark body.af-app .border-top,
html.af-dark body.af-app .border-bottom,
html.af-dark body.af-app .border-left,
html.af-dark body.af-app .border-right {
  border-color: var(--af-border) !important;
}

/* Select2: dropdowns often append to <body>, so do not require body.af-app nesting */
html.af-dark .select2-container--default .select2-selection--single,
html.af-dark .select2-container--default .select2-selection--multiple,
html.af-dark body.af-app .select2-container--default .select2-selection--single,
html.af-dark body.af-app .select2-container--default .select2-selection--multiple {
  background-color: var(--af-input-bg) !important;
  border-color: var(--af-input-border) !important;
  color: var(--af-text) !important;
}

html.af-dark .select2-container--default .select2-selection--single .select2-selection__rendered,
html.af-dark .select2-container--default .select2-selection--multiple .select2-selection__choice,
html.af-dark body.af-app .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--af-text) !important;
  background: transparent;
}

html.af-dark .select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: var(--af-primary-soft) !important;
  border-color: var(--af-border) !important;
  color: var(--af-text) !important;
}

html.af-dark .select2-dropdown,
html.af-dark .select2-container--default .select2-results__option,
html.af-dark .select2-search--dropdown .select2-search__field,
html.af-dark body.af-app .select2-dropdown,
html.af-dark body.af-app .select2-container--default .select2-results__option,
html.af-dark body.af-app .select2-search--dropdown .select2-search__field {
  background: var(--af-surface) !important;
  color: var(--af-text) !important;
  border-color: var(--af-border) !important;
}

html.af-dark .select2-container--default .select2-results__option[aria-selected="true"] {
  background: var(--af-primary-soft) !important;
  color: var(--af-text) !important;
}

html.af-dark .select2-container--default .select2-results__option--highlighted[aria-selected],
html.af-dark body.af-app .select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: var(--af-primary) !important;
  color: #fff !important;
}

html.af-dark .select2-container--default .select2-selection__arrow b {
  border-color: var(--af-muted) transparent transparent transparent !important;
}

html.af-dark body.af-app .dataTables_wrapper .dataTables_length select,
html.af-dark body.af-app .dataTables_wrapper .dataTables_filter input,
html.af-dark body.af-app .dataTables_wrapper .dataTables_info,
html.af-dark body.af-app .dataTables_wrapper .dataTables_paginate {
  color: var(--af-muted) !important;
  background: transparent;
}

html.af-dark body.af-app .dataTables_wrapper .dataTables_filter input,
html.af-dark body.af-app .dataTables_wrapper .dataTables_length select {
  background: var(--af-input-bg) !important;
  border: 1px solid var(--af-input-border) !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-app .btn-default,
html.af-dark body.af-app .btn-outline-secondary,
html.af-dark body.af-app .btn-light {
  background: var(--af-surface) !important;
  border-color: var(--af-border) !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-app .btn-secondary {
  background: #334155 !important;
  border-color: #334155 !important;
  color: #fff !important;
}

html.af-dark body.af-app .custom-control-label::before {
  background-color: var(--af-input-bg);
  border-color: var(--af-input-border);
}

html.af-dark body.af-app .progress {
  background-color: var(--af-border) !important;
}

html.af-dark body.af-app .jumbotron,
html.af-dark body.af-app .callout {
  background: var(--af-surface) !important;
  color: var(--af-text) !important;
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app pre,
html.af-dark body.af-app code {
  background: var(--af-input-bg) !important;
  color: var(--af-text) !important;
  border-color: var(--af-border);
}

/* Default brand marks stay readable on dark surfaces */
html.af-dark .af-sidebar__logo-full[src*="images/brand/"],
html.af-dark .af-sidebar__logo-mark[src*="images/brand/"],
html.af-dark .login-logo img[src*="images/brand/"],
html.af-dark .af-auth-logo[src*="images/brand/"] {
  filter: brightness(0) invert(1);
}

html.af-dark .af-pill--gray {
  background: #1e293b;
  color: #94a3b8;
}

html.af-dark .af-topbar {
  background: rgba(11, 18, 32, 0.86);
}

html.af-dark .af-chip {
  background: var(--af-surface);
  border-color: var(--af-border);
  color: var(--af-text);
}

html.af-dark .af-chip--ghost {
  background: transparent;
}

html.af-dark .af-chip select,
html.af-dark .af-chip select option,
html.af-dark select option,
html.af-dark .af-select option,
html.af-dark .form-control option,
html.af-dark .custom-select option {
  background: var(--af-surface) !important;
  color: var(--af-text) !important;
}

/* Compose / Send Single shared surface (overrides page-level #fff styles) */
html.af-dark body.af-app .af-single-card,
html.af-dark body.af-app .af-settings-card {
  background: var(--af-surface) !important;
  border-color: var(--af-border) !important;
  box-shadow: var(--af-shadow) !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-app .af-single-card__title,
html.af-dark body.af-app .af-label,
html.af-dark body.af-app .af-radio,
html.af-dark body.af-app .af-check {
  color: var(--af-text) !important;
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app .af-input,
html.af-dark body.af-app .af-select,
html.af-dark body.af-app .af-textarea,
html.af-dark body.af-app .af-single-card .select2-container .select2-selection--single,
html.af-dark body.af-app .af-single-card .select2-container .select2-selection--multiple {
  background: var(--af-input-bg) !important;
  border-color: var(--af-input-border) !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-app .af-meta,
html.af-dark body.af-app .af-meta strong,
html.af-dark body.af-app .af-cost-line {
  color: var(--af-muted) !important;
  background: var(--af-input-bg) !important;
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app .af-cost-line strong {
  color: var(--af-primary) !important;
}

html.af-dark body.af-app .af-btn-ghost {
  background: var(--af-surface) !important;
  color: var(--af-text) !important;
  border-color: var(--af-border) !important;
}

html.af-dark body.af-app .af-btn-ghost:hover {
  background: var(--af-sidebar-hover) !important;
}

html.af-dark body.af-app .af-tag-btn {
  background: var(--af-primary-soft) !important;
  border-color: var(--af-border) !important;
  color: var(--af-primary) !important;
}

html.af-dark body.af-app .af-balance-chip {
  background: var(--af-success-soft) !important;
  border-color: rgba(5, 150, 105, 0.35) !important;
  color: #6ee7b7 !important;
}

html.af-dark body.af-app .af-balance-chip a {
  color: #6ee7b7 !important;
}

html.af-dark body.af-app .content-header,
html.af-dark body.af-app .content-header h1,
html.af-dark body.af-app .content-header .container-fluid {
  background: transparent !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-app .af-sidebar,
html.af-dark body.af-app .af-sidebar__nav,
html.af-dark body.af-app .af-sidebar__profile {
  background: var(--af-sidebar-bg) !important;
  border-color: var(--af-border) !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-app .af-nav-group__label {
  color: var(--af-muted) !important;
}

html.af-dark body.af-app .af-nav-link {
  color: var(--af-sidebar-link) !important;
}

html.af-dark body.af-app .af-nav-link:hover,
html.af-dark body.af-app .af-nav-link.is-active {
  color: var(--af-text) !important;
}

html.af-dark body.af-app .af-sidebar__brand-sub,
html.af-dark body.af-app .af-sidebar__profile-name,
html.af-dark body.af-app .af-sidebar__profile-role {
  color: var(--af-muted) !important;
}

html.af-dark body.af-app .af-topbar__titles h1 {
  color: var(--af-text) !important;
}

html.af-dark body.af-app .af-topbar__titles p {
  color: var(--af-muted) !important;
}

/* —— Auth pages (login / register / password / admin login) —— */
body.af-auth {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--af-font-sans);
  background: var(--af-bg);
  color: var(--af-text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.af-auth a {
  color: var(--af-primary);
}

body.af-auth a:hover {
  color: var(--af-primary-dark);
}

.af-auth-top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--af-space-3);
  padding: 10px var(--af-pad-x);
  min-height: 56px;
  background: color-mix(in srgb, var(--af-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--af-border);
  padding-left: max(var(--af-pad-x), env(safe-area-inset-left));
  padding-right: max(var(--af-pad-x), env(safe-area-inset-right));
}

.af-auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
  color: inherit !important;
  font-family: var(--af-font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  min-width: 0;
}

.af-auth-brand img {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.af-auth-brand span {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  white-space: nowrap;
}

.af-auth-brand small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--af-muted);
}

.af-auth-top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.af-auth-top-actions a.af-auth-nav {
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--af-text) !important;
}

.af-auth-top-actions a.af-auth-nav:hover {
  background: var(--af-primary-soft);
  color: var(--af-primary-dark) !important;
}

.af-auth-top-actions .af-btn-primary {
  background: var(--af-primary) !important;
  color: #fff !important;
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.af-auth-top-actions .af-btn-primary:hover {
  background: var(--af-primary-dark) !important;
  color: #fff !important;
}

body.af-auth .af-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--af-radius-sm);
  border: 1px solid var(--af-border);
  background: var(--af-surface);
  color: var(--af-muted) !important;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

body.af-auth .af-icon-btn:hover {
  color: var(--af-primary) !important;
  border-color: var(--af-primary-soft);
}

.af-auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
}

.af-auth-form-col {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 40px) var(--af-pad-x) clamp(28px, 5vw, 56px);
}

.af-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--af-surface);
  border: 1px solid var(--af-border);
  border-radius: var(--af-radius);
  box-shadow: none;
  padding: clamp(18px, 3vw, 28px);
}

.af-auth-card h1 {
  font-family: var(--af-font-display);
  font-size: clamp(1.35rem, 1.1rem + 0.8vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 6px;
  color: var(--af-text);
}

.af-auth-card .af-lead {
  margin: 0 0 20px;
  font-size: var(--af-fs-sm);
  line-height: 1.55;
  color: var(--af-muted);
}

.af-auth-card .login-card-body,
.af-auth-card .card-body {
  padding: 0 !important;
  background: transparent !important;
  color: inherit !important;
}

.af-auth-card .login-box-msg {
  display: none;
}

.af-auth-card .form-control {
  height: 46px;
  border-radius: var(--af-radius-sm) 0 0 var(--af-radius-sm);
  border-color: var(--af-input-border) !important;
  background: var(--af-input-bg) !important;
  font-size: 16px !important; /* ≥16px prevents iOS focus zoom */
  font-weight: 600;
  color: var(--af-text) !important;
}

.af-auth-card .form-control::placeholder {
  color: var(--af-muted);
  font-weight: 600;
  opacity: 0.85;
}

.af-auth-card .form-control:focus {
  border-color: var(--af-primary) !important;
  box-shadow: 0 0 0 3px var(--af-primary-soft) !important;
}

.af-auth-card .input-group-text {
  border-radius: 0 var(--af-radius-sm) var(--af-radius-sm) 0;
  border-color: var(--af-input-border) !important;
  background: var(--af-bg) !important;
  color: var(--af-muted) !important;
}

.af-auth-card .btn-primary,
.af-auth-card .signIn,
.af-auth-card .login-button {
  background: var(--af-primary) !important;
  border-color: var(--af-primary) !important;
  border-radius: 999px !important;
  font-weight: 800;
  padding: 11px 16px;
  margin-top: 4px;
  color: #fff !important;
}

.af-auth-card .btn-primary:hover,
.af-auth-card .signIn:hover,
.af-auth-card .login-button:hover {
  background: var(--af-primary-dark) !important;
  border-color: var(--af-primary-dark) !important;
}

.af-auth-card .icheck-primary label,
.af-auth-card .text-sm {
  color: var(--af-muted) !important;
  font-size: 13px;
  font-weight: 600;
}

.af-auth-card a {
  font-weight: 700;
  text-decoration: none;
}

.af-auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  font-size: 13px;
}

.af-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--af-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.af-auth-divider::before,
.af-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--af-border);
}

.af-btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--af-border);
  border-radius: var(--af-radius, 10px);
  background: #fff !important;
  color: #1f2937 !important;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none !important;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.af-btn-google:hover {
  background: #f8fafc !important;
  border-color: color-mix(in srgb, var(--af-primary) 28%, var(--af-border));
  color: #111827 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

html.af-dark .af-btn-google {
  background: #fff !important;
  border-color: #d1d5db;
  color: #1f2937 !important;
}

html.af-dark .af-btn-google:hover {
  background: #f3f4f6 !important;
  color: #111827 !important;
}

.af-btn-google svg {
  flex-shrink: 0;
}

.af-auth-visual {
  display: none;
  position: relative;
  background:
    radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--af-primary) 14%, transparent), transparent 42%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--af-success) 10%, transparent), transparent 36%),
    var(--af-bg);
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 4vw, 40px);
  overflow: hidden;
  border-left: 1px solid var(--af-border);
}

.af-auth-visual-inner {
  position: relative;
  z-index: 1;
  max-width: 520px;
  width: 100%;
  text-align: center;
}

.af-auth-visual-inner img {
  width: 100%;
  height: auto;
  border-radius: var(--af-radius);
  box-shadow: var(--af-shadow);
  background: var(--af-surface);
  border: 1px solid var(--af-border);
}

.af-auth-visual-inner h2 {
  font-family: var(--af-font-display);
  font-size: clamp(1.2rem, 1rem + 0.6vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 20px 0 8px;
  color: var(--af-text);
}

.af-auth-visual-inner p {
  margin: 0;
  color: var(--af-muted);
  font-size: var(--af-fs-sm);
  line-height: 1.55;
}

.af-auth-demo {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.af-auth-demo a {
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff !important;
}

.af-auth-demo .demo-user { background: var(--af-primary); }
.af-auth-demo .demo-admin { background: var(--af-success); }

.af-auth-foot {
  text-align: center;
  padding: 0 var(--af-pad-x) max(20px, env(safe-area-inset-bottom));
  font-size: var(--af-fs-xs);
  color: var(--af-muted);
}

.af-auth-hide-sm { display: inline-flex; }
.af-auth-hide-md { display: inline-flex; }

html.af-dark .af-auth-brand img[src*="images/brand/"] {
  filter: brightness(0) invert(1);
}

html.af-dark body.af-auth .login-img {
  background-color: var(--af-bg);
}

html.af-dark body.af-auth {
  background: var(--af-bg) !important;
  color: var(--af-text) !important;
}

html.af-dark body.af-auth .af-auth-top {
  background: color-mix(in srgb, var(--af-surface) 92%, transparent);
  border-bottom-color: var(--af-border);
}

html.af-dark body.af-auth .af-auth-card {
  background: var(--af-surface) !important;
  border: 1px solid var(--af-border) !important;
  color: var(--af-text);
}

html.af-dark body.af-auth .af-auth-card h1,
html.af-dark body.af-auth .af-auth-brand span {
  color: var(--af-text) !important;
}

html.af-dark body.af-auth .af-icon-btn {
  background: var(--af-surface);
  border-color: var(--af-border);
  color: var(--af-muted) !important;
}

html.af-dark body.af-auth .af-auth-links a {
  color: var(--af-primary) !important;
}

@media (min-width: 992px) {
  .af-auth-shell {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  }

  .af-auth-visual {
    display: flex;
  }
}

@media (max-width: 991px) {
  .af-auth-hide-md {
    display: none !important;
  }

  .af-auth-card {
    max-width: 440px;
  }
}

/* —— Records lists & search (system-wide DataTables) —— */
body.af-app .af-records {
  background: var(--af-surface);
  border: 1px solid var(--af-border);
  border-radius: 14px;
  overflow: visible;
}

body.af-app .af-records__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--af-border);
  background: color-mix(in srgb, var(--af-surface) 92%, var(--af-bg));
}

body.af-app .af-records__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--af-text);
  letter-spacing: -0.01em;
}

body.af-app .af-records__subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--af-muted);
  max-width: 42rem;
}

body.af-app .af-records__toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  padding: 12px 18px;
  border-bottom: 1px solid var(--af-border);
  background: var(--af-surface);
}

body.af-app .af-records__search {
  position: relative;
  width: 100%;
  max-width: 420px;
}

body.af-app .af-records__search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--af-muted);
  font-size: 13px;
  pointer-events: none;
}

body.af-app .af-records__search input {
  width: 100%;
  height: 38px;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--af-border);
  border-radius: 999px;
  background: var(--af-bg);
  color: var(--af-text);
  font-size: 13px;
}

body.af-app .af-records__search input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--af-primary, #2563eb) 55%, var(--af-border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--af-primary, #2563eb) 18%, transparent);
}

body.af-app .af-records__filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}

body.af-app .af-records__filters .form-control,
body.af-app .af-records__filters select,
body.af-app .af-records__filters input[type="date"] {
  height: 38px;
  width: auto;
  min-width: 118px;
  flex: 0 1 auto;
  border-radius: 10px;
  border: 1px solid var(--af-border);
  background: var(--af-bg);
  color: var(--af-text);
  font-size: 13px;
  padding: 6px 10px;
}

body.af-app .af-records__filters select {
  max-width: 160px;
}

body.af-app .af-records__filters input[type="date"] {
  max-width: 160px;
}

/* DataTables responsive control spacing */
body.af-app table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
body.af-app table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
  padding-left: 2.2em !important;
}

body.af-app .af-records__body {
  padding: 8px 12px 16px;
}

body.af-app .af-records .table {
  margin-bottom: 0;
  border: none !important;
}

body.af-app .af-records .table thead th {
  border-bottom: 1px solid var(--af-border) !important;
  background: transparent !important;
}

body.af-app .af-records .table td {
  border-top: 1px solid var(--af-border) !important;
}

body.af-app .af-msg-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: min(420px, 46vw);
  white-space: normal;
  line-height: 1.35;
  color: var(--af-text);
}

body.af-app .af-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  border: 1px solid transparent;
}

body.af-app .af-status--ok {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}
body.af-app .af-status--warn {
  color: #b45309;
  background: #fffbeb;
  border-color: #fde68a;
}
body.af-app .af-status--danger {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}
body.af-app .af-status--info {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}
body.af-app .af-status--muted {
  color: #475569;
  background: #f1f5f9;
  border-color: #e2e8f0;
}

html.af-dark body.af-app .af-status--ok { color: #6ee7b7; background: #064e3b; border-color: #065f46; }
html.af-dark body.af-app .af-status--warn { color: #fcd34d; background: #78350f; border-color: #92400e; }
html.af-dark body.af-app .af-status--danger { color: #fca5a5; background: #7f1d1d; border-color: #991b1b; }
html.af-dark body.af-app .af-status--info { color: #93c5fd; background: #1e3a8a; border-color: #1e40af; }
html.af-dark body.af-app .af-status--muted { color: #cbd5e1; background: #1e293b; border-color: #334155; }

/* Polish all DataTables search/length/paginate across the app */
body.af-app .dataTables_wrapper .dataTables_filter label,
body.af-app .dataTables_wrapper .dataTables_length label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--af-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

body.af-app .dataTables_wrapper .dataTables_filter input {
  height: 36px !important;
  min-width: 200px;
  margin-left: 0 !important;
  padding: 6px 12px 6px 34px !important;
  border: 1px solid var(--af-border) !important;
  border-radius: 999px !important;
  background: var(--af-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 12px 50% !important;
  color: var(--af-text) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
}

body.af-app .dataTables_wrapper .dataTables_length select {
  height: 36px !important;
  border: 1px solid var(--af-border) !important;
  border-radius: 10px !important;
  background: var(--af-bg) !important;
  color: var(--af-text) !important;
  padding: 4px 28px 4px 10px !important;
}

body.af-app .dataTables_wrapper .dataTables_info {
  font-size: 12px;
  color: var(--af-muted);
  padding-top: 10px !important;
}

body.af-app .dataTables_wrapper .dataTables_paginate {
  padding-top: 8px !important;
}

body.af-app .dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 8px !important;
  border: 1px solid transparent !important;
  padding: 4px 10px !important;
  margin: 0 2px !important;
  color: var(--af-text) !important;
  background: transparent !important;
}

body.af-app .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.af-app .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: color-mix(in srgb, var(--af-primary, #2563eb) 14%, transparent) !important;
  border-color: color-mix(in srgb, var(--af-primary, #2563eb) 35%, var(--af-border)) !important;
  color: var(--af-text) !important;
}

body.af-app .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--af-bg) !important;
  border-color: var(--af-border) !important;
  color: var(--af-text) !important;
}

body.af-app .dataTables_wrapper .row {
  align-items: center;
  margin-left: 0;
  margin-right: 0;
}

body.af-app .table-body {
  padding: 12px 14px 18px !important;
}

@media (max-width: 767px) {
  body.af-app .af-records__search {
    max-width: none;
  }

  body.af-app .af-records__filters .form-control,
  body.af-app .af-records__filters select,
  body.af-app .af-records__filters input[type="date"] {
    flex: 1 1 calc(50% - 8px);
    max-width: none;
    min-width: 0;
  }

  body.af-app .af-msg-preview {
    max-width: 100%;
  }

  body.af-app .af-metric-grid[style*="repeat(4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  .af-auth-brand span {
    display: none;
  }

  .af-auth-hide-sm {
    display: none !important;
  }

  .af-auth-top-actions .af-btn-primary {
    padding: 8px 12px;
    font-size: 12px;
  }

  .af-auth-form-col {
    align-items: stretch;
    justify-content: flex-start;
    padding-top: 24px;
    width: 100%;
  }

  .af-auth-card {
    max-width: 100%;
    margin: 0 auto;
    padding: clamp(16px, 4vw, 22px);
  }

  html.af-dark .af-auth-card,
  html.af-dark body.af-auth .af-auth-card {
    background: var(--af-surface) !important;
    border: 1px solid var(--af-border) !important;
  }

  .af-auth-card h1 {
    font-size: 1.4rem;
  }
}

/* —— Wallet / billing —— */
body.af-app .af-wallet {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

body.af-app .af-wallet__hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 24px;
  padding: 22px 24px;
  border: 1px solid var(--af-border);
  border-radius: 16px;
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--af-primary, #2563eb) 14%, var(--af-surface)) 0%,
      var(--af-surface) 55%);
}

body.af-app .af-wallet__eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--af-muted);
}

body.af-app .af-wallet__balance {
  display: flex;
  align-items: baseline;
  gap: 10px;
  line-height: 1;
}

body.af-app .af-wallet__balance-num {
  font-size: clamp(2.2rem, 1.6rem + 2vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--af-text);
}

body.af-app .af-wallet__balance-unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--af-muted);
}

body.af-app .af-wallet__meta {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--af-muted);
}

body.af-app .af-wallet__dot {
  margin: 0 4px;
  opacity: 0.7;
}

body.af-app .af-wallet__hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.af-app .af-wallet__hero-actions .btn {
  border-radius: 999px;
  padding: 8px 16px;
}

body.af-app .af-wallet__tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

body.af-app .af-wallet__tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--af-border);
  border-radius: 14px;
  background: var(--af-surface);
  color: inherit;
  text-decoration: none !important;
  transition: border-color 0.15s ease, background 0.15s ease;
}

body.af-app .af-wallet__tile:hover {
  border-color: color-mix(in srgb, var(--af-primary, #2563eb) 40%, var(--af-border));
  background: color-mix(in srgb, var(--af-primary, #2563eb) 6%, var(--af-surface));
}

body.af-app .af-wallet__tile-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--af-muted);
}

body.af-app .af-wallet__tile-text {
  margin: 0;
  flex: 1;
  font-size: 13px;
  line-height: 1.45;
  color: var(--af-text);
}

body.af-app .af-wallet__tile-cta {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--af-primary, #3b82f6);
}

body.af-app .af-wallet__ref {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--af-bg);
  color: var(--af-text);
  border: 1px solid var(--af-border);
}

@media (max-width: 640px) {
  body.af-app .af-wallet__hero {
    padding: 18px;
  }

  body.af-app .af-wallet__hero-actions {
    width: 100%;
  }

  body.af-app .af-wallet__hero-actions .btn {
    flex: 1 1 auto;
  }

  body.af-app .af-wallet__tiles {
    grid-template-columns: 1fr;
  }
}

/* —— Dark mode: custom page shells that used hardcoded light colors —— */
html.af-dark .af-onboard-card,
html.af-dark .sid-metric,
html.af-dark .sid-panel,
html.af-dark .af-settings-card,
html.af-dark .af-plan-form .af-plan-section {
  background: var(--af-surface) !important;
  border-color: var(--af-border) !important;
  color: var(--af-text) !important;
}
html.af-dark .af-onboard-card h3,
html.af-dark .sid-metric__value,
html.af-dark .af-plan-section__title,
html.af-dark .af-plan-page-head h1 {
  color: var(--af-text) !important;
}
html.af-dark .af-label,
html.af-dark .af-hint,
html.af-dark .sid-metric__label,
html.af-dark .af-plan-page-head p,
html.af-dark .af-plan-form label {
  color: var(--af-muted) !important;
}
html.af-dark .af-input,
html.af-dark .af-select,
html.af-dark .af-plan-form .form-control {
  background: var(--af-input-bg) !important;
  border-color: var(--af-input-border) !important;
  color: var(--af-text) !important;
}
html.af-dark .sid-panel .card-header,
html.af-dark .af-settings-tabs {
  background: var(--af-table-stripe) !important;
  border-color: var(--af-border) !important;
}
html.af-dark .friend-drawer {
  background: var(--af-surface) !important;
  color: var(--af-text) !important;
}

/* —— Mobile: keep viewport static on form focus (iOS zooms if input < 16px) —— */
@media (max-width: 991.98px) {
  body.af-app input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="image"]),
  body.af-app select,
  body.af-app textarea,
  body.af-app .form-control,
  body.af-app .custom-select,
  body.af-app .select2-container .select2-selection--single,
  body.af-app .select2-container .select2-selection--multiple,
  body.af-app .select2-search__field,
  body.af-auth input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="image"]),
  body.af-auth select,
  body.af-auth textarea,
  body.af-auth .form-control,
  body.af-auth .custom-select {
    font-size: 16px !important;
  }

  body.af-app .select2-container--default .select2-selection--single .select2-selection__rendered,
  body.af-app .select2-container--default .select2-selection--multiple .select2-selection__choice {
    font-size: 16px !important;
    line-height: 1.4 !important;
  }
}
