:root {
    --bg: #f6f4f1;
    --panel: #ffffff;
    --ink: #202124;
    --muted: #6d6a66;
    --line: #ded8cf;
    --accent: #1f6f5b;
    --accent-dark: #174f42;
    --danger: #b73d37;
    --success: #176d3b;
    --shadow: 0 18px 45px rgba(40, 37, 32, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(100%, 420px);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 34px;
}

.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 26px;
    font-weight: 700;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 32px;
}

h2 {
    margin-bottom: 6px;
    font-size: 22px;
}

h3 {
    margin-bottom: 12px;
    font-size: 16px;
}

.muted,
.section-heading p,
.hint {
    color: var(--muted);
}

.hint {
    margin: 18px 0 0;
    font-size: 13px;
}

.login-form,
.product-form {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 7px;
    color: #3d3a36;
    font-size: 14px;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
}

select {
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 7px 9px;
}

input[type="file"] {
    padding: 9px;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 91, 0.16);
    outline: none;
}

button,
.logout {
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    font-weight: 700;
    padding: 10px 16px;
    text-align: center;
    text-decoration: none;
}

button:hover,
.logout:hover {
    background: var(--accent-dark);
}

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

.topnav a {
    min-height: 40px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--accent-dark);
    font-weight: 700;
    padding: 8px 13px;
    text-decoration: none;
}

.topnav a.active {
    background: #edf5f1;
    border-color: #b9d0c8;
}

.topnav .logout {
    border-color: var(--accent);
    color: white;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px clamp(18px, 4vw, 46px);
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.eyebrow {
    margin-bottom: 3px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.dashboard {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 28px clamp(18px, 4vw, 46px) 46px;
}

.alert {
    margin-bottom: 18px;
    border-radius: 6px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert.error {
    background: #f9e7e5;
    color: #84221d;
}

.alert.success {
    background: #e3f2e9;
    color: var(--success);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

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

.stats-grid article,
.report-grid article,
.product-form,
.inventory-panel,
.sales-panel,
.cart-panel,
.product-page {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stats-grid article {
    display: grid;
    gap: 8px;
    padding: 18px;
}

.report-grid article {
    display: grid;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.stats-grid span,
.report-grid span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stats-grid strong,
.report-grid strong {
    font-size: 28px;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(320px, 430px) 1fr;
    gap: 22px;
    align-items: start;
}

.product-form,
.inventory-panel,
.sales-panel,
.cart-panel,
.product-page {
    padding: 22px;
}

.product-page {
    max-width: 760px;
}

.product-page .product-form {
    border: 0;
    padding: 0;
}

.product-page .danger-zone {
    margin-top: 26px;
    border-top: 1px solid var(--line);
    padding-top: 22px;
}

.danger-zone .section-heading p {
    color: var(--danger);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

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

.current-image {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.inline-check input {
    width: auto;
    min-height: 0;
}

.current-image img {
    width: 72px;
    height: 72px;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.secondary-link,
.small-link {
    display: inline-grid;
    min-height: 36px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--accent-dark);
    font-weight: 700;
    padding: 7px 12px;
    text-decoration: none;
}

.secondary-link:hover,
.small-link:hover {
    background: #edf5f1;
}

.filter-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 130px 140px auto auto auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.export-row {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.sub-heading {
    margin-top: 22px;
}

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

.dashboard-grid section {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.simple-list {
    display: grid;
    gap: 10px;
}

.simple-list div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.simple-list div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.simple-list span {
    color: var(--muted);
    font-weight: 700;
}

.sizes-block {
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.size-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1080px;
}

.sales-table {
    min-width: 900px;
}

.cart-table {
    min-width: 900px;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td > span,
td strong + span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.product-thumb {
    width: 72px;
    height: 72px;
    display: block;
    max-width: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
    background: #f1eee9;
}

.no-image {
    display: inline-grid;
    width: 72px;
    height: 72px;
    place-items: center;
    border: 1px dashed var(--line);
    border-radius: 6px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.size-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.size-pills span {
    border: 1px solid #cfd9d3;
    border-radius: 999px;
    background: #f7fbf8;
    color: #24483d;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 700;
}

.size-pills .low-stock {
    border-color: #e2b4b0;
    background: #f9e7e5;
    color: var(--danger);
}

.row-actions {
    display: grid;
    gap: 8px;
    min-width: 320px;
}

.cart-form {
    display: grid;
    grid-template-columns: minmax(76px, 1fr) 58px 86px auto;
    gap: 6px;
    align-items: center;
}

.cart-form input {
    min-height: 36px;
    padding: 7px 8px;
}

.cart-edit-form {
    display: grid;
    grid-template-columns: 70px 92px auto;
    gap: 6px;
    align-items: center;
}

.cart-edit-form input {
    min-height: 36px;
    padding: 7px 8px;
}

.checkout-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-top: 18px;
}

.clear-cart-form {
    margin-top: 10px;
}

.small-button,
.edit-button,
.danger {
    min-height: 36px;
    padding: 7px 10px;
}

.small-button {
    background: var(--accent);
}

.edit-button {
    width: 100%;
    background: #edf5f1;
    border: 1px solid #b9d0c8;
    color: var(--accent-dark);
}

.edit-button:hover {
    background: #dfeee8;
}

.danger {
    background: transparent;
    border: 1px solid #e2b4b0;
    color: var(--danger);
}

.danger:hover {
    background: #f9e7e5;
}

.out-of-stock {
    color: var(--danger);
    font-size: 13px;
    font-weight: 700;
}

.empty-state {
    display: grid;
    gap: 6px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    padding: 28px;
    text-align: center;
}

.empty-state strong {
    color: var(--ink);
}

.receipt-body {
    background: #fff;
}

.receipt {
    width: min(760px, 100%);
    margin: 0 auto;
    padding: 28px;
}

.receipt-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    padding-bottom: 18px;
}

.receipt-table {
    min-width: 0;
    margin-top: 18px;
}

@media print {
    .receipt-head button {
        display: none;
    }
}

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

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

@media (max-width: 620px) {
    body {
        background: #fff;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 20px;
    }

    input,
    select,
    button,
    .logout {
        min-height: 46px;
        font-size: 16px;
    }

    .login-shell {
        align-items: start;
        padding: 16px;
    }

    .login-panel {
        width: 100%;
        margin-top: 24px;
        box-shadow: none;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 18px 14px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .topnav,
    .topnav a,
    .logout {
        width: 100%;
    }

    .topnav {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .topnav .logout {
        grid-column: 1 / -1;
    }

    .dashboard {
        padding: 18px 12px 32px;
    }

    .stats-grid,
    .report-grid,
    .dashboard-grid,
    .form-grid,
    .size-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        gap: 8px;
    }

    .stats-grid article {
        padding: 14px;
    }

    .stats-grid strong {
        font-size: 24px;
    }

    .login-panel,
    .product-form,
    .inventory-panel,
    .sales-panel,
    .cart-panel,
    .product-page {
        padding: 18px;
    }

    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .secondary-link {
        min-height: 46px;
    }

    .checkout-form,
    .cart-form,
    .cart-edit-form,
    .filter-form {
        grid-template-columns: 1fr;
    }

    .export-row {
        flex-direction: column;
    }

    .row-actions {
        min-width: 0;
    }

    .table-wrap {
        overflow: visible;
    }

    table,
    .sales-table,
    .cart-table {
        min-width: 0;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
        width: 100%;
    }

    thead {
        display: none;
    }

    tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 12px;
        overflow: hidden;
        background: #fff;
    }

    td {
        display: grid;
        grid-template-columns: 98px minmax(0, 1fr);
        gap: 12px;
        align-items: start;
        border-bottom: 1px solid var(--line);
        padding: 12px;
        text-align: right;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
        text-align: left;
        text-transform: uppercase;
    }

    td > * {
        justify-self: end;
        max-width: 100%;
    }

    td > strong,
    td > span,
    td strong + span {
        text-align: right;
    }

    .size-pills {
        justify-content: flex-end;
    }

    .product-thumb,
    .no-image,
    .current-image img {
        display: block;
        width: 86px;
        height: 86px;
        max-width: none;
    }

    .current-image {
        align-items: flex-start;
        flex-direction: column;
    }

    .checkout-form button,
    .clear-cart-form button,
    .row-actions button {
        width: 100%;
    }
}
