:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-hover: #f8f9fa;
  --border: #dee2e6;
  --border-focus: #adb5bd;
  --text: #212529;
  --text-muted: #6c757d;
  --accent: #0d6efd;
  --accent-hover: #0b5ed7;
  --secondary: #6c757d;
  --secondary-hover: #5c636a;
  --success: #198754;
  --warning: #ffc107;
  --error: #dc3545;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.1);
  --font: "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Login */
#login-screen,
#otp-screen,
#forgot-password-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.login-card:hover {
  box-shadow: var(--shadow-hover);
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-header h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.login-header h1 i {
  margin-right: 0.35rem;
  color: var(--accent);
}

.login-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

#login-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

#login-form label i {
  margin-right: 0.35rem;
  width: 1em;
  color: var(--secondary);
}

#login-form input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

#login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

#login-form button {
  width: 100%;
  padding: 0.75rem;
  margin-top: 0.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s ease, transform 0.1s ease;
}

#login-form button:hover {
  background: var(--accent-hover);
}

#login-form button:active {
  transform: scale(0.98);
}

#login-form button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#login-form button i {
  margin-right: 0.4rem;
}

.error {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 0.75rem;
  text-align: center;
}

.auth-links {
  text-align: center;
  margin: 1rem 0 0;
  font-size: 0.875rem;
}

.auth-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

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

.otp-card {
  max-width: 420px;
}

.otp-icon-wrap {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #e7f1ff 0%, #cfe2ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--accent);
}

.otp-inputs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.25rem 0 1.5rem;
}

.otp-digit {
  width: 2.75rem;
  height: 3.25rem;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.otp-digit:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.otp-submit-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}

.otp-submit-btn:hover {
  background: var(--accent-hover);
}

.otp-submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.otp-submit-btn i {
  margin-right: 0.4rem;
}

#forgot-password-form label,
#forgot-password-form button {
  display: block;
  width: 100%;
}

#forgot-password-form label {
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
}

#forgot-password-form input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  box-sizing: border-box;
}

#forgot-password-form button {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

#forgot-password-form button:hover {
  background: var(--accent-hover);
}

.settings-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 1rem;
}

.settings-reset-default-wrap {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.settings-hint.warning {
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.settings-reset-default-wrap .settings-hint {
  margin-top: 0.65rem;
  margin-bottom: 0;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 240px;
  background: linear-gradient(180deg, #1a1d24 0%, #252930 100%);
  color: #e2e6eb;
  display: flex;
  flex-direction: column;
  z-index: 50;
  box-shadow: 2px 0 12px rgba(0,0,0,0.08);
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand i {
  color: var(--accent);
  font-size: 1.2rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.45);
  padding: 0 0.75rem 0.5rem;
  margin-bottom: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  margin-bottom: 2px;
  border-radius: 8px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(13, 110, 253, 0.25);
  color: #fff;
}

.nav-item i {
  width: 1.1em;
  opacity: 0.9;
}

.sidebar-footer {
  padding: 1rem 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-org,
.sidebar-user {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 0.35rem;
}

.sidebar-org i,
.sidebar-user i {
  margin-right: 0.35rem;
  color: var(--accent);
}

.sidebar-logout {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sidebar-logout:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.2);
}

/* Main content */
.main-content {
  position: relative;
  margin-left: 240px;
  min-height: 100vh;
  padding: 1.5rem 2rem 2rem;
  max-width: 1400px;
}

/* Full-area loader when switching pages or saving */
.page-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(3px);
  transition: opacity 0.15s ease;
}

.page-loading-overlay.hidden {
  display: none !important;
}

.page-loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid rgba(13, 110, 253, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: page-loading-spin 0.75s linear infinite;
}

.page-loading-text {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

@keyframes page-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

#psmile-save-settings:not(:disabled):hover,
#settings-save-profile:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(13, 110, 253, 0.4);
}

#psmile-save-settings:not(:disabled):active,
#settings-save-profile:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(13, 110, 253, 0.25);
}

.page-title {
  margin: 0 0 1.25rem 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}

.page-desc {
  margin: -0.5rem 0 1rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.org-name { display: block; }
.org-name i { margin-right: 0.25rem; }

.btn-secondary {
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

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

.btn-primary {
  padding: 0.5rem 1rem;
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary i {
  margin-right: 0.35rem;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-label i {
  margin-right: 0.25rem;
  color: var(--secondary);
}

/* Hot leads page */
.page-hot-leads {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-subtitle {
  margin: -0.5rem 0 1.5rem 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.hot-leads-tiles {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .hot-leads-tiles {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 500px) {
  .hot-leads-tiles {
    grid-template-columns: 1fr;
  }
}

.hot-lead-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.hot-lead-tile:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.hot-lead-tile-main {
  background: linear-gradient(135deg, #fff5f0 0%, #fff 100%);
  border-color: rgba(255, 107, 53, 0.35);
}

.hot-lead-tile-value {
  display: block;
  font-size: 1.85rem;
  font-weight: 700;
  color: #e85d04;
}

.hot-lead-tile-main .hot-lead-tile-value {
  color: #d84315;
}

.hot-lead-tile-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.35rem;
  display: block;
}

.hot-lead-tile-label i {
  margin-right: 0.35rem;
  color: #ff6b35;
}

.hot-leads-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
  .hot-leads-charts-row {
    grid-template-columns: 1fr;
  }
}

.chart-card-half {
  min-width: 0;
}

.chart-wrap-short {
  min-height: 160px;
}

.hot-leads-actions {
  margin-bottom: 1.75rem;
}

.btn-boxy {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(45, 55, 72, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn-boxy:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.btn-boxy:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(45, 55, 72, 0.5);
  color: #fff;
}

.btn-boxy i {
  font-size: 1.2rem;
}

.hot-leads-table-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: var(--text);
}

.hot-leads-table-section h2 i {
  margin-right: 0.4rem;
  color: #ff6b35;
}

/* Services page */
.page-services {
  animation: fadeIn 0.25s ease;
}

.services-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.service-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.service-tile:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.service-tile-total {
  background: linear-gradient(135deg, #e8f4fd 0%, #fff 100%);
  border-color: rgba(13, 110, 253, 0.3);
}

.service-tile-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.service-tile-total .service-tile-value {
  color: #0d6efd;
}

.service-tile-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.25rem;
  display: block;
}

.services-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
  .services-charts-row {
    grid-template-columns: 1fr;
  }
}

/* Reports page */
.page-reports {
  animation: fadeIn 0.25s ease;
}

.reports-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.usage-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.usage-filter-panel {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,0.06));
}

.usage-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.85rem 1rem;
}

.usage-filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.usage-filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted, #6c757d);
}

.usage-filter-label i {
  margin-right: 0.25rem;
  opacity: 0.85;
}

.usage-preset-select,
.usage-date-input {
  min-height: 2.35rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border, #d0d5dd);
  border-radius: 8px;
  background: #fff;
  font-size: 0.92rem;
  color: var(--text, #212529);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.usage-preset-select:focus,
.usage-date-input:focus {
  outline: none;
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.usage-custom-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.06) 0%, rgba(25, 135, 84, 0.06) 100%);
  border: 1px dashed rgba(13, 110, 253, 0.28);
  animation: usageCustomIn 0.22s ease;
}

.usage-custom-panel.hidden {
  display: none;
}

@keyframes usageCustomIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.usage-date-sep {
  align-self: center;
  padding-bottom: 0.35rem;
  color: var(--muted, #6c757d);
  font-weight: 600;
}

.usage-apply-btn {
  min-height: 2.35rem;
  white-space: nowrap;
}

.usage-filter-hint {
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  color: var(--muted, #6c757d);
}

.usage-charts-row {
  margin-bottom: 1rem;
}

.usage-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted, #6c757d);
}

.usage-detail-text {
  margin: 0;
  padding: 0.25rem 0 0.5rem;
  color: var(--text, #212529);
  line-height: 1.5;
  font-size: 0.95rem;
}

@media (max-width: 768px) {
  .usage-filter-row {
    flex-direction: column;
    align-items: stretch;
  }
  .usage-custom-panel {
    width: 100%;
  }
  .usage-date-sep {
    display: none;
  }
}

.report-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.report-tile:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.report-tile-main {
  background: linear-gradient(135deg, #e8f4fd 0%, #fff 100%);
  border-color: rgba(13, 110, 253, 0.3);
}

.report-tile-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.report-tile-main .report-tile-value {
  color: #0d6efd;
}

.report-tile-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.25rem;
  display: block;
}

.report-tile-label i {
  margin-right: 0.25rem;
  color: var(--secondary);
}

.reports-tiles {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.reports-tiles .report-tile {
  flex: 1;
  min-width: 0;
}

@media (max-width: 900px) {
  .reports-tiles {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

.reports-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
  .reports-charts-row {
    grid-template-columns: 1fr;
  }
}

/* Sidebar logo & avatar */
.sidebar-logo-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
}

.sidebar-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-logo.hidden { display: none; }
.sidebar-brand-icon { font-size: 1.2rem; color: var(--accent); }
.sidebar-brand-text { margin-left: 0.5rem; }

.sidebar-user-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.sidebar-avatar-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.sidebar-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-avatar.hidden { display: none; }
.sidebar-avatar-fallback { font-size: 1.75rem; color: rgba(255,255,255,0.6); }
.sidebar-user-meta { min-width: 0; display: flex; flex-direction: column; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user { font-size: 0.72rem; color: rgba(255,255,255,0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Settings page */
.page-settings { animation: fadeIn 0.25s ease; max-width: 760px; }

.settings-hero {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  border-radius: 16px;
  background: linear-gradient(135deg, #0d4a8c 0%, #0d6efd 55%, #4dabf7 100%);
  color: #fff;
  box-shadow: 0 12px 32px rgba(13, 110, 253, 0.22);
}
.settings-hero-icon {
  flex: 0 0 auto;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}
.settings-hero-title { margin: 0 0 0.25rem; font-size: 1.4rem; font-weight: 700; }
.settings-hero-sub { margin: 0; font-size: 0.9rem; line-height: 1.5; color: rgba(255, 255, 255, 0.88); }

.settings-grid { display: flex; flex-direction: column; gap: 1.25rem; }

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.settings-card-header { margin-bottom: 1.25rem; }
.settings-card-heading { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.3rem; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.settings-card-heading i { color: var(--accent); }
.settings-card-desc { margin: 0; font-size: 0.85rem; line-height: 1.55; color: var(--text-muted); }
.settings-card-desc code,
.settings-status-text code { background: var(--surface-hover); padding: 0.05rem 0.4rem; border-radius: 5px; font-size: 0.82em; }

/* Status card */
.settings-card-status { display: flex; padding: 1.25rem 1.5rem; }
.settings-status-row { display: flex; align-items: center; gap: 1rem; width: 100%; }
.settings-status-icon {
  flex: 0 0 auto;
  width: 2.85rem;
  height: 2.85rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: #fff7ed;
  color: #c2410c;
}
.settings-card-status.is-secure .settings-status-icon { background: #ecfdf5; color: #047857; }
.settings-status-body { min-width: 0; }
.settings-status-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.4rem;
  background: #fff7ed;
  color: #c2410c;
}
.settings-card-status.is-secure .settings-status-badge { background: #ecfdf5; color: #047857; }
.settings-status-text { margin: 0; font-size: 0.85rem; line-height: 1.55; color: var(--text-muted); }

/* Form */
.settings-form .form-row-group { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.settings-form .form-row { flex: 1; min-width: 200px; }
.settings-form .form-row.form-row-full { min-width: 100%; flex-basis: 100%; }
.settings-form .form-row label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--text); }
.settings-label-note { font-weight: 400; color: var(--text-muted); }
.settings-form .form-row input {
  width: 100%;
  padding: 0.62rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.settings-form .form-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.14); }

.settings-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.settings-divider::before,
.settings-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.settings-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 0.5rem; }
.settings-message { margin: 0; font-size: 0.86rem; }
.settings-message.success { color: var(--success); }
.settings-message.error { color: var(--error); }

/* Danger card */
.settings-card-danger { border-color: #fecaca; background: #fffafa; }
.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.1rem;
  border-radius: 9px;
  border: 1px solid #fca5a5;
  background: #fff;
  color: #b91c1c;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-danger-outline:hover { background: #fef2f2; border-color: #f87171; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.filters label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.filters input[type="date"],
.filters select {
  padding: 0.4rem 0.6rem;
  margin-left: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

/* Charts row – bar + line, compact and aesthetic */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .charts-row {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.25s ease, transform 0.2s ease, border-color 0.2s ease;
  max-height: 280px;
}

.chart-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: var(--border-focus);
}

.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chart-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.chart-title i {
  margin-right: 0.4rem;
  color: var(--accent);
}

.chart-time-select {
  padding: 0.35rem 0.6rem 0.35rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
  min-width: 120px;
  appearance: auto;
}

.chart-time-select:hover {
  border-color: var(--accent);
}

.chart-time-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 180px;
  height: 180px;
}

.chart-wrap canvas {
  max-width: 100%;
  max-height: 180px;
}

.calls-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: var(--text);
}

.calls-section h2 i {
  margin-right: 0.35rem;
  color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calls-table {
  width: 100%;
  border-collapse: collapse;
}

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

.calls-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.calls-table tbody tr {
  transition: background 0.15s ease;
}

.calls-table tbody tr:hover {
  background: var(--surface-hover);
}

.calls-table td {
  font-size: 0.875rem;
}

.intent-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.intent-badge.appointment_booking { background: rgba(25, 135, 84, 0.15); color: #198754; }
.intent-badge.appointment_cancellation { background: rgba(220, 53, 69, 0.15); color: #dc3545; }
.intent-badge.appointment_rescheduling { background: rgba(255, 193, 7, 0.25); color: #856404; }
.intent-badge.packages_discounts { background: rgba(13, 110, 253, 0.15); color: #0d6efd; }
.intent-badge.general_enquiry { background: rgba(108, 117, 125, 0.2); color: var(--text-muted); }

/* Audio controls – hover, active (playing), inactive (disabled) */
.audio-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.audio-controls button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.audio-controls button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(13, 110, 253, 0.2);
}

.audio-controls button:active:not(:disabled) {
  transform: scale(0.96);
}

/* Inactive: disabled state */
.audio-controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.audio-controls button:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Active: currently playing */
.audio-controls button.playing {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  opacity: 1;
}

.audio-controls button.playing:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 2px 10px rgba(13, 110, 253, 0.4);
}

.audio-controls .download-btn {
  margin-left: 0.15rem;
}

.recording-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
}

.recording-link:hover {
  text-decoration: underline;
}

.transcript-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.transcript-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.reclassify-btn {
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  margin-left: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s ease, color 0.2s ease;
}

.reclassify-btn:hover {
  background: rgba(255, 193, 7, 0.2);
  color: #856404;
  border-color: var(--warning);
}

.reclassify-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.pagination button {
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.pagination button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  box-shadow: var(--shadow-hover);
}

.modal-content h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: var(--text);
}

.modal-content h3 i {
  margin-right: 0.35rem;
  color: var(--accent);
}

#transcript-text {
  white-space: pre-wrap;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
  max-height: 50vh;
  overflow: auto;
}

.modal-content .btn-primary {
  margin-top: 0.5rem;
}

/* ========== Mobile responsive (layout unchanged on desktop) ========== */
.main-mobile-header {
  display: none;
}

@media (max-width: 768px) {
  .main-mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 45;
    box-shadow: var(--shadow);
  }

  .hamburger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 1.15rem;
    transition: background 0.2s ease, border-color 0.2s ease;
  }

  .hamburger-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
    color: var(--accent);
  }

  .main-mobile-header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
  }

  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 50;
  }

  #dashboard-screen.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 49;
    transition: opacity 0.2s ease;
  }

  #dashboard-screen.sidebar-open .sidebar-overlay {
    display: block;
    cursor: pointer;
  }

  .main-content {
    margin-left: 0;
    padding: 3.5rem 0.75rem 1.5rem;
    max-width: 100%;
  }

  .page-title {
    font-size: 1.05rem;
    margin-bottom: 0.85rem;
  }

  .page-subtitle,
  .page-desc {
    font-size: 0.8rem;
    margin-bottom: 1rem;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
  }

  .stat-card {
    padding: 0.65rem 0.5rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .chart-card-head {
    margin-bottom: 0.5rem;
  }

  .chart-title {
    font-size: 0.85rem;
  }

  .chart-time-select {
    font-size: 0.75rem;
    min-width: 100px;
    padding: 0.3rem 0.5rem;
  }

  .chart-wrap {
    min-height: 140px;
    height: 140px;
  }

  .chart-wrap canvas {
    max-height: 140px;
  }

  .chart-card {
    padding: 0.75rem 0.85rem;
    max-height: 220px;
  }

  .charts-row {
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .calls-section h2,
  .hot-leads-table-section h2 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
  }

  .table-wrap {
    border-radius: 8px;
    margin-bottom: 1rem;
  }

  .calls-table th,
  .calls-table td {
    padding: 0.45rem 0.5rem;
    font-size: 0.75rem;
  }

  .calls-table th {
    font-size: 0.7rem;
  }

  .intent-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.35rem;
  }

  .audio-controls button {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  .transcript-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
  }

  .recording-link {
    font-size: 0.8rem;
  }

  .reclassify-btn {
    font-size: 0.65rem;
    padding: 0.15rem 0.3rem;
  }

  .btn-primary,
  .btn-secondary {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .filters label,
  .filters input[type="date"],
  .filters select {
    font-size: 0.8rem;
  }

  .hot-leads-tiles {
    gap: 0.6rem;
    margin-bottom: 1rem;
  }

  .hot-lead-tile {
    padding: 0.75rem;
  }

  .hot-lead-tile-value {
    font-size: 1.35rem;
  }

  .hot-lead-tile-label {
    font-size: 0.7rem;
  }

  .hot-leads-charts-row,
  .services-charts-row,
  .reports-charts-row {
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .chart-wrap-short {
    min-height: 120px;
  }

  .chart-card-half .chart-title {
    font-size: 0.8rem;
  }

  .services-tiles {
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .service-tile {
    padding: 0.65rem;
  }

  .service-tile-value {
    font-size: 1.2rem;
  }

  .service-tile-label {
    font-size: 0.65rem;
  }

  .reports-tiles {
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .report-tile {
    padding: 0.65rem;
  }

  .report-tile-value {
    font-size: 1.1rem;
  }

  .report-tile-label {
    font-size: 0.65rem;
  }

  .settings-heading {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }

  .settings-form .form-row label {
    font-size: 0.8rem;
  }

  .settings-form .form-row input {
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
  }

  .settings-form .form-row-group {
    margin-bottom: 0.75rem;
  }

  .settings-form .form-row {
    min-width: 160px;
  }

  .settings-preview-wrap {
    width: 64px;
    height: 64px;
  }

  .settings-preview-fallback {
    font-size: 2rem;
  }

  .settings-upload-actions .btn-primary,
  .settings-upload-actions .btn-secondary {
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
  }

  .pagination {
    gap: 0.5rem;
    margin-top: 0.75rem;
  }

  .pagination button {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .modal-content {
    padding: 1rem;
    max-height: 85vh;
  }

  .modal-content h3 {
    font-size: 1rem;
  }

  #transcript-text {
    font-size: 0.8rem;
  }

  .sidebar-brand {
    padding: 1rem 1rem 1.25rem;
    font-size: 1.1rem;
  }

  .nav-section-label {
    font-size: 0.65rem;
    padding: 0 0.6rem 0.4rem;
  }

  .nav-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  .nav-item i {
    font-size: 0.9rem;
  }

  .sidebar-footer {
    padding: 0.75rem 1rem;
  }

  .sidebar-org,
  .sidebar-user {
    font-size: 0.7rem;
  }

  .sidebar-user-name {
    font-size: 0.75rem;
  }

  .sidebar-logout {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }
}

/* Perfect Smile — booking control */
.psmile-config-version {
  margin-left: 0.75rem;
  font-size: 0.875rem;
}

.page-psmile-booking .psmile-page-subtitle {
  margin-top: -0.25rem;
  margin-bottom: 1rem;
  color: var(--text-muted, #6c757d);
}

.page-psmile-booking {
  animation: fadeIn 0.25s ease;
}

.page-psmile-booking .page-subtitle {
  margin-bottom: 0.85rem;
}

.psmile-top-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

.psmile-top-tab {
  flex: 0 0 auto;
  padding: 0.5rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: inherit;
}

.psmile-top-tab.active {
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  margin-bottom: -1px;
  color: var(--text);
}

.psmile-sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.psmile-sub-tab {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-hover);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}

.psmile-sub-tab.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent, #0d6efd);
}

.psmile-sub-panel {
  margin-bottom: 1rem;
}

.psmile-scheme-days-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.psmile-scheme-type-label {
  white-space: nowrap;
  vertical-align: middle;
}

.psmile-tab-panel {
  margin-bottom: 1rem;
}

.psmile-table-scroll {
  overflow-x: auto;
}

.psmile-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.psmile-data-table th,
.psmile-data-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  vertical-align: top;
}

.psmile-data-table th {
  background: var(--surface-hover);
  text-align: left;
}

.psmile-td-c {
  text-align: center;
}

.psmile-td-stack {
  min-width: 6.5rem;
}

.psmile-td-stack .psmile-to-yesno {
  width: 100%;
  max-width: 5.5rem;
  margin: 0 auto 0.35rem;
  display: block;
  font-size: 0.85rem;
}

.psmile-td-stack .psmile-to-hours,
.psmile-td-stack .psmile-to-ref-hours,
.psmile-td-stack .psmile-to-ref-maxgbp {
  width: 100%;
  max-width: 5.5rem;
  margin: 0.2rem auto 0;
  box-sizing: border-box;
}

.psmile-td-stack .psmile-to-cond {
  margin-top: 0.35rem;
}

.psmile-plan-cell {
  max-width: 16rem;
}

/* Patient schemes: two plan chips per row */
.psmile-scheme-plans-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 0.5rem;
  min-width: 11rem;
  max-width: 24rem;
}

.psmile-scheme-plans-grid > .psmile-chip {
  width: auto;
  min-width: 0;
  max-width: 100%;
}

/* Treatment overrides: two plan chips per row */
.psmile-treat-plans-cell {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 0.5rem;
  min-width: 11rem;
  max-width: 28rem;
  vertical-align: top;
}

.psmile-treat-plans-cell > .psmile-chip {
  width: auto;
  min-width: 0;
  max-width: 100%;
}

.psmile-dow-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  min-width: 9rem;
}

.psmile-dow-cb {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.72rem;
  white-space: nowrap;
}

.psmile-plan-inline {
  font-size: 0.72rem !important;
  padding: 0.25rem 0.35rem !important;
  min-height: auto !important;
}

.psmile-to-hours {
  width: 6.25rem;
  margin-top: 0.25rem;
}

.psmile-clin-treat-dd {
  position: relative;
  min-width: 9.5rem;
  max-width: 17rem;
}

.psmile-clin-treat-btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.psmile-clin-treat-preview {
  display: block;
  font-size: 0.78rem;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
}

.psmile-clin-treat-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 60;
  min-width: min(100vw - 2rem, 22rem);
  max-width: 26rem;
  max-height: 20rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
}

.psmile-clin-treat-panel.hidden {
  display: none !important;
}

.psmile-clin-treat-search {
  width: 100%;
  margin-bottom: 0.45rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  box-sizing: border-box;
}

.psmile-clin-treat-list {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.2rem;
  max-height: 14rem;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -0.15rem;
}

/* One treatment per row (not inline-wrapped columns). */
.psmile-clin-treat-list .psmile-clin-treat-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.3rem 0.35rem;
  border-radius: 6px;
  cursor: pointer;
}

.psmile-clin-treat-list .psmile-clin-treat-row:hover {
  background: var(--surface-hover);
}

.psmile-clin-treat-list .psmile-clin-treat-row .psmile-clin-treat-cb {
  flex: 0 0 auto;
  margin-top: 0.15rem;
}

.psmile-clin-treat-list .psmile-clin-treat-row > span {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  word-break: break-word;
}

.psmile-plan-picker-dd {
  position: relative;
  min-width: 9.5rem;
  max-width: 17rem;
}

.psmile-plan-picker-btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.psmile-plan-picker-preview {
  display: block;
  font-size: 0.78rem;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
}

.psmile-plan-picker-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 60;
  min-width: min(100vw - 2rem, 22rem);
  max-width: 26rem;
  max-height: 20rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
}

.psmile-plan-picker-panel.hidden {
  display: none !important;
}

.psmile-plan-picker-panel.psmile-plan-picker-panel--floating {
  position: fixed !important;
  z-index: 1200;
}

/* Patient schemes table is only two rows — avoid clipping dropdown under table border */
#psmile-panel-schemes .table-wrap.psmile-table-scroll {
  overflow: visible;
}

#psmile-schemes-table td.psmile-scheme-plan-picker-cell {
  overflow: visible;
  position: relative;
}

.psmile-plan-picker-search {
  width: 100%;
  margin-bottom: 0.45rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  box-sizing: border-box;
}

.psmile-plan-picker-list {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.2rem;
  max-height: 14rem;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -0.15rem;
}

.psmile-plan-picker-list .psmile-plan-picker-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.3rem 0.35rem;
  border-radius: 6px;
  cursor: pointer;
}

.psmile-plan-picker-list .psmile-plan-picker-row:hover {
  background: var(--surface-hover);
}

.psmile-plan-picker-list .psmile-plan-picker-row .psmile-plan-picker-cb {
  flex: 0 0 auto;
  margin-top: 0.15rem;
}

.psmile-plan-picker-list .psmile-plan-picker-row > span {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  word-break: break-word;
}

.psmile-scheme-plan-picker-cell,
.psmile-treat-plans-cell {
  vertical-align: top;
  min-width: 10rem;
}

.psmile-clinician-table .psmile-clin-treat-col {
  vertical-align: top;
  min-width: 10rem;
}

.psmile-clinician-table .psmile-clin-plans-col {
  vertical-align: top;
  min-width: 12rem;
  max-width: 22rem;
}

.psmile-clinician-table .psmile-clin-role-select,
.psmile-clinician-table input.psmile-clin-role {
  min-width: 8.5rem;
  max-width: 11rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--bg, #fff);
  color: inherit;
}

.psmile-clin-treat-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 0.35rem 0.45rem;
  max-width: min(100%, 56rem);
  vertical-align: top;
}

.psmile-clin-treat-cell > .psmile-chip {
  width: auto;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 13rem;
}

.psmile-th-sub {
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.muted {
  color: var(--text-muted);
}

.psmile-plan-type-badge {
  display: inline-block;
  margin: 0.15rem 0.35rem 0.15rem 0;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: var(--surface-hover);
  font-size: 0.78rem;
}

.psmile-sticky-actions {
  position: sticky;
  z-index: 40;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.psmile-sticky-actions .psmile-save-btn {
  width: auto;
  min-width: 9rem;
  margin-top: 0;
}

.psmile-sticky-actions .psmile-save-inline-msg {
  margin: 0;
  flex: 1 1 12rem;
}

.psmile-sidebar-save-hint {
  margin-top: 0.75rem !important;
  margin-bottom: 0 !important;
  font-size: 0.8rem !important;
}

@media (max-width: 768px) {
  .psmile-sticky-actions {
    top: 52px;
    z-index: 44;
  }
}

.psmile-banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #e7f1ff;
  color: var(--text);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.psmile-banner.psmile-banner-error {
  background: #f8d7da;
  border-color: #f5c2c7;
  color: #842029;
}

.psmile-layout {
  display: grid;
  grid-template-columns: 1fr min(380px, 100%);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .psmile-layout {
    grid-template-columns: 1fr;
  }
}

.psmile-sidebar {
  min-width: 0;
}

.psmile-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.psmile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.psmile-nested-card {
  margin-top: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-hover);
}

.psmile-field-inline {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.psmile-field-inline input[type="checkbox"] {
  margin-top: 0.25rem;
}

.psmile-card-tight .psmile-pay-table input,
.psmile-card-tight .psmile-pay-table select {
  width: 100%;
  min-width: 0;
}

.psmile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.psmile-subhead {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1rem 0 0.35rem;
  color: var(--text);
}

.psmile-card-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.psmile-card-title i {
  margin-right: 0.35rem;
  color: var(--accent);
}

.psmile-hint {
  margin: 0 0 1rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.stripe-setup-guide {
  margin: 0.5rem 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
}

.stripe-setup-guide-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.stripe-setup-steps {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  color: var(--text, #1f2937);
  line-height: 1.45;
}

.stripe-setup-steps li {
  margin: 0.45rem 0;
}

.stripe-endpoint-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.4rem 0 0.25rem;
}

.stripe-endpoint-url {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 0.35rem 0.5rem;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 0.8rem;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.psmile-loading {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.psmile-loading.hidden {
  display: none;
}

.psmile-table-wrap {
  margin-top: 0.5rem;
}

.psmile-table th:nth-child(3),
.psmile-table td:nth-child(3) {
  text-align: center;
  width: 140px;
}

.psmile-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 0.5rem;
  align-content: start;
}

.psmile-chip {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
  white-space: normal;
  word-break: break-word;
  min-height: 2.25rem;
  box-sizing: border-box;
  width: 100%;
}

.psmile-chip input {
  margin: 0;
}

.psmile-form-grid {
  display: grid;
  gap: 1rem;
  max-width: 480px;
}

.psmile-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
}

.psmile-field input,
.psmile-field select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}

.psmile-field-hint {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-muted);
  max-width: 36rem;
}

.psmile-field.psmile-check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.psmile-field.psmile-check input {
  width: auto;
}

.psmile-sidebar .psmile-card {
  position: sticky;
  top: 1rem;
}

.psmile-pay-table-wrap {
  margin: 1rem 0;
}

.psmile-pay-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.psmile-pay-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.35rem 0.5rem 0.35rem 0;
  vertical-align: top;
  width: 38%;
}

.psmile-pay-table td {
  padding: 0.25rem 0;
}

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

/* Practitioner / treatment lists: wrap in viewport (no horizontal crawl) */
.psmile-picker-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  max-height: min(320px, 48vh);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-hover);
}

.psmile-picker-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  gap: 0.5rem;
  align-items: stretch;
  width: 100%;
}

.psmile-picker-item {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.35;
  cursor: pointer;
  text-align: left;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  hyphens: auto;
  transition: border-color 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.psmile-picker-item:hover {
  border-color: var(--border-focus);
  background: var(--surface-hover);
}

.psmile-picker-item.active {
  border-color: var(--accent);
  background: #e7f1ff;
  box-shadow: 0 0 0 1px rgba(13, 110, 253, 0.2);
}

.psmile-detail-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--surface-hover);
  min-height: 3rem;
}

.psmile-detail-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.psmile-detail-dl {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
  font-size: 0.875rem;
  align-items: start;
}

.psmile-detail-dl dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.psmile-detail-dl dd {
  margin: 0;
  word-break: break-word;
}

.psmile-detail-multiline {
  white-space: pre-wrap;
  max-height: 10rem;
  overflow: auto;
}

.psmile-inline-err {
  font-size: 0.875rem;
  color: var(--error);
}

.psmile-treatment-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.psmile-field-grow {
  flex: 1 1 180px;
  min-width: 140px;
}

.psmile-field-toolbar-check {
  padding-bottom: 0.35rem;
}

/* —— How it works (in-app user guide) —— */
.page-how-it-works {
  max-width: 920px;
  margin: 0 auto 3rem;
}

.guide-hero {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 2rem;
  background: linear-gradient(135deg, #0d4a8c 0%, #0d6efd 42%, #4dabf7 100%);
  box-shadow: 0 12px 40px rgba(13, 110, 253, 0.25);
}

.guide-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 100% 0%, rgba(255, 255, 255, 0.2), transparent 55%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(255, 255, 255, 0.12), transparent 50%);
  pointer-events: none;
}

.guide-hero-inner {
  position: relative;
  z-index: 1;
  padding: 2rem 2rem 2.25rem;
  color: #fff;
}

.guide-kicker {
  margin: 0 0 0.75rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.92;
}

.guide-kicker i {
  margin-right: 0.4rem;
  opacity: 0.95;
}

.guide-hero-title {
  margin: 0 0 0.75rem 0;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.guide-hero-lead {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.65;
  max-width: 52rem;
  opacity: 0.97;
}

.guide-hero-lead strong {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.guide-body {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.guide-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem 1.5rem 1.6rem;
  box-shadow: var(--shadow);
}

.guide-section-accent {
  border-color: rgba(13, 110, 253, 0.22);
  box-shadow: 0 4px 20px rgba(13, 110, 253, 0.08);
}

.guide-section-head {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.guide-icon-wrap {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(13, 110, 253, 0.12), rgba(13, 110, 253, 0.06));
  color: var(--accent);
  font-size: 1.2rem;
}

.guide-section-accent .guide-icon-wrap {
  background: linear-gradient(145deg, rgba(13, 110, 253, 0.2), rgba(13, 110, 253, 0.08));
}

.guide-h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.guide-h2-standalone {
  margin-bottom: 0.35rem;
}

.guide-h2 i {
  margin-right: 0.45rem;
  color: var(--accent);
}

.guide-h3 {
  margin: 0 0 0.65rem 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.guide-h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.guide-h4 i {
  margin-right: 0.35rem;
  color: var(--accent);
}

.guide-lead {
  margin: 0 0 0.85rem 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
}

.guide-lead:last-child {
  margin-bottom: 0;
}

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

@media (max-width: 900px) {
  .guide-grid-2 {
    grid-template-columns: 1fr;
  }
}

.guide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.35rem 1.35rem 1.4rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.guide-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: rgba(13, 110, 253, 0.15);
}

.guide-card-span-2 {
  grid-column: 1 / -1;
}

.guide-card-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  background: linear-gradient(145deg, #e7f1ff, #f0f7ff);
  color: var(--accent);
  font-size: 1.1rem;
}

.guide-card p {
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
  line-height: 1.62;
  color: var(--text);
}

.guide-card p:last-child {
  margin-bottom: 0;
}

.guide-card code {
  font-size: 0.85em;
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

.guide-subcards {
  display: grid;
  gap: 1rem;
  margin-top: 1.35rem;
}

.guide-subcard {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.15rem;
}

.guide-subcard p {
  margin: 0 0 0.65rem 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
}

.guide-subcard p:last-child {
  margin-bottom: 0;
}

.guide-subcard .guide-list {
  margin: 0 0 0.65rem 1.1rem;
  padding: 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
}

.guide-subcard .guide-list li {
  margin-bottom: 0.45rem;
}

.guide-subcard .guide-list li:last-child {
  margin-bottom: 0;
}

.guide-scenarios-intro {
  margin: 0 0 1rem 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.guide-scenario-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.guide-scenario-item {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  font-size: 0.88rem;
  line-height: 1.58;
}

.guide-scenario-num {
  flex-shrink: 0;
  width: 1.85rem;
  height: 1.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), #4dabf7);
}

.guide-section-habits {
  background: linear-gradient(145deg, #f8fff9 0%, #f0fdf4 100%);
  border-color: rgba(25, 135, 84, 0.25);
}

.guide-habits-inner .guide-h2 {
  color: #146c43;
}

.guide-habits-inner .guide-h2 i {
  color: var(--success);
}

.guide-habits-inner p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text);
}

.guide-footnote {
  margin: 0;
  padding: 0 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  font-style: italic;
}

@media (max-width: 768px) {
  .guide-hero-inner {
    padding: 1.35rem 1.1rem 1.5rem;
  }

  .page-how-it-works {
    margin-bottom: 2rem;
  }
}

/* Treatment plan reminders */
.page-tp-reminders {
  max-width: 1480px;
  width: 100%;
}

.tp-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.tp-page-title {
  margin-bottom: 0.35rem;
}

.tp-page-subtitle {
  margin: 0;
  max-width: 46rem;
  line-height: 1.55;
}

.tp-stat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  flex-shrink: 0;
}

.tp-stat-pill {
  min-width: 6.25rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.tp-stat-pill-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.tp-stat-pill-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.tp-stat-pill-active .tp-stat-pill-value {
  color: var(--accent);
}

.tp-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.tp-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.tp-filters-panel {
  position: sticky;
  top: 1rem;
  overflow: visible;
}

.tp-results-panel {
  overflow: hidden;
  min-width: 0;
}

.tp-panel-head {
  padding: 1.1rem 1.25rem 0.95rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fafbfc 0%, var(--surface) 100%);
}

.tp-panel-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tp-panel-title i {
  color: var(--accent);
  font-size: 0.95rem;
}

.tp-panel-desc {
  margin: 0.4rem 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.tp-panel-body {
  padding: 1.15rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tp-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eef1f4;
}

.tp-filter-group:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.tp-filter-group-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #495057;
}

.tp-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.tp-field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #343a40;
  line-height: 1.3;
}

.tp-field-help {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.tp-filter-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.62rem 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 8px;
  font: inherit;
  font-size: 0.94rem;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tp-date-input {
  min-height: 2.65rem;
}

.tp-filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.14);
}

.tp-filter-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: #f1f3f5;
}

.tp-option-card {
  padding: 0.85rem 0.9rem;
  border: 1px solid #dee2e6;
  border-radius: 10px;
  background: #f8f9fa;
}

.tp-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  margin: 0;
}

.tp-checkbox-label input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.tp-checkbox-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.tp-checkbox-text strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.tp-checkbox-text small {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  font-weight: 400;
}

.tp-filter-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.15rem;
  padding-top: 0.25rem;
}

.tp-fetch-btn,
.tp-export-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.tp-fetch-btn.is-loading {
  opacity: 0.92;
  pointer-events: none;
}

.tp-filters-hint {
  margin: 0;
  padding: 0.75rem 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px dashed #dee2e6;
}

.tp-reminders-banner {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #e7f1ff;
  color: #084298;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid #b6d4fe;
}

.tp-reminders-banner.tp-banner-error {
  background: #f8d7da;
  color: #842029;
  border-color: #f1aeb5;
}

.tp-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tp-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.tp-tab.tp-tab-active {
  background: #e7f1ff;
  border-color: #b6d4fe;
  color: #084298;
  font-weight: 600;
}

.tp-outcomes-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.tp-outcomes-panel {
  margin-top: 0;
}

.tp-outcomes-table td {
  vertical-align: top;
  font-size: 0.88rem;
}

.tp-outcome-when {
  white-space: nowrap;
  color: var(--text-muted);
}

.tp-outcome-patient {
  font-weight: 600;
  min-width: 9rem;
}

.tp-patient-id {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

.tp-outcome-notes {
  max-width: 16rem;
  line-height: 1.45;
  color: #444;
}

.tp-outcome-media {
  white-space: nowrap;
}

.tp-outcome-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.tp-outcome-continue {
  background: #d1e7dd;
  color: #0f5132;
}

.tp-outcome-callback {
  background: #cff4fc;
  color: #055160;
}

.tp-outcome-close {
  background: #f8d7da;
  color: #842029;
}

.tp-outcome-muted {
  background: #e9ecef;
  color: #495057;
}

.tp-campaign-tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: #f1f3f5;
  font-size: 0.8rem;
}

.tp-pending-label {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.tp-outcomes-table .audio-controls {
  display: inline-flex;
  gap: 0.25rem;
}

.tp-results-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}

.tp-results-toolbar-left,
.tp-results-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.tp-selection-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0 0.35rem;
}

.tp-call-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tp-table-shell {
  position: relative;
  min-height: 280px;
}

.tp-table-wrap {
  margin: 0;
}

.tp-table-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(2px);
}

.tp-table-loading-inner {
  text-align: center;
  padding: 1.5rem;
}

.tp-spinner {
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 auto 0.75rem;
  border: 3px solid #dee2e6;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tp-spin 0.75s linear infinite;
}

@keyframes tp-spin {
  to { transform: rotate(360deg); }
}

.tp-table-loading-text {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 500;
}

.tp-reminders-table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: #f8f9fa;
  white-space: nowrap;
}

.tp-reminders-table tbody tr:hover {
  background: #f8fbff;
}

.tp-reminders-table .tp-col-check {
  width: 2.75rem;
  text-align: center;
}

.tp-cohort-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.tp-badge-not-accepted {
  background: #fff3cd;
  color: #664d03;
}

.tp-badge-fta {
  background: #f8d7da;
  color: #842029;
}

.tp-muted {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tp-empty-state {
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.tp-empty-icon {
  font-size: 2rem;
  color: #ced4da;
  margin-bottom: 0.75rem;
}

.tp-empty-title {
  margin: 0 0 0.35rem;
  font-weight: 600;
  color: var(--text);
}

.tp-empty-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 28rem;
  margin-inline: auto;
}

.tp-hint {
  padding: 0 1rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 1024px) {
  .tp-layout {
    grid-template-columns: 1fr;
  }

  .tp-filters-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .tp-page-header {
    flex-direction: column;
  }

  .tp-results-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .tp-results-toolbar-left,
  .tp-results-toolbar-right {
    justify-content: stretch;
  }

  .tp-call-btn {
    flex: 1;
  }
}

/* ── Boxly integration (Booking control → Integrations) ── */
.boxly-integration {
  font-family: var(--font);
  color: var(--text);
  animation: fadeIn 0.3s ease;
}

.boxly-integration-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.35rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.08) 0%, rgba(99, 102, 241, 0.06) 100%);
  border: 1px solid rgba(13, 110, 253, 0.15);
}

.boxly-integration-brand {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.boxly-integration-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 12px;
  background: linear-gradient(145deg, #2d3748 0%, #1a202c 100%);
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px rgba(45, 55, 72, 0.25);
}

.boxly-integration-title {
  margin: 0 0 0.35rem 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.boxly-integration-subtitle {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-muted, #6c757d);
  max-width: 42rem;
}

.boxly-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.boxly-status-pill.active {
  background: rgba(21, 128, 61, 0.12);
  border-color: rgba(21, 128, 61, 0.35);
  color: #15803d;
}

.boxly-status-pill.warn {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.35);
  color: #b45309;
}

.boxly-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.boxly-setup-steps {
  margin-bottom: 1.25rem;
  padding: 1.15rem 1.25rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.boxly-section-label {
  margin: 0 0 0.85rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.boxly-section-label i {
  margin-right: 0.4rem;
  color: var(--accent, #0d6efd);
  opacity: 0.9;
}

.boxly-steps-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-muted, #5c6370);
}

.boxly-steps-list li {
  margin-bottom: 0.45rem;
}

.boxly-steps-list strong {
  color: var(--text);
  font-weight: 600;
}

.boxly-form-card {
  margin-bottom: 1.15rem;
  padding: 1.2rem 1.25rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

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

.boxly-field-span2 {
  grid-column: 1 / -1;
}

.boxly-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.boxly-field-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.boxly-required {
  color: #dc3545;
}

.boxly-optional {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.boxly-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.boxly-input:focus {
  outline: none;
  border-color: var(--accent, #0d6efd);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.boxly-select {
  cursor: pointer;
}

.boxly-field-hint,
.boxly-field-meta {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted, #6c757d);
}

.boxly-field-meta {
  color: #15803d;
  font-weight: 500;
}

.boxly-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.boxly-toggle {
  margin-top: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent, #0d6efd);
  flex-shrink: 0;
}

.boxly-mapping-intro {
  margin: -0.35rem 0 0.85rem 0;
}

.boxly-label-map-grid {
  margin-top: 0.25rem;
}

.boxly-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 1rem 0 0.5rem;
}

.boxly-action-msg {
  font-size: 0.875rem;
  font-weight: 500;
  margin-left: 0.25rem;
}

.boxly-footnote {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.boxly-footnote i {
  margin-right: 0.35rem;
  opacity: 0.85;
}

.psmile-top-tab.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .boxly-form-grid {
    grid-template-columns: 1fr;
  }

  .boxly-field-span2 {
    grid-column: auto;
  }

  .boxly-integration-header {
    flex-direction: column;
  }
}
