:root {
	--bg: #f4f7fb;
	--bg-soft: #eef4f8;
	--surface: #ffffff;
	--surface-2: #f8fafc;
	--text: #1f2937;
	--text-muted: #6b7280;
	--border: rgba(15, 23, 42, 0.08);
	--shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
	--font-fa: "Vazir", Tahoma, sans-serif;
	--font-en: "Inter", "Segoe UI", Tahoma, sans-serif;
}

body[data-theme="dark"] {
	--bg: #0f172a;
	--bg-soft: #111827;
	--surface: #172033;
	--surface-2: #1e293b;
	--text: #e5eefb;
	--text-muted: #94a3b8;
	--border: rgba(148, 163, 184, 0.18);
	--shadow: 0 14px 40px rgba(2, 6, 23, 0.45);
}

html,
body {
	min-height: 100%;
}

body {
	background: var(--bg);
	color: var(--text);
}

body.rtl {
	font-family: var(--font-fa);
}

body.ltr {
	font-family: var(--font-en);
}

.clinic-nav {
	background: var(--surface);
	backdrop-filter: blur(14px);
}

.login-page {
	background:
		radial-gradient(circle at top left, rgba(16, 185, 129, 0.14), transparent 35%),
		radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.14), transparent 30%),
		var(--bg-soft);
}

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

.navbar-brand {
	letter-spacing: -0.02em;
}

.stat-label {
	font-size: 0.85rem;
	color: var(--text-muted);
	margin-bottom: 0.4rem;
}

.stat-value {
	font-size: 2rem;
	font-weight: 700;
	line-height: 1;
}

.table > :not(caption) > * > * {
	padding: 0.9rem 0.75rem;
	background: transparent;
	color: var(--text);
}

.nav-link.active {
	font-weight: 600;
}

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

.table,
.form-label,
.dropdown-item,
.form-check-label,
dt,
dd,
.navbar-brand,
.nav-link,
.btn,
.alert,
.list-group-item {
	color: var(--text);
}

.form-control,
.form-select {
	background: var(--surface-2);
	border-color: var(--border);
	color: var(--text);
}

.shamsi-date,
.shamsi-month {
	direction: ltr;
	text-align: left;
	font-family: var(--font-en);
}

.form-control:focus,
.form-select:focus {
	background: var(--surface);
	color: var(--text);
	border-color: #22c55e;
	box-shadow: 0 0 0 0.2rem rgba(34, 197, 94, 0.15);
}

.dropdown-menu,
.list-group-item,
.modal-content {
	background: var(--surface);
	border-color: var(--border);
	color: var(--text);
}

.modal-backdrop.show {
	background: rgba(15, 23, 42, 0.36);
	backdrop-filter: blur(7px);
}

.table-responsive {
	border-radius: 0.75rem;
}

.diagnosis-multiselect {
	min-height: 12rem;
}

/* Select2 RTL fix */
[dir="rtl"] .select2-container--bootstrap-5 .select2-selection {
	text-align: right;
}

[dir="rtl"] .select2-container--bootstrap-5 .select2-dropdown {
	direction: rtl;
	text-align: right;
}

[dir="rtl"] .select2-search__field {
	direction: rtl;
}

/* Select2 full width fix */
.select2-container {
	width: 100% !important;
}

.patient-form-section {
	height: 100%;
	padding: 1.1rem;
	border: 1px solid var(--border);
	border-radius: 1rem;
	background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.bulk-create-patient-modal .modal-dialog {
	max-width: 1080px;
}

.bulk-create-patient-modal .modal-content {
	border: 1px solid rgba(148, 163, 184, 0.18);
	border-radius: 1.25rem;
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.98)),
		var(--surface);
	box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22);
}

body[data-theme="dark"] .bulk-create-patient-modal .modal-content {
	background:
		linear-gradient(180deg, rgba(23, 32, 51, 0.96), rgba(30, 41, 59, 0.98)),
		var(--surface);
}

.bulk-create-patient-modal .modal-header,
.bulk-create-patient-modal .modal-footer {
	border-color: var(--border);
	background: transparent;
}

.bulk-create-patient-modal .modal-body {
	background:
		radial-gradient(circle at top right, rgba(34, 197, 94, 0.08), transparent 28%),
		radial-gradient(circle at bottom left, rgba(14, 165, 233, 0.08), transparent 24%);
}

.patient-form-section-head {
	margin-bottom: 1rem;
	padding-bottom: 0.85rem;
	border-bottom: 1px solid var(--border);
}

.patient-notes-field {
	min-height: 9rem;
}

.preferences-diagnosis-actions {
	white-space: nowrap;
}

.bulk-turn-grid .row-item {
	border-bottom: 1px solid var(--border);
	padding-bottom: 0.85rem;
	margin-bottom: 0.85rem;
}

.bulk-turn-grid .row-item:last-child {
	border-bottom: 0;
	margin-bottom: 0;
	padding-bottom: 0;
}

.bulk-turn-counter {
	display: flex;
	align-items: baseline;
	gap: 0.4rem;
	font-size: 0.95rem;
}

.bulk-turn-row {
	border: 1px solid var(--border);
	border-radius: 1rem;
	overflow: hidden;
}

.bulk-turn-row .card-header {
	background: linear-gradient(180deg, rgba(15, 23, 42, 0.03), var(--surface));
	border-bottom: 1px solid var(--border);
}

.bulk-turn-row--collapsed .card-header {
	border-bottom: 0;
}

.bulk-turn-row .card-body {
	background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.bulk-toggle-row {
	min-width: 6.5rem;
}

.bulk-row-summary-title {
	max-width: 28rem;
	word-break: break-word;
}

.bulk-row-errors ul {
	margin-bottom: 0;
}

.turn-form-block,
.turn-summary-block {
	padding: 1.1rem;
	border: 1px solid var(--border);
	border-radius: 1rem;
	background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.turn-financial-strip {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	align-items: center;
}

.turn-financial-item {
	min-width: 10rem;
}

.turn-topup-box {
	display: flex;
	flex-wrap: wrap;
	align-items: end;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem;
	border-radius: 0.9rem;
	border: 1px dashed var(--border);
	background: rgba(15, 23, 42, 0.02);
}

.turn-topup-input {
	width: min(100%, 16rem);
}

.turn-payment-option {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	height: 100%;
	padding: 1rem;
	border: 1px solid var(--border);
	border-radius: 1rem;
	background: var(--surface);
	cursor: pointer;
}

.turn-payment-option--active {
	border-color: rgba(34, 197, 94, 0.5);
	box-shadow: 0 0 0 0.2rem rgba(34, 197, 94, 0.12);
	background: linear-gradient(180deg, rgba(34, 197, 94, 0.08), var(--surface));
}

.turn-payment-option input {
	margin-bottom: 0.35rem;
}

.turn-payment-option__title {
	font-weight: 700;
}

.turn-payment-option__text {
	font-size: 0.88rem;
	color: var(--text-muted);
}

.datepicker-plot-area {
	z-index: 1085 !important;
	width: min(20rem, calc(100vw - 1.5rem));
	max-width: calc(100vw - 1.5rem);
	font-family: var(--font-en);
}

.datepicker-plot-area *,
.datepicker-plot-area .toolbox {
	font-family: var(--font-en);
}

.datepicker-plot-area .datepicker-day-view,
.datepicker-plot-area .datepicker-month-view,
.datepicker-plot-area .datepicker-year-view {
	width: 100%;
}

.wallet-profile-form {
	padding: 1rem;
	border-radius: 0.9rem;
	border: 1px dashed var(--border);
	background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.wallet-profile-stack {
	display: grid;
	gap: 0.9rem;
	margin-bottom: 1rem;
}

.wallet-profile-form__head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.85rem;
}

.wallet-quick-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.financial-report-card {
	border: 1px solid var(--border);
	background: linear-gradient(180deg, rgba(15, 23, 42, 0.02), var(--surface));
}

.financial-report-tabs {
	gap: 0.75rem;
}

.financial-report-tabs .nav-link {
	border-radius: 999px;
	color: var(--text-muted);
	background: var(--surface);
	border: 1px solid var(--border);
}

.financial-report-tabs .nav-link.active {
	color: #0f172a;
	background: rgba(14, 165, 233, 0.14);
	border-color: rgba(14, 165, 233, 0.28);
}

.financial-summary-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.9rem;
}

.financial-summary-card {
	padding: 1rem;
	border-radius: 1rem;
	border: 1px solid var(--border);
	background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.financial-summary-card--danger {
	background: linear-gradient(180deg, rgba(239, 68, 68, 0.08), var(--surface));
}

.financial-summary-card__label {
	display: block;
	margin-bottom: 0.5rem;
	font-size: 0.88rem;
	color: var(--text-muted);
}

.financial-summary-card__value {
	font-size: 1.15rem;
	line-height: 1.2;
}

.daily-register-summary-card {
	border: 1px solid var(--border);
	background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.daily-register-summary-card--info {
	background: linear-gradient(180deg, rgba(59, 130, 246, 0.12), var(--surface));
}

.daily-register-summary-card--success {
	background: linear-gradient(180deg, rgba(34, 197, 94, 0.14), var(--surface));
}

.daily-register-summary-card--danger {
	background: linear-gradient(180deg, rgba(239, 68, 68, 0.14), var(--surface));
}

.daily-register-summary-card--warning {
	background: linear-gradient(180deg, rgba(249, 115, 22, 0.14), var(--surface));
}

.daily-register-summary-card--muted {
	background: linear-gradient(180deg, rgba(100, 116, 139, 0.12), var(--surface));
}

.daily-register-summary-card .stat-value {
	font-size: 1.7rem;
}

.daily-register-filter-bar .btn {
	width: auto;
}

.daily-register-notes {
	max-width: 220px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.financial-tools-head {
	padding-inline: 0.15rem;
}

.financial-timeline-detail {
	max-width: 26rem;
	font-size: 0.92rem;
	color: var(--text-muted);
}

.secondary-log-card {
	border: 1px solid var(--border);
	background: linear-gradient(180deg, rgba(15, 23, 42, 0.015), var(--surface));
}

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

.turn-summary-row {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--border);
}

.turn-summary-row:nth-last-child(-n+2) {
	border-bottom: 0;
	padding-bottom: 0;
}

.dashboard-safe-card {
	border: 1px solid var(--border);
}

.dashboard-safe-card--positive {
	background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), var(--surface));
}

.dashboard-safe-card--neutral {
	background: linear-gradient(180deg, rgba(148, 163, 184, 0.16), var(--surface));
}

.dashboard-safe-card__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	border-radius: 999px;
	background: rgba(15, 23, 42, 0.08);
}

.dashboard-safe-card__icon svg {
	width: 1.35rem;
	height: 1.35rem;
}

.dashboard-safe-card__link {
	font-weight: 600;
	color: var(--text);
	text-decoration: none;
}

.safe-balance-card {
	border: 1px solid var(--border);
	background: linear-gradient(180deg, rgba(15, 23, 42, 0.03), var(--surface));
}

.safe-balance-card--positive {
	background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), var(--surface));
}

.safe-balance-card--negative {
	background: linear-gradient(180deg, rgba(239, 68, 68, 0.14), var(--surface));
}

.safe-balance-value {
	font-size: clamp(2rem, 5vw, 3.25rem);
	font-weight: 700;
	line-height: 1;
}

.safe-summary-card {
	border: 1px solid var(--border);
	background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.safe-summary-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	padding: 0.8rem 0;
	border-bottom: 1px solid var(--border);
}

.safe-summary-row:last-child {
	padding-bottom: 0;
	border-bottom: 0;
}

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

.safe-summary-value {
	font-weight: 600;
}

.safe-summary-value--in {
	color: #15803d;
}

.safe-summary-value--out {
	color: #b91c1c;
}

.safe-table-note {
	max-width: 24rem;
	white-space: normal;
}

.safe-entry-links .btn {
	width: auto;
}

.dt-top-bar,
.dt-bottom-bar {
	width: 100%;
	gap: 0.75rem;
}

.dt-top-bar .dt-buttons {
	display: flex;
	gap: 0.4rem;
	flex-wrap: wrap;
}

.dt-top-bar .dt-buttons:empty {
	display: none;
}

[dir="rtl"] .dt-top-bar {
	flex-direction: row-reverse;
}

[dir="rtl"] .dt-bottom-bar {
	flex-direction: row-reverse;
}

.dataTables_filter label,
.dataTables_length label {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin: 0;
}

.dt-top-bar .dataTables_filter,
.dt-bottom-bar .dataTables_length,
.dt-bottom-bar .dataTables_info,
.dt-bottom-bar .dataTables_paginate {
	margin: 0;
}

.dataTables_filter input {
	width: 200px;
	min-width: 150px;
	border-radius: 0.375rem;
	border: 1px solid #dee2e6;
	padding: 0.375rem 0.75rem;
	margin: 0;
}

.dataTables_length select {
	border-radius: 0.375rem;
	border: 1px solid #dee2e6;
	padding: 0.25rem 0.5rem;
}

[dir="rtl"] .dataTables_filter label,
[dir="rtl"] .dataTables_length label {
	flex-direction: row-reverse;
}

[dir="rtl"] .dt-bottom-bar .ms-auto {
	margin-left: 0 !important;
	margin-right: auto !important;
}

.dataTables_wrapper .dataTables_info {
	padding-top: 0.5rem;
	color: #6c757d;
	font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
	border-radius: 0.375rem !important;
}

.dt-table th.no-export,
.dt-table td.no-export {
	white-space: nowrap;
	min-width: 100px;
}

.dt-table td.col-date,
.dt-table th.col-date {
	white-space: nowrap;
	min-width: 100px;
}

.dt-table td.col-text,
.dt-table th.col-text,
.dt-table .col-text {
	display: block;
	max-width: 200px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.dt-table td.col-text,
.dt-table th.col-text {
	display: table-cell;
}

.safe-note-text {
	max-width: 200px;
}

.header-tools .btn,
.header-tools .dropdown-toggle {
	white-space: nowrap;
}

body.rtl .navbar-nav {
	padding-right: 0;
}

.header-tools {
	flex-wrap: wrap;
}

.btn,
.form-control,
.form-select {
	border-radius: 0.8rem;
}

.alert {
	border-radius: 0.9rem;
	border: 1px solid var(--border);
}

.table td,
.table th {
	vertical-align: middle;
}

.card-body {
	padding: 1.25rem;
}

@media (max-width: 991.98px) {
	.navbar .container {
		align-items: flex-start;
	}

	.financial-summary-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.header-tools {
		padding-top: 0.75rem;
		gap: 0.75rem !important;
	}
}

@media (max-width: 767.98px) {
	main.container {
		padding-top: 1rem !important;
		padding-bottom: 1rem !important;
	}

	.card-body {
		padding: 1rem;
	}

	.patient-form-section {
		padding: 0.9rem;
	}

	.turn-form-block,
	.turn-summary-block {
		padding: 0.9rem;
	}

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

	.turn-topup-box {
		padding: 0.85rem;
	}

	.turn-topup-input {
		width: 100%;
	}

	.turn-summary-grid {
		grid-template-columns: 1fr;
	}

	.turn-summary-row {
		padding-bottom: 0.6rem;
	}

	.d-flex.gap-2,
	.d-flex.gap-3 {
		flex-wrap: wrap;
	}

	.table-responsive {
		border: 1px solid var(--border);
	}

	.btn {
		width: 100%;
	}

	.text-end {
		text-align: start !important;
	}

	td.text-end,
	th.text-end {
		text-align: start !important;
	}

	.row-item .btn {
		width: 100%;
	}

	.bulk-turn-counter {
		justify-content: flex-start;
	}

	.bulk-turn-row .card-header {
		align-items: flex-start !important;
	}

	.preferences-diagnosis-actions .btn {
		width: auto;
	}

	.safe-summary-row {
		align-items: flex-start;
	}

	.dt-top-bar .dataTables_filter,
	.dt-top-bar .dataTables_filter label {
		width: 100%;
	}

	.daily-register-filter-bar .btn {
		width: 100%;
	}

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

	.dt-bottom-bar .ms-auto,
	[dir="rtl"] .dt-bottom-bar .ms-auto {
		margin-left: 0 !important;
		margin-right: 0 !important;
	}
}

@media (max-width: 575.98px) {
	.financial-summary-grid {
		grid-template-columns: 1fr;
	}

	.login-page .card {
		border-radius: 1.1rem;
	}

	.navbar-brand {
		max-width: 210px;
		line-height: 1.35;
	}

	.table > :not(caption) > * > * {
		padding: 0.75rem 0.65rem;
		font-size: 0.94rem;
	}
}

@media print {
	.no-export {
		display: none !important;
	}
}
