@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --secondary-color: #6B7280;
    --secondary-hover: #525a65;
    --text-color: #333333;
    --text-muted: #6c757d;
    --light-bg: #f5f7fb;
    --border-color: #e2e8f0;
    --success-color: #38b000;
    --danger-color: #d90429;
    --warning-color: #ff9e00;
    --heading-color: #2d3748;
    --label-color: #4b5563;
    --placeholder-color: #bdbdbd;
    --disabled-color: #9ca3af;
    --table-header-bg: #f1f5f9;
    --table-header-color: #64748b;
    --white-color: #ffffff;
    --toast-error-text: #856404;
    --toast-error-bg: #fff3cd;
    --toast-error-border: #ffeeba;
    --radius-base: 8px;

    --primary-color-rgb: 67, 97, 238;
    --success-color-rgb: 56, 176, 0;
    --danger-color-rgb: 217, 4, 41;
    --warning-color-rgb: 255, 158, 0;
    --black-rgb: 0, 0, 0;
    --white-rgb: 255, 255, 255;

    --primary-focus-shadow: rgba(var(--primary-color-rgb), 0.15);
    --primary-hover-bg-light: rgba(var(--primary-color-rgb), 0.03);
    --success-bg-light: rgba(var(--success-color-rgb), 0.08);
    --success-bg-light-hover: rgba(var(--success-color-rgb), 0.12);
    --danger-bg-light: rgba(var(--danger-color-rgb), 0.08);
    --danger-bg-light-hover: rgba(var(--danger-color-rgb), 0.12);
    --overlay-bg: rgba(var(--white-rgb), 0.8);
    --toast-success-bg: rgba(var(--success-color-rgb), 0.95);
    --toast-error-bg-rgba: rgba(var(--danger-color-rgb), 0.95);
    --toast-warning-bg: rgba(var(--warning-color-rgb), 0.95);

    --card-shadow-base: rgba(var(--black-rgb), 0.05);
    --card-shadow-hover: rgba(var(--black-rgb), 0.08);
    --card-shadow: 0 4px 6px var(--card-shadow-base);
    --card-shadow-hover-val: 0 8px 16px var(--card-shadow-hover);
    --top-row-shadow: rgba(var(--black-rgb), 0.08);
    --edit-footer-shadow: rgba(var(--black-rgb), 0.03);

    --transition: all 0.25s ease;
    --input-height: calc(1.5em + .75rem + 2px);
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.6;
}

body {
    padding-bottom: 100px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

a, .btn-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover, .btn-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

input, select, textarea {
    font-family: inherit;
    border-radius: var(--radius-base) !important;
    border-color: var(--border-color) !important;
    transition: var(--transition);
    min-height: 44px;
}

input:focus, select:focus, textarea:focus {
    box-shadow: 0 0 0 3px var(--primary-focus-shadow) !important;
    border-color: var(--primary-color) !important;
}

input::placeholder {
    color: var(--placeholder-color) !important;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--heading-color);
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
}

p {
    color: var(--text-color);
    margin-bottom: 1rem;
}

.btn {
    border-radius: var(--radius-base);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: var(--transition);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    color: var(--white-color);
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    color: var(--white-color);
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    color: var(--white-color);
    background-color: var(--secondary-hover);
    border-color: var(--secondary-hover);
    transform: translateY(-1px);
}

.btn:not(.btn-sm):not(.btn-lg) {
    height: var(--input-height);
    display: inline-flex;
    align-items: center;
}

.btn > span {
    display: flex;
    align-items: center;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.alert > :not(.material-icons):not([class*="icon"]):last-child {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

app {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-row {
    height: 3.5rem;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 12px var(--top-row-shadow);
    background-color: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}

.main {
    flex: 1;
}

.main .top-row {
    background-color: var(--white-color);
    border-bottom: 1px solid var(--border-color);
    justify-content: flex-end;
    padding: 0 1rem;
}

.main .top-row > a, .main .top-row .btn-link {
    white-space: nowrap;
    margin-left: 1.5rem;
    font-weight: 500;
}

.main .top-row a:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-tr {
    cursor: pointer;
}

.content {
    padding-top: 1.5rem;
    padding-bottom: 2.5rem;
}

.navbar-toggler {
    background-color: transparent;
    border: none;
}

.valid.modified:not([type="checkbox"]) {
    outline: none;
    border-color: var(--success-color) !important;
}

.invalid {
    outline: none;
    border-color: var(--danger-color) !important;
}

.validation-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

#blazor-error-ui {
    background: var(--toast-error-bg);
    border-top: 1px solid var(--toast-error-border);
    bottom: 0;
    box-shadow: 0 -2px 5px var(--top-row-shadow);
    display: none;
    left: 0;
    padding: 1rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: var(--toast-error-text);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 1rem;
    opacity: 0.7;
}

#blazor-error-ui .dismiss:hover {
    opacity: 1;
}

.blazored-toast-success {
    background-color: var(--toast-success-bg);
    border-radius: var(--radius-base);
}

.blazored-toast-error {
    background-color: var(--toast-error-bg-rgba);
    border-radius: var(--radius-base);
}

.blazored-toast-warning {
    background-color: var(--toast-warning-bg);
    border-radius: var(--radius-base);
}

table {
    background-color: var(--white-color);
    border-radius: var(--radius-base);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin-bottom: 1rem;
    position: relative;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

@media (max-width: 768px) {
    .table-responsive {
        border: 1px solid var(--border-color);
        border-radius: var(--radius-base);
    }

    table.table-mobile-stack {
        overflow: hidden;
    }

    table.table-mobile-stack thead {
        display: none;
    }

    table.table-mobile-stack tbody tr {
        display: block;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-base);
        margin-bottom: 1rem;
        padding: 1rem;
        background-color: var(--white-color);
    }

    table.table-mobile-stack tbody td {
        display: block;
        border: none;
        padding: 0.5rem 0;
        text-align: left;
        position: relative;
    }

    table.table-mobile-stack tbody td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--label-color);
        margin-right: 0.5rem;
    }
}

td {
    position: relative;
    overflow: visible;
}

td .typeahead-dropdown {
    z-index: 1100;
}

table thead th {
    background-color: var(--table-header-bg);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.04rem;
    padding: 0.75rem 1rem;
    color: var(--table-header-color);
    border-bottom: 1px solid var(--border-color);
}

table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-top: 1px solid var(--border-color);
}

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

table tbody tr:hover {
    background-color: var(--primary-hover-bg-light);
}

.table-vertical tr {
    display: inline-block;
    float: left;
}

.table-vertical th, .table-vertical td {
    display: block;
}

.table-vertical tr > *:first-child {
    border-top: 0;
}

table.table-hover.table-clickable {
    table-layout: fixed;
    width: 100%;
}

table.table-hover.table-clickable tbody tr {
    cursor: pointer;
}

table tbody tr.table-active,
table tbody tr.table-active:hover {
    background-color: rgba(var(--primary-color-rgb), 0.08) !important;
    color: var(--heading-color);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(var(--primary-color-rgb), 0.015);
}


.table-card .card-body {
    padding: 0;
}

.table-card .table {
    margin-bottom: 0;
    border: 0;
    box-shadow: none;
    border-radius: 0;
}

.table td .btn-sm + .btn-sm {
    margin-left: 0.35rem;
}

.page-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.page-header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: nowrap;
    align-items: center;
}

.page-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--heading-color);
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    line-height: 1.1;
}

.page-title-count {
    font-size: 0.95rem;
    color: var(--primary-color);
    background-color: rgba(var(--primary-color-rgb), 0.08);
    border-radius: var(--radius-base);
    padding: 0.15rem 0.55rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
}

.page-search {
    flex: 1 1 260px;
    min-width: 180px;
    max-width: 380px;
}

.page-search-input {
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
}

.page-header-actions .btn {
    flex-shrink: 0;
}

@media (min-width: 576px) {
    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .page-header .page-title {
        font-size: 1.875rem;
    }
}

@media (max-width: 575.98px) {
    .page-header-actions {
        flex-wrap: wrap;
    }
}

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

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-view {
    height: 100%;
    width: 100%;
    display: grid;
    grid-template-rows: 9fr 1fr;
    gap: 1rem;
}

.grid-view-11 {
    height: 100%;
    width: 100%;
    display: grid;
    grid-template-rows: 1fr min-content;
    padding: 1.25rem;
    gap: 1rem;
}

.grid-view.reverse {
    grid-template-rows: 1fr 9fr;
}

.edit-footer {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
    padding: 1rem 0;
    background-color: var(--white-color);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -1px 3px var(--edit-footer-shadow);
    position: sticky;
    bottom: 0;
    z-index: 100;
}

.sticky-footer-card {
    position: sticky;
    bottom: 0.75rem;
    z-index: 100;
    margin-bottom: 0;
    box-shadow: 0 -2px 8px var(--edit-footer-shadow);
}

.sticky-footer-card .card-body {
    padding: 0.5rem 1.25rem;
}

.sticky-footer-card h5 {
    margin-bottom: 0.35rem;
    font-size: 1.05rem;
}

.sticky-footer-card p {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.sticky-footer-card .text-right {
    margin-top: 0.5rem;
}

.base {
    display: grid;
    grid-template-rows: 5fr auto;
    gap: 1rem;
}

.spread {
    justify-content: space-around;
}

.w-95 {
    width: 95%;
}

.loading-overlay {
    position: absolute;
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 0;
    background-color: var(--overlay-bg);
    left: 0;
    z-index: 1000;
    backdrop-filter: blur(3px);
}

.tr-success {
    background-color: var(--success-bg-light);
}

.tr-success:hover {
    background-color: var(--success-bg-light-hover);
}

.tr-danger {
    background-color: var(--danger-bg-light);
}

.tr-danger:hover {
    background-color: var(--danger-bg-light-hover);
}

.form-group.row .d-flex {
    align-items: center;
}

.label, .form-label {
    display: inline-block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--label-color);
}

.form-select, .form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--white-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-base);
    transition: var(--transition);
}

.form-select {
    padding-right: 2.25rem;
    background: var(--white-color) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e") no-repeat right 0.75rem center / 16px 12px;
    appearance: none;
    height: var(--input-height);
}

.form-select:focus {
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: 0 0 0 3px var(--primary-focus-shadow);
}

.input-group > .form-select:not(:last-child), .input-group > .form-select:not(:last-child):focus {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.flex-vert {
    flex-direction: column;
}

.wide-small {
    margin: 0 -1.5rem;
}

.pointer {
    cursor: pointer;
}

.lds-ellipsis {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 20px;
    margin: auto;
}

.lds-ellipsis div {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.lds-ellipsis div:nth-child(1) {
    left: 8px;
    animation: lds-ellipsis1 0.6s infinite;
}

.lds-ellipsis div:nth-child(2) {
    left: 8px;
    animation: lds-ellipsis2 0.6s infinite;
}

.lds-ellipsis div:nth-child(3) {
    left: 32px;
    animation: lds-ellipsis2 0.6s infinite;
}

.lds-ellipsis div:nth-child(4) {
    left: 56px;
    animation: lds-ellipsis3 0.6s infinite;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    font-weight: 400;
    transition: var(--transition);
}

.dropdown-item.active, .dropdown-item:active {
    color: #fff;
    text-decoration: none;
    background-color: var(--primary-color);
}

.dropdown-item:hover {
    background-color: var(--border-color);
    color: var(--text-color);
}

.dropdown-item.disabled, .dropdown-item:disabled {
    color: var(--disabled-color);
    pointer-events: none;
    background-color: transparent;
}

.dropdown-menu {
    border-radius: var(--radius-base);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 0.5rem 0;
}

.dropdown-menu.show {
    display: block;
    animation: dropdown-fade 0.2s ease-out;
}

.dropdown-header {
    display: block;
    padding: 0.5rem 1rem;
    margin-bottom: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 600;
}

.dropdown-item-text {
    display: block;
    padding: 0.25rem 1.5rem;
    color: var(--text-color);
}

.movement-card {
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-base);
    background-color: white;
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
}

.movement-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    border-color: var(--primary-color);
}

.movement-card:hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--primary-color);
}

.movement-card.selected {
    border-color: var(--success-color);
    background-color: var(--success-bg-light);
    box-shadow: 0 0 0 2px var(--success-bg-light);
}

.movement-card.selected::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--success-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.card {
    border-radius: var(--radius-base);
    border: 1px solid rgba(226, 232, 240, 0.9);
    background-color: var(--white-color);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

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

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

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

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

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

.bg-light {
    background-color: var(--light-bg) !important;
}

.shadow-sm {
    box-shadow: var(--card-shadow) !important;
}

.rounded {
    border-radius: var(--radius-base) !important;
}

.rounded-lg {
    border-radius: var(--radius-base) !important;
}

.fw-bold {
    font-weight: 600 !important;
}

.text-sm {
    font-size: 0.875rem !important;
}

.text-xs {
    font-size: 0.75rem !important;
}

.light-shadow-modal {
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.custom-modal-content {
    height: calc(100% - 40px);
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-width: 800px;
    margin: 0 auto;
}

.modal-content-header {
    flex: 0 0 auto;
    padding: 20px 24px 16px 24px;
    border-bottom: 1px solid #dee2e6;
    background-color: white;
    text-align: center;
}

.modal-content-header h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #212529;
}

.modal-content-body {
    flex: 1 1 0;
    padding: 20px 24px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.modal-content-footer {
    flex: 0 0 auto;
    padding: 16px 24px 20px 24px;
    border-top: 1px solid #dee2e6;
    background-color: white;
    margin-top: auto;
}

.modal-footer-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
}

.modal-footer-buttons .btn {
    min-width: 100px;
    font-weight: 500;
    margin: 0 6px;
}

.modal-content-body .form-group {
    margin-bottom: 1.5rem;
}

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

.modal-content-body label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #495057;
}

.modal-content-body .form-control,
.modal-content-body .form-select {
    font-size: 0.9rem;
}

.modal-content-body .table {
    margin-bottom: 1rem;
}

.modal-content-body .table-sm th,
.modal-content-body .table-sm td {
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
}

.modal-content-body .alert {
    padding: 0.75rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-base);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.modal-content-body .alert:last-child {
    margin-bottom: 0;
}

.modal-content-body .alert-info {
    background-color: #e7f3ff;
    border-color: #b8daff;
    color: #0c5460;
}

.modal-content-body .input-group {
    margin-bottom: 1rem;
}

.modal-content-body .btn-sm {
    min-height: 32px;
    min-width: 32px;
}

/* Medium screens - better handling for complex button layouts */
@media (max-width: 1200px) and (min-width: 769px) {
    .modal-footer-buttons {
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .modal-footer-buttons .btn {
        min-width: 140px;
        font-size: 0.9rem;
        margin: 0;
        flex: 0 1 auto;
    }

    /* Auto-apply grid layout for 2+ buttons */
    .modal-footer-buttons:has(.btn:nth-child(2)) {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-gap: 12px;
        justify-items: stretch;
    }

    .modal-footer-buttons:has(.btn:nth-child(2)) .btn {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .custom-modal-content {
        max-width: none;
    }

    .modal-content-header,
    .modal-content-body,
    .modal-content-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .modal-footer-buttons {
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
        margin: 0;
    }

    .modal-footer-buttons .btn {
        min-width: 120px;
        font-size: 0.875rem;
        margin: 0;
        flex: 0 1 auto;
    }

    /* Auto-apply grid layout for 2+ buttons */
    .modal-footer-buttons:has(.btn:nth-child(2)) {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-gap: 10px;
        justify-items: stretch;
    }

    .modal-footer-buttons:has(.btn:nth-child(2)) .btn {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .modal-content-header {
        padding: 16px 12px 12px 12px;
    }

    .modal-content-body {
        padding: 16px 12px;
    }

    .modal-content-footer {
        padding: 12px 12px 16px 12px;
    }

    .modal-footer-buttons {
        flex-direction: column;
        margin: -4px 0;
    }

    .modal-footer-buttons .btn {
        width: 100%;
        min-width: auto;
        margin: 4px 0;
    }
}

.modal-content-body .form-check-inline {
    align-items: center;
    user-select: none; /* Prevents text selection */
}

.modal-content-body .form-check-inline .form-check-input {
    margin-top: 0;
    margin-right: 0.5rem;
    position: relative;
    top: 0;
}

.modal-content-body .form-check-inline .form-check-label {
    margin-bottom: 0;
    cursor: pointer;
}

.modal-content-body .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.modal-content-body .form-check {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.modal-content-body .form-check-input:focus,
.modal-content-body .form-check-input:active,
.modal-content-body .form-check-input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.modal-content-body .form-check-input:checked:focus {
    box-shadow: none !important;
    outline: none !important;
}

.modal-content-body .form-check-input {
    outline: none;
}

.form-check {
    display: flex !important;
    align-items: center !important;
    margin-bottom: 0.5rem !important;
}

.form-check-input {
    margin: 0 0.5rem 0 0 !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
}

.form-check-inline {
    margin-right: 1rem !important;
    margin-bottom: 0 !important;
}

.form-check-label {
    margin-bottom: 0 !important;
    cursor: pointer !important;
}

.table td {
    vertical-align: middle;
}

.table input {
    margin: 0;
}

@media (min-width: 1200px) {
    .custom-modal-content {
        max-width: 900px;
    }
}

@keyframes lds-ellipsis1 {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes lds-ellipsis3 {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(0);
    }
}

@keyframes lds-ellipsis2 {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(24px, 0);
    }
}

@keyframes dropdown-fade {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 576px) {
    .container-fluid, .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .btn {
        min-height: 48px;
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }

    .btn-sm {
        min-height: 40px;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.125rem;
    }

    .form-control, .form-select {
        min-height: 48px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    table {
        font-size: 0.875rem;
    }

    table thead th {
        padding: 0.5rem 0.75rem;
        font-size: 0.6875rem;
    }

    table tbody td {
        padding: 0.75rem;
    }

    .dropdown-item {
        padding: 0.75rem 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .movement-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .edit-footer {
        padding: 1rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .edit-footer .btn {
        flex: 1;
        min-width: calc(50% - 0.25rem);
    }

    .card {
        border-radius: var(--radius-base);
    }

    .top-row {
        padding: 0 1rem;
    }

    .movement-card h5 {
        font-size: 1rem;
    }

    .movement-card p {
        font-size: 0.8125rem;
    }

    .card-title {
        font-size: 1rem;
    }

    .table-hover tbody td:before {
        font-size: 0.6875rem;
    }
}

@media (max-width: 768px) {
    .main .top-row:not(.auth) {
        display: none;
    }

    .main .top-row.auth {
        justify-content: space-between;
    }

    .main .top-row a, .main .top-row .btn-link {
        margin-left: 0;
    }

    h1 {
        font-size: 1.75rem;
    }

    .content {
        padding: 1rem;
    }

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

    .navbar-toggler {
        min-height: 44px;
        min-width: 44px;
    }

    .card {
        margin-bottom: 1rem;
    }

    .form-group {
        margin-bottom: 1.5rem;
    }

    .btn-group-vertical .btn {
        margin-bottom: 0.5rem;
    }

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

    .card-deck {
        display: block !important;
    }

    .card-deck .card {
        display: block;
        width: 100%;
        margin-bottom: 1rem;
        max-width: none;
        flex: none;
    }

    .movement-card {
        margin-bottom: 1rem;
        text-align: center;
    }

    .movement-card .card-body {
        padding: 1.5rem 1rem;
    }

    .movement-card h5 {
        margin-bottom: 0.75rem;
        font-size: 1.125rem;
    }

    .movement-card p {
        margin-bottom: 0;
        font-size: 0.875rem;
        line-height: 1.4;
    }

    .table-responsive {
        border: none;
        box-shadow: none;
    }

    .table-hover {
        font-size: 0.875rem;
    }

    .table-hover thead {
        display: none;
    }

    .table-hover tbody tr {
        display: block;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-base);
        margin-bottom: 1rem;
        padding: 1rem;
        background-color: var(--white-color);
    }

    .table-hover tbody td {
        display: block;
        border: none;
        padding: 0.5rem 0;
        text-align: left;
        width: 100% !important;
    }

    .table-hover tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--label-color);
        display: block;
        margin-bottom: 0.25rem;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.05rem;
    }

    .table-hover tbody td:nth-child(1):before {
        content: "Artikel";
    }

    .table-hover tbody td:nth-child(2):before {
        content: "Menge";
    }

    .table-hover tbody td:nth-child(3):before {
        content: "Einheit";
    }

    .table-hover tbody td:nth-child(4):before {
        content: "";
    }

    .table-hover tbody td:last-child {
        text-align: center;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
        margin-top: 0.5rem;
    }

    .table-hover tbody td:last-child:before {
        display: none;
    }

    .table .form-control,
    .table .input-group,
    .table .btn {
        width: 100%;
    }

    .table .input-group {
        margin-bottom: 0.5rem;
    }

    .table .btn {
        min-height: 48px;
        padding: 0.75rem 1rem;
    }

    .table .btn-sm {
        min-height: 40px;
        padding: 0.5rem 0.75rem;
    }

    .typeahead-dropdown {
        position: fixed !important;
        left: 1rem !important;
        right: 1rem !important;
        width: auto !important;
        max-height: 300px;
        z-index: 1100;
        border-radius: var(--radius-base);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    }

    .typeahead-dropdown .dropdown-item {
        padding: 0.75rem 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
        white-space: normal;
        word-wrap: break-word;
    }

    .typeahead-action {
        padding: 1rem !important;
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .typeahead-action .btn {
        width: 100%;
        justify-content: center;
    }

    .input-group {
        display: flex;
        flex-wrap: nowrap;
    }

    .input-group .form-control {
        flex: 1;
        min-width: 0;
    }

    .input-group-append .btn {
        min-width: 48px;
        flex-shrink: 0;
    }

    .d-flex.flex-wrap.gap-2 {
        gap: 0.5rem !important;
    }

    .chip,
    [class*="chip"] {
        margin-right: 0.5rem !important;
        margin-bottom: 0.5rem !important;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }

    .validation-message,
    .text-danger {
        font-size: 0.8125rem;
        margin-top: 0.5rem;
        display: block;
    }

    .alert {
        padding: 1rem;
        margin-bottom: 1rem;
        font-size: 0.875rem;
        border-radius: var(--radius-base);
        display: flex;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .alert .material-icons {
        margin-right: 0.5rem;
    }

    .card {
        margin-bottom: 1.5rem;
        border-radius: var(--radius-base);
    }

    .card-body {
        padding: 1.25rem;
    }

    .card-title {
        font-size: 1.125rem;
        margin-bottom: 0.75rem;
    }

    .card hr {
        margin: 1rem 0;
    }

    .card .text-right {
        text-align: center !important;
    }

    .card .btn {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .grid-view {
        height: auto;
        grid-template-rows: 1fr auto;
        min-height: 60vh;
    }

    .grid-view > div:first-child {
        overflow-y: auto;
        max-height: 60vh;
    }

    .grid-view > div:last-child {
        flex-shrink: 0;
        padding: 1rem;
        border-top: 1px solid var(--border-color);
        background-color: var(--white-color);
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    .grid-view > div:first-child {
        max-height: 50vh;
    }

    .movement-card .card-body {
        padding: 0.75rem 0;
    }

    .card-body {
        padding: 1rem;
    }
}

@media (min-width: 768px) {
    .sidebar {
        width: 250px;
        height: 100vh;
        position: sticky;
        top: 0;
        background-color: var(--white-color);
        box-shadow: 1px 0 3px var(--top-row-shadow);
    }

    .main .top-row {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .main > div {
        padding-left: 2rem !important;
    }

    .navbar-toggler {
        display: none;
    }

    .sidebar .collapse {
        display: block;
    }
}

@media (min-width: 1200px) {
    .backdrop-large {
        width: 66% !important;
    }

    .flex-vert {
        flex-direction: row;
    }

    .wide-small {
        margin: 0 -15px;
    }
}

.cursor-pointer {
    cursor: pointer;
}

.order-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-base);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    min-width: fit-content;
}

.order-status-badge .badge-text {
    font-size: 0.7rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    font-weight: 500;
}

/* Ready for Invoicing - Bright Orange */
.order-status-badge.ready-for-invoicing {
    background-color: #ff6b35;
    color: white;
    border-color: #ff6b35;
    box-shadow: 0 2px 4px rgba(255, 107, 53, 0.2);
}

.order-status-badge.ready-for-invoicing:hover {
    background-color: #ff5722;
    box-shadow: 0 4px 8px rgba(255, 107, 53, 0.3);
    transform: translateY(-1px);
}

/* Partially Invoiced - Blue */
.order-status-badge.partially-invoiced {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(var(--primary-color-rgb), 0.2);
}

.order-status-badge.partially-invoiced:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 8px rgba(var(--primary-color-rgb), 0.3);
    transform: translateY(-1px);
}

/* Automatically Invoiced - Green */
.order-status-badge.automatically-invoiced {
    background-color: var(--success-color);
    color: white;
    border-color: var(--success-color);
    box-shadow: 0 2px 4px rgba(var(--success-color-rgb), 0.2);
}

.order-status-badge.automatically-invoiced:hover {
    background-color: #2e9500;
    box-shadow: 0 4px 8px rgba(var(--success-color-rgb), 0.3);
    transform: translateY(-1px);
}

/* Manually Invoiced - Gray */
.order-status-badge.manually-invoiced {
    background-color: #6c757d;
    color: white;
    border-color: #6c757d;
    box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2);
}

.order-status-badge.manually-invoiced:hover {
    background-color: #545b62;
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
    transform: translateY(-1px);
}

/* Contract Billing - Purple */
.order-status-badge.contract-billing {
    background-color: #6f42c1;
    color: white;
    border-color: #6f42c1;
    box-shadow: 0 2px 4px rgba(111, 66, 193, 0.2);
}

.order-status-badge.contract-billing:hover {
    background-color: #5a32a3;
    box-shadow: 0 4px 8px rgba(111, 66, 193, 0.3);
    transform: translateY(-1px);
}

/* Compact version for small spaces */
.order-status-badge.compact {
    padding: 0.35rem 0.65rem;
    font-size: 0.7rem;
}

.order-status-badge.compact .badge-text {
    font-size: 0.65rem;
}

.order-status-badge[title]:hover {
    cursor: help;
}

.sticky-details-card {
    position: sticky;
    top: 4rem;
    height: fit-content;
    max-height: calc(100vh - 5rem);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sticky-details-card .card-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: opacity(0.6);
    transition: filter 0.2s ease;
    width: 18px;
    height: 18px;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    filter: opacity(1) brightness(1.1);
}

input[type="date"]:focus::-webkit-calendar-picker-indicator {
    filter: opacity(1);
}

/* Navigation Improvements */
.dropdown-menu {
    border-radius: var(--radius-base);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 0.5rem 0;
    margin-top: 0.25rem;
}

.dropdown-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 1rem 0.25rem 1rem;
    margin-top: 0.25rem;
}

.dropdown-header:first-child {
    margin-top: 0;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.9375rem;
    color: var(--text-color);
    transition: background-color 0.15s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--light-bg);
    color: var(--text-color);
}

.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--primary-hover-bg-light);
    color: var(--primary-color);
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: var(--border-color);
}

/* Wizard Styles */
.wizard-container {
}

.wizard-progress {
    background: var(--white-color);
    padding: 2rem;
    border-radius: var(--radius-base);
    box-shadow: var(--card-shadow);
}

.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
}

.step-indicator {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--light-bg);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s ease;
    font-size: 1.125rem;
}

.wizard-step.active .step-indicator {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.3);
}

.wizard-step.completed .step-indicator {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.step-label {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
}

.wizard-step.active .step-label {
    color: var(--primary-color);
    font-weight: 600;
}

.wizard-step.completed .step-label {
    color: var(--text-color);
}

.step-connector {
    flex: 1;
    height: 2px;
    background-color: var(--border-color);
    margin: 0 1rem;
    margin-bottom: 2rem;
    transition: background-color 0.3s ease;
}

.step-connector.completed {
    background-color: var(--success-color);
}

.wizard-content {
    background: var(--white-color);
    padding: 2.5rem;
    border-radius: var(--radius-base);
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    min-height: 450px;
}

.wizard-step-content h3 {
    color: var(--heading-color);
    font-size: 1.5rem;
}

.wizard-navigation {
    background: var(--white-color);
    padding: 1.5rem 2rem;
    border-radius: var(--radius-base);
    box-shadow: var(--card-shadow);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.order-line-card {
    background: var(--light-bg);
    padding: 1.5rem;
    border-radius: var(--radius-base);
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.review-section {
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--heading-color);
    margin-bottom: 1rem;
}

.review-card {
    background: var(--light-bg);
    padding: 1.5rem;
    border-radius: var(--radius-base);
    border: 1px solid var(--border-color);
}

.review-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.review-item:last-child {
    border-bottom: none;
}

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

.review-value {
    font-weight: 500;
    color: var(--text-color);
}

.review-item-line {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.review-item-line:last-child {
    border-bottom: none;
}

.total-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-base);
    border: 1px solid var(--border-color);
}

/* Responsive Wizard */
@media (max-width: 768px) {
    .wizard-steps {
        flex-direction: column;
    }

    .step-connector {
        width: 2px;
        height: 40px;
        margin: 0.5rem 0;
    }

    .wizard-content {
        padding: 1.5rem;
        min-height: 350px;
    }

    .wizard-navigation {
        padding: 1rem;
    }

    .step-indicator {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

.order-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.order-card {
    border-radius: var(--radius-base);
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
    background: var(--white-color);
}

.order-card:hover {
    background: rgba(var(--primary-color-rgb), 0.02);
    transform: translateX(2px);
}

.order-card-normal {
    border-left-color: var(--border-color);
}

.order-card-critical {
    border-left-color: var(--danger-color);
    background: rgba(var(--danger-color-rgb), 0.03);
}

.order-card-critical:hover {
    background: rgba(var(--danger-color-rgb), 0.05);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.375rem;
}

.order-card-title {
    display: flex;
    align-items: center;
}

.order-card-body {
    padding-left: 0;
}

.order-meta {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
}

.order-meta > span {
    display: flex;
    align-items: center;
}

.order-items small {
    display: flex;
    align-items: center;
}

/* Invoice Cards */
.invoice-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.invoice-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-base);
    background: var(--white-color);
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.invoice-card:hover {
    background: rgba(var(--success-color-rgb), 0.02);
    border-color: var(--success-color);
}

.invoice-card-content {
    flex: 1;
}

/* Activity Cards */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.activity-card {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-base);
    background: var(--white-color);
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.activity-card:hover {
    background: rgba(var(--primary-color-rgb), 0.02);
}

.activity-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-base);
    flex-shrink: 0;
    font-size: 1.125rem;
}

.activity-card-content {
    flex: 1;
    min-width: 0;
}

.activity-card-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.125rem;
}

.activity-type {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--heading-color);
}

.activity-amount {
    font-weight: 600;
    font-size: 0.8125rem;
}

.activity-description {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.warehouse-stock-section {
    border: none;
    margin: 0;
}

.warehouse-stock-section[open] {
    background: var(--white-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-base);
    padding: 0;
    overflow: hidden;
}

.warehouse-stock-summary {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--white-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-base);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    list-style: none;
    font-size: 0.95rem;
    color: var(--text-color);
}

.warehouse-stock-summary:hover {
    background: rgba(var(--primary-color-rgb), 0.02);
    border-color: var(--primary-color);
}

.warehouse-stock-summary .chevron-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    color: var(--text-muted-color);
}

.warehouse-stock-section[open] .warehouse-stock-summary {
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius-base) var(--radius-base) 0 0;
}

.warehouse-stock-section[open] .warehouse-stock-summary .chevron-icon {
    transform: rotate(90deg);
}

.warehouse-stock-content {
    padding: 1rem;
}

@media (max-width: 768px) {
    .order-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .invoice-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .activity-card {
        flex-direction: column;
        gap: 0.75rem;
    }

    .activity-card-actions {
        width: 100%;
    }

    .activity-card-actions .btn {
        flex: 1;
    }
}
