@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-VariableFont_opsz,wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Italic-VariableFont_opsz,wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #ffffff;
    color: #111827;
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    justify-content: center;
}

a {
    color: inherit;
    text-decoration: none;
}

select {
    appearance: none;
    background-color: #fff;
    background-image: none; /* arrow is a real DOM .select-arrow span injected by JS */
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 32px 8px 12px; /* right padding keeps room for the icon */
    font-size: 16px;
    color: #374151;
    cursor: pointer;
    min-width: 80px;
}

select:hover {
    border-color: #d1d5db;
    background-color: #f9fafb;
}

select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.select-wrapper {
    position: relative;
    display: inline-block;
}

.select-wrapper:has(select.input),
.field .select-wrapper,
.popover-field .select-wrapper {
    display: block;
}

.select-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #6b7280;
    width: 20px !important;
    height: 20px !important;
    transition: transform 0.2s ease;
}

select.select-open ~ .select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

input .material-symbols-rounded {
    font-size: 22px;
    color: #6b7280;
}

.hidden {
    display: none !important;
}

select[data-csd-initialized] {
    display: none;
}

.popover {
    position: absolute;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 8px;
    z-index: 1000;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.97);
    transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

.popover.active {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
}

.popover-tile {
    font-size: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 10px;
}

.popover-tile:hover {
    background: #f3f4f6;
}

.popover-tile .material-symbols-rounded {
    width: 20px;
    height: 20px;
    color: #6b7280;
}

.popover-tile.logout .material-symbols-rounded {
    color: #ef4444;
}

.popover-field {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.popover-field label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
}

.popover-field select {
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background-color: #fff;
    outline: none;
    cursor: pointer;
}

.popover-field select:focus {
    border-color: #0066FF;
}

.panel {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.material-symbols-rounded {
    width: 26px;
    height: 26px;
    display: inline-block;
    vertical-align: middle;
    fill: currentColor;
    flex-shrink: 0;
}

.search-wrapper {
    position: relative;
    width: 100%;
}

.search {
    width: 100%;
    padding: 8px 40px 8px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    background: #fafafa;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    letter-spacing: .35px;
}

.search:focus {
    border-color: #0066FF;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
    background: #fff;
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: color 0.15s, background-color 0.15s;
    border-radius: 6px;
    z-index: 10;
}

.search-clear[hidden] {
    display: none;
}

.search-clear:hover {
    color: #111827;
    background: rgba(0, 0, 0, 0.05);
}

.search-clear .material-symbols-rounded {
    width: 20px;
    height: 20px;
}

.search:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.8;
    transform: none;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 14px;
    min-height: 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: #f3f4f6;
    transform: translateY(-1px);
}

.btn-icon.btn-danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

.btn-icon .material-symbols-rounded {
    width: 20px;
    height: 20px;
}

.table-wrap .btn-icon .material-symbols-rounded {
    width: 18px;
    height: 18px;
}

.table-wrap {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 232px)
}

.table-container {
    overflow-y: auto;
    overflow-x: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    container-type: inline-size;
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: #c1c7cd #fff;
    container-type: inline-size;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.table-container table th:last-child,
.table-container table td:last-child {
    width: 1%;
    white-space: nowrap;
}

.table-container thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 2;
    white-space: nowrap;
}

.table-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: #fff;
}

.table-container::-webkit-scrollbar-thumb {
    background: #c1c7cd;
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #9aa0a6;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table .btn,
table .btn-ghost,
table .btn-primary,
table .btn-secondary,
table .btn-danger,
table .btn-warning,
table .btn-icon {
    border-radius: 8px;
    padding: 8px;
    font-size: 14px;
    width: 24px;
    height: 24px;
    min-width: 14px;
    min-height: 14px;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    background-color: transparent;
    border: 1px solid transparent;
}

table .btn:hover,
table .btn-ghost:hover,
table .btn-primary:hover,
table .btn-secondary:hover,
table .btn-danger:hover,
table .btn-warning:hover,
table .btn-icon:hover {
    transform: translateY(-1px);
}

table .material-symbols-rounded {
    width: 18px;
    height: 18px;
}

thead {
    background: #f8fafc;
    color: #4b5563;
    position: sticky;
    top: 0;
    z-index: 2;
}

thead th {
    padding: 10px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid #e5e7eb;
}

tbody tr {
    border-bottom: 1px solid #f1f5f9;
    height: 45px;
    max-height: 45px;
}

tbody tr:hover {
    background: #f9fafb;
}

tbody td {
    padding: 10px 12px;
    color: #111827;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field label,
.parsed-data-title {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

.field-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: -4px;
}

.input {
    width: 100%;
    height: 38px;
    max-height: 38px;
    padding: 8px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    background-color: #fafafa;
    font-size: 16px;
    letter-spacing: 0.75px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    color: #374151;
}

/* Restore right padding so the SVG arrow (background-image) is never clipped */
select.input {
    padding-right: 32px;
}

.input:focus {
    border-color: #0066FF;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
    background-color: #fff;
}

.input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.8;
}

.input .material-symbols-rounded {
    width: 22px;
    height: 22px;
    color: #6b7280;
}

.input-with-suffix {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    max-height: 38px;
}

.input-with-suffix .input {
    border: none;
    border-radius: 8px 0 0 8px;
    flex: 1;
    max-height: 36px;
}

.input-with-suffix .input:focus {
    border: none;
    box-shadow: none;
}

.input-with-suffix:focus-within {
    border-color: #0066FF;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.input-suffix {
    padding: 10px;
    background: #f1f5f9;
    border-radius: 0 7px 7px 0;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    flex-shrink: 0;
}

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 6px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 2000;
}

.modal {
    width: min(720px, 100%);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 32px);
    position: relative;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

.close-btn {
    border: none;
    background: #f8fafc;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s;
    border: 1px solid #e5e7eb;
    font-size: 26px;
    position: relative;
    z-index: 11;
}

.close-btn:hover {
    background: #e5e7eb;
}

.close-btn .material-symbols-rounded {
    width: 26px;
    height: 26px;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal.settings-modal {
    width: min(960px, 100%);
    max-height: calc(100vh - 32px);
}

/* Small / confirm modal helpers */
.modal-sm {
    max-width: 480px;
    margin: 0 12px;
}

.modal-confirm-overlay {
    z-index: 3000;
}

.confirm-message {
    color: #374151;
    line-height: 1.6;
    font-size: 14px;
    margin: 0;
}

.modal.settings-modal .modal-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 20px;
}

.modal.settings-modal .settings-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 16px;
    overflow: hidden;
}

.modal.settings-modal .form-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.modal.settings-modal .form-actions {
    flex-shrink: 0;
}

.error-container {
    padding: 20px;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1.5px solid #fca5a5;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.error-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 4px;
}

.error-title {
    font-size: 20px;
    font-weight: 700;
    color: #991b1b;
    margin: 0;
}

.error-message {
    font-size: 14px;
    color: #7f1d1d;
    line-height: 1.5;
    margin: 0;
}

.error-details {
    margin-top: 8px;
}

.error-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: #991b1b;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    transition: background-color 0.15s;
}

.error-details summary:hover {
    background: #fef2f2;
}

.error-details pre {
    margin-top: 10px;
    padding: 12px;
    background: #fff;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 11px;
    font-family: 'Consolas', 'Monaco', monospace;
    max-height: 300px;
    color: #7f1d1d;
    line-height: 1.5;
}

.error-footer-text {
    font-size: 13px;
    color: #991b1b;
    margin: 0;
}

body.modal-open {
    overflow: hidden;
}

body.modal-open .hamburger-btn,
body.modal-open .mobile-scanner-btn,
body.modal-open .mobile-menu {
    display: none !important;
}



.label-with-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.label-with-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

.label-with-checkbox span {
    line-height: 1.2;
}

.rights-hidden {
    display: none !important;
}

.rights-disabled {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}

.dropzone-wrapper {
    position: relative;
}

.dropzone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 14px;
    display: grid;
    place-items: center;
    gap: 6px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.dropzone.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f9fafb;
    border-color: #e5e7eb;
    pointer-events: none;
}

.dropzone.disabled .dropzone-icon {
    color: #9ca3af;
}

.dropzone.disabled .dropzone-text {
    color: #9ca3af;
}

.dropzone.dragging {
    border-color: #2563eb;
    background: #eff6ff;
}

.dropzone input[type="file"] {
    display: none;
}

.dropzone-icon {
    color: #2563eb;
}

.dropzone-icon .material-symbols-rounded {
    width: 32px;
    height: 32px;
}

.dropzone-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropzone-hint {
    color: #9ca3af;
    font-size: 12px;
    font-weight: 400;
}


.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, background-color 0.15s, filter 0.15s, opacity 0.15s, color 0.15s, border-color 0.15s, width 0.15s, min-width 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    max-height: 40px;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #0066FF 0%, #00D4AA 100%);
}

.btn-primary:disabled {
    filter: grayscale(0.5) opacity(0.6);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary:hover {
    box-shadow: 0 8px 18px rgba(0, 102, 255, 0.25);
}

.btn-primary.loading:disabled {
    filter: none;
    opacity: 1;
    cursor: wait;
}

.btn-ghost {
    color: #111827;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.btn-ghost:hover {
    background: #f1f5f9;
}

.btn-ghost-premium {
    padding: 9px 13px;
    color: #111827;
    background: #f8fafc;
    border: 2px solid transparent;
    background-image: linear-gradient(#f8fafc, #f8fafc), linear-gradient(135deg, #0066FF 0%, #00D4AA 100%);
    background-origin: border-box;
    background-clip: padding-box, border-box;
}

.btn-ghost-premium:hover {
    padding: 9px 13px;
    color: #111827;
    background: #f8fafc;
    border: 2px solid transparent;
    background-image: linear-gradient(#f8fafc, #f8fafc), linear-gradient(135deg, #0066FF 0%, #00D4AA 100%);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    box-shadow: 0 8px 18px rgba(0, 102, 255, 0.25);
}

.btn-secondary {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    color: #111827;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-danger {
    color: #dc2626;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.btn-danger:hover {
    background: #fee2e2;
}

.btn-warning {
    color: #d97706;
}

.btn-warning:hover {
    background: rgba(180, 83, 9, 0.1)
}

.btn-add {
    color: #009678;
}

.btn-add:hover {
    background: rgba(0, 212, 170, 0.2);
}

.btn-info {
    color: #374151;
}

.btn-info:hover {
    color: #0284c7;
    background: #bae6fd;
}

.btnSpinner {
    animation: spin 1s linear infinite;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.15s ease, opacity 0.15s ease, margin-right 0.15s ease;
}

/* Hidden state: collapse width to 0 and pull in the flex gap so the button
   shows no extra space. The negative margin-right cancels the button's gap: 8px. */
.btn-spinner-hidden {
    width: 0;
    opacity: 0;
    pointer-events: none;
    margin-right: -8px;
}

.btn-ghost:disabled,
.btn-ghost:disabled:hover,
.btn-info:disabled,
.btn-info:disabled:hover,
.btn-danger:disabled,
.btn-danger:disabled:hover,
.btn-warning:disabled,
.btn-warning:disabled:hover {
    background: #f3f4f6;
    color: #9ca3af;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.8;
    transform: none;
}

/* ── Custom multi-select ─────────────────── */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-align: left;
    cursor: pointer;
    background-color: #f9fafb;
    font-size: 16px;
    color: #374151;
}

.dropdown-toggle:hover {
    border-color: #9ca3af;
}

.dropdown-toggle:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dropdown-toggle:disabled,
.custom-dropdown.disabled .dropdown-toggle {
    background: #f3f4f6;
    color: #9ca3af;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.8;
    transform: none;
}

.dropdown-arrow {
    font-size: 10px;
    color: #6b7280;
    transition: transform 0.2s;
}

.dropdown-toggle .material-symbols-rounded {
    display: inline-block;
    transition: transform 0.2s ease;
}

.dropdown-toggle.active .dropdown-arrow,
.dropdown-toggle.active .material-symbols-rounded {
    transform: rotate(180deg);
}

@keyframes dropdown-open {
    from { opacity: 0; transform: scaleY(0.96) translateY(-6px); }
    to   { opacity: 1; transform: scaleY(1)    translateY(0); }
}

@keyframes dropdown-close {
    from { opacity: 1; transform: scaleY(1)    translateY(0); }
    to   { opacity: 0; transform: scaleY(0.96) translateY(-6px); }
}

@keyframes dropdown-open-above {
    from { opacity: 0; transform: scaleY(0.96) translateY(6px); }
    to   { opacity: 1; transform: scaleY(1)    translateY(0); }
}

@keyframes dropdown-close-above {
    from { opacity: 1; transform: scaleY(1)    translateY(0); }
    to   { opacity: 0; transform: scaleY(0.96) translateY(6px); }
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    min-height: 30px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 2500;
    display: none;
    transform-origin: top center;
    padding: 8px;
}

.dropdown-menu::-webkit-scrollbar {
    width: 4px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.dropdown-menu.show {
    display: block;
    position: fixed;
    right: auto;
    bottom: auto;
    animation: dropdown-open 0.15s ease forwards;
}

.dropdown-menu.closing {
    display: block;
    position: fixed;
    right: auto;
    bottom: auto;
    animation: dropdown-close 0.12s ease forwards;
    pointer-events: none;
}

.dropdown-menu.opens-above {
    transform-origin: bottom center;
}

.dropdown-menu.opens-above.show {
    animation: dropdown-open-above 0.15s ease forwards;
}

.dropdown-menu.opens-above.closing {
    animation: dropdown-close-above 0.12s ease forwards;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 15px;
    white-space: nowrap;
    border-radius: 8px;
}

.dropdown-item + .dropdown-item {
    margin-top: 4px;
}

.dropdown-item:hover {
    background-color: #f3f4f6;;
}

.dropdown-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.dropdown-item span {
    color: #374151;
    user-select: none;
    font-weight: 400;
    font-size: 15px;
}

/* ── Custom single-select (CustomSingleSelect component) ─────────────────── */
.csd-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.csd-text.csd-placeholder {
    color: #9ca3af;
}

.csd-item.csd-item-selected {
    background-color: #f0f6fe;
}

.csd-item.csd-item-disabled {
    color: #d1d5db;
    cursor: not-allowed;
    pointer-events: none;
}

.csd-item.csd-item-disabled:hover {
    background-color: transparent;
}

/* ── Popover-field: make custom dropdown match native select styles ── */
.popover-field .custom-dropdown {
    width: 100%;
}

.popover-field .dropdown-toggle {
    height: auto;
    max-height: none;
    padding: 8px 10px;
    font-size: 14px;
    background-color: #fff;
}

.popover-field .dropdown-toggle:focus,
.popover-field .dropdown-toggle.active {
    border-color: #0066FF;
    box-shadow: none;
}

@media (hover: none) and (pointer: coarse) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* iOS date inputs — normalize to match .input style */
@supports (-webkit-touch-callout: none) {
    input,
    select,
    textarea {
        font-size: 16px !important;
    }

    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        -webkit-appearance: none;
        appearance: none;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        height: 38px;
        max-height: 38px;
        padding: 10px 12px;
        font-size: 16px; /* prevents auto-zoom on iOS */
        font-family: inherit;
        color: #111827;
        background-color: #fafafa;
        border: 1.5px solid #e5e7eb;
        border-radius: 8px;
        outline: none;
        box-sizing: border-box;
        transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    }

    input[type="date"]:focus,
    input[type="time"]:focus,
    input[type="datetime-local"]:focus {
        border-color: #0066FF;
        box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
        background-color: #fff;
    }

    #inOperationDate {
        height: 38px;
        max-height: 38px;
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@media (max-width: 1024px) {
    /* iOS: prevent the page from scrolling behind an open modal */
    body.modal-open {
        position: fixed;
        width: 100%;
        /* top is set dynamically by JS to preserve scroll position */
    }

    .modal-backdrop:not(:has(> .modal-sm)) {
        padding: 0;
    }

    .modal:not(.modal-sm) {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important; /* do NOT anchor to visual-viewport bottom */
        width: 100% !important;
        height: 100vh !important;  /* fallback */
        height: 100lvh !important; /* large viewport: never shrinks when keyboard opens */
        max-height: none !important;
        border-radius: 0 !important;
    }

    .import-modal .modal-body,
    .modal.settings-modal .modal-body {
        padding: 12px;
    }

    .grid-row {
        grid-template-columns: 1fr;
    }

    .patient-panel {
        grid-template-columns: 1fr;
    }

    tbody tr {
        border-bottom: 1px solid #f1f5f9;
        height: 37px;
        max-height: 37px;
    }

    .input {
        letter-spacing: normal;
    };
}

/* ── Empty / loading states (shared across pages) ── */
.empty-state,
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    text-align: center;
    flex: 1;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state-text {
    font-size: 14px;
    color: #9ca3af;
    font-style: italic;
}

.loading-state {
    flex-direction: row;
    gap: 12px;
}

/* ── Item count badge ── */
.item-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 8px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0066FF 0%, #00D4AA 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    margin-left: 8px;
}

/* ── No-data row (fills full height/width of the table container) ── */
.no-data-row td {
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    font-size: 14px;
}

.table-container:has(tbody tr.no-data-row:only-child) {
    display: flex;
    flex-direction: column;
}

.table-container:has(tbody tr.no-data-row:only-child) table {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.table-container:has(tbody tr.no-data-row:only-child) thead {
    flex-shrink: 0;
}

.table-container:has(tbody tr.no-data-row:only-child) thead tr {
    display: table;
    width: 100%;
    table-layout: auto;
}

.table-container:has(tbody tr.no-data-row:only-child) tbody {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.table-container tbody tr.no-data-row:only-child {
    flex: 1;
    display: flex;
    height: auto;
    max-height: none;
}

.table-container tbody tr.no-data-row:only-child td {
    position: sticky;
    left: 0;
    width: 100cqi;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* ── Column sorting ─────────────────────────────────────────────────────── */
thead th.th-sortable {
    cursor: pointer;
    user-select: none;
}

thead th.th-sortable:hover {
    background: #eef2f7;
    color: #1f2937;
}

thead th.th-sortable::before {
    content: '';
    display: inline-flex;
    width: 6px;
    visibility: hidden;
}

thead th.th-sortable .sort-icon {
    display: inline-flex;
    vertical-align: middle;
    margin-left: 4px;
    width: 14px;
    height: 14px;
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.25s ease;
}

thead th.sort-asc .sort-icon,
thead th.sort-desc .sort-icon {
    opacity: 0.8;
    color: #0066ff;
}

thead th.sort-desc .sort-icon {
    transform: rotate(180deg);
}

/* ── Modal loading overlay ──────────────────────────────────────────────── */
.modal-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

.modal-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #0066FF;
    border-radius: 50%;
    animation: modal-spin 0.7s linear infinite;
}

@keyframes modal-spin {
    to { transform: rotate(360deg); }
}
