html {
  font-size: 14px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

:root {
  --sidebar-width: 272px;
  --topnav-height: 64px;
  --footer-height: 56px;
  --app-bg: #f5f7fb;
  --app-surface: #ffffff;
  --app-surface-muted: #f8fafc;
  --app-border: #e3e8ef;
  --app-text: #172033;
  --app-muted: #64748b;
  --app-sidebar: #111827;
  --app-sidebar-2: #172033;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 14px 38px rgba(15, 23, 42, 0.1);
}

* {
  letter-spacing: 0;
}

body {
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.06), rgba(37, 99, 235, 0.02) 290px),
    var(--app-bg);
  color: var(--app-text);
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  margin-bottom: 0;
  min-height: 100vh;
  padding-bottom: var(--footer-height);
}

a {
  text-decoration: none;
}

.global-loader {
  align-items: center;
  background: rgba(15, 23, 42, 0.28);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 2000;
}

.global-loader__panel {
  align-items: center;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  color: var(--app-text);
  display: flex;
  font-weight: 700;
  gap: 0.85rem;
  min-width: 148px;
  padding: 1rem 1.2rem;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.22rem rgba(15, 118, 110, 0.16);
}

.btn {
  border-radius: 8px;
  font-weight: 600;
}

.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-strong);
  --bs-btn-hover-border-color: var(--brand-strong);
  --bs-btn-active-bg: var(--brand-strong);
  --bs-btn-active-border-color: var(--brand-strong);
}

.btn-outline-primary {
  --bs-btn-color: var(--brand);
  --bs-btn-border-color: rgba(15, 118, 110, 0.42);
  --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand);
}

.card,
.opd-card,
.page-head {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  background: var(--app-surface);
  border-bottom-color: var(--app-border);
}

.app-shell {
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.08), transparent 360px),
    linear-gradient(180deg, #f7f9fd 0%, #eef3f8 100%);
  margin-bottom: 0;
  min-height: 100vh;
}

.top-navbar {
  background: linear-gradient(135deg, #172033 0%, #0f766e 58%, #2563eb 100%);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  height: var(--topnav-height);
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1040;
}

.top-navbar .navbar-brand,
.top-navbar .nav-link {
  color: #fff !important;
}

.top-navbar .nav-link {
  border-radius: 8px;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.top-navbar .nav-link:hover,
.top-navbar .nav-link:focus {
  background: rgba(255, 255, 255, 0.12);
}

.top-navbar .dropdown-menu {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 0.45rem;
}

.brand-mark,
.user-avatar {
  align-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.user-avatar {
  background: #fff;
  color: var(--brand);
  height: 32px;
  width: 32px;
}

.sidebar {
  background: linear-gradient(180deg, var(--app-sidebar) 0%, var(--app-sidebar-2) 100%);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  position: fixed;
  top: var(--topnav-height);
  transition: transform 0.24s ease-in-out;
  width: var(--sidebar-width);
  z-index: 1030;
}

.sidebar .nav {
  gap: 0.2rem;
  padding: 0 0.75rem;
}

.sidebar .nav-link {
  align-items: center;
  border-radius: 8px;
  color: #bac6d6;
  display: flex;
  gap: 0.75rem;
  min-height: 42px;
  padding: 0.68rem 0.9rem;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

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

.sidebar .nav-link.active {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.28), rgba(37, 99, 235, 0.2));
  color: #fff;
  font-weight: 700;
}

.sidebar .nav-link i {
  align-items: center;
  color: inherit;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 1.05rem;
  justify-content: center;
  width: 1.5rem;
}

.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topnav-height);
  min-height: calc(100vh - var(--topnav-height));
  padding: 1.5rem 1.5rem calc(1.5rem + var(--footer-height));
}

.app-footer {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--app-border);
  bottom: 0;
  color: var(--app-muted);
  display: flex;
  font-size: 0.82rem;
  gap: 0.75rem;
  height: var(--footer-height);
  justify-content: space-between;
  left: var(--sidebar-width);
  padding: 0 1.5rem;
  position: fixed;
  right: 0;
  z-index: 1020;
}

.app-footer__version {
  color: var(--app-text);
  font-weight: 600;
}

.breadcrumb {
  --bs-breadcrumb-divider-color: var(--app-muted);
  font-size: 0.875rem;
}

.breadcrumb a {
  color: var(--brand);
}

.page-header,
.page-head {
  margin-bottom: 1.35rem;
}

.page-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.page-header h3,
.page-title,
.main-content > .d-flex h3 {
  color: var(--app-text);
  font-size: clamp(1.35rem, 1.1rem + 0.55vw, 1.8rem);
  font-weight: 800;
}

.page-title {
  margin: 0;
}

.page-subtitle,
.muted {
  color: var(--app-muted);
}

.page-subtitle {
  margin: 0.2rem 0 0;
}

.setup-card {
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.setup-card:hover {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
  transform: translateY(-3px);
}

.setup-icon,
.metric-icon,
.stat-icon {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  flex-shrink: 0;
  height: 54px;
  justify-content: center;
  width: 54px;
}

.metric-icon {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.35rem;
}

.opd-card {
  margin-bottom: 1rem;
}

.card-pad {
  padding: 1rem;
}

.opd-registration-form .card-pad {
  padding: .85rem;
}

.opd-registration-form .form-label {
  margin-bottom: .25rem;
  font-size: .86rem;
}

.opd-registration-form .form-text,
.opd-registration-form .text-danger {
  font-size: .78rem;
}

.opd-registration-head .page-subtitle,
.opd-registration-head .muted {
  font-size: .86rem;
}

.opd-registration-photo {
  width: 88px;
  height: 88px;
  object-fit: cover;
}

.opd-registration-form .btn-sm {
  min-height: 32px;
}

.opd-registration-form .input-group-sm > .btn {
  min-width: 38px;
}

.service-only-search {
  max-width: 340px;
}

.service-only-list-wrap {
  overflow: hidden;
}

.service-only-list-header {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(130px, 1fr) minmax(180px, 2fr) 76px 110px 58px;
  gap: .5rem;
  align-items: center;
  padding: .45rem .5rem;
  border-bottom: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.service-only-list {
  max-height: 260px;
  overflow: auto;
}

.service-only-item {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(130px, 1fr) minmax(180px, 2fr) 76px 110px 58px;
  align-items: center;
  gap: .5rem;
  min-height: 34px;
  padding: .35rem .5rem;
  border-width: 0 0 1px;
  border-radius: 0;
}

.service-only-item .service-department,
.service-only-item .service-type,
.service-only-item .service-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .82rem;
}

.service-only-item .service-name {
  font-weight: 700;
  color: var(--bs-success);
}

.service-only-item .service-price {
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
}

.service-only-item.active {
  color: var(--bs-body-color);
  border-color: var(--bs-primary);
  background: rgba(13, 110, 253, .08);
}

.service-only-item.active .service-name,
.service-only-item.active .service-price {
  color: var(--bs-success) !important;
}

@media (max-width: 767.98px) {
  .service-only-list-header {
    display: none;
  }

  .service-only-item {
    grid-template-columns: 1fr auto;
  }

  .service-only-item .service-department,
  .service-only-item .service-type,
  .service-only-item .service-name {
    grid-column: 1 / -1;
  }
}

#serviceOnlySelectedBody td,
#serviceOnlySelectedBody .muted {
  color: #000;
}

.section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.opd-setup-list-expanded {
  flex: 0 0 100%;
  max-width: 100%;
  width: 100%;
}

.opd-setup-search {
  min-width: min(100%, 240px);
}

.opd-setup-list-tools .section-title {
  line-height: 1.7;
}

.opd-setup-pagination .btn {
  min-width: 38px;
}

.section-subtitle {
  color: #334155;
  font-size: 0.86rem;
  font-weight: 800;
  margin: 1.25rem 0 0.6rem;
  text-transform: uppercase;
}

.table {
  --bs-table-hover-bg: rgba(15, 118, 110, 0.04);
  color: var(--app-text);
}

.table > :not(caption) > * > * {
  padding: 0.85rem 1rem;
}

.table thead th {
  background: var(--app-surface-muted);
  color: #526179;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.action-table-overflow {
  overflow: visible;
}

.action-table-overflow .dropdown-menu,
.queue-action-menu,
.patient-action-menu {
  z-index: 1080;
}

@media (max-width: 991.98px) {
  .action-table-overflow {
    overflow-x: auto;
    overflow-y: visible;
  }
}

.badge {
  border-radius: 999px;
  font-weight: 700;
  padding: 0.42em 0.7em;
}

.badge-soft {
  align-items: center;
  background: #e0f2fe;
  border-radius: 8px;
  color: #075985;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.22rem 0.55rem;
}

.permission-group {
  background: #ffffff;
  border: 1px solid var(--app-border);
  border-left: 5px solid #2563eb;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  height: 100%;
  padding: 1rem;
}

.permission-group-menu {
  border-left-color: #2563eb;
}

.permission-group-patient {
  background: #f8fafc;
  border-left-color: #0891b2;
}

.permission-group-queue {
  background: #f7fee7;
  border-left-color: #65a30d;
}

.permission-group__head {
  align-items: center;
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
}

.permission-group__head h6 {
  color: var(--app-text);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.permission-group__head p {
  color: var(--app-muted);
  font-size: 0.78rem;
  margin: 0.1rem 0 0;
}

.permission-group__icon {
  align-items: center;
  background: #dbeafe;
  border-radius: 8px;
  color: #1d4ed8;
  display: inline-flex;
  flex: 0 0 36px;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.permission-group-patient .permission-group__icon {
  background: #cffafe;
  color: #0e7490;
}

.permission-group-queue .permission-group__icon {
  background: #d9f99d;
  color: #3f6212;
}

.permission-check {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 8px;
  display: flex;
  font-size: 0.86rem;
  font-weight: 600;
  margin: 0;
  padding: 0.55rem 0.7rem;
}

.permission-check:hover {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.tenant-brand-logo {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  height: 56px;
  object-fit: contain;
  padding: 0.35rem;
  width: 56px;
}

.brand-preview {
  align-items: center;
  background: var(--app-surface-muted);
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  display: flex;
  height: 120px;
  justify-content: center;
  overflow: hidden;
}

.brand-preview img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.brand-empty {
  color: #94a3b8;
  font-size: 2rem;
}

.day-check-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.day-check {
  align-items: center;
  background: var(--app-surface-muted);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  font-weight: 600;
  gap: 0.55rem;
  min-height: 42px;
  padding: 0.55rem 0.7rem;
}

.day-check .form-check-input {
  flex: 0 0 auto;
  margin: 0;
}

.department-check-list {
  display: grid;
  gap: 0.55rem;
}

.department-check {
  align-items: center;
  background: var(--app-surface-muted);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  font-weight: 600;
  gap: 0.6rem;
  min-height: 42px;
  padding: 0.55rem 0.7rem;
}

.department-check--locked {
  cursor: not-allowed;
  opacity: 0.88;
}

.department-check .form-check-input {
  flex: 0 0 auto;
  margin: 0;
}

.form-control,
.form-select,
.input-group-text {
  border-color: #d8e0ea;
  border-radius: 8px;
}

.form-control,
.form-select {
  min-height: 42px;
}

.form-label {
  color: #334155;
  font-weight: 700;
}

.setup-notes {
  color: var(--app-muted);
  display: grid;
  gap: 0.6rem;
  margin: 0.85rem 0 0;
  padding-left: 1.15rem;
}

.sidebar-backdrop {
  display: none;
}

.text-orange {
  color: #fd7e14 !important;
}

.bg-orange {
  background-color: rgba(253, 126, 20, 0.1) !important;
}

.text-indigo {
  color: #6610f2 !important;
}

.bg-indigo {
  background-color: rgba(102, 16, 242, 0.1) !important;
}

.text-teal {
  color: #20c997 !important;
}

.bg-teal {
  background-color: rgba(32, 201, 151, 0.1) !important;
}

.text-purple {
  color: #6f42c1 !important;
}

.bg-purple {
  background-color: rgba(111, 66, 193, 0.1) !important;
}

.auth-page {
  align-items: center;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.22), transparent 300px),
    linear-gradient(135deg, #101827 0%, #172033 48%, #1f4f4a 100%);
  display: flex;
  justify-content: center;
  margin: 0;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(2, 6, 23, 0.32);
  max-width: 430px;
  padding: clamp(1.5rem, 4vw, 2.4rem);
  width: 100%;
}

.auth-icon {
  align-items: center;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  border-radius: 8px;
  color: #fff;
  display: flex;
  font-size: 2rem;
  height: 68px;
  justify-content: center;
  margin: 0 auto 1.35rem;
  width: 68px;
}

.btn-login {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  border: none;
  color: #fff;
  min-height: 46px;
  width: 100%;
}

.btn-login:hover,
.btn-login:focus {
  color: #fff;
  filter: brightness(0.96);
}

.auth-card .input-group-text {
  background: var(--app-surface-muted);
}

.login-loading-overlay {
  align-items: center;
  background: rgba(15, 23, 42, 0.58);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1.5rem;
  position: fixed;
  z-index: 1080;
}

.login-loading-panel {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  max-width: 320px;
  padding: 1.5rem;
  text-align: center;
  width: 100%;
}

.opd-pdf-preview-modal .modal-body {
  min-height: min(78vh, 760px);
}

.opd-pdf-preview-modal iframe {
  height: min(78vh, 760px);
}

#opdPdfPreviewLoader {
  z-index: 2;
}

@media (max-width: 991.98px) {
  .top-navbar .container-fluid {
    min-height: var(--topnav-height);
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 1rem 1rem calc(1rem + var(--footer-height));
  }

  .app-footer {
    left: 0;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .sidebar-backdrop {
    background: rgba(15, 23, 42, 0.48);
    bottom: 0;
    left: 0;
    position: fixed;
    right: 0;
    top: var(--topnav-height);
    z-index: 1025;
  }

  .sidebar-backdrop.show {
    display: block;
  }
}

@media (max-width: 575.98px) {
  .main-content {
    padding: 0.85rem;
  }

  .page-header,
  .page-head,
  .main-content > .d-flex {
    align-items: flex-start !important;
    flex-direction: column;
  }

  .page-header .btn,
  .page-head .btn,
  .main-content > .d-flex .btn {
    width: 100%;
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
