/* ==========================================================================
   Artius Dental System — enterprise layout and component metrics
   --------------------------------------------------------------------------
   This is the final, screen-only metrics layer for the legacy Bootstrap 4 UI.
   It centralises spacing, type, control sizes and responsive behaviour while
   leaving tenant colours and the Liquid Glass paint layer intact.
   ========================================================================== */

:root {
    --ds-primary: var(--lg-accent, #1976d2);
    /* Action hover is intentionally darker than the brand colour. The Liquid
       Glass "soft" accent is a surface tint and is not safe behind white text. */
    --ds-primary-hover: #125ea8;
    --ds-primary-rgb: var(--lg-accent-rgb, 25, 118, 210);

    --ds-secondary: #526175;
    --ds-secondary-hover: #3f4d61;
    --ds-success: #238636;
    --ds-success-hover: #196c2b;
    --ds-danger: #c93c37;
    --ds-danger-hover: #a82d2a;
    --ds-warning: #8a4b00;
    --ds-warning-hover: #6f3c00;
    --ds-info: #1976d2;

    --ds-gray-50: #f8fafc;
    --ds-gray-100: #f1f5f9;
    --ds-gray-200: #e2e8f0;
    --ds-gray-300: #cbd5e1;
    --ds-gray-400: #94a3b8;
    --ds-gray-500: #64748b;
    --ds-gray-600: #475569;
    --ds-gray-700: #334155;
    --ds-gray-800: #1e293b;
    --ds-gray-900: #0f172a;

    --ds-bg-page: #f4f7fa;
    --ds-bg-card: #ffffff;
    --ds-bg-surface: var(--ds-bg-card);
    --ds-text-primary: #172033;
    --ds-text-secondary: #526175;
    --ds-text-muted: #5b6b7f;
    --ds-text-inverse: #ffffff;
    --ds-border-color: rgba(23, 43, 77, 0.14);
    --ds-primary-light: rgba(var(--ds-primary-rgb), 0.12);

    --ds-space-1: 4px;
    --ds-space-2: 8px;
    --ds-space-3: 12px;
    --ds-space-4: 16px;
    --ds-space-5: 20px;
    --ds-space-6: 24px;
    --ds-space-8: 32px;
    --ds-space-10: 40px;
    --ds-space-xs: var(--ds-space-1);
    --ds-space-sm: var(--ds-space-2);
    --ds-space-md: var(--ds-space-4);
    --ds-space-lg: var(--ds-space-6);
    --ds-space-xl: var(--ds-space-8);

    --ds-page-gutter: 24px;
    --ds-control-height: 40px;
    --ds-control-height-sm: 32px;
    --ds-control-height-lg: 48px;

    --ds-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --ds-font-size-xs: 11px;
    --ds-font-size-sm: 12px;
    --ds-font-size-md: 14px;
    --ds-font-size-lg: 16px;
    --ds-font-size-xl: 20px;
    --ds-font-size-2xl: 24px;
    --ds-font-weight-normal: 400;
    --ds-font-weight-medium: 500;
    --ds-font-weight-semibold: 600;
    --ds-font-weight-bold: 700;
    --ds-line-height-tight: 1.25;
    --ds-line-height-normal: 1.5;

    --ds-radius-sm: 6px;
    --ds-radius-md: 10px;
    --ds-radius-lg: 16px;
    --ds-border-radius: var(--ds-radius-md);
    --ds-border-radius-lg: var(--ds-radius-lg);
    --ds-shadow-sm: 0 1px 2px rgba(23, 43, 77, 0.06),
        0 4px 12px rgba(23, 43, 77, 0.06);
    --ds-shadow-md: 0 4px 16px rgba(23, 43, 77, 0.10);
    --ds-shadow-lg: 0 12px 36px rgba(23, 43, 77, 0.18);
    --ds-transition: 160ms ease;
}

html[data-theme="dark"] {
    --ds-bg-page: #111827;
    --ds-bg-card: #1f2937;
    --ds-text-primary: #f1f5f9;
    --ds-text-secondary: #cbd5e1;
    --ds-text-muted: #a7b4c6;
    --ds-border-color: rgba(226, 232, 240, 0.16);
    --ds-gray-50: #111827;
    --ds-gray-100: #1f2937;
    --ds-gray-200: #334155;
    --ds-gray-300: #475569;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    color: var(--ds-text-primary);
    font-family: var(--ds-font-family);
    font-size: var(--ds-font-size-md);
    font-weight: var(--ds-font-weight-normal);
    line-height: var(--ds-line-height-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--ds-text-primary);
    font-family: var(--ds-font-family);
    font-weight: var(--ds-font-weight-semibold);
    line-height: var(--ds-line-height-tight);
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 17px !important; }
h5 { font-size: 15px; }
h6 { font-size: 14px; }

p {
    line-height: var(--ds-line-height-normal);
}

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

.card-title {
    margin-bottom: var(--ds-space-4);
    font-size: var(--ds-font-size-lg);
    font-weight: var(--ds-font-weight-semibold);
    line-height: var(--ds-line-height-tight);
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid rgba(var(--ds-primary-rgb), 0.28);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Page shell and section rhythm
   -------------------------------------------------------------------------- */

.page-wrapper {
    min-width: 0;
}

.page-wrapper > .page-titles {
    width: 100%;
    margin: 0 !important;
    padding: var(--ds-space-4) var(--ds-page-gutter);
}

.page-titles {
    align-items: center;
}

.page-titles h3 {
    margin: 0;
    font-size: var(--ds-font-size-xl) !important;
    font-weight: var(--ds-font-weight-semibold);
    line-height: 1.3;
}

.page-titles .breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    margin: 0;
    font-size: var(--ds-font-size-sm);
    line-height: 1.5;
}

.page-titles .breadcrumb-item,
.page-titles .breadcrumb li {
    margin: 0;
}

.page-wrapper > .container-fluid {
    width: 100%;
    padding: var(--ds-page-gutter);
}

/* A few legacy screens place their cards directly under .page-wrapper. */
.page-wrapper > .card {
    margin-right: var(--ds-page-gutter);
    margin-left: var(--ds-page-gutter);
}

.container-fluid,
.card-body,
.modal-body,
.tab-pane,
[class*="col-"] {
    min-width: 0;
}

.card {
    margin-bottom: var(--ds-space-6);
}

.card-body {
    padding: var(--ds-space-5);
}

.card-header {
    padding: var(--ds-space-4) var(--ds-space-5);
}

.card-footer {
    padding: var(--ds-space-3) var(--ds-space-5);
}

.card-body > hr,
.modal-body > hr {
    margin: var(--ds-space-5) 0;
}

.form-group {
    margin-bottom: var(--ds-space-4);
}

.form-group:last-child {
    margin-bottom: 0;
}

.tab-content > .tab-pane:not(.p-0):not(.p-10):not(.p-20) {
    padding-top: var(--ds-space-4);
}

.button-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ds-space-2);
}

.button-group .btn {
    margin: 0 !important;
}

/* Bootstrap 3 compatibility still used throughout the Razor views. */
.col-xs-12 {
    position: relative;
    width: 100%;
    min-height: 1px;
    padding-right: 15px;
    padding-left: 15px;
}

.pull-left { float: left; }
.pull-right { float: right; }

/* --------------------------------------------------------------------------
   Controls and buttons
   -------------------------------------------------------------------------- */

label,
.control-label {
    margin-bottom: 6px;
    color: var(--ds-text-secondary);
    font-size: 13px;
    font-weight: var(--ds-font-weight-semibold);
    line-height: 1.4;
}

.form-control:not(.form-control-sm),
.custom-select,
.custom-file-label,
.input-group-text {
    min-height: var(--ds-control-height);
    padding: 8px 12px;
    font-size: var(--ds-font-size-md);
    line-height: 1.45;
}

/* Periodontal charting is a dense clinical data grid, not a conventional
   form. Keep its 195 one-character cells compact instead of inheriting the
   standard 40/44px control height. */
.form-control.txtChartingSPT {
    height: 28px;
    min-height: 28px;
    padding: 2px;
    font-size: 12px !important;
    line-height: 22px;
}

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

.form-control-file {
    display: block;
    width: 100%;
    min-height: var(--ds-control-height);
    padding: 8px 12px;
    border: 1px solid var(--ds-border-color);
    border-radius: var(--lg-radius-ctrl, var(--ds-radius-md));
    background: var(--ds-bg-card);
    color: var(--ds-text-primary);
    font-size: var(--ds-font-size-md);
    line-height: 1.45;
}

.input-group-text {
    display: flex;
    align-items: center;
}

.btn {
    min-height: var(--ds-control-height);
    padding: 8px 14px;
    font-size: var(--ds-font-size-md);
    font-weight: var(--ds-font-weight-medium);
    line-height: 1.4;
    white-space: normal;
}

.btn-sm,
.btn-group-sm > .btn {
    min-height: var(--ds-control-height-sm);
    padding: 5px 10px;
    font-size: var(--ds-font-size-sm) !important;
}

.btn-lg,
.btn-group-lg > .btn {
    min-height: var(--ds-control-height-lg);
    padding: 11px 18px;
    font-size: 15px !important;
}

.btn-circle {
    min-height: 40px;
    padding: 0;
}

.btn-circle.btn-sm {
    min-height: 35px;
}

.btn-circle.btn-lg {
    min-height: 50px;
}

.btn i,
.btn .mdi,
.btn .fa,
.btn .fas {
    line-height: 1;
}

/* Final AA-safe mapping for the legacy Bootstrap action palette. Earlier
   tenant/theme files still own decorative colour, while solid controls use
   design-system action tokens with readable white labels. */
.btn-primary,
.btn-info,
.btn-primary.disabled,
.btn-info.disabled,
.btn-primary:disabled,
.btn-info:disabled {
    border-color: var(--ds-primary) !important;
    background-color: var(--ds-primary) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-primary:hover:not(:disabled):not(.disabled),
.btn-primary:focus:not(:disabled):not(.disabled),
.btn-info:hover:not(:disabled):not(.disabled),
.btn-info:focus:not(:disabled):not(.disabled) {
    border-color: var(--ds-primary-hover) !important;
    background-color: var(--ds-primary-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-secondary,
.btn-secondary.disabled,
.btn-secondary:disabled {
    border-color: var(--ds-secondary) !important;
    background-color: var(--ds-secondary) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-secondary:hover:not(:disabled):not(.disabled),
.btn-secondary:focus:not(:disabled):not(.disabled) {
    border-color: var(--ds-secondary-hover) !important;
    background-color: var(--ds-secondary-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-success,
.btn-success.disabled,
.btn-success:disabled {
    border-color: var(--ds-success) !important;
    background-color: var(--ds-success) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-success:hover:not(:disabled):not(.disabled),
.btn-success:focus:not(:disabled):not(.disabled) {
    border-color: var(--ds-success-hover) !important;
    background-color: var(--ds-success-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-danger,
.btn-danger.disabled,
.btn-danger:disabled {
    border-color: var(--ds-danger) !important;
    background-color: var(--ds-danger) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-danger:hover:not(:disabled):not(.disabled),
.btn-danger:focus:not(:disabled):not(.disabled) {
    border-color: var(--ds-danger-hover) !important;
    background-color: var(--ds-danger-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-warning,
.btn-warning.disabled,
.btn-warning:disabled {
    border-color: var(--ds-warning) !important;
    background-color: var(--ds-warning) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-warning:hover:not(:disabled):not(.disabled),
.btn-warning:focus:not(:disabled):not(.disabled) {
    border-color: var(--ds-warning-hover) !important;
    background-color: var(--ds-warning-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-outline-primary,
.btn-outline-info {
    border-color: var(--ds-primary) !important;
    color: var(--ds-primary-hover) !important;
}

.btn-outline-secondary {
    border-color: var(--ds-secondary) !important;
    color: var(--ds-secondary) !important;
}

.btn-outline-success {
    border-color: var(--ds-success) !important;
    color: var(--ds-success) !important;
}

.btn-outline-danger {
    border-color: var(--ds-danger) !important;
    color: var(--ds-danger) !important;
}

.btn-outline-warning {
    border-color: var(--ds-warning) !important;
    color: var(--ds-warning) !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-info:hover,
.btn-outline-info:focus {
    border-color: var(--ds-primary-hover) !important;
    background-color: var(--ds-primary-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    border-color: var(--ds-secondary-hover) !important;
    background-color: var(--ds-secondary-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-outline-success:hover,
.btn-outline-success:focus {
    border-color: var(--ds-success-hover) !important;
    background-color: var(--ds-success-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    border-color: var(--ds-danger-hover) !important;
    background-color: var(--ds-danger-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.btn-outline-warning:hover,
.btn-outline-warning:focus {
    border-color: var(--ds-warning-hover) !important;
    background-color: var(--ds-warning-hover) !important;
    color: var(--ds-text-inverse) !important;
}

.text-primary,
.text-info {
    color: var(--ds-primary-hover) !important;
}

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

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

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

.bg-primary,
.bg-info {
    background-color: var(--ds-primary) !important;
    color: var(--ds-text-inverse) !important;
}

.bg-success {
    background-color: var(--ds-success) !important;
    color: var(--ds-text-inverse) !important;
}

.bg-danger {
    background-color: var(--ds-danger) !important;
    color: var(--ds-text-inverse) !important;
}

.bg-warning {
    background-color: var(--ds-warning) !important;
    color: var(--ds-text-inverse) !important;
}

/* .label is widely used as a spacing class on real buttons and controls.
   Restore control geometry without changing intentional status chips. */
.btn.label,
.label.btn {
    display: inline-flex;
    width: auto;
    min-height: var(--ds-control-height);
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: var(--lg-radius-ctrl, var(--ds-radius-md));
    font-size: var(--ds-font-size-md);
    font-weight: var(--ds-font-weight-medium);
    line-height: 1.4;
    letter-spacing: normal;
}

.btn-sm.label,
.label.btn-sm {
    min-height: var(--ds-control-height-sm);
    padding: 5px 10px;
    font-size: var(--ds-font-size-sm);
}

.form-control.label,
.label.form-control {
    display: block;
    width: 100%;
    min-height: var(--ds-control-height);
    padding: 8px 12px;
    border-radius: var(--lg-radius-ctrl, var(--ds-radius-md));
    font-size: var(--ds-font-size-md);
    line-height: 1.45;
    letter-spacing: normal;
}

/* Dismissal is neutral; red remains reserved for destructive actions. */
.modal-footer .btn-danger[data-dismiss="modal"],
.modal-footer button.btn-danger[data-dismiss="modal"] {
    color: #fff !important;
    border-color: var(--ds-gray-500) !important;
    background-color: var(--ds-gray-500) !important;
}

.modal-footer .btn-danger[data-dismiss="modal"]:hover,
.modal-footer button.btn-danger[data-dismiss="modal"]:hover {
    border-color: var(--ds-gray-600) !important;
    background-color: var(--ds-gray-600) !important;
}

.select2-container {
    max-width: 100%;
}

.select2-container--default .select2-selection--single {
    min-height: var(--ds-control-height);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-right: 34px;
    padding-left: 12px;
    font-size: var(--ds-font-size-md);
    line-height: calc(var(--ds-control-height) - 2px);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: calc(var(--ds-control-height) - 2px);
}

.select2-container--default .select2-selection--multiple {
    min-height: var(--ds-control-height);
    padding: 2px 6px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    margin-top: 4px;
    padding: 2px 8px;
    line-height: 22px;
}

.bootstrap-select > .dropdown-toggle {
    min-height: var(--ds-control-height);
}

/* --------------------------------------------------------------------------
   Tables and DataTables
   -------------------------------------------------------------------------- */

.table {
    margin-bottom: var(--ds-space-4);
    font-size: 13px;
}

.table th,
.table td {
    padding: 10px 12px;
    line-height: 1.4;
    vertical-align: middle;
}

.table thead th {
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-semibold);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.table-sm th,
.table-sm td,
.right-sidebar .table th,
.right-sidebar .table td {
    padding: 6px 8px;
}

.table-responsive {
    width: 100%;
    max-width: 100%;
    margin-bottom: var(--ds-space-4);
    border-radius: var(--ds-radius-sm);
    -webkit-overflow-scrolling: touch;
}

.dataTable {
    table-layout: auto;
}

.dataTables_wrapper {
    width: 100%;
    max-width: 100%;
}

.dataTables_length,
.dataTables_filter,
.dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    font-size: var(--ds-font-size-sm) !important;
    line-height: 1.5;
}

.dataTables_length label,
.dataTables_filter label {
    font-size: var(--ds-font-size-sm) !important;
}

.dataTables_length select,
.dataTables_filter input {
    min-height: 36px;
    padding: 6px 10px;
    color: var(--ds-text-primary);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    width: auto;
    min-width: 36px;
    height: 36px;
    margin: 2px;
    padding: 7px 10px;
    font-size: var(--ds-font-size-sm) !important;
    line-height: 20px;
}

/* --------------------------------------------------------------------------
   Navigation and modal system
   -------------------------------------------------------------------------- */

.nav-tabs {
    gap: 2px;
}

.nav-tabs .nav-link {
    min-height: 40px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: var(--ds-font-weight-medium);
    line-height: 20px;
}

.modal-dialog {
    margin-top: 24px;
    margin-bottom: 24px;
}

.modal-content {
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow: hidden;
}

.modal-header {
    flex: 0 0 auto;
    align-items: center;
    padding: 16px 20px;
}

.modal-header .modal-title,
.modal-title {
    font-size: 17px;
    font-weight: var(--ds-font-weight-semibold);
    line-height: 1.35;
}

.modal-header .close {
    display: inline-flex;
    width: 40px;
    min-width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    margin: -8px -8px -8px auto;
    padding: 0;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-footer {
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    padding: 12px 20px;
}

.modal-footer > :not(:first-child),
.modal-footer > :not(:last-child) {
    margin: 0;
}

.modal-footer .button-group {
    justify-content: flex-end;
}

.modal-md {
    max-width: 640px;
}

/* Compact appointment/treatment context strip shared by the two clinical workspaces. */
.appointment-context {
    width: 100%;
    margin: 0;
}

.appointment-context td {
    padding: 4px 20px 4px 0;
    vertical-align: top;
}

.appointment-context td:last-child {
    padding-right: 0;
}

.invoice[style*="20%"],
.prescription[style*="20%"],
.medical-certiciate[style*="20%"],
.container-fluid[style*="20%"] {
    width: 100%;
    max-width: 1200px;
    margin-right: auto;
    margin-left: auto;
    padding: var(--ds-page-gutter) !important;
}

.invoice-actions {
    width: auto;
    margin: 0;
}

.invoice-actions tr {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--ds-space-2);
}

.invoice-actions td {
    display: block;
    padding: 0;
}

#formPaymentOption > .row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-right: 0;
    margin-left: 0;
}

#formPaymentOption .non-redemption {
    width: 100%;
    max-width: none;
    padding-right: 0;
    padding-left: 0;
}

#formPaymentOption .paymentMethod {
    width: 100%;
    max-width: 180px;
    height: auto;
    border-radius: var(--ds-radius-sm);
}

#formPaymentOption .paymentMethod:focus-visible {
    outline: 3px solid rgba(var(--ds-primary-rgb), 0.30);
    outline-offset: 2px;
}

/* Standalone status pages (for example, access denied) do not render the app shell. */
.standalone-state {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    padding: var(--ds-space-6);
    background: var(--ds-bg-page);
}

.standalone-state__card {
    width: 100%;
    max-width: 520px;
    padding: var(--ds-space-8);
    border: 1px solid var(--ds-border-color);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-bg-card);
    box-shadow: var(--ds-shadow-md);
    text-align: center;
}

.standalone-state__icon {
    display: inline-flex;
    width: 56px;
    height: 56px;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--ds-space-4);
    border-radius: 50%;
    background: rgba(var(--ds-primary-rgb), 0.12);
    color: var(--ds-primary);
    font-size: 24px;
}

.standalone-state__title {
    margin: 0 0 var(--ds-space-2);
    font-size: var(--ds-font-size-2xl);
}

.standalone-state__copy {
    margin: 0 auto var(--ds-space-5);
    color: var(--ds-text-secondary);
    line-height: var(--ds-line-height-normal);
}

.standalone-state__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--ds-space-2);
}

.enterprise-empty {
    padding: var(--ds-space-8) var(--ds-space-5);
    color: var(--ds-text-secondary);
    text-align: center;
}

/* Clinical visualisations preserve their working dimensions inside a
   dedicated pan surface at every viewport width. */
#odontogram,
#periodontalChart,
#contenido {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   Base design-system components used by newer pages
   -------------------------------------------------------------------------- */

.ds-page-header {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-4);
    margin: var(--ds-space-6) var(--ds-page-gutter) 0;
    padding: 0;
}

.ds-page-header-title {
    color: var(--ds-text-primary);
    font-size: var(--ds-font-size-xl);
    font-weight: var(--ds-font-weight-semibold);
    line-height: 1.3;
}

.ds-page-header-subtitle {
    max-width: 760px;
    margin-top: var(--ds-space-1);
    color: var(--ds-text-secondary);
    font-size: 13px;
    line-height: var(--ds-line-height-normal);
}

.ds-page-header-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--ds-space-2);
}

.ds-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--ds-space-4);
    color: var(--ds-text-muted);
    font-size: var(--ds-font-size-sm);
}

.ds-breadcrumb .separator {
    color: var(--ds-gray-400);
}

.ds-card {
    margin-bottom: var(--ds-space-6);
    overflow: hidden;
    border: 1px solid var(--ds-border-color);
    border-radius: var(--lg-radius-card, var(--ds-radius-lg));
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--ds-shadow-sm);
}

html[data-theme="dark"] .ds-card {
    background: var(--ds-bg-card);
}

.ds-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    padding: var(--ds-space-4) var(--ds-space-5);
    border-bottom: 1px solid var(--ds-border-color);
}

.ds-card-body {
    padding: var(--ds-space-5);
}

.ds-card-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--ds-space-2);
    padding: var(--ds-space-3) var(--ds-space-5);
    border-top: 1px solid var(--ds-border-color);
}

.ds-btn {
    display: inline-flex;
    min-height: var(--ds-control-height);
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--lg-radius-ctrl, var(--ds-radius-md));
    background: transparent;
    color: var(--ds-text-primary);
    font-size: var(--ds-font-size-md);
    font-weight: var(--ds-font-weight-medium);
    line-height: 1.4;
    cursor: pointer;
    transition: background-color var(--ds-transition),
        border-color var(--ds-transition), box-shadow var(--ds-transition);
}

.ds-btn:hover {
    text-decoration: none;
}

.ds-btn-primary {
    border-color: var(--ds-primary);
    background: var(--ds-primary);
    color: #fff;
}

.ds-btn-primary:hover,
.ds-btn-primary:focus {
    border-color: var(--ds-primary-hover);
    background: var(--ds-primary-hover);
    color: #fff;
}

.ds-btn-outline {
    border-color: var(--ds-gray-300);
    background: rgba(255, 255, 255, 0.72);
    color: var(--ds-text-secondary);
}

.ds-btn-outline:hover,
.ds-btn-outline:focus {
    border-color: var(--ds-primary);
    color: var(--ds-primary);
}

.ds-form-group {
    margin-bottom: var(--ds-space-4);
}

.ds-form-label {
    display: block;
    margin-bottom: 6px;
    color: var(--ds-text-secondary);
    font-size: 13px;
    font-weight: var(--ds-font-weight-semibold);
}

.ds-form-control {
    display: block;
    width: 100%;
    min-height: var(--ds-control-height);
    padding: 8px 12px;
    border: 1px solid var(--ds-border-color);
    border-radius: var(--ds-radius-md);
    background: var(--ds-bg-card);
    color: var(--ds-text-primary);
    font-size: var(--ds-font-size-md);
    line-height: 1.45;
}

.ds-form-control:focus {
    border-color: var(--ds-primary);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(var(--ds-primary-rgb), 0.18);
}

.ds-badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: var(--ds-font-size-xs);
    font-weight: var(--ds-font-weight-semibold);
    line-height: 1.25;
    white-space: nowrap;
}

.ds-badge-success {
    background: #dcfce7;
    color: #166534;
}

.ds-badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.ds-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.ds-badge-neutral {
    background: var(--ds-gray-100);
    color: var(--ds-gray-600);
}

.ds-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--ds-border-color);
}

.ds-table {
    margin-bottom: 0;
}

.ds-text-right { text-align: right !important; }
.ds-col-center { text-align: center !important; }
.ds-mb-md { margin-bottom: var(--ds-space-4) !important; }
.ds-mb-lg { margin-bottom: var(--ds-space-6) !important; }

/* --------------------------------------------------------------------------
   Responsive hardening
   -------------------------------------------------------------------------- */

@media (max-width: 991.98px) {
    :root {
        --ds-page-gutter: 20px;
    }

    .invoice[style*="20%"],
    .prescription[style*="20%"],
    .medical-certiciate[style*="20%"],
    .container-fluid[style*="20%"] {
        padding-right: var(--ds-page-gutter) !important;
        padding-left: var(--ds-page-gutter) !important;
    }

    .fc .fc-toolbar {
        flex-wrap: wrap;
        gap: var(--ds-space-2);
    }

    .fc .fc-toolbar-chunk {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .datepicker-inline {
        width: 100% !important;
        font-size: 13px !important;
    }

    .datepicker-inline table {
        width: 100%;
    }

    .datepicker td,
    .datepicker th {
        min-width: 32px;
        height: 32px;
        padding: 5px 4px !important;
        font-size: 13px;
        line-height: 1.2;
    }
}

@media (max-width: 767.98px) {
    :root {
        --ds-page-gutter: 16px;
        --ds-control-height: 44px;
        --ds-control-height-sm: 40px;
    }

    .form-control:not(.form-control-sm),
    .custom-select,
    .ds-form-control,
    .select2-container--default .select2-selection--single .select2-selection__rendered,
    .select2-container--default .select2-search__field {
        font-size: 16px !important;
    }

    .form-control.txtChartingSPT {
        font-size: 16px !important;
    }

    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .page-wrapper {
        margin-left: 0 !important;
        padding-top: 60px;
    }

    .footer {
        left: 0 !important;
    }

    .left-sidebar,
    .sidebar-footer {
        position: fixed !important;
        left: -240px !important;
        transition: left 160ms ease;
    }

    body.show-sidebar .left-sidebar,
    body.show-sidebar .sidebar-footer {
        left: 0 !important;
    }

    .btn-circle.btn-sm {
        width: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .page-wrapper > .page-titles {
        gap: var(--ds-space-2);
        padding-top: var(--ds-space-3);
        padding-bottom: var(--ds-space-3);
    }

    .page-titles > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .page-titles .breadcrumb {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .page-titles .text-right {
        text-align: left !important;
    }

    .page-titles[style*="position: fixed"],
    .page-titles[style*="position:fixed"] {
        position: static !important;
        top: auto !important;
        width: auto !important;
    }

    .page-titles[style*="position: fixed"] + .container-fluid[style*="margin-top"],
    .page-titles[style*="position:fixed"] + .container-fluid[style*="margin-top"] {
        margin-top: 0 !important;
    }

    .ds-page-header {
        align-items: flex-start;
        flex-direction: column;
        margin-top: var(--ds-space-4);
    }

    .ds-page-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .card-body,
    .ds-card-body,
    .modal-body {
        padding: var(--ds-space-4);
    }

    .card-header,
    .ds-card-header {
        padding: var(--ds-space-3) var(--ds-space-4);
    }

    .card-footer,
    .ds-card-footer,
    .modal-footer {
        padding: var(--ds-space-3) var(--ds-space-4);
    }

    .card-body > .col-4.pull-right,
    .card-body > .card-body.col-4.pull-right {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        float: none;
    }

    .form-group.row > label,
    .modal-body .form-group.row > label,
    .form-group.row > .control-label {
        margin-bottom: 6px;
        text-align: left !important;
    }

    .button-group.pull-right,
    .btn-group.pull-right {
        float: none;
    }

    .button-group {
        max-width: 100%;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    /* The legacy hidden-xs utility otherwise leaves many tabs completely blank. */
    .nav-tabs .hidden-xs-down {
        display: inline !important;
    }

    .nav-tabs .nav-link {
        min-height: 44px;
        padding: 11px 13px;
    }

    .tab-content > .tab-pane.p-20 {
        padding: var(--ds-space-4) !important;
    }

    .appointment-context,
    .appointment-context tbody {
        display: block;
        width: 100%;
        max-width: 100%;
    }

    .appointment-context {
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    .appointment-context tr {
        display: flex;
        width: max-content;
        min-width: 100%;
        align-items: stretch;
    }

    .appointment-context td {
        display: block;
        min-width: 148px;
        max-width: 220px;
        flex: 0 0 auto;
        padding: 8px 12px !important;
        border-right: 1px solid var(--ds-border-color);
        overflow-wrap: anywhere;
    }

    .appointment-context td:last-child {
        border-right: 0;
    }

    .invoice-actions {
        width: 100%;
        float: none;
    }

    .invoice-actions tr {
        width: 100%;
        justify-content: flex-start;
    }

    .invoice-actions td {
        flex: 1 1 calc(50% - var(--ds-space-2));
    }

    .invoice-actions .btn {
        width: 100%;
    }

    #formPaymentOption > .row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #formPaymentOption .paymentMethod {
        max-width: none;
    }

    .table-responsive,
    .dataTables_wrapper,
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }

    .dataTables_wrapper table.dataTable.nowrap,
    .dataTables_wrapper table.display.nowrap {
        min-width: 620px;
    }

    .card-body > table.table,
    .modal-body > table.table,
    .modal-body > form > table.table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-dialog,
    .modal-dialog.modal-sm,
    .modal-dialog.modal-md,
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl,
    .modal-dialog.modal-xxl,
    .modal-dialog[style*="width"],
    .modal-dialog[style*="max-width"] {
        width: auto !important;
        max-width: calc(100vw - 16px) !important;
        margin: 8px auto !important;
    }

    .modal-content {
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
    }

    .modal-body {
        overflow-x: auto;
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-header .modal-title,
    .modal-title {
        overflow-wrap: anywhere;
        font-size: var(--ds-font-size-lg);
    }

    .modal-footer .button-group {
        width: 100%;
    }

    .modal-footer {
        padding-bottom: max(var(--ds-space-3), env(safe-area-inset-bottom));
    }

    .modal-footer .button-group > .btn,
    .modal-footer > .btn {
        flex: 1 1 auto;
    }

    .right-sidebar,
    .right-sidebar.rside-book {
        top: 60px !important;
        right: auto !important;
        left: -340px !important;
        width: calc(100vw - 32px) !important;
        max-width: 320px;
        height: calc(100vh - 60px) !important;
        height: calc(100dvh - 60px) !important;
        z-index: 1035 !important;
    }

    .right-sidebar.shw-rside,
    .right-sidebar.rside-book.shw-rside {
        right: auto !important;
        left: 0 !important;
        width: calc(100vw - 32px) !important;
        max-width: 320px;
    }

    .right-sidebar.rside-book .rside-book-tab {
        right: -32px;
        width: 32px;
        height: 48px;
    }

    .right-sidebar .r-panel-body {
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }

    .topbar .top-navbar {
        padding-right: 8px;
    }

    .topbar .top-navbar .navbar-nav > .nav-item > .nav-link {
        display: flex;
        min-width: 44px;
        min-height: 50px;
        align-items: center;
        justify-content: center;
        padding-right: 8px;
        padding-left: 8px;
    }

    .topbar .dropdown-menu,
    body .dropdown-menu {
        max-width: calc(100vw - 16px);
    }

    .sweet-alert {
        position: fixed !important;
        top: 50% !important;
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
        max-width: 480px;
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
        margin: 0 auto !important;
        padding: 20px 16px !important;
        overflow-y: auto;
        transform: translateY(-50%);
    }

    .sweet-alert h2 {
        font-size: 20px;
        line-height: 1.35;
    }

    .sweet-alert button {
        min-height: 44px;
    }

    .datepicker-inline {
        width: 100% !important;
        font-size: 14px !important;
    }

    .datepicker-inline table {
        width: 100%;
    }

    .datepicker td,
    .datepicker th {
        height: 36px;
        padding: 6px 4px !important;
        font-size: 13px;
        line-height: 1.2;
    }

    .fc .fc-toolbar {
        align-items: flex-start;
    }

    .fc .fc-toolbar-title {
        font-size: 16px !important;
        line-height: 1.35;
        white-space: normal;
    }

    .fc-header-toolbar .fc-button,
    .fc .fc-button {
        min-height: 40px;
        padding: 8px 10px !important;
        font-size: 13px !important;
    }

    .fc .fc-col-header-cell-cushion,
    .fc .fc-daygrid-day-number {
        padding: 6px 4px;
        font-size: 12px !important;
        line-height: 1.25;
    }

    .select2-dropdown,
    .datepicker-dropdown,
    .bootstrap-datetimepicker-widget,
    .daterangepicker,
    .context-menu-list,
    .popover {
        max-width: calc(100vw - 16px) !important;
    }

    .daterangepicker {
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
        overflow-y: auto;
    }

    .note-editor .note-toolbar {
        display: flex;
        flex-wrap: wrap;
    }

    .note-editor .note-toolbar .note-btn-group {
        margin-bottom: 4px;
    }

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

    /* Preserve intrinsic clinical drawing dimensions so the containers above
       can pan horizontally instead of scaling or distorting their canvases. */
    #odontogram canvas,
    #odontogram svg,
    #periodontalChart canvas,
    #periodontalChart svg,
    #contenido canvas,
    #contenido svg {
        max-width: none;
    }

    #artius-notif-panel {
        top: 58px !important;
        right: 8px !important;
        bottom: 8px !important;
        left: 8px !important;
        width: auto !important;
        max-width: none !important;
        max-height: none !important;
    }

    #artius-notif-list {
        max-height: none !important;
    }

    #artius-notif-mark-all,
    #artius-notif-panel button {
        min-width: 44px;
        min-height: 44px;
    }

    .pk-prompt-card {
        right: 12px !important;
        bottom: max(12px, env(safe-area-inset-bottom)) !important;
        left: 12px !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100dvh - 24px);
        padding: 16px !important;
        overflow-y: auto;
    }

    .pk-prompt-btn,
    .pk-prompt-x {
        min-height: 44px !important;
    }

    .pk-prompt-x {
        min-width: 44px !important;
        margin: -8px -8px 0 0 !important;
    }

    .doctor-block-float {
        top: auto !important;
        right: 8px !important;
        bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px)) !important;
        left: 8px !important;
        width: auto !important;
        max-width: none !important;
        max-height: 46vh !important;
        max-height: 46dvh !important;
        font-size: 13px !important;
        transform: none !important;
    }

    .doctor-block-float .dbf-header {
        min-height: 44px;
        padding: 8px 12px !important;
        cursor: default;
    }

    .doctor-block-float .dbf-collapse {
        display: inline-flex;
        min-width: 36px;
        min-height: 36px;
        align-items: center;
        justify-content: center;
        font-size: 20px !important;
    }

    .perio-note-float {
        top: auto !important;
        right: 8px !important;
        bottom: max(136px, calc(env(safe-area-inset-bottom) + 120px)) !important;
        left: 8px !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        height: min(55vh, 480px) !important;
        height: min(55dvh, 480px) !important;
        max-height: 55vh !important;
        max-height: 55dvh !important;
        z-index: 1038 !important;
        transform: none !important;
    }

    .perio-note-float.collapsed {
        right: 8px !important;
        left: auto !important;
        width: min(320px, calc(100vw - 16px)) !important;
        height: auto !important;
        min-height: 0 !important;
    }

    .perio-note-head {
        min-height: 44px;
        padding: 6px 8px 6px 12px !important;
        cursor: default !important;
    }

    .perio-note-btn {
        display: inline-flex;
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        padding: 0 8px !important;
    }

    .perio-note-resize {
        display: none !important;
    }

    .chat-float-panel,
    .chat-window {
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: none !important;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        border-radius: 0 !important;
    }

    .chat-float-actions a,
    .chat-float-actions button,
    .chat-back,
    .chat-attach-btn,
    .chat-send-btn {
        display: inline-flex;
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
    }

    #cbctProgressCard {
        right: 8px !important;
        bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px)) !important;
        left: 8px !important;
        width: auto !important;
        max-width: none !important;
    }

    #cbctPCancel {
        min-width: 44px;
        min-height: 44px;
    }

    .ia-overlay,
    .fp-overlay,
    .cbct-overlay {
        padding-top: env(safe-area-inset-top);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
    }

    .ia-tool,
    .ia-op,
    .ia-color,
    .ia-width,
    .ia-btn,
    .fp-btn,
    .cbct-tab,
    .cbct-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .fp-panel {
        width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0 !important;
    }

    .cbct-bar {
        gap: 8px;
        padding: 8px;
    }

    .cbct-name {
        width: 100%;
        max-width: none !important;
    }

    .cbct-actions {
        width: 100%;
        margin-left: 0;
        overflow-x: auto;
    }

    .jq-toast-wrap {
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
        max-width: none !important;
    }

    .context-menu-list {
        max-height: calc(100dvh - 16px);
        overflow-y: auto;
    }

    .context-menu-item {
        min-height: 40px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
}

@media (max-width: 575.98px) {
    .col-xs-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .page-titles h3,
    .ds-page-header-title {
        font-size: 18px !important;
    }

    .dataTables_length,
    .dataTables_filter,
    .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        width: 100%;
        margin-top: var(--ds-space-2);
        text-align: left !important;
    }

    .dataTables_filter label,
    .dataTables_filter input {
        width: 100%;
        margin-left: 0 !important;
    }

    .dataTables_wrapper .dataTables_paginate {
        text-align: center !important;
        white-space: normal;
    }

    .login-register {
        position: fixed;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 24px 16px;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .login-box {
        width: 100%;
        max-width: 400px;
    }

    .login-box .card-body {
        padding: 20px 16px;
    }

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

    .standalone-state {
        padding: 16px;
    }

    .standalone-state__card {
        padding: 24px 18px;
    }

    .standalone-state__actions > .btn,
    .standalone-state__actions > .ds-btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
