:root {
    --purple: #a64d79;
    --orange: #e69138;
    --ready-red: #cc3f4b;
    --surface-raised: #1a1a20;
}

body {
    overflow: hidden;
}

.app-sidebar {
    overflow-y: auto;
}

.app-sidebar__footer form {
    margin: 0;
}

.sidebar-logout {
    width: 100%;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.app-content {
    scroll-behavior: smooth;
}

.login-subtitle {
    margin: -12px 0 24px;
    color: #9a9ab0;
    font-size: 12px;
    text-align: center;
}

.install-card {
    width: min(720px, calc(100vw - 28px));
    max-height: calc(100vh - 32px);
    margin: auto;
    overflow-y: auto;
}

.install-card h1,
.install-card > p {
    text-align: center;
}

.form-divider {
    width: 100%;
    height: 1px;
    margin: 5px 0;
    border: 0;
    background: var(--gold-border);
}

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

.page-actions__right,
.form-actions,
.filter-actions,
.sticky-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.division-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--gold-soft);
    border-radius: 12px;
    background: #111115;
}

.division-tabs a {
    padding: 8px 13px;
    border-radius: 8px;
    color: #a7a7b8;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.division-tabs a:hover,
.division-tabs a.is-active {
    background: var(--gold-soft);
    color: var(--gold-light);
}

.dashboard-metrics a {
    color: inherit;
    text-decoration: none;
}

.metric-card {
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    position: absolute;
    right: -28px;
    bottom: -42px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(212, 175, 55, .08);
    content: "";
}

.metric-card--production {
    border-left: 4px solid var(--orange);
}

.metric-card--ready {
    border-left: 4px solid var(--ready-red);
}

.metric-card--shipped {
    border-left: 4px solid var(--blue);
}

.metric-card--profit {
    border-left: 4px solid var(--green);
}

.metric-card__value {
    position: relative;
    z-index: 1;
    overflow-wrap: anywhere;
}

.division-overview {
    display: grid;
    gap: 9px;
}

.division-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 10px;
    border: 1px solid var(--gold-soft);
    border-radius: 12px;
    background: #111115;
    text-decoration: none;
    transition: transform var(--transition), border-color var(--transition);
}

.division-row:hover {
    border-color: var(--gold);
    transform: translateX(2px);
}

.division-row__mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 10px;
    background: var(--gold-soft);
    color: var(--gold);
    font-weight: 800;
}

.division-row strong,
.division-row small {
    display: block;
}

.division-row strong {
    font-size: 13px;
}

.division-row small {
    margin-top: 2px;
    color: #9999aa;
    font-size: 11px;
}

.division-row__arrow {
    color: var(--gold);
    font-size: 22px;
}

.empty-state.compact {
    padding: 18px;
}

.filters-panel {
    padding: 13px 16px;
}

.filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(130px, 1fr));
    gap: 10px;
}

.filter-search {
    grid-row: span 2;
}

.filter-actions {
    margin-top: 12px;
}

.workflow-section {
    margin-bottom: 18px;
    overflow: hidden;
    border: 1px solid var(--gold-soft);
    border-radius: var(--radius-lg);
    background: rgba(17, 17, 21, .76);
    box-shadow: 0 0 18px rgba(0, 0, 0, .35);
}

.workflow-section > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 15px;
    border-bottom: 1px solid #2a2a33;
    background: #15151a;
}

.workflow-section > header > div {
    display: flex;
    align-items: center;
    gap: 9px;
}

.workflow-section > header h2 {
    margin: 0;
    font-size: 15px;
}

.workflow-section > header > strong {
    display: grid;
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    place-items: center;
    border-radius: 99px;
    background: #24242a;
    font-size: 12px;
}

.workflow-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 10px currentColor;
}

.workflow-section--production .workflow-dot {
    background: var(--orange);
    color: var(--orange);
}

.workflow-section--ready .workflow-dot {
    background: var(--ready-red);
    color: var(--ready-red);
}

.workflow-section--shipped .workflow-dot {
    background: var(--blue);
    color: var(--blue);
}

.workflow-section .table-wrap {
    border: 0;
    border-radius: 0;
}

.orders-table td:first-child strong,
.orders-table td:first-child small,
.orders-table td:nth-child(2) strong,
.orders-table td:nth-child(2) small,
.orders-table td:nth-child(3) strong,
.orders-table td:nth-child(3) small,
.data-table td > small {
    display: block;
}

.orders-table td small,
.data-table td > small {
    margin-top: 2px;
    color: #9191a3;
    font-size: 10px;
}

.money-cell {
    font-weight: 700;
    color: var(--gold-light);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border: 1px solid transparent;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

.status--new {
    border-color: rgba(166, 77, 121, .55);
    background: rgba(166, 77, 121, .2);
    color: #eba9cc;
}

.status--production {
    border-color: rgba(230, 145, 56, .55);
    background: rgba(230, 145, 56, .18);
    color: #ffc077;
}

.status--ready {
    border-color: rgba(231, 76, 60, .58);
    background: rgba(231, 76, 60, .18);
    color: #ffaaa1;
}

.status--shipped {
    border-color: rgba(59, 130, 246, .56);
    background: rgba(59, 130, 246, .18);
    color: #a9c8ff;
}

.status--completed {
    border-color: rgba(46, 204, 113, .55);
    background: rgba(46, 204, 113, .17);
    color: #8be5ae;
}

.status--cancelled {
    border-color: rgba(150, 150, 160, .45);
    background: rgba(150, 150, 160, .15);
    color: #bdbdca;
}

.quick-toggle-form,
.status-action-form {
    margin: 0;
}

.quick-toggle {
    display: grid;
    width: 30px;
    height: 30px;
    padding: 0;
    place-items: center;
    border: 1px solid #34343d;
    border-radius: 8px;
    background: #111115;
    color: #6f6f7d;
    cursor: pointer;
}

.quick-toggle:hover {
    border-color: var(--gold);
}

.quick-toggle.is-checked {
    border-color: rgba(46, 204, 113, .55);
    background: rgba(46, 204, 113, .16);
    color: #8be5ae;
}

.status-action-form select {
    max-width: 118px;
    min-height: 30px;
    padding: 4px 6px;
    border: 1px solid #34343d;
    border-radius: 8px;
    background: #111115;
    color: #eee;
    font-size: 10px;
}

.order-actions {
    flex-wrap: nowrap;
}

.orders-mobile {
    display: none;
}

.month-subgroup {
    padding: 12px;
}

.month-subgroup + .month-subgroup {
    border-top: 1px solid #2a2a33;
}

.month-subgroup h3 {
    margin: 0 0 10px;
    color: var(--gold);
    font-size: 12px;
    text-transform: uppercase;
}

.archive-filters,
.report-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 160px auto;
    align-items: end;
    gap: 10px;
}

.archive-month .section-header {
    padding-bottom: 10px;
    border-bottom: 1px solid #2a2a33;
}

.order-form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(290px, 370px);
    align-items: start;
    gap: 16px;
}

.order-customer-panel {
    position: sticky;
    top: 0;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.check-card,
.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid var(--gold-soft);
    border-radius: 10px;
    background: rgba(212, 175, 55, .05);
    color: #d8d8e4;
    font-size: 12px;
    cursor: pointer;
}

.check-card input,
.check-row input {
    width: 17px;
    height: 17px;
    accent-color: var(--gold);
}

.sticky-actions {
    margin-top: 18px;
}

.management-layout {
    display: grid;
    grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
    align-items: start;
    gap: 16px;
}

.management-form {
    position: sticky;
    top: 0;
}

.component-editor {
    display: grid;
    gap: 6px;
    max-height: 310px;
    padding: 10px;
    overflow-y: auto;
    border: 1px solid var(--gold-soft);
    border-radius: 12px;
    background: #111115;
}

.component-editor h3 {
    margin: 0 0 5px;
    color: var(--gold);
    font-size: 12px;
}

.component-editor label {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 74px;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid #24242b;
    font-size: 11px;
}

.component-editor label:last-child {
    border-bottom: 0;
}

.component-editor label span,
.component-editor label small {
    display: block;
}

.component-editor label small {
    color: #808090;
    font-size: 9px;
}

.component-editor input {
    min-height: 30px;
    padding: 4px 7px;
    border: 1px solid #34343d;
    border-radius: 7px;
    background: #19191f;
    color: #fff;
}

.components-cell {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.is-muted {
    opacity: .52;
}

.inventory-layout {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    margin-top: 16px;
}

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

.inventory-card {
    padding: 12px;
    border: 1px solid var(--gold-soft);
    border-radius: 13px;
    background: #111115;
}

.inventory-card.is-low {
    border-color: rgba(231, 76, 60, .52);
    box-shadow: inset 3px 0 0 var(--red);
}

.inventory-card__top,
.inventory-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.inventory-card__top strong,
.inventory-card__top small {
    display: block;
}

.inventory-card__top small,
.inventory-card__footer {
    color: #9292a3;
    font-size: 10px;
}

.stock-value {
    color: var(--gold-light);
    font-size: 18px;
    font-weight: 800;
    white-space: nowrap;
}

.stock-value small {
    display: inline;
    font-size: 9px;
}

.stock-progress {
    height: 4px;
    margin: 10px 0;
    overflow: hidden;
    border-radius: 99px;
    background: #292930;
}

.stock-progress span,
.ranking-bar span {
    display: block;
    width: var(--stock-width, var(--bar-width, 0%));
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
}

.inventory-card.is-low .stock-progress span {
    background: var(--red);
}

.inventory-card__footer a {
    color: var(--gold);
    text-decoration: none;
}

.stock-adjust-form {
    display: grid;
    grid-template-columns: 92px minmax(90px, 1fr) auto;
    gap: 5px;
    margin-top: 10px;
}

.stock-adjust-form input {
    min-width: 0;
    min-height: 30px;
    padding: 5px 7px;
    border: 1px solid #34343d;
    border-radius: 7px;
    background: #19191f;
    color: #fff;
    font-size: 10px;
}

.value-positive {
    color: #7ee2a7;
    font-weight: 700;
}

.value-negative {
    color: #ff9188;
    font-weight: 700;
}

.ranking-list,
.expense-list {
    display: grid;
    gap: 10px;
}

.ranking-row > div:first-child,
.expense-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ranking-row strong,
.ranking-row span,
.expense-list strong,
.expense-list small {
    display: block;
}

.ranking-row strong,
.expense-list strong {
    font-size: 11px;
}

.ranking-row span,
.expense-list small {
    color: #9292a3;
    font-size: 9px;
}

.ranking-bar {
    height: 5px;
    margin-top: 5px;
    overflow: hidden;
    border-radius: 99px;
    background: #292930;
}

.expense-list > div {
    padding-bottom: 9px;
    border-bottom: 1px solid #292930;
}

.expense-list > div:last-child {
    border-bottom: 0;
}

.report-filters {
    grid-template-columns: repeat(3, minmax(150px, 220px)) auto;
}

body.light .division-tabs,
body.light .workflow-section,
body.light .component-editor,
body.light .inventory-card,
body.light .division-row,
body.light .quick-toggle,
body.light .status-action-form select {
    background: #e1e1e1;
    color: #222;
}

body.light .workflow-section > header {
    background: #d4d4d4;
    border-bottom-color: #b8b8b8;
}

body.light .check-card,
body.light .check-row {
    color: #222;
}

@media (max-width: 1280px) {
    .filter-grid {
        grid-template-columns: repeat(3, minmax(140px, 1fr));
    }

    .filter-search {
        grid-row: auto;
    }

    .inventory-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .order-form-layout,
    .management-layout,
    .inventory-layout {
        grid-template-columns: 1fr;
    }

    .order-customer-panel,
    .management-form {
        position: static;
    }

    .orders-desktop {
        display: none;
    }

    .orders-mobile {
        display: grid;
        gap: 9px;
        padding: 10px;
    }

    .order-card {
        padding: 12px;
        border: 1px solid var(--gold-soft);
        border-radius: 13px;
        background: #111115;
    }

    .order-card__top {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 9px;
    }

    .order-card__top strong,
    .order-card__top small {
        display: block;
    }

    .order-card__top strong {
        font-size: 13px;
    }

    .order-card__top small {
        margin-top: 2px;
        color: #9292a3;
        font-size: 9px;
    }

    .order-card__customer {
        margin: 10px 0 7px;
        font-size: 12px;
        font-weight: 650;
    }

    .order-card__meta {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 10px;
        color: #a5a5b5;
        font-size: 10px;
    }

    .order-card__meta strong {
        margin-left: auto;
        color: var(--gold-light);
    }

    .order-card__checks {
        display: flex;
        gap: 7px;
        margin: 10px 0;
    }

    .order-card .order-actions {
        justify-content: space-between;
    }

    body.light .order-card {
        background: #e1e1e1;
    }
}

@media (max-width: 700px) {
    .page-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .page-actions__right {
        justify-content: space-between;
    }

    .division-tabs {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        text-align: center;
    }

    .filter-grid,
    .archive-filters,
    .report-filters,
    .check-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        justify-content: stretch;
    }

    .filter-actions .btn {
        flex: 1;
    }

    .stock-adjust-form {
        grid-template-columns: 1fr 1fr;
    }

    .stock-adjust-form .btn {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    body {
        overflow: auto;
    }

    .app-sidebar {
        align-items: center;
    }

    .app-logo {
        flex: 0 0 auto;
    }

    .app-logo__mark {
        width: 36px;
        height: 36px;
    }

    .app-menu {
        flex: 1 0 auto;
    }

    .app-menu__item {
        min-width: 42px;
    }

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

    .metric-card {
        min-height: 112px;
    }

    .metric-card__value {
        font-size: 21px;
    }

    .form-grid--2 {
        grid-template-columns: 1fr;
    }
}
