:root {
    --bg-primary: #eceeef;
    --bg-secondary: #f7f8f9;
    --surface: #ffffff;
    --surface-strong: #eff2f4;
    --accent: #25a9bf;
    --accent-strong: #198da1;
    --text-primary: #5f6166;
    --text-secondary: #80848b;
    --surface-border: rgba(95, 97, 102, 0.18);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background:
        radial-gradient(1150px 560px at 18% -20%, rgba(37, 169, 191, 0.16), transparent 60%),
        radial-gradient(980px 530px at 86% -12%, rgba(95, 97, 102, 0.1), transparent 58%),
        var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    font-family: "Source Sans 3", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent-strong);
}

a:hover {
    color: var(--accent);
}

.app-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 246, 248, 0.94));
    border-bottom: 1px solid var(--surface-border);
    backdrop-filter: blur(10px);
    gap: .75rem;
    min-height: 70px;
    display: grid !important;
    grid-template-columns: auto 1fr auto;
    align-items: center;
}

.app-header-start,
.app-header-actions {
    min-width: 0;
    position: relative;
    z-index: 1;
}

.app-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    text-decoration: none;
    min-width: 0;
    justify-self: center;
}

.app-logo-img {
    height: 46px;
    max-width: 220px;
    width: auto;
    display: block;
    object-fit: contain;
}

.app-icon-button {
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-icon-button svg {
    width: 1.1rem;
    height: 1.1rem;
    display: block;
}

.app-power-icon {
    display: inline-block;
    font-size: 1.1rem;
    line-height: 1;
    transform: translateY(-.03rem);
}

.app-locale-button {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    line-height: 1;
    min-height: 2.2rem;
    height: 2.2rem;
    padding-inline: .55rem;
}

.app-locale-button svg {
    width: 1rem;
    height: auto;
    display: block;
    border-radius: .15rem;
    box-shadow: 0 0 0 1px rgba(95, 97, 102, 0.14);
}

.app-shell {
    display: flex;
    min-height: calc(100vh - 70px);
    position: relative;
}

.app-sidebar {
    width: 260px;
    background: rgba(245, 247, 249, 0.98);
    border-right: 1px solid var(--surface-border);
    transition: width .2s ease;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 70px);
    scrollbar-width: thin;
    scrollbar-color: rgba(95, 97, 102, 0.45) rgba(95, 97, 102, 0.08);
}

.app-sidebar.collapsed {
    width: 72px;
}

.app-sidebar::-webkit-scrollbar {
    width: 8px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: rgba(95, 97, 102, 0.08);
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(95, 97, 102, 0.42);
    border-radius: 999px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(95, 97, 102, 0.56);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 35, 0.38);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 999;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.app-sidebar .nav-link {
    color: var(--text-primary);
    border-radius: .62rem;
    margin-bottom: .25rem;
    border: 1px solid transparent;
}

.app-sidebar .nav-link.active,
.app-sidebar .nav-link:hover {
    background: rgba(37, 169, 191, 0.14);
    border-color: rgba(37, 169, 191, 0.36);
    color: #435056;
}

.app-content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
}

.card,
.accordion-item,
.list-group-item,
.table,
.modal-content {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--surface-border);
}

.accordion-button {
    background: var(--surface);
    color: var(--text-primary);
}

.accordion-button:not(.collapsed) {
    background: rgba(37, 169, 191, 0.1);
    color: #4d5960;
}

.table {
    --bs-table-bg: var(--surface);
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--surface-border);
    --bs-table-striped-bg: rgba(95, 97, 102, 0.05);
    --bs-table-striped-color: var(--text-primary);
}

.table-dark {
    --bs-table-bg: var(--surface);
    --bs-table-color: var(--text-primary);
    --bs-table-striped-bg: rgba(95, 97, 102, 0.05);
}

.form-control,
.form-select,
.input-group-text,
.form-check-input {
    background: #ffffff;
    color: var(--text-primary);
    border-color: rgba(95, 97, 102, 0.26);
}

.form-control::placeholder,
.form-select::placeholder {
    color: rgba(128, 132, 139, 0.92);
}

.form-control:focus,
.form-select:focus {
    color: var(--text-primary);
    background: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(37, 169, 191, 0.18);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.btn {
    font-weight: 600;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: var(--accent-strong) !important;
    border-color: var(--accent-strong) !important;
    color: #ffffff !important;
}

.btn-secondary {
    background: #f2f3f5;
    border-color: rgba(95, 97, 102, 0.3);
    color: #5f6166;
}

.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:active {
    background: #e4e8eb !important;
    border-color: rgba(95, 97, 102, 0.45) !important;
    color: #4f5459 !important;
}

.btn-outline-light {
    border-color: rgba(95, 97, 102, 0.36);
    color: #5f6166;
}

.btn-outline-light:hover {
    background: #f2f3f5;
    border-color: rgba(95, 97, 102, 0.5);
    color: #4f5459;
}

.btn-lime {
    background: #63656b;
    border-color: #63656b;
    color: #ffffff;
}

.btn-lime:hover,
.btn-lime:focus,
.btn-lime:active {
    background: #565960 !important;
    border-color: #565960 !important;
    color: #ffffff !important;
}

.alert-success {
    background: rgba(37, 169, 191, 0.12);
    border-color: rgba(37, 169, 191, 0.35);
    color: #4e5860;
}

.alert-danger {
    background: rgba(207, 74, 74, 0.12);
    border-color: rgba(214, 102, 102, 0.5);
    color: #7a3a3a;
}

.text-muted,
.text-secondary,
.text-light-emphasis {
    color: var(--text-secondary) !important;
}

.badge.text-bg-secondary {
    background-color: rgba(37, 169, 191, 0.12) !important;
    color: #4f5b63 !important;
    border: 1px solid rgba(37, 169, 191, 0.28);
}

.badge.text-bg-info {
    background-color: rgba(95, 97, 102, 0.1) !important;
    color: #5f6166 !important;
    border: 1px solid rgba(95, 97, 102, 0.3);
}

.progress {
    background: var(--surface-strong);
    border: 1px solid rgba(95, 97, 102, 0.18);
}

.progress-bar {
    background-color: var(--accent);
}

.nutrition-actions-card {
    border-style: dashed;
}

.nutrition-quick-actions {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.nutrition-quick-actions .btn {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
}

.barcode-scanner-preview {
    border: 1px solid rgba(95, 97, 102, 0.16);
    border-radius: .75rem;
    overflow: hidden;
    background: #111519;
}

.barcode-scanner-reader {
    width: 100%;
    min-height: 260px;
}

.barcode-scanner-reader > div {
    width: 100% !important;
}

.barcode-scanner-reader video,
.barcode-scanner-reader img {
    width: 100%;
    display: block;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.barcode-scanner-preview video {
    width: 100%;
    display: block;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.media-image {
    border: 1px solid rgba(95, 97, 102, 0.13);
    background: #ffffff;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    justify-content: center;
    margin-bottom: 0;
}

.pagination .page-item {
    list-style: none;
}

.pagination .page-link {
    border-radius: .7rem;
    border: 1px solid rgba(95, 97, 102, 0.22);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.96);
    min-width: 2.35rem;
    text-align: center;
    box-shadow: 0 8px 18px rgba(95, 97, 102, 0.08);
}

.pagination .page-link:hover,
.pagination .page-link:focus {
    color: var(--accent-strong);
    background: rgba(37, 169, 191, 0.08);
    border-color: rgba(37, 169, 191, 0.34);
    box-shadow: 0 0 0 .2rem rgba(37, 169, 191, 0.12);
}

.pagination .page-item.active .page-link {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
}

.pagination .page-item.disabled .page-link {
    color: rgba(128, 132, 139, 0.9);
    background: rgba(242, 243, 245, 0.92);
    border-color: rgba(95, 97, 102, 0.14);
    box-shadow: none;
}

.media-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 190px;
    padding: 1rem;
    border: 1px solid rgba(95, 97, 102, 0.16);
    border-radius: .75rem;
    background:
        linear-gradient(130deg, rgba(37, 169, 191, 0.08), rgba(255, 255, 255, 0.92) 54%),
        #f6f7f8;
}

.media-placeholder img {
    width: min(270px, 74%);
    height: auto;
    max-height: 90px;
    object-fit: contain;
}

.media-placeholder-card {
    border-top-left-radius: calc(.375rem - 1px);
    border-top-right-radius: calc(.375rem - 1px);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.install-banner-card {
    background: #ffffff;
    border: 1px solid rgba(37, 169, 191, 0.26) !important;
    max-width: min(96vw, 760px);
}

.install-banner-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-right: auto;
}

.install-logo {
    height: 44px;
    width: auto;
    display: block;
    object-fit: contain;
}

.install-title {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.1;
}

.install-subtitle {
    color: var(--text-secondary);
    font-size: .84rem;
}

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        top: 70px;
        left: -270px;
        width: 260px !important;
        height: calc(100vh - 70px);
        z-index: 1000;
        transition: left .25s ease;
    }

    .app-sidebar.mobile-open {
        left: 0;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: .55rem .75rem !important;
        gap: .5rem;
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .app-header-start {
        gap: .45rem !important;
    }

    .app-header-actions {
        gap: .4rem !important;
    }

    .app-content {
        padding: 1rem;
    }

    .app-logo-img {
        height: 34px;
        max-width: 132px;
    }

    #sidebarToggle {
        padding-inline: .7rem;
        font-size: .875rem;
    }

    .app-header .btn {
        min-height: 2.05rem;
    }

    .app-locale-button {
        gap: .25rem;
        min-height: 2.05rem;
        height: 2.05rem;
        padding-inline: .5rem;
    }

    .app-locale-button svg {
        width: .9rem;
    }

    .app-power-icon {
        font-size: 1rem;
    }

    .media-placeholder {
        min-height: 150px;
    }

    .media-placeholder img {
        max-height: 72px;
    }

    .install-banner-brand {
        width: 100%;
    }

    .install-banner-card .card-body {
        padding: .75rem;
    }
}
