:root {
    --bg: #f3f6f4;
    --panel: #ffffff;
    --ink: #17211c;
    --muted: #607168;
    --line: #d8e1dc;
    --accent: #0f7a5a;
    --accent-dark: #0a6046;
    --danger: #b42318;
    --warn: #9a5b00;
}

* {
    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,
a {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 24px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 28px;
}

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

p {
    margin: 6px 0 0;
    color: var(--muted);
}

a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.admin-link,
.nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.top-actions {
    display: grid;
    grid-template-columns: auto minmax(150px, 220px) auto;
    gap: 10px;
    align-items: center;
}

.register-label {
    margin: 0;
    color: var(--muted);
}

.nav {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 0.85fr);
    gap: 20px;
    padding: 20px;
}

.products {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    align-content: start;
}

.product {
    min-height: 120px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    padding: 18px;
    box-shadow: 0 2px 10px rgba(23, 33, 28, 0.08);
}

.product span {
    font-size: 24px;
    font-weight: 700;
}

.product strong {
    font-size: 22px;
    color: var(--accent);
}

.product:active {
    transform: translateY(1px);
}

.checkout,
.panel,
.login {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(23, 33, 28, 0.08);
}

.checkout {
    position: sticky;
    top: 16px;
    align-self: start;
    padding: 20px;
}

.cart {
    min-height: 140px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fbfdfc;
}

.cart.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.cart-line {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    text-align: left;
    padding: 12px 4px;
    cursor: pointer;
}

.cart-line:last-child {
    border-bottom: 0;
}

.cart-line strong {
    white-space: nowrap;
}

.cart-line small {
    color: var(--muted);
}

.total-row,
.change-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: baseline;
    margin-top: 18px;
    font-size: 22px;
}

.total-row strong,
.change-row strong {
    font-size: 30px;
}

.change-row.negative strong {
    color: var(--warn);
}

.change-row.positive strong {
    color: var(--accent);
}

label {
    display: block;
    margin: 18px 0 8px;
    font-weight: 700;
}

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

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

.quick-cash {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.quick-cash button,
.numpad button {
    min-height: 58px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    color: var(--ink);
    cursor: pointer;
    font-size: 24px;
    font-weight: 700;
}

.quick-cash button {
    min-height: 48px;
    font-size: 18px;
    color: var(--accent);
}

.quick-cash button:active,
.numpad button:active {
    transform: translateY(1px);
}

.primary,
.secondary,
.small {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

.primary {
    margin-top: 18px;
    background: var(--accent);
    color: #ffffff;
}

.primary:hover {
    background: var(--accent-dark);
}

.secondary {
    margin-top: 10px;
    background: #eef3f0;
    color: var(--ink);
}

.secondary.compact {
    min-height: 42px;
}

.small {
    min-height: 38px;
    padding: 0 12px;
    background: var(--accent);
    color: #ffffff;
}

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

.notice {
    margin: 16px 20px 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: #e8f6ef;
    border: 1px solid #bee8d0;
    color: #0a6046;
    font-weight: 700;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
    gap: 20px;
    padding: 20px;
}

.panel {
    padding: 20px;
}

.danger-zone {
    border-color: #f0b8b3;
}

.history {
    grid-column: 1 / -1;
}

.metric {
    font-size: 34px;
    color: var(--ink);
    font-weight: 700;
}

.register-summary {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.register-summary div {
    display: grid;
    grid-template-columns: minmax(100px, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfdfc;
}

.register-summary span {
    color: var(--muted);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.product-admin {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 110px;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.product-fields {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(90px, 0.5fr) minmax(90px, 0.5fr) 70px 120px;
    gap: 10px;
    align-items: center;
}

.product-admin.header-row {
    grid-template-columns: minmax(150px, 1fr) minmax(90px, 0.5fr) minmax(90px, 0.5fr) 70px 120px 110px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.product-admin.new-row {
    grid-template-columns: minmax(150px, 1fr) minmax(90px, 0.5fr) minmax(90px, 0.5fr) 70px 120px;
    border-bottom: 0;
}

.product-admin input[type="checkbox"] {
    width: 24px;
    min-height: 24px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-size: 14px;
}

td input[type="checkbox"] {
    width: 24px;
    min-height: 24px;
}

@media (max-width: 720px) {
    .product-admin,
    .product-fields,
    .product-admin.header-row {
        grid-template-columns: 1fr;
    }

    .product-admin.header-row {
        display: none;
    }
}

.login-page {
    display: grid;
    place-items: center;
    padding: 20px;
}

.login {
    width: min(420px, 100%);
    padding: 24px;
}

.login a {
    display: inline-block;
    margin-top: 16px;
}

@media (max-width: 860px) {
    .layout,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .checkout {
        position: static;
    }

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

    .top-actions {
        width: 100%;
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .layout,
    .admin-grid {
        padding: 12px;
    }

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

    .product {
        min-height: 104px;
        padding: 12px;
    }

    .product span {
        font-size: 20px;
    }

    .product strong,
    .total-row,
    .change-row {
        font-size: 20px;
    }

    .total-row strong,
    .change-row strong {
        font-size: 26px;
    }
}
