:root {
    --brand: #5858b7;
    --brand-dark: #080936;
    --brand-deep: #11135a;
    --brand-accent: #7d7cff;
    --brand-soft: #eee3f7;
    --brand-surface: #ffffff;
    --text-strong: #181936;
    --text-muted: #73758c;
}

body {
    background:
        radial-gradient(circle at top left, rgba(125, 124, 255, 0.16), transparent 28rem),
        linear-gradient(135deg, #f6effb 0%, #efe3f8 100%);
    color: var(--text-strong);
    overflow-x: hidden;
}

body:has(.app-main) {
    overflow-x: hidden;
    overflow-y: hidden;
}

.app-main {
    height: calc(100vh - 58px);
    overflow-x: hidden;
    overflow-y: hidden;
    padding: 1.25rem 0;
}

.app-container {
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
}

.app-page {
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
}

.min-h-0 {
    min-height: 0;
}

.panel-card {
    background: var(--brand-surface);
    border-radius: 1rem;
    box-shadow: 0 1rem 2.5rem rgba(17, 19, 90, 0.08);
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 1.25rem;
}

.panel-header {
    align-items: flex-start;
    display: flex;
    flex-shrink: 0;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.panel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.25rem;
    scrollbar-color: #cbcbcb transparent;
    scrollbar-width: thin;
}

.panel-scroll > .row {
    margin-left: 0;
    margin-right: 0;
}

.panel-scroll::-webkit-scrollbar {
    height: 0;
    width: 4px;
}

.panel-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.panel-scroll::-webkit-scrollbar-thumb {
    background: #cbcbcb;
    border-radius: 999px;
}

.panel-scroll::-webkit-scrollbar-thumb:hover {
    background: #b7b7b7;
}

.landing-dashboard {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.85fr);
}

.machines-panel,
.reports-panel {
    overflow-x: hidden;
    overflow-y: hidden;
}

.list-page,
.form-page {
    display: flex;
    flex-direction: column;
}

.list-scroll {
    padding-bottom: 0.25rem;
}

.form-card {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: hidden;
}

.form-card > .card-body {
    flex: 1 1 auto;
}

.bg-brand {
    background: linear-gradient(135deg, var(--brand), var(--brand-deep) 55%, var(--brand-dark));
}

.app-navbar {
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.14), transparent 18rem),
        linear-gradient(135deg, var(--brand), var(--brand-deep) 58%, var(--brand-dark));
    box-shadow: 0 0.9rem 2rem rgba(17, 19, 90, 0.14);
    padding: 0.5rem 0;
}

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

.app-brand {
    align-items: center;
    display: inline-flex;
    font-weight: 800;
    min-width: 0;
    padding-bottom: 0;
    padding-top: 0;
}

.app-brand-logo {
    flex: 0 0 auto;
    height: 68px;
    object-fit: contain;
    width: 68px;
}

.app-navbar-toggler {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.9rem;
    padding: 0.45rem 0.6rem;
}

.app-navbar-toggler:focus {
    box-shadow: 0 0 0 0.18rem rgba(255, 255, 255, 0.18);
}

.nav-action {
    align-items: center;
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.86);
    display: inline-flex;
    font-size: 0.9rem;
    font-weight: 600;
    gap: 0.42rem;
    min-height: 38px;
    padding: 0.5rem 0.85rem;
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-action:hover,
.nav-action:focus {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    transform: translateY(-1px);
}

.nav-action-button {
    background: transparent;
    border: 0;
    font: inherit;
}

.brand-heading,
.text-brand {
    color: var(--brand);
}

.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand-deep);
    --bs-btn-border-color: var(--brand-deep);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    box-shadow: 0 0.75rem 1.5rem rgba(17, 19, 90, 0.18);
}

.btn-outline-brand {
    --bs-btn-color: var(--brand-deep);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-deep);
    --bs-btn-hover-border-color: var(--brand-deep);
}

.auth-page {
    align-items: center;
    background:
        radial-gradient(circle at 70% 18%, rgba(255, 255, 255, 0.14), transparent 18rem),
        linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 42%, var(--brand-dark) 100%);
    color: #fff;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: clamp(1.25rem, 4vw, 3rem);
}

body:has(.auth-page) {
    background: var(--brand-dark);
}

.app-container:has(.auth-page) {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
}

.auth-shell {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 420px;
    min-height: calc(100vh - clamp(2.5rem, 8vw, 6rem));
    width: 100%;
}

.auth-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1.75rem;
    box-shadow: 0 1.4rem 2.4rem rgba(5, 6, 34, 0.2);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(1.4rem, 5vw, 2.2rem);
    width: 100%;
}

.auth-brand {
    margin-bottom: 2.2rem;
    text-align: center;
}

.auth-brand-logo {
    display: block;
    height: clamp(104px, 28vw, 150px);
    margin: 0 auto 1.25rem;
    object-fit: contain;
    width: clamp(104px, 28vw, 150px);
}

.auth-brand-title {
    font-size: clamp(1.25rem, 4vw, 1.7rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 0.35rem;
}

.auth-brand-subtitle {
    color: rgba(255, 255, 255, 0.78);
    font-size: clamp(0.92rem, 2.5vw, 1.08rem);
    font-weight: 600;
    margin-bottom: 0;
}

.auth-shell h1 {
    font-size: clamp(1.45rem, 5vw, 2.25rem);
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.16;
    margin-bottom: 2rem;
    text-align: center;
    text-transform: uppercase;
}

.auth-form-title {
    color: #fff;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 800;
    line-height: 1.08;
    margin-bottom: 1.75rem;
}

.auth-card .form-label {
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.auth-card .form-control {
    background: transparent;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 0;
    color: #fff;
    font-size: 0.88rem;
    padding: 0.55rem 0;
}

.auth-card .form-control:focus {
    background: transparent;
    border-color: #fff;
    box-shadow: none;
    color: #fff;
}

.auth-card .form-control::placeholder {
    color: rgba(255, 255, 255, 0.62);
}

.auth-card .text-muted {
    color: rgba(255, 255, 255, 0.74) !important;
}

.auth-card .btn-brand {
    --bs-btn-bg: #fff;
    --bs-btn-border-color: #fff;
    --bs-btn-color: var(--brand-deep);
    --bs-btn-hover-bg: rgba(255, 255, 255, 0.88);
    --bs-btn-hover-border-color: rgba(255, 255, 255, 0.88);
    --bs-btn-hover-color: var(--brand-dark);
    border-radius: 999px;
    box-shadow: 0 0.75rem 1.5rem rgba(5, 6, 34, 0.26);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    min-height: 42px;
    text-transform: uppercase;
}

.machine-card,
.event-card {
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.event-location {
    color: var(--text-strong);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
}

.event-card-main {
    min-width: 0;
}

.event-client,
.event-location {
    overflow-wrap: anywhere;
}

.month-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    overflow: visible;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
}

.month-switcher::-webkit-scrollbar {
    display: none;
}

.month-switcher-link {
    background: var(--brand-surface);
    border: 1px solid rgba(88, 88, 183, 0.22);
    border-radius: 999px;
    color: var(--brand-deep);
    display: inline-flex;
    flex: 0 0 64px;
    font-size: 0.9rem;
    font-weight: 700;
    justify-content: center;
    line-height: 1.2;
    padding: 0.58rem 0.85rem;
    text-align: center;
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.month-switcher-link:hover,
.month-switcher-link:focus,
.month-switcher-link.active {
    background: var(--brand-deep);
    border-color: var(--brand-deep);
    color: #fff;
}

.event-icon-actions {
    display: flex;
    gap: 0.3rem;
    justify-content: flex-start;
}

.event-pagination {
    background: var(--brand-surface);
    border-radius: 0.9rem;
    box-shadow: 0 0.5rem 1.5rem rgba(17, 19, 90, 0.06);
    padding: 0.85rem 1rem;
}

.event-pagination .page-link {
    color: var(--brand-deep);
}

.event-pagination .page-item.disabled .page-link {
    color: var(--text-muted);
}

.icon-btn {
    align-items: center;
    display: inline-flex;
    height: 32px;
    justify-content: center;
    padding: 0;
    width: 32px;
}

.machine-card:hover,
.event-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 1rem 2rem rgba(17, 19, 90, 0.14) !important;
}

.detail-grid span {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.detail-grid strong {
    display: block;
    color: var(--text-strong);
}

.dashboard-card span,
.expense-total-box span {
    display: block;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 0.35rem;
}

.dashboard-card strong {
    display: block;
    color: var(--brand);
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    line-height: 1.1;
}

.chart-wrap {
    height: min(32vh, 300px);
    min-height: 220px;
}

.expense-total-box {
    background: var(--brand-soft);
    border: 1px solid rgba(125, 124, 255, 0.2);
    border-radius: 0.9rem;
    padding: 1rem;
}

.expense-total-box strong {
    color: var(--brand);
    display: block;
    font-size: 1.35rem;
}

.modal-fullscreen-sm-down .modal-body {
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: #cbcbcb transparent;
    scrollbar-width: thin;
}

.modal-body .row {
    margin-left: 0;
    margin-right: 0;
}

.modal-body,
.modal-body * {
    min-width: 0;
}

.modal-body .form-control,
.modal-body .form-select,
.modal-body input[type="file"] {
    max-width: 100%;
}

.modal-body::-webkit-scrollbar {
    height: 0;
    width: 4px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #cbcbcb;
    border-radius: 999px;
}

.image-preview-modal img {
    max-height: 75vh;
    object-fit: contain;
}

.staff-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 72px;
}

.staff-avatar-placeholder {
    align-items: center;
    background: var(--brand-soft);
    border: 1px solid rgba(125, 124, 255, 0.35);
    color: var(--brand);
    display: inline-flex;
    font-size: 1.5rem;
    font-weight: 700;
    justify-content: center;
}

@media (max-width: 767.98px) {
    .auth-page {
        padding: 1.25rem;
    }

    .auth-shell {
        min-height: calc(100vh - 2.5rem);
    }

    .auth-card {
        border-radius: 1.35rem;
    }
}

@media (max-width: 575.98px) {
    body:has(.app-main) {
        overflow-x: hidden;
        overflow-y: hidden;
    }

    body:has(.landing-dashboard),
    body:has(.event-list-page) {
        overflow-y: auto;
    }

    .app-main {
        height: calc(100vh - 112px);
        padding: 0.75rem 0;
    }

    body:has(.landing-dashboard) .app-main,
    body:has(.event-list-page) .app-main {
        height: auto;
        min-height: calc(100vh - 112px);
        overflow-y: visible;
    }

    body:has(.landing-dashboard) .app-container,
    body:has(.event-list-page) .app-container {
        height: auto;
        min-height: 0;
    }

    body {
        font-size: 0.95rem;
    }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .navbar-brand {
        font-size: 1rem;
        white-space: normal;
        max-width: calc(100% - 62px);
    }

    .app-brand-logo {
        height: 58px;
        width: 92px;
    }

    .auth-brand-logo {
        height: 112px;
        width: 112px;
    }

    .app-navbar {
        padding: 0.45rem 0;
    }

    .navbar .container {
        align-items: center;
        flex-direction: row;
    }

    .navbar-actions {
        align-items: stretch;
        flex-direction: column;
        gap: 0.35rem;
        padding: 0.8rem 0 0.15rem;
        width: 100%;
    }

    .navbar-collapse {
        width: 100%;
    }

    .navbar-actions form,
    .navbar-actions .nav-action {
        width: 100%;
    }

    .navbar-actions .nav-action {
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 0.9rem;
        justify-content: flex-start;
        min-height: 44px;
        padding: 0.65rem 0.85rem;
    }

    .card-body {
        padding: 1rem;
    }

    .landing-dashboard {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        height: auto;
        overflow: visible;
    }

    .machines-panel {
        flex: 0 0 auto;
        min-height: auto;
    }

    .reports-panel {
        flex: 0 0 auto;
        min-height: auto;
    }

    .panel-card {
        border-radius: 0.85rem;
        padding: 1.1rem;
    }

    .landing-dashboard .panel-card {
        display: block;
        overflow: visible;
    }

    .landing-dashboard .panel-scroll {
        overflow: visible;
        padding-right: 0;
    }

    .panel-header {
        align-items: flex-start;
        flex-direction: row;
        gap: 0.75rem;
    }

    .panel-header .btn {
        width: auto;
    }

    .panel-header .add-machine-btn {
        align-items: center;
        border-radius: 50%;
        display: inline-flex;
        flex: 0 0 36px;
        font-size: 1.05rem;
        font-weight: 800;
        height: 36px;
        justify-content: center;
        margin-left: auto;
        min-height: 36px;
        padding: 0;
        width: 36px;
    }

    .landing-dashboard .panel-header h1,
    .landing-dashboard .panel-header h2 {
        line-height: 1.2;
    }

    .landing-dashboard .panel-header p:last-child {
        line-height: 1.45;
    }

    .machine-card .card-body {
        padding: 1.05rem;
    }

    .machine-card .card-title {
        font-size: 1.1rem;
        line-height: 1.25;
    }

    .machine-card-actions {
        margin-top: 1.1rem !important;
    }

    .dashboard-card .card-body {
        min-height: 108px;
        padding: 1rem;
    }

    .dashboard-card span {
        line-height: 1.25;
    }

    .dashboard-card strong {
        font-size: 1.35rem;
    }

    .list-page > .d-flex:first-child {
        flex-shrink: 0;
    }

    .event-list-page {
        height: auto;
        overflow: visible;
    }

    .month-switcher {
        flex-wrap: nowrap;
        gap: 0.5rem;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .month-switcher-link {
        align-items: center;
        background: var(--brand-surface);
        border: 1px solid rgba(88, 88, 183, 0.22);
        border-radius: 999px;
        color: var(--brand-deep);
        display: inline-flex;
        flex: 0 0 auto;
        font-size: 0.86rem;
        font-weight: 700;
        justify-content: center;
        min-width: 52px;
        padding: 0.48rem 0.75rem;
        text-decoration: none;
    }

    .month-switcher-link.active {
        background: var(--brand-deep);
        border-color: var(--brand-deep);
        color: #fff;
    }

    .event-page-header {
        gap: 0.5rem !important;
    }

    .event-header-actions {
        align-self: flex-start;
        flex: 0 0 auto;
    }

    .event-header-actions .btn {
        font-size: 0.82rem;
        min-height: 34px;
        padding: 0.35rem 0.6rem;
        white-space: nowrap;
    }

    .event-header-actions .add-event-btn {
        margin-left: auto;
        width: auto;
    }

    .list-scroll {
        margin-right: -0.25rem;
        padding-right: 0.25rem;
    }

    .event-list-page .list-scroll {
        margin-right: 0;
        overflow: visible;
        padding-right: 0;
    }

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

    .event-actions .btn,
    .machine-card .btn:not(.icon-btn) {
        flex: 1 1 100%;
    }

    .machine-card-actions .icon-btn {
        flex: 0 0 42px;
        height: 42px;
        width: 42px;
    }

    .event-card-body {
        padding: 0.85rem;
    }

    .event-location {
        font-size: 1rem;
    }

    .event-client,
    .event-card-meta {
        font-size: 0.82rem;
    }

    .event-card-meta {
        line-height: 1.35;
    }

    .event-card-meta .col-12:last-child {
        display: none;
    }

    .event-card-side .badge {
        font-size: 0.68rem;
    }

    .event-icon-actions {
        border-top: 1px solid rgba(17, 19, 90, 0.08);
        flex-wrap: wrap;
        max-width: none;
        padding-top: 0.65rem;
    }

    .event-pagination {
        padding: 0.85rem;
    }

    .event-pagination .pagination {
        width: 100%;
    }

    .event-pagination .page-item {
        flex: 1 1 0;
    }

    .event-pagination .page-link {
        text-align: center;
    }

    .icon-btn {
        flex: 0 0 32px;
        min-height: 32px;
    }

    .chart-wrap {
        height: 260px;
        min-height: 240px;
    }

    .form-card .panel-scroll {
        padding-right: 0;
    }

    .event-edit-form select[multiple] {
        min-height: 140px;
        max-width: 100%;
    }

    .form-actions {
        flex-direction: column;
    }

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

    .modal-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .modal-fullscreen-sm-down {
        height: 100% !important;
        margin: 0 !important;
        max-width: none !important;
        min-height: 100% !important;
        width: 100vw !important;
    }

    .modal.show {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .modal-fullscreen-sm-down .modal-content {
        border: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        height: 100% !important;
        max-height: none !important;
        min-height: 100% !important;
        overflow: hidden;
    }

    .modal-dialog-scrollable.modal-fullscreen-sm-down .modal-content {
        max-height: none !important;
    }

    .modal-fullscreen-sm-down .modal-content > form {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        height: 100%;
        min-height: 0;
    }

    .modal-fullscreen-sm-down .modal-header {
        align-items: flex-start;
        flex-shrink: 0;
        gap: 0.75rem;
        padding: 0.9rem 1rem;
    }

    .modal-fullscreen-sm-down .modal-title {
        font-size: 1rem !important;
        line-height: 1.25;
        word-break: break-word;
    }

    .modal-fullscreen-sm-down .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 1rem;
    }

    .modal-fullscreen-sm-down .modal-body .row {
        --bs-gutter-x: 0;
    }

    .modal-fullscreen-sm-down .modal-body .form-control,
    .modal-fullscreen-sm-down .modal-body .form-select,
    .modal-fullscreen-sm-down .modal-body textarea,
    .modal-fullscreen-sm-down .modal-body input {
        box-sizing: border-box;
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    .modal-fullscreen-sm-down .modal-body [class*="col-"] {
        min-width: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .modal-fullscreen-sm-down .modal-body select.form-select {
        display: block !important;
        max-width: calc(100vw - 2rem) !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .modal-fullscreen-sm-down .modal-body select.form-select option {
        max-width: calc(100vw - 2rem);
        white-space: normal;
    }

    .modal-fullscreen-sm-down .modal-footer {
        background: var(--brand-surface);
        flex-shrink: 0;
        padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom));
        position: relative;
        z-index: 2;
    }

    .modal-fullscreen-sm-down .modal-footer .btn {
        min-height: 44px;
    }

    .modal-fullscreen-sm-down .detail-grid > [class*="col-"],
    .modal-fullscreen-sm-down .modal-body .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
    }

    .modal-fullscreen-sm-down .expense-total-box {
        border-radius: 0.75rem;
        padding: 0.85rem;
    }

    .modal-fullscreen-sm-down .expense-total-box strong {
        font-size: 1.05rem;
        overflow-wrap: anywhere;
    }

    .modal-fullscreen-sm-down input[type="file"] {
        font-size: 0.85rem;
        white-space: normal;
    }

    .modal-footer .btn,
    .modal-footer form,
    .modal-footer form .btn {
        width: 100%;
    }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .landing-dashboard {
        display: flex;
        flex-direction: column;
    }

    .machines-panel,
    .reports-panel {
        flex: 1 1 0;
    }
}
