:root {
    --brand-50: #f5f1ff;
    --brand-100: #ece4ff;
    --brand-200: #dccbff;
    --brand-300: #cab0ff;
    --brand-400: #b590ff;
    --brand-500: #9a6dff;
    --brand-600: #7d4ddb;
    --brand-700: #6439b4;
    --ink-900: #232032;
    --ink-700: #4a455d;
    --ink-500: #78718f;
    --ink-300: #a49eb7;
    --surface-0: #ffffff;
    --surface-1: #fcfbff;
    --surface-2: #f4f2fb;
    --border: #e6e1f3;
    --danger: #d84f6a;
    --success: #239d77;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 9px;
    --shadow-soft: 0 12px 30px rgba(63, 35, 124, 0.08);
    --shadow-strong: 0 18px 50px rgba(62, 30, 121, 0.12);
    --card-radius: 20px;
    --card-border: #e5ddf4;
    --card-border-strong: #ece5f9;
    --card-bg: linear-gradient(180deg, #fdfbff 0%, #f7f3ff 100%);
    --card-head-bg: linear-gradient(180deg, #fcf9ff 0%, #f4effd 100%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink-900);
    font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
    background: radial-gradient(1200px 800px at 5% 0%, #f7f3ff 0%, #f0eef8 40%, #edeaf5 100%);
}

.app-layout {
    min-height: 100vh;
    display: flex;
    position: relative;
}

.app-sidebar {
    width: 286px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #faf7ff 0%, #f3effb 100%);
    border-right: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 10;
}

.brand-box {
    border: 1px solid #ece7fa;
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-lg);
    padding: 0.8rem 0.9rem;
    box-shadow: 0 6px 18px rgba(72, 40, 130, 0.06);
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.brand-subtitle {
    color: var(--ink-500);
    font-size: 0.78rem;
}

.menu-group-title {
    color: var(--ink-500);
    font-size: 0.71rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin: 0.3rem 0 0.3rem;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--ink-700);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.53rem 0.58rem;
    font-size: 0.93rem;
    transition: all 0.16s ease;
}

.menu-link:hover {
    background: rgba(167, 126, 252, 0.09);
    border-color: rgba(168, 126, 251, 0.2);
    color: #563699;
}

.menu-link.active {
    background: linear-gradient(90deg, rgba(161, 112, 255, 0.17), rgba(161, 112, 255, 0.08));
    border-color: rgba(161, 112, 255, 0.34);
    color: #4c2e8b;
    font-weight: 600;
}

.menu-link .menu-icon {
    width: 1.15rem;
    text-align: center;
    font-size: 0.95rem;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 0.9rem;
}

.user-card {
    border: 1px solid #e7e1f5;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-md);
    padding: 0.7rem;
    margin-bottom: 0.55rem;
}

.user-card .name {
    font-weight: 600;
    font-size: 0.92rem;
}

.user-card .meta {
    color: var(--ink-500);
    font-size: 0.76rem;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid #e7e1f4;
    padding: 0.8rem 1rem;
    position: sticky;
    top: 0;
    z-index: 9;
}

.page-title {
    font-size: 1rem;
    font-weight: 600;
    color: #362f4e;
}

.company-switch {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--ink-500);
    font-size: 0.8rem;
}

.company-switch-form {
    display: grid;
    grid-template-columns: auto minmax(240px, 290px);
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    padding: 0.34rem 0.44rem 0.34rem 0.58rem;
    border: 1px solid #e3dcf4;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(249, 246, 255, 0.94) 100%);
    box-shadow: 0 10px 22px rgba(70, 42, 129, 0.08);
}

.company-switch-label {
    margin: 0;
    white-space: nowrap;
    color: var(--ink-500);
    font-weight: 700;
    font-size: 0.79rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1;
}

.company-switch-select,
.company-switch-fixed {
    min-width: 260px;
    border-radius: 12px;
    border-color: #d8cef0;
    color: #2f2845;
    background-color: #fff;
    font-weight: 600;
    min-height: 42px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.company-switch-select:hover {
    border-color: #cab9f0;
}

.company-switch-select:focus {
    border-color: #b497f8;
    box-shadow: 0 0 0 0.2rem rgba(146, 101, 238, 0.14);
}

.company-switch-fixed {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 0.74rem;
    font-size: 0.87rem;
}

.company-switch-picker {
    position: relative;
    min-width: 260px;
}

.company-switch-trigger {
    width: 100%;
    min-height: 42px;
    border: 1px solid #d8cef0;
    border-radius: 12px;
    background: #fff;
    color: #2f2845;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.72rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.company-switch-trigger:hover {
    border-color: #cab9f0;
    background: #fefcff;
}

.company-switch-trigger:focus-visible {
    outline: none;
    border-color: #b497f8;
    box-shadow: 0 0 0 0.2rem rgba(146, 101, 238, 0.14);
}

.company-switch-trigger[aria-expanded="true"] {
    border-color: #b497f8;
    box-shadow: 0 0 0 0.2rem rgba(146, 101, 238, 0.12);
}

.company-switch-trigger-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.company-switch-trigger-icon {
    color: #61577e;
    font-size: 0.8rem;
    transition: transform 0.15s ease;
}

.company-switch-trigger[aria-expanded="true"] .company-switch-trigger-icon {
    transform: rotate(180deg);
}

.company-switch-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 40;
    border: 1px solid #dfd4f2;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 14px 30px rgba(64, 37, 120, 0.14);
    padding: 0.3rem;
    max-height: 280px;
    overflow: auto;
    display: none;
}

.company-switch-picker.is-open .company-switch-menu {
    display: block;
}

.company-switch-option {
    width: 100%;
    border: 0;
    background: transparent;
    border-radius: 9px;
    color: #352d4f;
    padding: 0.45rem 0.56rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    font-size: 0.86rem;
    font-weight: 500;
    text-align: left;
}

.company-switch-option:hover {
    background: #f5f1ff;
}

.company-switch-option:focus-visible {
    outline: none;
    background: #f1ebff;
}

.company-switch-option-check {
    color: #7b4ee0;
    opacity: 0;
}

.company-switch-option.is-active {
    background: #f2ecff;
    color: #2d2348;
    font-weight: 600;
}

.company-switch-option.is-active .company-switch-option-check {
    opacity: 1;
}

.companies-form-card .card-body {
    padding: 1.15rem 1.2rem;
}

.companies-form-grid .form-label {
    font-weight: 600;
    color: #443c5c;
    margin-bottom: 0.35rem;
}

.companies-form-grid .form-control {
    border-radius: 12px;
}

.companies-active-col {
    display: block;
}

.companies-active-box {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.companies-active-box .form-check-input {
    margin-top: 0;
}

.companies-active-check {
    min-height: 44px;
    margin: 0;
    border: 1px solid #e4dcf4;
    border-radius: 12px;
    background: #fcfaff;
    padding: 0.62rem 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.companies-active-check .form-check-input {
    margin-top: 0;
}

.companies-active-check .form-check-label {
    font-weight: 600;
    color: #4a4263;
}

.companies-form-actions {
    border-top: 1px solid #ede7f8;
    padding-top: 0.9rem;
}

.users-form-card .card-body {
    padding: 1.2rem 1.25rem;
}

.users-form-grid .form-label {
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #443c5c;
}

.users-form-grid .form-control,
.users-form-grid .form-select {
    border-radius: 12px;
}

.users-block {
    height: 100%;
    border: 1px solid #e5ddf5;
    border-radius: 13px;
    background: linear-gradient(180deg, #ffffff 0%, #fbf8ff 100%);
    padding: 0.7rem 0.78rem;
}

.users-top-field {
    min-height: 100%;
}

.users-password-box .form-label,
.users-company-box .form-label,
.users-master-box .form-label {
    margin-bottom: 0.32rem;
}

.users-active-box {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
}

.users-active-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c6388;
    letter-spacing: 0.01em;
}

.users-active-check {
    margin: 0;
}

.users-master-scope {
    border-radius: 12px;
    padding: 0.62rem 0.82rem;
}

.users-company-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.users-company-add-btn {
    border-radius: 999px;
    padding: 0.3rem 0.64rem;
    font-size: 0.76rem;
    white-space: nowrap;
    min-width: 0;
}

.users-form-actions {
    border-top: 1px solid #ede7f8;
    margin-top: 0.95rem;
    padding-top: 0.92rem;
}

.users-form-actions .btn {
    min-width: 128px;
}

.form-contour-grid > [class*="col-"] {
    position: relative;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0.72rem 0.75rem 0.68rem;
    min-height: 100%;
}

.form-contour-grid > [class*="col-"]::before {
    content: "";
    position: absolute;
    inset: 0.24rem;
    border: 1px solid #e4dcf4;
    border-radius: 14px;
    background: linear-gradient(180deg, #fefcff 0%, #f8f4ff 100%);
    z-index: 0;
}

.form-contour-grid > [class*="col-"] > * {
    position: relative;
    z-index: 1;
}

.form-contour-grid > [class*="col-"] .form-label {
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #453d5f;
}

.form-contour-grid > [class*="col-"] .text-muted {
    color: #6e6688 !important;
}

.form-contour-grid > [class*="col-"] .form-control,
.form-contour-grid > [class*="col-"] .form-select {
    background-color: #fff;
}

.form-contour-grid > [class*="col-"] .form-check {
    margin: 0.06rem 0 0;
}

.form-contour-grid > [class*="col-"].contour-skip {
    border: 0;
    background: transparent;
    padding: 0;
}

.form-contour-grid > [class*="col-"].contour-skip::before {
    display: none;
}

.op-create-card {
    padding: 1.15rem 1.2rem;
}

.op-create-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid #ece3fb;
    border-radius: 13px;
    background: linear-gradient(180deg, #fcf9ff 0%, #f7f2ff 100%);
}

.op-create-title {
    font-size: 1rem;
    font-weight: 700;
    color: #342b4d;
}

.op-create-subtitle {
    font-size: 0.83rem;
    color: #6f6688;
}

.op-create-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d9c9ff;
    border-radius: 999px;
    padding: 0.2rem 0.62rem;
    font-size: 0.74rem;
    font-weight: 600;
    color: #6b4cb4;
    background: #fff;
    white-space: nowrap;
}

.op-create-grid .form-label {
    font-weight: 600;
    color: #453d5f;
    margin-bottom: 0.34rem;
}

.op-create-grid .form-control,
.op-create-grid .form-select {
    border-radius: 11px;
}

.op-field-error {
    border-color: #dc3545 !important;
    background-color: #fff7f8 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.14) !important;
}

.content-wrap {
    padding: 1.15rem;
}

.card,
.card-soft {
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-soft);
    background: var(--card-bg);
    overflow: hidden;
}

.card .card-header,
.card-soft .card-header {
    background: var(--card-head-bg);
    border-bottom: 1px solid var(--card-border-strong);
    border-top-left-radius: var(--card-radius);
    border-top-right-radius: var(--card-radius);
    padding: 0.78rem 0.95rem;
}

.card .card-body,
.card-soft .card-body {
    padding: 1rem;
    background: transparent;
}

.card > .table-responsive,
.card-soft > .table-responsive {
    border-radius: inherit;
}

.module-page {
    --module-card-radius: 20px;
}

.module-page .h4 {
    letter-spacing: 0.01em;
}

.module-page .card,
.module-page .card-soft {
    border-radius: 22px;
    border-color: #e4ddf4;
    box-shadow: 0 14px 30px rgba(67, 39, 125, 0.09);
}

.module-filter-card,
.module-table-card {
    border-radius: var(--module-card-radius);
}

.module-filter-card .card-body {
    padding: 1rem 1.05rem;
}

.module-filter-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbf7ff 100%);
}

.module-filter-card .form-control,
.module-filter-card .form-select {
    border-radius: 12px;
}

.module-table-card > .table-responsive {
    border: 1px solid #ece5f9;
    border-radius: 16px;
    background: #fff;
    overflow: auto;
}

.module-table-card {
    padding: 0.42rem;
    background: linear-gradient(180deg, #fdfbff 0%, #f7f3ff 100%);
}

.module-table-card .table {
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
}

.module-table-card .table thead th {
    background: linear-gradient(180deg, #fbf8ff 0%, #f4f0fc 100%);
    border-bottom: 1px solid #e9e3f6;
    color: #6f6789;
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.module-table-card .table thead th:first-child {
    border-top-left-radius: 14px;
}

.module-table-card .table thead th:last-child {
    border-top-right-radius: 14px;
}

.module-table-card .table > :not(caption) > * > * {
    padding: 0.72rem 0.74rem;
}

.module-table-card .table tbody tr {
    transition: background-color 0.16s ease;
}

.module-table-card .table tbody tr:hover {
    background: #faf7ff;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ink-900);
    --bs-table-striped-color: var(--ink-900);
    --bs-table-striped-bg: #f8f6fc;
    --bs-table-border-color: #ece7f6;
}

.table thead th {
    color: var(--ink-500);
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
    white-space: nowrap;
}

.table > :not(caption) > * > * {
    padding: 0.7rem 0.72rem;
}

.production-orders-table {
    min-width: 1240px;
}

.production-orders-table th:nth-child(1),
.production-orders-table td:nth-child(1) {
    min-width: 230px;
    white-space: nowrap;
}

.production-orders-table th:nth-child(4),
.production-orders-table td:nth-child(4) {
    min-width: 96px;
}

.production-orders-table th:nth-child(6),
.production-orders-table td:nth-child(6) {
    min-width: 96px;
}

.production-orders-table .op-actions-col,
.production-orders-table .op-actions-cell {
    min-width: 320px;
}

.production-orders-table .op-actions-cell {
    white-space: nowrap;
}

.op-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: nowrap;
}

.op-actions form {
    margin: 0;
    display: inline-flex;
}

.op-actions .btn {
    font-size: 0.84rem;
    line-height: 1.2;
    padding: 0.33rem 0.58rem;
    white-space: nowrap;
}

.op-row-new > td {
    background: linear-gradient(90deg, #fff4cc 0%, #ffefb3 100%) !important;
    border-top-color: #e9c96b !important;
    border-bottom-color: #e9c96b !important;
    font-weight: 600;
}

.op-row-new > td:first-child {
    border-left: 4px solid #d69e00;
}

@keyframes opRowPulse {
    0% { box-shadow: inset 0 0 0 0 rgba(214, 158, 0, 0.0); }
    50% { box-shadow: inset 0 0 0 999px rgba(255, 214, 92, 0.18); }
    100% { box-shadow: inset 0 0 0 0 rgba(214, 158, 0, 0.0); }
}

.op-row-new > td {
    animation: opRowPulse 1.2s ease 1;
}

.form-control,
.form-select {
    border-radius: 10px;
    border-color: #ded8ef;
    color: var(--ink-900);
    background-color: #fff;
}

.form-control:focus,
.form-select:focus {
    border-color: #b497f8;
    box-shadow: 0 0 0 0.18rem rgba(146, 101, 238, 0.16);
}

.btn {
    border-radius: 10px;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(90deg, #8250e5 0%, #9b6bff 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(90deg, #7546d2 0%, #8b59f2 100%);
}

.btn-outline-secondary {
    border-color: #d3caea;
    color: #5f5679;
}

.alert {
    border: 0;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(62, 40, 110, 0.08);
}

.kpi-card {
    border-radius: 15px;
    padding: 0.86rem;
    min-height: 118px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid #e6e0f4;
    background: linear-gradient(180deg, #ffffff 0%, #fbf9ff 100%);
}

.kpi-card .kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 0.95rem;
    margin-bottom: 0.45rem;
}

.kpi-card .kpi-label {
    color: #544d6d;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
}

.kpi-card .kpi-value {
    font-size: 1.43rem;
    font-weight: 700;
    color: #2f2843;
}

.kpi-material .kpi-icon { background: linear-gradient(150deg, #7f56da, #9e76ff); }
.kpi-product .kpi-icon { background: linear-gradient(150deg, #6f85ff, #8d9fff); }
.kpi-formula .kpi-icon { background: linear-gradient(150deg, #9f68e4, #b686ff); }
.kpi-critical .kpi-icon { background: linear-gradient(150deg, #e76a90, #f08bab); }
.kpi-open .kpi-icon { background: linear-gradient(150deg, #6d8bf1, #94adff); }
.kpi-completed .kpi-icon { background: linear-gradient(150deg, #2eaf89, #54c7a1); }

.metric-card {
    border-radius: 15px;
    padding: 0.9rem;
    min-height: 112px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid #e6e0f4;
    background: linear-gradient(180deg, #ffffff 0%, #fbf9ff 100%);
}

.dashboard-page .kpi-card,
.dashboard-page .metric-card {
    border-radius: 18px;
}

.dashboard-page .chart-body {
    padding: 0.88rem 0.9rem 0.82rem;
}

.dashboard-page .table th,
.dashboard-page .table td {
    vertical-align: middle;
}

.formula-page .card-soft {
    border-color: #e7e1f4;
}

.formula-page .h4 {
    letter-spacing: 0.01em;
}

.formula-page .table-responsive {
    border-radius: 14px;
}

.formula-page .table thead th {
    background: #f7f3ff;
}

.formula-page .table tbody tr:hover {
    background: #fbf9ff;
}

.formula-main-card .card-body,
.formula-items-card .card-body,
.formula-list-card .table-responsive {
    padding: 1rem;
}

.formula-list-card.module-table-card {
    padding: 0;
    background: linear-gradient(180deg, #fdfbff 0%, #f7f3ff 100%);
}

.formula-list-card .card-header {
    border-bottom: 1px solid #ece5f9;
}

.formula-list-table-wrap {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: auto;
}

.formula-list-card.module-table-card > .table-responsive {
    border: 0;
    border-radius: 0;
    background: transparent;
}

.formula-list-table-wrap .table thead th:first-child {
    border-top-left-radius: 0;
}

.formula-list-table-wrap .table thead th:last-child {
    border-top-right-radius: 0;
}

.metric-card .metric-label {
    color: #4e4866;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-transform: none;
    line-height: 1.3;
    margin-bottom: 0.42rem;
}

.metric-card .metric-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
    color: #2f2843;
}

.dashboard-card-link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
    border-radius: 15px;
}

.dashboard-card-link .kpi-card,
.dashboard-card-link .metric-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.dashboard-card-link:hover .kpi-card,
.dashboard-card-link:hover .metric-card,
.dashboard-card-link:focus-visible .kpi-card,
.dashboard-card-link:focus-visible .metric-card {
    transform: translateY(-4px);
    border-color: #cdbdf2;
    box-shadow: 0 18px 30px rgba(72, 40, 130, 0.16);
    background: linear-gradient(180deg, #ffffff 0%, #f8f4ff 100%);
}

.dashboard-card-link:focus-visible {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    .dashboard-card-link .kpi-card,
    .dashboard-card-link .metric-card {
        transition: none;
    }
}

.chart-body {
    height: 300px;
}

.auth-body {
    min-height: 100vh;
    background: radial-gradient(1000px 500px at 15% 10%, #e9dbff 0%, #f0e8ff 36%, #f9f6ff 100%);
    position: relative;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 430px;
    border: 1px solid #dfd2fb;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-strong);
}

.app-dialog-open {
    overflow: hidden;
}

.app-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(26, 19, 46, 0.48);
    display: grid;
    place-items: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
}

.app-dialog {
    width: min(560px, 100%);
    max-height: min(82vh, 720px);
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid #e8e1fb;
    background: #ffffff;
    box-shadow: 0 24px 54px rgba(38, 21, 78, 0.28);
    display: flex;
    flex-direction: column;
    animation: appDialogIn 0.16s ease-out;
}

.app-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem 0.8rem;
    border-bottom: 1px solid #efe9fb;
    background: linear-gradient(180deg, #faf7ff 0%, #ffffff 100%);
}

.app-dialog-title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    color: #30274a;
}

.app-dialog-close {
    border: 1px solid #d7ccf2;
    color: #5f5679;
    background: #fff;
    width: 30px;
    height: 30px;
    line-height: 1;
    border-radius: 9px;
    font-size: 1.2rem;
}

.app-dialog-body {
    padding: 0.95rem 1rem;
    color: #312b45;
    font-size: 0.95rem;
    line-height: 1.42;
    overflow: auto;
}

.app-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.85rem 1rem 0.95rem;
    border-top: 1px solid #efe9fb;
    background: #fcfbff;
}

@keyframes appDialogIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-card-body {
    padding: 1.55rem;
}

.auth-logo {
    width: 56px;
    height: 56px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #8a5dee, #ad86ff);
    color: #fff;
    font-size: 1.35rem;
    margin-bottom: 0.95rem;
    box-shadow: 0 10px 20px rgba(129, 84, 228, 0.29);
}

.auth-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.auth-subtitle {
    font-size: 0.84rem;
    color: var(--ink-500);
    margin-bottom: 1.2rem;
}

.auth-input .input-group-text {
    border-radius: 10px 0 0 10px;
    border-color: #ded8ef;
    background: #f7f3ff;
    color: #775abf;
}

.auth-input .form-control {
    border-left: 0;
    border-radius: 0 10px 10px 0;
}

.auth-note {
    margin-top: 0.95rem;
    font-size: 0.75rem;
    color: var(--ink-500);
}

.print-document {
    max-width: 1080px;
}

.print-op-sheet {
    max-width: 800px;
    margin: 0 auto;
}

.print-op-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.print-op-title {
    font-size: 1.16rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.print-op-subtitle {
    color: var(--ink-500);
    font-size: 0.88rem;
}

.print-op-meta {
    text-align: right;
    font-size: 0.86rem;
    line-height: 1.45;
}

.print-op-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 0.26rem 0.8rem;
    font-size: 0.9rem;
}

.print-op-grid .k {
    color: #4e4a60;
    font-weight: 600;
}

.print-op-grid .v {
    color: #1f1a2f;
}

.print-op-obs {
    font-size: 0.88rem;
}

.print-op-table th,
.print-op-table td {
    padding: 0.42rem 0.46rem !important;
}

.print-op-step td {
    background: #f6f4fb !important;
    font-weight: 700;
    color: #1f1a2f;
}

.print-op-total td {
    background: #f9f7fd !important;
}

.print-op-tech .card-body {
    font-size: 0.86rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.print-only {
    display: none;
}

.print-preview-full {
    width: 100%;
    max-width: none;
    margin: 0 0 1rem;
}

.print-preview-full .card-soft {
    border-radius: var(--radius-lg);
}

.print-preview-full .card-soft .card-header {
    padding: 0.75rem 1rem;
}

.print-preview-full .table thead th {
    font-size: 0.74rem;
}

.print-preview-full .table > :not(caption) > * > * {
    padding: 0.7rem 0.72rem;
}

.print-doc-title {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.print-doc-subtitle {
    color: var(--ink-500);
    font-size: 0.92rem;
    margin-top: 0.16rem;
}

.print-doc-right {
    text-align: right;
    font-size: 0.9rem;
}

.print-signatures {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 1rem;
}

.print-sign-line {
    border-top: 1px solid #8f8f8f;
    padding-top: 0.42rem;
    text-align: center;
    color: #555;
    font-size: 0.82rem;
}

.purchases-report-sheet .card-header {
    padding: 0.7rem 0.9rem;
}

.purchases-report-table th,
.purchases-report-table td {
    vertical-align: middle;
}

.purchases-report-table td:nth-child(2) {
    min-width: 230px;
}

.purchases-col-short {
    display: none;
}

.purchase-request-input {
    min-width: 110px;
}

@media (max-width: 1600px) {
    .app-sidebar {
        width: 262px;
        padding: 0.9rem 0.82rem;
        gap: 0.68rem;
    }

    .brand-box {
        padding: 0.72rem 0.78rem;
    }

    .menu-group-title {
        font-size: 0.68rem;
        margin: 0.22rem 0 0.22rem;
    }

    .menu-link {
        padding: 0.48rem 0.52rem;
        font-size: 0.88rem;
        gap: 0.52rem;
    }

    .menu-link .menu-icon {
        width: 1rem;
        font-size: 0.88rem;
    }

    .topbar {
        padding: 0.66rem 0.8rem;
    }

    .page-title {
        font-size: 0.92rem;
    }

    .company-switch-form {
        grid-template-columns: auto minmax(205px, 240px);
        padding: 0.28rem 0.38rem 0.28rem 0.5rem;
        border-radius: 12px;
    }

    .company-switch-label {
        font-size: 0.72rem;
    }

    .company-switch-picker,
    .company-switch-select,
    .company-switch-fixed {
        min-width: 220px;
    }

    .company-switch-trigger,
    .company-switch-select,
    .company-switch-fixed {
        min-height: 38px;
        font-size: 0.83rem;
    }

    .content-wrap {
        padding: 0.92rem;
    }

    .card .card-header,
    .card-soft .card-header {
        padding: 0.68rem 0.82rem;
    }

    .card .card-body,
    .card-soft .card-body {
        padding: 0.86rem;
    }

    .module-table-card {
        padding: 0.34rem;
    }

    .module-table-card .table thead th,
    .table thead th {
        font-size: 0.69rem;
        letter-spacing: 0.05em;
    }

    .module-table-card .table > :not(caption) > * > *,
    .table > :not(caption) > * > * {
        padding: 0.56rem 0.58rem;
    }

    .btn {
        font-size: 0.84rem;
    }

    .btn-sm {
        --bs-btn-padding-y: 0.25rem;
        --bs-btn-padding-x: 0.46rem;
        --bs-btn-font-size: 0.76rem;
    }

    .production-orders-table {
        min-width: 1080px;
    }

    .production-orders-table th:nth-child(1),
    .production-orders-table td:nth-child(1) {
        min-width: 190px;
    }

    .production-orders-table th:nth-child(4),
    .production-orders-table td:nth-child(4),
    .production-orders-table th:nth-child(6),
    .production-orders-table td:nth-child(6) {
        min-width: 84px;
    }

    .production-orders-table .op-actions-col,
    .production-orders-table .op-actions-cell {
        min-width: 260px;
    }

    .op-actions .btn {
        padding: 0.28rem 0.5rem;
        font-size: 0.77rem;
    }
}

@media (max-width: 1366px) {
    .app-sidebar {
        width: 236px;
        padding: 0.78rem 0.72rem;
    }

    .brand-title {
        font-size: 0.98rem;
    }

    .brand-subtitle {
        font-size: 0.71rem;
    }

    .menu-link {
        padding: 0.42rem 0.46rem;
        font-size: 0.84rem;
    }

    .topbar {
        padding: 0.58rem 0.72rem;
    }

    .content-wrap {
        padding: 0.74rem;
    }

    .company-switch-form {
        grid-template-columns: auto minmax(185px, 220px);
    }

    .company-switch-picker,
    .company-switch-select,
    .company-switch-fixed {
        min-width: 200px;
    }

    .card,
    .card-soft {
        border-radius: 16px;
    }

    .module-page .card,
    .module-page .card-soft {
        border-radius: 18px;
    }

    .module-filter-card .card-body {
        padding: 0.82rem;
    }

    .module-table-card .table thead th,
    .table thead th {
        font-size: 0.66rem;
        letter-spacing: 0.04em;
    }

    .module-table-card .table > :not(caption) > * > *,
    .table > :not(caption) > * > * {
        padding: 0.5rem 0.52rem;
    }

    .production-orders-table {
        min-width: 980px;
    }

    .production-orders-table th:nth-child(1),
    .production-orders-table td:nth-child(1) {
        min-width: 165px;
    }

    .production-orders-table .op-actions-col,
    .production-orders-table .op-actions-cell {
        min-width: 228px;
    }

    .op-actions {
        gap: 0.3rem;
    }

    .kpi-card .kpi-value,
    .metric-card .metric-value {
        font-size: 1.26rem;
    }

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

@media (max-width: 1200px) {
    .app-sidebar {
        width: 216px;
    }

    .menu-link span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .company-switch-form {
        grid-template-columns: auto minmax(170px, 200px);
    }

    .company-switch-picker,
    .company-switch-select,
    .company-switch-fixed {
        min-width: 184px;
    }

    .production-orders-table {
        min-width: 920px;
    }
}

@media (max-width: 1100px) {
    .app-sidebar {
        width: 250px;
    }

    .print-preview-full {
        max-width: 100%;
    }
}

@media (max-width: 992px) {
    .app-layout {
        display: block;
    }

    .app-sidebar {
        width: 100%;
        position: relative;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        border-radius: 0;
    }

    .topbar {
        position: relative;
    }

    .company-switch {
        width: 100%;
        justify-content: flex-start;
    }

    .company-switch-form {
        width: 100%;
        grid-template-columns: 1fr;
        gap: 0.42rem;
        padding: 0.55rem;
    }

    .company-switch-label {
        font-size: 0.76rem;
    }

    .company-switch-select,
    .company-switch-fixed,
    .company-switch-picker {
        min-width: 0;
        width: 100%;
    }

    .op-create-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .users-company-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .users-company-add-btn {
        width: 100%;
        min-width: 0;
    }

    .companies-active-col {
        display: block;
    }
}

@page {
    size: A4 portrait;
    margin: 10mm;
}

@media print {
    body {
        background: #fff !important;
    }

    .app-sidebar,
    .topbar,
    .no-print,
    .alert {
        display: none !important;
    }

    .app-layout,
    .app-main {
        display: block !important;
        min-height: 0 !important;
    }

    .content-wrap {
        padding: 0 !important;
    }

    .card,
    .card-soft {
        box-shadow: none !important;
        border: 1px solid #d9d9d9 !important;
        background: #fff !important;
        break-inside: avoid;
    }

    .table thead th {
        color: #444 !important;
    }

    .print-signatures {
        margin-top: 1rem !important;
    }

    .print-only {
        display: block !important;
    }

    .print-op-sheet {
        max-width: 100% !important;
    }

    .print-op-title {
        font-size: 15px !important;
    }

    .print-op-subtitle,
    .print-op-meta,
    .print-op-grid,
    .print-op-obs,
    .print-op-tech .card-body {
        font-size: 11px !important;
    }

    .print-op-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 2px 8px !important;
    }

    .print-op-table {
        font-size: 11px !important;
    }

    .print-op-table th,
    .print-op-table td {
        padding: 3px 5px !important;
        line-height: 1.3 !important;
    }

    .print-op-table tr {
        break-inside: avoid;
    }

    .purchases-print-head {
        margin-bottom: 4px !important;
    }

    .purchases-report-sheet {
        border: 0 !important;
    }

    .purchases-report-sheet .card-header {
        border: 0 !important;
        padding: 0 0 4px !important;
        margin-bottom: 2px;
    }

    .purchases-report-sheet .table-responsive {
        overflow: visible !important;
    }

    .purchases-report-table {
        font-size: 9.4px !important;
        table-layout: fixed;
        width: 100%;
    }

    .purchases-report-table th,
    .purchases-report-table td {
        padding: 2px 3px !important;
        line-height: 1.15 !important;
    }

    .purchases-report-table th {
        white-space: nowrap !important;
    }

    .purchases-col-full {
        display: none !important;
    }

    .purchases-col-short {
        display: inline !important;
    }

    .purchases-report-table th:nth-child(1),
    .purchases-report-table td:nth-child(1) {
        width: 11% !important;
    }

    .purchases-report-table th:nth-child(2),
    .purchases-report-table td:nth-child(2) {
        width: 30% !important;
        min-width: 0 !important;
        white-space: normal !important;
    }

    .purchases-report-table th:nth-child(3),
    .purchases-report-table td:nth-child(3) {
        width: 5% !important;
        text-transform: uppercase;
    }

    .purchases-report-table th:nth-child(4),
    .purchases-report-table td:nth-child(4) {
        width: 13% !important;
    }

    .purchases-report-table th:nth-child(5),
    .purchases-report-table td:nth-child(5) {
        width: 13% !important;
    }

    .purchases-report-table th:nth-child(6),
    .purchases-report-table td:nth-child(6) {
        width: 12% !important;
    }

    .purchases-report-table th:nth-child(7),
    .purchases-report-table td:nth-child(7) {
        width: 8% !important;
    }

    .purchases-report-table th:nth-child(8),
    .purchases-report-table td:nth-child(8) {
        width: 8% !important;
    }

    .purchases-report-table tr {
        break-inside: avoid;
    }
}
