:root {
    --sidebar-width: 270px;
}

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

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
}

.sidebar {
    background: #101820;
    color: #fff;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 22px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
}

.sidebar-close {
    flex: 0 0 auto;
}

.sidebar nav {
    flex: 1;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, .76);
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.sidebar-mobile-actions {
    border-top: 1px solid rgba(255, 255, 255, .14);
    padding: 14px 4px 0;
}

.sidebar-user {
    color: rgba(255, 255, 255, .82);
    font-weight: 600;
    margin-bottom: 10px;
    padding: 0 8px;
}

.sidebar nav a.active,
.sidebar nav a:hover {
    background: rgba(255, 255, 255, .11);
    color: #fff;
}

.main {
    min-width: 0;
}

.topbar {
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search {
    flex: 1;
    max-width: 560px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.flag-icon {
    width: 24px;
    height: 16px;
    object-fit: cover;
    display: block;
}

.flag-frame {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 22px;
    border: 1px solid var(--bs-border-color);
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
    flex: 0 0 auto;
}

.language-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.content {
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.page-actions .btn,
.table-actions .btn,
.alert-card-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
}

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tabs .nav-link {
    white-space: nowrap;
    border-radius: 8px 8px 0 0;
}

.metric-card {
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    padding: 16px;
    background: var(--bs-tertiary-bg);
    min-height: 112px;
}

.metric-card .label {
    color: var(--bs-secondary-color);
    font-size: .85rem;
}

.metric-card .value {
    font-size: 1.35rem;
    font-weight: 700;
    margin-top: 8px;
}

.chart-card .card-body {
    height: 260px;
}

.chart-card canvas {
    width: 100% !important;
    height: 100% !important;
}

.metric-positive {
    border-left: 4px solid #198754;
}

.metric-warning {
    border-left: 4px solid #ffc107;
}

.metric-negative {
    border-left: 4px solid #dc3545;
}

.metric-neutral {
    border-left: 4px solid var(--bs-border-color);
}

.vehicle-thumb {
    width: 76px;
    height: 54px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bs-tertiary-bg);
}

.photo-main {
    width: 100%;
    max-height: 430px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--bs-tertiary-bg);
}

.table-actions {
    white-space: nowrap;
}

.target-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    color: var(--bs-secondary-color);
    font-size: .92rem;
}

.target-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.alert-card-list {
    display: none;
}

.alert-card {
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background: var(--bs-body-bg);
    padding: 14px;
}

.alert-card.is-unread {
    border-left: 4px solid var(--bs-warning);
}

.alert-card + .alert-card {
    margin-top: 12px;
}

.alert-card-top,
.alert-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.alert-card-top {
    justify-content: space-between;
    margin-bottom: 10px;
}

.alert-card-title {
    font-size: 1rem;
    margin: 0 0 6px;
}

.alert-card-message {
    color: var(--bs-secondary-color);
    margin: 0 0 12px;
}

.alert-card-actions form {
    margin: 0;
}

.reservation-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.reservation-chip,
.calendar-event {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    color: #fff;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
}

.reservation-viewing {
    background: #0d6efd;
}

.reservation-sale {
    background: #198754;
}

.reservation-transport {
    background: #fd7e14;
}

.reservation-general {
    background: #6f42c1;
}

.reservation-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bs-body-bg);
}

.calendar-weekday {
    padding: 10px;
    background: var(--bs-tertiary-bg);
    border-right: 1px solid var(--bs-border-color);
    font-weight: 700;
    font-size: .9rem;
}

.calendar-day {
    min-height: 116px;
    padding: 8px;
    border-top: 1px solid var(--bs-border-color);
    border-right: 1px solid var(--bs-border-color);
}

.calendar-day.is-empty {
    background: var(--bs-tertiary-bg);
}

.calendar-date {
    font-weight: 700;
    margin-bottom: 6px;
}

.calendar-event {
    display: flex;
    width: 100%;
    margin-bottom: 5px;
    border-radius: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 0;
    cursor: grab;
    text-align: left;
}

.calendar-event:active {
    cursor: grabbing;
}

.calendar-day.drop-target {
    outline: 2px dashed var(--bs-primary);
    outline-offset: -6px;
    background: rgba(13, 110, 253, .08);
}

.calendar-more {
    color: var(--bs-secondary-color);
    font-size: .85rem;
}

.quick-status-form {
    min-width: 160px;
}

.dashboard-focus {
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    padding: 16px;
    background: var(--bs-body-bg);
}

.dashboard-focus-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.dashboard-accordion .accordion-item {
    border-color: var(--bs-border-color);
}

.dashboard-accordion .accordion-button {
    font-weight: 700;
}

.dashboard-accordion .accordion-body {
    background: var(--bs-body-bg);
}

.costs-sort-panel {
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    padding: 14px 16px;
    background: var(--bs-body-bg);
}

.costs-sort-control {
    min-width: 280px;
}

.costs-search-control {
    flex: 1 1 320px;
    min-width: 260px;
}

.costs-vehicle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.costs-vehicle-card a {
    display: block;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    color: var(--bs-body-color);
    background: var(--bs-body-bg);
    text-decoration: none;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.costs-vehicle-card a:hover {
    transform: translateY(-2px);
    border-color: rgba(13, 110, 253, .45);
    box-shadow: 0 10px 26px rgba(15, 23, 42, .08);
}

.costs-card-photo {
    height: 132px;
    background: var(--bs-tertiary-bg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-secondary-color);
    font-size: 2rem;
}

.costs-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.costs-card-body {
    padding: 14px;
}

.costs-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.costs-card-top strong {
    font-size: 1.05rem;
    line-height: 1.2;
}

.costs-card-top span {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 3px 8px;
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    font-size: .8rem;
}

.costs-card-meta {
    min-height: 22px;
    margin-bottom: 12px;
}

.costs-card-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.costs-card-metrics div {
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    padding: 8px;
    background: var(--bs-tertiary-bg);
}

.costs-card-metrics small,
.costs-card-metrics b {
    display: inline;
}

.costs-card-metrics small {
    color: var(--bs-secondary-color);
    font-size: .76rem;
    line-height: 1.15;
    margin-right: 4px;
}

.costs-card-metrics b {
    font-size: .92rem;
    line-height: 1.2;
}

.costs-vehicle-card.active a {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .16), 0 12px 30px rgba(13, 110, 253, .10);
}

@media (max-width: 991.98px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: fixed;
        left: -280px;
        width: var(--sidebar-width);
        z-index: 20;
        transition: left .2s ease;
        overflow-y: auto;
    }
    .sidebar.open {
        left: 0;
    }
    .topbar {
        padding: 8px 10px;
        gap: 8px;
    }
    .content {
        padding: 16px;
    }
    .page-header {
        align-items: flex-start;
        margin-bottom: 18px;
    }
    .page-header .h3 {
        flex: 1 1 auto;
        min-width: 0;
    }
    .page-actions {
        flex: 0 0 auto;
        max-width: 58%;
    }
    .page-actions .btn {
        min-height: 42px;
    }
    .btn-icon-label span {
        display: none;
    }
    .btn-icon-label {
        width: 38px;
        height: 38px;
        padding: 0;
    }
    .nav-tabs {
        margin-left: -16px;
        margin-right: -16px;
        padding: 0 16px 1px;
        border-bottom: 1px solid var(--bs-border-color);
    }
    .nav-tabs .nav-link {
        background: var(--bs-tertiary-bg);
        border: 1px solid var(--bs-border-color);
        border-radius: 8px;
        margin-bottom: 8px;
    }
    .nav-tabs .nav-link.active {
        background: var(--bs-primary);
        border-color: var(--bs-primary);
        color: #fff;
    }
    .alert-table-card {
        display: none;
    }
    .alert-card-list {
        display: block;
    }
    .search {
        max-width: none;
        min-width: 0;
        flex: 1 1 auto;
    }
    .search .form-control {
        min-width: 0;
        padding-left: 10px;
        padding-right: 10px;
    }
    .user-menu {
        display: none;
    }
    .language-toggle span {
        display: none;
    }
    .language-toggle .flag-frame {
        display: inline-flex;
    }
    .language-toggle::after {
        display: none;
    }
    .topbar > .btn,
    .topbar > a.btn,
    .language-toggle {
        width: 42px;
        height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 42px;
        padding: 0;
    }
    .flag-icon {
        width: 24px;
        height: 16px;
    }
    .flag-frame {
        width: 30px;
        height: 22px;
        border-radius: 5px;
    }
    .reservation-calendar {
        display: block;
        border: 0;
        background: transparent;
    }
    .calendar-weekday,
    .calendar-day.is-empty {
        display: none;
    }
    .calendar-day {
        min-height: 0;
        margin-bottom: 10px;
        border: 1px solid var(--bs-border-color);
        border-radius: 8px;
        background: var(--bs-body-bg);
    }
    .calendar-day:has(.calendar-event) {
        display: block;
    }
    .calendar-day:not(:has(.calendar-event)) {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .page-actions {
        width: 100%;
        max-width: none;
        justify-content: flex-start;
    }
    .page-actions .btn:not(.btn-icon-label) {
        flex: 1 1 0;
        min-width: 0;
    }
    .vehicle-actions {
        flex: 1 1 100%;
        justify-content: flex-start;
    }
    .alert-card-actions .btn span {
        display: none;
    }
    .alert-card-actions .btn {
        width: 38px;
        height: 38px;
        padding: 0;
    }
}

@media (min-width: 992px) {
    .sidebar-mobile-actions {
        display: none;
    }
    .alert-table-card {
        display: block;
    }
}

@media print {
    .sidebar,
    .topbar,
    .btn,
    form,
    .nav-tabs {
        display: none !important;
    }
    .app-shell {
        display: block;
    }
    .content {
        padding: 0;
    }
    .card {
        border: 0;
    }
}
