/* =========================================================
   HT Health / Premium Unified Theme
   Cleaned + Deduplicated
========================================================= */

/* ===== Root Tokens ===== */
:root {
  --brand: #dc2626;
  --brand-600: #dc2626;
  --brand-700: #b91c1c;
  --brand-soft: #fee2e2;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;

  --border: #e2e8f0;
  --border-soft: rgba(226, 232, 240, 0.9);

  --ink: #0f172a;
  --muted: #64748b;

  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #2563eb;

  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;

  --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 24px 50px rgba(2, 6, 23, 0.16);

  --mobile-max: 520px;
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-nav-shadow: 0 -8px 28px rgba(15, 23, 42, 0.12);

  --dt-row-hover: rgba(220, 38, 38, 0.03);
  --dt-head-bg: linear-gradient(180deg, #fff, #f8fafc);
  --dt-border: rgba(15, 23, 42, 0.08);
  --dt-border-strong: rgba(15, 23, 42, 0.12);
}

/* ===== Reset ===== */
* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    "Inter",
    "Noto Sans Thai",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(circle at top right, rgba(220, 38, 38, 0.06), transparent 28%),
    linear-gradient(180deg, #fafbfd 0%, #f5f7fb 100%);
}

a {
  color: var(--info);
  text-decoration: none;
}

a:hover {
  color: #1d4ed8;
}

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

.container {
  max-width: 1120px;
}

.pb-mobile {
  padding-bottom: 6rem !important;
}

.page-shell {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

/* ===== Common App UI ===== */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.app-brand__badge {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-600), #fb7185);
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.25);
}

.app-brand__title {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-brand__subtitle {
  font-size: 0.88rem;
  color: var(--muted);
}

.card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-soft {
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
}

.card-body {
  padding: 1rem;
}

.card-title {
  margin-bottom: 0.4rem;
  font-size: 1rem;
  font-weight: 700;
}

.card-subtitle,
.text-muted {
  color: var(--muted) !important;
}

.hero-panel {
  padding: 1.25rem;
  border-radius: 24px;
  color: #fff;
  background: linear-gradient(135deg, #dc2626 0%, #f97316 100%);
  box-shadow: 0 16px 40px rgba(220, 38, 38, 0.22);
}

.hero-panel .muted-on-dark {
  color: rgba(255, 255, 255, 0.78) !important;
}

.kpi-card {
  min-height: 126px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-label,
.kpi-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.kpi-label {
  font-weight: 700;
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--brand-700);
  font-size: 1.15rem;
}

.metric-chip,
.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-soft.success {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.badge-soft.warning {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.badge-soft.danger {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.badge-soft.info {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.btn {
  min-height: 46px;
  border-radius: 14px;
  font-weight: 700;
  box-shadow: none !important;
}

.btn-sm {
  min-height: 40px;
  border-radius: 12px;
}

.btn-primary,
.btn-danger {
  border: none;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
}

.btn-primary:hover,
.btn-danger:hover {
  filter: brightness(0.96);
}

.btn-outline-secondary,
.btn-outline-primary {
  border-color: var(--border);
  color: var(--ink);
  background: #fff;
}

.btn-outline-secondary:hover,
.btn-outline-primary:hover {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--ink);
}

.form-label {
  margin-bottom: 0.45rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.form-control,
.form-select {
  min-height: 48px;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

textarea.form-control {
  min-height: 108px;
}

.form-control:focus,
.form-select:focus {
  border-color: #fca5a5;
  box-shadow: 0 0 0 0.2rem rgba(220, 38, 38, 0.12);
}

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
  vertical-align: middle;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  border-bottom-color: var(--border);
}

.table tbody td {
  border-color: #eef2f7;
}

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

.list-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}

.list-card + .list-card {
  margin-top: 0.85rem;
}

.reading-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.reading-time {
  font-size: 0.86rem;
  color: var(--muted);
}

.reading-note {
  font-size: 0.9rem;
  color: #475569;
}

.empty-state {
  padding: 1.4rem;
  border: 1px dashed #cbd5e1;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  text-align: center;
}

.section-title {
  margin-bottom: 0.25rem;
  font-size: 1.04rem;
  font-weight: 800;
}

.section-subtitle {
  font-size: 0.88rem;
  color: var(--muted);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

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

.auth-cover {
  margin-bottom: 1rem;
  padding: 1.2rem;
  border-radius: 24px;
  background: linear-gradient(135deg, #dc2626 0%, #fb7185 100%);
  color: #fff;
}

.auth-cover small {
  color: rgba(255, 255, 255, 0.82);
}

.content-html > *:last-child {
  margin-bottom: 0;
}

.content-html .table-responsive {
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.content-html .table-responsive + * {
  margin-top: 1rem;
}

.content-html .btn {
  min-height: 42px;
}

.content-html form {
  display: grid;
  gap: 0.85rem;
}

.fab {
  position: fixed;
  right: 1rem;
  bottom: 5.5rem;
  z-index: 999;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: #fff;
  font-size: 1.35rem;
  box-shadow: 0 14px 28px rgba(220, 38, 38, 0.28);
}

/* ===== Admin Layout ===== */
body.admin-route {
  overflow-x: hidden;
}

body.admin-sidebar-open {
  overflow: hidden;
}

.admin-layout {
  display: block;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
}

.admin-main {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.admin-sidebar {
  --admin-sidebar-w: 300px;
  --admin-sidebar-bg: linear-gradient(180deg, #0f172a 0%, #111827 52%, #172033 100%);
  --admin-sidebar-border: rgba(255, 255, 255, 0.08);
  --admin-sidebar-text: rgba(255, 255, 255, 0.94);
  --admin-sidebar-muted: rgba(255, 255, 255, 0.62);
  --admin-sidebar-soft: rgba(255, 255, 255, 0.06);
  --admin-sidebar-soft-2: rgba(255, 255, 255, 0.1);
  --admin-sidebar-active: linear-gradient(135deg, #ef4444 0%, #dc2626 55%, #b91c1c 100%);

  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1045;
  width: var(--admin-sidebar-w);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--admin-sidebar-border);
  background: var(--admin-sidebar-bg);
  color: var(--admin-sidebar-text);
  box-shadow: 0 24px 50px rgba(2, 6, 23, 0.3);
}

.admin-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--admin-sidebar-border);
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(8px);
}

.admin-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  color: inherit;
}

.admin-sidebar__brand:hover {
  color: inherit;
}

.admin-sidebar__brand strong {
  display: block;
  font-size: 1rem;
  line-height: 1.12;
  color: #fff;
}

.admin-sidebar__brand small {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.79rem;
  color: var(--admin-sidebar-muted);
}

.admin-sidebar__logo {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 14px 28px rgba(220, 38, 38, 0.3);
}

.admin-sidebar__close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--admin-sidebar-soft);
  color: #fff;
}

.admin-sidebar__close:hover {
  background: var(--admin-sidebar-soft-2);
}

.admin-sidebar__section-label {
  padding: 0.95rem 1rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--admin-sidebar-muted);
}

.admin-sidebar__nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0.8rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.admin-sidebar__nav::-webkit-scrollbar {
  width: 8px;
}

.admin-sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.admin-sidebar__nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.88rem;
  margin-bottom: 0.42rem;
  padding: 0.84rem 0.88rem;
  border: 1px solid transparent;
  border-radius: 18px;
  background: transparent;
  color: var(--admin-sidebar-text);
  transition: 0.2s ease;
}

.admin-sidebar__nav a:hover {
  transform: translateX(2px);
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.admin-sidebar__nav a.active {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--admin-sidebar-active);
  color: #fff;
  box-shadow: 0 16px 30px rgba(185, 28, 28, 0.28);
}

.admin-sidebar__icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.04rem;
}

.admin-sidebar__nav a.active .admin-sidebar__icon {
  background: rgba(255, 255, 255, 0.18);
}

.admin-sidebar__text {
  flex: 1 1 auto;
  min-width: 0;
}

.admin-sidebar__text strong {
  display: block;
  font-size: 0.93rem;
  color: inherit;
}

.admin-sidebar__text small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.77rem;
  color: var(--admin-sidebar-muted);
}

.admin-sidebar__nav a.active .admin-sidebar__text small {
  color: rgba(255, 255, 255, 0.88);
}

.admin-sidebar__active-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.18);
}

.admin-sidebar__footer {
  padding: 0.95rem 1rem 1rem;
  border-top: 1px solid var(--admin-sidebar-border);
  background: rgba(255, 255, 255, 0.02);
}

.admin-sidebar__hint {
  display: flex;
  align-items: flex-start;
  gap: 0.68rem;
  padding: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--admin-sidebar-muted);
  font-size: 0.84rem;
}

.admin-sidebar__hint i {
  color: #fbbf24;
}

.admin-sidebar__logout {
  padding: 0.7rem 0.95rem !important;
  border-radius: 14px !important;
  font-weight: 700;
}

.admin-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
  transition: 0.22s ease;
}

body.admin-sidebar-open .admin-sidebar-backdrop {
  opacity: 1;
  visibility: visible;
}

.admin-mobilebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

.admin-mobilebar__left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.admin-mobilebar__title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 800;
}

.admin-mobilebar__subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-menu-btn {
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.82));
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.admin-topbar__title-wrap {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.admin-topbar__eyebrow {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-700);
}

.admin-topbar__title-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.admin-topbar__title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.admin-topbar__subtitle {
  margin: 0;
  color: var(--muted);
}

.admin-topbar__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-page-head__icon--topbar {
  width: 52px;
  height: 52px;
  margin: 0;
  box-shadow: 0 10px 26px rgba(220, 38, 38, 0.22);
}

.admin-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.admin-page-head__title {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}

.admin-page-head__icon {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-600), #fb7185);
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 10px 26px rgba(220, 38, 38, 0.25);
}

.admin-page-head h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.admin-page-head p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.admin-page-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-surface {
  width: 100%;
  overflow: visible;
  padding: 1rem;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-sm);
}

.admin-helperbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.82rem 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.admin-helperbar__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-table-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.admin-table-search {
  position: relative;
  flex: 1 1 260px;
  max-width: 420px;
}

.admin-table-search i {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.admin-table-search input {
  padding-left: 2.6rem;
  background: #fff;
}

.admin-results-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 700;
}

.admin-callout {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.admin-callout strong {
  font-size: 0.95rem;
}

.admin-section-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.8fr;
  gap: 1rem;
}

.admin-empty {
  padding: 1rem;
  border: 1px dashed #cbd5e1;
  border-radius: 18px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.admin-content-stack,
.admin-content-stack--page {
  display: grid;
  gap: 1rem;
}

.admin-content-stack--page > * {
  min-width: 0;
}

.admin-surface .table-responsive {
  width: 100%;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(226, 232, 240, 0.92);
  background: #fff;
}

.admin-surface .card + .card {
  margin-top: 1rem;
}

.admin-surface .card,
.admin-surface .patients-hero,
.admin-surface .patients-panel,
.admin-surface .patient-drawer,
.admin-surface .admin-callout,
.admin-surface .summary-card,
.admin-surface .report-card {
  border-radius: 22px !important;
}

.admin-surface .card-header {
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.92));
}

.admin-surface .section-title {
  letter-spacing: -0.02em;
}

.report-page .report-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

/* ===== Mobile App Route ===== */
body.app-route {
  padding-bottom: calc(96px + var(--mobile-safe-bottom));
  background:
    radial-gradient(circle at top, rgba(220, 38, 38, 0.08), transparent 32%),
    linear-gradient(180deg, #fff8f9 0%, #fff4f6 100%);
}

body.app-route .container {
  max-width: var(--mobile-max);
}

body.app-route .page-shell {
  padding-top: 0.5rem;
  padding-bottom: 1rem;
}

body.app-route .pb-mobile {
  padding-bottom: calc(110px + var(--mobile-safe-bottom)) !important;
}

body.app-route .app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  margin-bottom: 0.9rem;
  padding: 0.2rem 0 0.6rem;
  background: linear-gradient(
    180deg,
    rgba(255, 244, 246, 0.98) 0%,
    rgba(255, 244, 246, 0.92) 75%,
    rgba(255, 244, 246, 0) 100%
  );
  backdrop-filter: blur(8px);
}

.page-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 0.9rem;
  padding: 1rem 1rem 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 24px;
  background: linear-gradient(135deg, #ef4444 0%, #e11d48 100%);
  color: #fff;
  box-shadow: 0 16px 40px rgba(225, 29, 72, 0.2);
}

.page-hero::before,
.page-hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.page-hero::before {
  top: -44px;
  right: -34px;
  width: 150px;
  height: 150px;
}

.page-hero::after {
  left: -22px;
  bottom: -26px;
  width: 92px;
  height: 92px;
}

.page-hero > * {
  position: relative;
  z-index: 1;
}

.page-hero h1,
.page-hero h2,
.page-hero h3 {
  margin: 0 0 0.35rem;
  font-size: 1.18rem;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.9rem;
  line-height: 1.55;
}

body.app-route .card,
body.app-route .card-soft,
body.app-route .hero-panel,
body.app-route .list-card,
body.app-route .empty-state,
body.app-route .content-html .table-responsive {
  border-color: #f3d6de;
  box-shadow: 0 12px 28px rgba(120, 20, 44, 0.07);
}

body.app-route .card,
body.app-route .card-soft {
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.98);
}

body.app-route .card-body {
  padding: 1rem;
}

body.app-route .app-brand__badge {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: linear-gradient(135deg, #ef4444 0%, #e11d48 100%);
  box-shadow: 0 10px 24px rgba(225, 29, 72, 0.22);
}

body.app-route .app-brand__title {
  font-size: 1rem;
}

body.app-route .app-brand__subtitle,
body.app-route .section-subtitle {
  color: #8b5c67;
}

body.app-route .section-title {
  font-size: 1rem;
}

body.app-route .metric-chip,
body.app-route .badge-soft {
  border-color: #fecdd3;
  background: #fff1f3;
  color: #be123c;
}

body.app-route .btn {
  min-height: 44px;
  border-radius: 999px;
  font-weight: 800;
}

body.app-route .btn-sm {
  min-height: 40px;
  border-radius: 999px;
}

body.app-route .btn-primary,
body.app-route .btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #be123c 100%);
}

body.app-route .form-control,
body.app-route .form-select {
  min-height: 46px;
  border-color: #f3c8d1;
  border-radius: 16px;
}

body.app-route textarea.form-control {
  border-radius: 18px;
}

body.app-route .content-html form {
  gap: 1rem;
}

body.app-route .table-responsive {
  padding: 0.25rem;
  border-radius: 18px;
  background: #fffafb;
}

body.app-route .table thead th {
  border-bottom-color: #f8d6de;
  background: #fff7f8;
  color: #8b5c67;
}

body.app-route .table tbody td {
  border-color: #fde8ec;
}

/* ===== Mobile Bottom Nav ===== */
.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 0.45rem;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.65rem calc(0.55rem + var(--mobile-safe-bottom));
  border-top: 1px solid #f3c8d1;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--mobile-nav-shadow);
  backdrop-filter: blur(18px);
}

.mobile-nav a {
  position: relative;
  flex: 1;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  padding: 0.45rem 0.12rem;
  border-radius: 14px;
  color: #7a5560;
  font-size: 0.72rem;
  font-weight: 700;
}

.mobile-nav a i {
  font-size: 1.18rem;
}

.mobile-nav a.active {
  background: transparent;
  color: #be123c;
}

.mobile-nav a.active::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 4px;
  border-radius: 999px;
  background: #e11d48;
}

.mobile-nav a.is-primary {
  margin-top: -18px;
  min-width: 70px;
}

.mobile-nav a.is-primary i {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 2px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444 0%, #be123c 100%);
  color: #fff;
  box-shadow: 0 12px 26px rgba(225, 29, 72, 0.28);
}

.mobile-nav a.is-primary span {
  font-size: 0.7rem;
}

.mobile-nav a.is-primary.active::before {
  display: none;
}

/* ===== Toast ===== */
.ht-toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(86px + var(--mobile-safe-bottom));
  z-index: 2000;
  width: min(calc(100% - 24px), 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.ht-toast {
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
  padding: 12px 14px;
  border-radius: 16px;
  background: #4a1020;
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 12px 24px rgba(120, 20, 44, 0.2);
}

.ht-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ===== DataTables Premium ===== */
.dataTables_wrapper .row {
  row-gap: 0.8rem;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  font-size: 0.88rem;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
  font-weight: 700;
  color: var(--muted);
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: none;
}

.dataTables_wrapper .dataTables_filter input {
  min-width: 240px;
  padding-left: 0.9rem;
  padding-right: 0.9rem;
}

.dataTables_wrapper .dataTables_info {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  min-width: 38px;
  height: 38px;
  line-height: 38px !important;
  margin: 0 0.08rem;
  padding: 0 0.8rem !important;
  border: 1px solid transparent !important;
  border-radius: 12px !important;
  background: #fff !important;
  color: var(--ink) !important;
  font-size: 0.88rem;
  font-weight: 700;
  transition: all 0.16s ease;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  border-color: var(--dt-border-strong) !important;
  background: #fff5f5 !important;
  color: var(--brand-700) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  border: none !important;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700)) !important;
  color: #fff !important;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.18);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  opacity: 0.45;
  cursor: not-allowed !important;
  background: #fff !important;
  border-color: transparent !important;
}

table.dataTable,
.notifications-table {
  width: 100% !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  background: #fff;
}

.table-responsive table.dataTable thead th,
.table-responsive .notifications-table thead th,
.admin-surface table.dataTable thead th,
.admin-surface table.dataTable thead td {
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
  padding: 1rem 0.85rem !important;
  border-top: 0 !important;
  border-bottom: 1px solid rgba(226, 232, 240, 0.92) !important;
  background: var(--dt-head-bg);
  color: #334155;
  font-size: 0.79rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
  padding-right: 2rem !important;
}

.table-responsive table.dataTable tbody td,
.table-responsive .notifications-table tbody td,
.admin-surface table.dataTable tbody td,
.admin-surface .table tbody td {
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
  border-color: rgba(226, 232, 240, 0.78) !important;
  background: #fff;
  transition: background-color 0.15s ease;
}

table.dataTable.stripe tbody tr.odd td,
table.dataTable.display tbody tr.odd td {
  background: #fcfdff;
}

.admin-surface .table tbody tr:hover,
.admin-surface table.dataTable tbody tr:hover,
table.dataTable tbody tr:hover td,
.notifications-table tbody tr:hover td {
  background: var(--dt-row-hover) !important;
}

table.dataTable tbody tr:focus-within td {
  background: #f7f9fc !important;
}

.notifications-table tbody tr.deleted-row td {
  background: #fcfcfd !important;
  opacity: 0.72;
}

.notifications-table .form-control,
.notifications-table .form-select {
  min-height: 36px;
  border-radius: var(--radius-xs);
  border-color: rgba(15, 23, 42, 0.1);
  font-size: 0.88rem;
  box-shadow: none;
}

.notifications-table .form-control:focus,
.notifications-table .form-select:focus {
  border-color: rgba(220, 38, 38, 0.25);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.08);
}

.notifications-table .btn-sm,
.table-actions .btn {
  min-height: 36px;
  padding: 0.45rem 0.7rem;
  border-radius: 11px;
}

.dataTables_wrapper .dataTables_processing {
  padding: 0.9rem 1rem;
  border: 1px solid var(--dt-border);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

table.dataTable tbody td.dataTables_empty {
  padding: 2rem 1rem !important;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

div.dataTables_scrollHead table.dataTable {
  margin-bottom: 0 !important;
}

div.dataTables_scrollBody {
  border-bottom: 0 !important;
}

div.dataTables_scrollBody::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

div.dataTables_scrollBody::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.35);
}

div.dataTables_scrollBody::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.1);
}

/* ===== DataTables Responsive child / parent ===== */
table.dataTable tbody td.dtr-control,
table.dataTable tbody th.dtr-control {
  cursor: pointer;
  white-space: nowrap;
}

table.dataTable tbody tr.parent > td,
table.dataTable tbody tr.dt-hasChild > td,
.notifications-table tbody tr.parent > td,
.notifications-table tbody tr.dt-hasChild > td {
  background: #f8fbff !important;
  border-bottom-color: rgba(220, 38, 38, 0.12) !important;
}

table.dataTable.stripe tbody tr.parent.odd > td,
table.dataTable.stripe tbody tr.parent.even > td,
table.dataTable.display tbody tr.parent.odd > td,
table.dataTable.display tbody tr.parent.even > td,
table.dataTable.stripe tbody tr.dt-hasChild.odd > td,
table.dataTable.stripe tbody tr.dt-hasChild.even > td,
table.dataTable.display tbody tr.dt-hasChild.odd > td,
table.dataTable.display tbody tr.dt-hasChild.even > td {
  background: #f8fbff !important;
}

table.dataTable tbody tr.child,
.notifications-table tbody tr.child {
  background: #f8fafc !important;
}

table.dataTable tbody tr.child > td,
.notifications-table tbody tr.child > td {
  padding: 0 !important;
  border-top: 0 !important;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06) !important;
  background: #f8fafc !important;
}

table.dataTable tbody tr.child ul.dtr-details,
.notifications-table tbody tr.child ul.dtr-details {
  margin: 0 !important;
  padding: 0.85rem 1rem !important;
  background: linear-gradient(180deg, #fbfdff 0%, #f8fafc 100%);
}

table.dataTable tbody tr.child ul.dtr-details > li,
.notifications-table tbody tr.child ul.dtr-details > li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.5rem;
  padding: 0.55rem 0 !important;
  border-bottom: 1px dashed rgba(15, 23, 42, 0.08);
}

table.dataTable tbody tr.child ul.dtr-details > li:last-child,
.notifications-table tbody tr.child ul.dtr-details > li:last-child {
  border-bottom: 0;
}

table.dataTable tbody tr.child span.dtr-title,
.notifications-table tbody tr.child span.dtr-title {
  min-width: 0;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 800;
}

table.dataTable tbody tr.child span.dtr-data,
.notifications-table tbody tr.child span.dtr-data {
  min-width: 0;
  color: #0f172a;
  font-size: 0.9rem;
  word-break: break-word;
}

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  width: 22px;
  height: 22px;
  margin-right: 0.7rem;
  border: 1px solid rgba(220, 38, 38, 0.14);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(220, 38, 38, 0.2);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

table.dataTable.dtr-inline.collapsed > tbody > tr:hover > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr:hover > th.dtr-control:before {
  transform: scale(1.06);
  box-shadow: 0 10px 20px rgba(220, 38, 38, 0.24);
  filter: brightness(0.98);
}

table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.dt-hasChild > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.dt-hasChild > th.dtr-control:before {
  content: "−";
  border-color: rgba(15, 23, 42, 0.12);
  background: linear-gradient(135deg, #0f172a, #334155);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

table.dataTable.dtr-inline.collapsed > tbody > tr.deleted-row > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.deleted-row > th.dtr-control:before {
  opacity: 0.7;
}

/* ===== Notification Admin Page ===== */
.notification-admin-page .dataTables_wrapper {
  color: var(--ink);
  font-size: 0.92rem;
}

.notification-admin-page .table-responsive {
  overflow: hidden;
  border: 1px solid var(--dt-border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

/* ===== Utility / Special tables ===== */
.admin-table-shell {
  padding: 0.9rem;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.92));
  box-shadow: var(--shadow-sm);
}

.admin-table-shell .table-responsive {
  border: none;
  background: transparent;
}

.admin-table-shell__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.admin-table-shell__title {
  margin: 0;
  color: #0f172a;
  font-size: 1.02rem;
  font-weight: 800;
}

.admin-table-shell__subtitle {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-toolbar-inline,
.table-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.settings-table td {
  vertical-align: middle;
}

.settings-table textarea.form-control {
  min-height: 64px;
  resize: vertical;
}

.settings-table .setting-key {
  color: #0f172a;
  font-weight: 800;
}

.settings-table .setting-updated {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.78rem;
}

.audit-log-ua {
  display: block;
  max-width: 320px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ===== Responsive ===== */
@media (min-width: 992px) {
  .page-shell--admin {
    max-width: none;
    padding: 1.15rem 1rem 1.5rem calc(300px + 1rem) !important;
  }

  .mobile-nav,
  .admin-mobilebar,
  .admin-sidebar-backdrop {
    display: none !important;
  }

  .admin-sidebar {
    transform: none !important;
  }
}

@media (max-width: 991.98px) {
  .page-shell--admin {
    padding: 1rem 0.75rem 1.1rem !important;
  }

  .admin-sidebar {
    width: min(88vw, 320px);
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

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

  .admin-topbar {
    display: none !important;
  }

  .admin-page-head__icon {
    width: 48px;
    height: 48px;
  }

  .admin-section-grid {
    grid-template-columns: 1fr;
  }

  .dataTables_wrapper .dataTables_filter input {
    min-width: 100%;
  }

  .admin-table-shell {
    padding: 0.8rem;
  }
}

@media (max-width: 767.98px) {
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 1.6rem;
  }

  .card,
  .admin-surface,
  .hero-panel,
  .admin-topbar,
  .admin-mobilebar {
    border-radius: 20px;
  }

  .admin-page-head h1,
  .admin-topbar__title {
    font-size: 1.08rem;
  }

  .admin-topbar__subtitle,
  .admin-page-head p {
    font-size: 0.88rem;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: left !important;
  }

  .dataTables_wrapper .dataTables_filter input {
    margin-top: 0.45rem;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button {
    min-width: 34px;
    height: 34px;
    line-height: 34px !important;
    padding: 0 0.6rem !important;
    margin: 0.1rem;
  }

  table.dataTable thead th,
  .notifications-table thead th {
    padding: 0.85rem 0.7rem !important;
  }

  table.dataTable tbody td,
  .notifications-table tbody td {
    padding: 0.8rem 0.7rem !important;
  }

  table.dataTable tbody tr.child ul.dtr-details,
  .notifications-table tbody tr.child ul.dtr-details {
    padding: 0.75rem 0.85rem !important;
  }

  table.dataTable tbody tr.child ul.dtr-details > li,
  .notifications-table tbody tr.child ul.dtr-details > li {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
  table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
    width: 20px;
    height: 20px;
    margin-right: 0.55rem;
    font-size: 12px;
  }
}

@media (min-width: 768px) {
  body.app-route .container {
    max-width: 720px;
  }

  body.app-route {
    padding-bottom: 0;
  }

  .mobile-nav {
    display: none;
  }

  .ht-toast-wrap {
    left: auto;
    right: 18px;
    bottom: 18px;
    transform: none;
    width: min(420px, calc(100% - 36px));
  }

  .ht-toast {
    text-align: left;
  }
}