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

:root {
    color-scheme: light;
    --bg: #f4f8ef;
    --bg-deep: #edf5e4;
    --panel: #ffffff;
    --line: #d7e4cb;
    --line-strong: #bfd3ae;
    --text: #1f2f1e;
    --muted: #587054;
    --accent: #8bbc3a;
    --accent-dark: #6f9f27;
    --accent-soft: #f1f8e6;
    --danger: #b93232;
    --ok: #167a45;
    --warn: #a06716;
    --info: #2d8d3f;
    --shadow-sm: 0 6px 16px rgba(48, 87, 34, 0.08);
    --shadow-md: 0 14px 28px rgba(48, 87, 34, 0.12);
    --radius-lg: 14px;
    --radius-md: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Manrope", "Segoe UI", sans-serif;
    background:
        radial-gradient(1200px 420px at 5% -10%, #e4f1d6 0%, rgba(228, 241, 214, 0) 70%),
        radial-gradient(900px 340px at 95% -12%, #dcedca 0%, rgba(220, 237, 202, 0) 70%),
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 240px);
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
}

a,
a:visited,
a:hover,
a:focus {
    color: var(--accent-dark);
    text-decoration: none;
}

a.btn,
a.btn:visited,
a.btn:hover,
a.btn:focus {
    color: var(--text);
}

a.btn-primary,
a.btn-primary:visited,
a.btn-primary:hover,
a.btn-primary:focus {
    color: #fff;
}

a.btn-danger,
a.btn-danger:visited,
a.btn-danger:hover,
a.btn-danger:focus {
    color: var(--danger);
}

a.icon-btn,
a.icon-btn:visited,
a.icon-btn:hover,
a.icon-btn:focus {
    color: var(--text);
}

a.icon-btn-danger,
a.icon-btn-danger:visited,
a.icon-btn-danger:hover,
a.icon-btn-danger:focus {
    color: var(--danger);
}

body.ui-font-sm {
    font-size: 14px;
}

body.ui-font-lg {
    font-size: 16px;
}

.wrap {
    max-width: 1320px;
    margin: 0 auto;
    padding: 18px;
}

.topbar {
    position: sticky;
    top: 12px;
    z-index: 30;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 1;
    min-width: 160px;
}

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

.topbar-controls .inline-form {
    margin-left: 8px;
}

.brand {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: #284423;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

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

.brand-text {
    line-height: 1.1;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 7px 10px;
    line-height: 1.2;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.nav a:hover {
    border-color: #c8dcb4;
    background: var(--accent-soft);
    transform: translateY(-1px);
}

.nav a.is-active {
    border-color: var(--accent);
    background: linear-gradient(180deg, #97c84b 0%, #7faf2f 100%);
    color: #fff;
    box-shadow: 0 6px 14px rgba(127, 175, 47, 0.28);
}

.nav-drawer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.nav-drawer a {
    font-size: 14px;
    padding: 10px 11px;
    border-color: #dce8cf;
    background: #f7fbf2;
    color: #2f4a2b;
}

.nav-drawer-group {
    border: 1px solid #dce8cf;
    border-radius: var(--radius-md);
    background: #f7fbf2;
    padding: 7px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-drawer-group__title {
    font-size: 12px;
    font-weight: 800;
    color: #3c5b35;
    padding: 2px 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.nav-drawer-group.is-active .nav-drawer-group__title {
    color: #2d4827;
}

.nav-drawer a.nav-sub {
    background: #ffffff;
    border-color: #e0ebd4;
    margin-left: 6px;
}

.nav-user {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

.menu-toggle {
    min-width: 110px;
}

.settings-toggle {
    min-width: 42px;
    padding: 8px 10px;
    font-size: 18px;
    line-height: 1;
}

.menu-drawer {
    position: fixed;
    inset: 0;
    background: rgba(29, 46, 25, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 80;
}

.menu-drawer.is-open {
    opacity: 1;
    pointer-events: auto;
}

.menu-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: min(390px, 94vw);
    background: linear-gradient(180deg, #ffffff 0%, #f6fbf1 100%);
    border-left: 1px solid var(--line);
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
    padding: 14px;
    transform: translateX(100%);
    transition: transform .24s ease;
    overflow-y: auto;
    box-shadow: -18px 0 40px rgba(28, 44, 21, 0.25);
}

.menu-drawer.is-open .menu-drawer__panel {
    transform: translateX(0);
}

.menu-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e4eddc;
}

.menu-drawer__close {
    width: 32px;
    height: 32px;
    font-size: 18px;
}

.menu-section {
    padding: 10px 0;
    border-bottom: 1px solid #e4eddc;
}

.menu-section:last-child {
    border-bottom: none;
}

.menu-section__title {
    font-size: 13px;
    font-weight: 800;
    color: #4f6542;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.ui-settings {
    display: grid;
    gap: 10px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    animation: panel-rise .22s ease;
}

.panel-soft {
    background: #f7fbf2;
}

.panel-compact {
    padding: 12px;
}

.form-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 12px;
    background: #fff;
}

.generation-box {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #f9fcf4;
    padding: 12px;
}

.generation-box__title {
    font-weight: 800;
    margin-bottom: 8px;
}

.status {
    margin-bottom: 12px;
    background: #e8f9ef;
    border: 1px solid #b4e6c8;
    border-left: 4px solid var(--ok);
    color: var(--ok);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.actions-reset {
    margin: 0;
}

.actions-inline-tight {
    margin: 0;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

.section-head {
    justify-content: space-between;
    align-items: center;
}

.btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: background .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.btn:hover {
    border-color: var(--line-strong);
    background: #f7fbf2;
    transform: translateY(-1px);
}

.btn-primary {
    border-color: var(--accent);
    background: linear-gradient(180deg, #97c84b 0%, #7faf2f 100%);
    color: #fff;
    box-shadow: 0 7px 15px rgba(127, 175, 47, 0.26);
}

.btn-primary:hover {
    border-color: var(--accent-dark);
    background: linear-gradient(180deg, #89b73e 0%, #719f27 100%);
}

.btn-danger {
    border-color: #e7b9b9;
    color: var(--danger);
    background: #fff7f7;
}

.icon-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    transition: all .14s ease;
}

.icon-btn:hover {
    border-color: #b8c3d6;
    background: #f4faee;
    transform: translateY(-1px);
}

.icon-btn-danger {
    color: var(--danger);
    border-color: #e5b4b4;
    background: #fff9f9;
}

.icon-btn-danger:hover {
    background: #fff1f1;
    border-color: #d99b9b;
}

.inline-icon {
    display: inline-flex;
    margin: 0;
}

.inline {
    display: inline;
}

.inline-form {
    display: inline;
    margin: 0;
}

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

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-end {
    justify-content: flex-end;
}

.field-full {
    grid-column: 1 / -1;
}

.generation-inline-grid {
    display: grid;
    gap: 12px;
}

.generation-inline-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.generation-inline-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-grid {
    grid-template-columns: minmax(260px, 2fr) minmax(130px, 1fr) minmax(130px, 1fr);
    gap: 8px 10px;
    align-items: start;
}

.product-grid .field {
    gap: 4px;
}

.product-grid .field-product-select {
    grid-column: auto;
}

.product-grid .field-main-1 {
    grid-column: 1 / span 2;
}

.product-grid .field-main-2 {
    grid-column: 3;
}

.product-grid .field-main-3,
.product-grid .field-storage-1,
.product-grid .field-exp-1 {
    grid-column: 1;
}

.product-grid .field-main-4,
.product-grid .field-storage-2,
.product-grid .field-exp-2 {
    grid-column: 2;
}

.product-grid .field-main-5,
.product-grid .field-storage-3,
.product-grid .field-exp-3 {
    grid-column: 3;
}

.product-grid label {
    font-size: 12px;
}

.product-grid input,
.product-grid select {
    padding: 7px 9px;
    font-size: 13px;
}

@media (max-width: 1200px) {
    .product-grid {
        grid-template-columns: minmax(220px, 1.6fr) minmax(120px, 1fr) minmax(120px, 1fr);
    }

    .generation-inline-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .generation-inline-grid,
    .generation-inline-grid-2,
    .generation-inline-grid-3 {
        grid-template-columns: 1fr;
    }
}

label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: 14px;
    background: #ffffff;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #9cc57f;
    box-shadow: 0 0 0 3px rgba(127, 175, 47, 0.18);
    background: #fdfefe;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

textarea.textarea-70 {
    min-height: 70px;
}

textarea.textarea-60 {
    min-height: 60px;
}

.input-compact {
    width: 84px;
    padding: 6px 8px;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}

thead th {
    color: #506648;
    font-weight: 800;
    background: #f5faef;
    position: sticky;
    top: 0;
    z-index: 1;
}

tbody tr:nth-child(even) {
    background: #fbfef8;
}

tbody tr:hover {
    background: #f3f9ea;
}

body.ui-density-compact th,
body.ui-density-compact td {
    padding: 7px 6px;
}

body.ui-density-compact input,
body.ui-density-compact textarea,
body.ui-density-compact select,
body.ui-density-compact .btn {
    padding-top: 7px;
    padding-bottom: 7px;
}

body.ui-density-comfy th,
body.ui-density-comfy td {
    padding: 12px 10px;
}

body.ui-density-comfy input,
body.ui-density-comfy textarea,
body.ui-density-comfy select,
body.ui-density-comfy .btn {
    padding-top: 11px;
    padding-bottom: 11px;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--line);
    background: #f7fbf2;
}

.badge-on,
.badge-success {
    color: var(--ok);
    border-color: #b4e6c8;
    background: #e8f9ef;
}

.badge-off,
.badge-danger {
    color: #8d2f2f;
    border-color: #e9c5c5;
    background: #fff2f2;
}

.badge-info {
    color: #2f7a2c;
    border-color: #c6e0aa;
    background: #eff8e4;
}

.badge-warn {
    color: #8a5b12;
    border-color: #eed8b2;
    background: #fff8e9;
}

.badge-neutral {
    color: #506648;
    border-color: #cfdec0;
    background: #f1f8e8;
}

.badge.deleted,
.badge-folder-deleted {
    color: #8d2f2f;
    border-color: #e4bcbc;
    background: #fff2f2;
}

.badge-folder-production {
    color: #8a5b12;
    border-color: #eed8b2;
    background: #fff8e9;
}

.badge-folder-partners {
    color: #2f7a2c;
    border-color: #c6e0aa;
    background: #eff8e4;
}

.badge-folder-storage,
.badge-folder-buhg,
.badge-folder-adv,
.badge-folder-template {
    color: #3f5b35;
    border-color: #cfdec0;
    background: #f1f8e8;
}

.kpi-label {
    font-size: 13px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 800;
    margin-top: 6px;
}

.errors {
    margin: 0 0 12px 0;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid #efc1c1;
    border-left: 4px solid #cd5959;
    background: #fff4f4;
    color: #8d2f2f;
    box-shadow: var(--shadow-sm);
}

.errors li {
    margin: 4px 0;
}

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

.text-13 {
    font-size: 13px;
}

.text-12 {
    font-size: 12px;
}

.stack-4 {
    display: grid;
    gap: 4px;
}

.stack-10 {
    display: grid;
    gap: 10px;
}

.divider {
    margin: 16px 0;
    border: none;
    border-top: 1px solid var(--line);
}

.title-reset {
    margin: 0;
}

.title-topless {
    margin-top: 0;
}

.subtitle {
    margin-top: 4px;
}

.mt-0 {
    margin-top: 0;
}

.mt-12 {
    margin-top: 12px;
}

.mt-14 {
    margin-top: 14px;
}

.mt-4 {
    margin-top: 4px;
}

.mb-12 {
    margin-bottom: 12px;
}

.mb-14 {
    margin-bottom: 14px;
}

.maxw-120 {
    max-width: 120px;
}

.maxw-170 {
    max-width: 170px;
}

.maxw-180 {
    max-width: 180px;
}

.maxw-220 {
    max-width: 220px;
}

.maxw-240 {
    max-width: 240px;
}

.maxw-300 {
    max-width: 300px;
}

.maxw-320 {
    max-width: 320px;
}

.maxw-360 {
    max-width: 360px;
}

.maxw-420 {
    max-width: 420px;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.pager__summary {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.pager__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.pager__item {
    display: inline-flex;
}

.pager__link {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 14px;
    line-height: 1;
    font-weight: 700;
}

.pager__item:not(.disabled) .pager__link:hover {
    border-color: #b8c3d6;
    background: #f1f7ff;
}

.pager__item.active .pager__link {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.pager__item.disabled .pager__link {
    color: #98a3b3;
    background: #f8fafc;
    cursor: not-allowed;
}

.pager svg {
    width: 1rem;
    height: 1rem;
    max-width: 1rem;
    max-height: 1rem;
}

@keyframes panel-rise {
    from {
        opacity: .72;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1100px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .wrap {
        padding: 12px;
    }

    .grid,
    .grid-cols-2,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        top: 8px;
    }

    .topbar-right {
        min-width: 100%;
    }

    .topbar-controls {
        width: 100%;
        justify-content: flex-end;
    }

    .topbar-controls .inline-form {
        margin-left: 6px;
    }

    .menu-toggle {
        min-width: 98px;
    }

    .settings-toggle {
        min-width: 38px;
        padding: 7px 8px;
        font-size: 16px;
    }

    .brand-logo {
        width: 30px;
        height: 30px;
    }

    .menu-drawer__panel {
        width: min(350px, 94vw);
    }

    table {
        font-size: 13px;
    }

    .icon-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .pager {
        gap: 8px;
    }

    .pager__link {
        min-width: 30px;
        height: 30px;
        padding: 0 8px;
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

body.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(850px 320px at 20% 12%, #dfe9ff 0%, rgba(223, 233, 255, 0) 70%),
        linear-gradient(180deg, #eff8e4 0%, #f4f7fc 100%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.auth-title {
    margin: 0 0 8px;
    font-size: 24px;
}

.auth-subtitle {
    margin: 0 0 16px;
    color: var(--muted);
}

.auth-card label {
    display: block;
    margin: 10px 0 6px;
}

.auth-submit {
    width: 100%;
    margin-top: 16px;
}

.auth-error {
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid #efc7c7;
    background: #fff2f2;
    color: #9b3b3b;
    border-radius: 10px;
    font-size: 14px;
}

.auth-hint {
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
}
