﻿* {
    box-sizing: border-box;
}
[hidden] {
    display: none !important;
}
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f6fa;
    color: #06152b;
}
.topbar {
    background: #142238;
    color: #fff;
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}
.topbar h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
}
.topbar p {
    margin: 10px 0 0;
}
.login-topbar {
    justify-content: flex-start;
}
.login-brand-logo {
    display: block;
    width: 280px;
    max-width: 100%;
    height: auto;
}
.app-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.app-brand-logo {
    display: block;
    width: 230px;
    max-width: 100%;
    height: auto;
    justify-self: center;
}
.app-topbar .topbar-actions {
    justify-self: end;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.topbar-actions form {
    margin: 0;
}
.environment-badge {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 999px;
    padding: 7px 12px;
    color: #e7edf7;
    font-size: 13px;
    font-weight: 800;
}
.layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: calc(100vh - 110px);
}
.nav-symbols {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}
.sidebar {
    background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
    border-right: 1px solid #d9e2ef;
    padding: 18px 16px;
    box-shadow: 8px 0 24px rgba(20, 34, 56, .03);
}
.sidebar a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    text-decoration: none;
    color: #10233d;
    font-weight: 700;
    border: 1px solid transparent;
    border-radius: 9px;
    margin-bottom: 5px;
    white-space: nowrap;
    line-height: 1.2;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.sidebar a:hover {
    background: #eaf1ff;
    border-color: #d4e0f5;
    color: #0b3f91;
}
.sidebar a.active {
    background: #eaf1ff;
    border-color: #dbe7fb;
    color: #06152b;
    box-shadow: inset 3px 0 0 #3167e8;
}
.sidebar a.nav-section-break {
    margin-top: 12px;
    padding-top: 12px;
}
.sidebar a.nav-section-break::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -7px;
    height: 1px;
    background: #e6edf7;
}
.sidebar .nav-icon {
    display: inline-flex;
    align-items: center;
    width: 22px;
    height: 22px;
    justify-content: center;
    border-radius: 7px;
    background: #eef4ff;
    color: #1655a6;
    font-size: 13px;
    flex: 0 0 22px;
}
.sidebar .nav-icon svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.sidebar a.active .nav-icon,
.sidebar a:hover .nav-icon {
    background: #dbe8ff;
    color: #0b4fc4;
}
main {
    min-width: 0;
    padding: 30px;
}
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}
.page-head h2 {
    margin: 0;
    font-size: 26px;
}
.page-head p {
    margin: 7px 0 0;
}
.head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.head-actions form {
    margin: 0;
}
.card {
    background: #fff;
    border: 1px solid #d9e2ef;
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: 0 8px 24px rgba(20, 34, 56, .05);
}
.card h3 {
    margin-top: 0;
}
.btn {
    display: inline-block;
    background: #3167e8;
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 11px 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.btn.grey {
    background: #e7edf7;
    color: #142238;
}
.btn.compact {
    padding: 8px 12px;
    font-size: 13px;
}
button.btn {
    font-family: inherit;
}
input,
select,
textarea {
    width: 100%;
    padding: 11px;
    border: 1px solid #cbd7e6;
    border-radius: 7px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
}
input:focus,
select:focus,
textarea:focus {
    outline: 0;
    border-color: #3167e8;
    box-shadow: 0 0 0 3px rgba(49, 103, 232, .14);
}
textarea {
    min-height: 92px;
    resize: vertical;
}
label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}
.login {
    max-width: 420px;
    margin: 70px auto;
    padding: 0 18px;
}
.login-card h2 {
    margin-top: 0;
}
.login-card .btn {
    width: 100%;
    margin-top: 14px;
    font-size: 16px;
}
.form-error {
    margin: 9px 0 0;
    color: #b91c1c;
    font-weight: 700;
}
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
.stats .card span {
    display: block;
    color: #64748b;
}
.stats .card b {
    display: block;
    margin-top: 8px;
    font-size: 24px;
}
.stat-card {
    min-height: 86px;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.quick-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 12px;
    align-items: end;
}
.product-filter-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(220px, 1fr);
    gap: 12px;
    align-items: end;
}
.product-filter-grid .filter-check {
    min-height: 43px;
}
.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.order-form {
    display: grid;
    grid-template-columns: minmax(170px, .8fr) minmax(220px, 1fr) minmax(220px, 1fr) minmax(200px, 1fr) minmax(180px, .8fr);
    gap: 12px;
}
.order-edit-form {
    display: grid;
    grid-template-columns: minmax(150px, .7fr) minmax(220px, 1.2fr) minmax(150px, .7fr) minmax(160px, .7fr);
    gap: 12px;
    align-items: end;
}
.order-edit-form .wide {
    grid-column: 1 / -1;
}
.order-item-form {
    display: grid;
    grid-template-columns: minmax(260px, 1.6fr) minmax(110px, .5fr) repeat(4, minmax(120px, .6fr));
    gap: 12px;
    align-items: end;
}
.client-search-form {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
}
.client-form {
    display: grid;
    grid-template-columns: minmax(240px, 1.4fr) repeat(4, minmax(150px, .7fr));
    gap: 12px;
    align-items: end;
}
.invoice-form {
    display: grid;
    grid-template-columns: minmax(150px, .7fr) minmax(220px, 1.2fr) minmax(150px, .7fr) minmax(180px, .8fr) minmax(130px, .6fr) minmax(130px, .6fr);
    gap: 12px;
    align-items: end;
}
.invoice-form .wide {
    grid-column: 1 / -1;
}
.client-form .wide {
    grid-column: 1 / -1;
}
.material-form {
    display: grid;
    grid-template-columns: minmax(180px, .8fr) minmax(240px, 1.3fr) repeat(4, minmax(130px, .7fr));
    gap: 12px;
    align-items: end;
}
.category-list {
    display: grid;
    gap: 10px;
}
.category-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
    border: 1px solid #d9e2ef;
    border-radius: 12px;
    padding: 12px;
    background: #f7f9fc;
}
.category-form {
    display: grid;
    grid-template-columns: minmax(160px, .8fr) minmax(240px, 1.3fr) minmax(110px, .5fr) auto auto;
    gap: 10px;
    align-items: end;
}
.new-category-form {
    grid-template-columns: minmax(160px, .8fr) minmax(240px, 1.3fr) minmax(110px, .5fr) auto;
}
.category-meta,
.category-actions {
    display: flex;
    align-items: center;
    min-height: 43px;
}
.delete-inline {
    margin: 0;
}
.material-form .wide {
    grid-column: 1 / -1;
}
.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}
.row-note {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 13px;
}
.details-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 0;
}
.details-grid div {
    border: 1px solid #d9e2ef;
    border-radius: 10px;
    padding: 12px;
    background: #f7f9fc;
}
.details-grid dt {
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
}
.details-grid dd {
    margin: 6px 0 0;
    font-weight: 700;
}
.danger-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    border-color: #fecaca;
}
.danger-card h3,
.danger-card p {
    margin: 0;
}
.danger-card p {
    margin-top: 6px;
}
.danger-btn {
    background: #b91c1c;
}
.notice {
    border: 1px solid #d9e2ef;
    border-radius: 12px;
    margin-bottom: 18px;
    padding: 14px 16px;
}
.notice b,
.notice span {
    display: block;
}
.notice span {
    margin-top: 4px;
    color: #475569;
}
.notice.success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #14532d;
}
.danger-notice {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 14px;
}
.section-head h3,
.section-head p {
    margin: 0;
}
.section-head p {
    margin-top: 6px;
}
.table-wrap {
    overflow-x: auto;
}
.inventory-table {
    min-width: 860px;
}
.orders-table {
    min-width: 940px;
}
.clients-table {
    min-width: 920px;
}
.products-table {
    min-width: 980px;
}
.invoice-orders-table {
    min-width: 760px;
}
.invoices-table {
    min-width: 760px;
}
.order-items-table {
    min-width: 1180px;
}
.order-items-table input,
.order-items-table select {
    padding: 9px;
}
.row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}
.row-actions form {
    margin: 0;
}
.inventory-table th:last-child,
.inventory-table td:last-child,
.orders-table th:last-child,
.orders-table td:last-child,
.clients-table th:last-child,
.clients-table td:last-child,
.products-table th:last-child,
.products-table td:last-child,
.invoice-orders-table th:last-child,
.invoice-orders-table td:last-child,
.invoices-table th:last-child,
.invoices-table td:last-child,
.order-items-table th:last-child,
.order-items-table td:last-child {
    text-align: right;
}
.price-pill {
    display: inline-block;
    border-radius: 999px;
    padding: 7px 10px;
    font-weight: 800;
    white-space: nowrap;
}
.price-pill.fresh {
    background: #d9fbe7;
    color: #166534;
}
.price-pill.stale {
    background: #fff0c4;
    color: #92400e;
}
.price-pill.old,
.price-pill.missing {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
}
.badge.amber {
    background: #fff0c4;
    color: #92400e;
}
.badge.green {
    background: #d9fbe7;
    color: #166534;
}
.muted {
    color: #64748b;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    padding: 10px;
    border-bottom: 1px solid #dbe3ee;
    text-align: left;
}
th {
    background: #f7f9fc;
    width: 38%;
}
tr:last-child th,
tr:last-child td {
    border-bottom: 0;
}
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 800px) {
    .topbar {
        display: block;
        padding: 16px 18px;
    }
    .topbar h1 {
        font-size: 20px;
    }
    .topbar-actions {
        justify-content: flex-start;
        margin-top: 14px;
    }
    .app-topbar {
        display: grid;
        grid-template-columns: 1fr;
    }
    .app-brand-logo {
        grid-row: 1;
        width: 220px;
    }
    .app-topbar-title {
        grid-row: 2;
        text-align: center;
    }
    .app-topbar .topbar-actions {
        grid-row: 3;
        justify-self: center;
        justify-content: center;
        margin-top: 0;
    }
    .layout,
    .stats {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding: 8px;
        border-right: 0;
        border-bottom: 1px solid #d9e2ef;
    }
    .sidebar a {
        flex: 0 0 auto;
        margin: 0;
        white-space: nowrap;
    }
    .sidebar .nav-section-break {
        margin-top: 0;
        padding-top: 12px;
        border-top: 0;
        border-left: 1px solid #d9e2ef;
    }
    .filter-grid {
        grid-template-columns: 1fr;
    }
    .product-filter-grid {
        grid-template-columns: 1fr;
    }
    .filter-actions {
        align-items: stretch;
    }
    .filter-actions .btn {
        text-align: center;
        width: 100%;
    }
    .order-form,
    .order-edit-form,
    .order-item-form,
    .client-search-form,
    .client-form,
    .invoice-form {
        grid-template-columns: 1fr;
    }
    .material-form {
        grid-template-columns: 1fr;
    }
    .category-row,
    .category-form,
    .new-category-form {
        grid-template-columns: 1fr;
    }
    .category-actions,
    .category-actions .btn,
    .delete-inline .btn {
        width: 100%;
    }
    .details-grid {
        grid-template-columns: 1fr;
    }
    .danger-card {
        display: block;
    }
    .danger-card form {
        margin-top: 12px;
    }
    .danger-card .btn {
        width: 100%;
    }
    .form-actions {
        display: block;
    }
    .form-actions .btn {
        width: 100%;
    }
    .section-head {
        display: block;
    }
    .section-head .badge {
        margin-top: 10px;
    }
    main {
        padding: 20px;
    }
    .page-head {
        display: block;
    }
    .page-head .btn {
        margin-top: 12px;
    }
}
