:root {
    --ink: #111827;
    --muted: #6b7280;
    --line: #d1d5db;
    --panel: #ffffff;
    --canvas: #f8fafc;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --paid: #22c55e;
    --cancel: #ef4444;
    --free: #f97316;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    min-height: 60px;
    border: 0;
    border-radius: 8px;
    padding: 0 18px;
    font-weight: 700;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

input,
select {
    width: 100%;
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    background: white;
}

.hidden {
    display: none !important;
}

.screen {
    min-height: 100vh;
}

.login-screen {
    display: grid;
    place-items: center;
    padding: 18px;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(249, 115, 22, 0.16)),
        var(--canvas);
}

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

.login-card h1 {
    margin: 0 0 12px;
    font-size: 34px;
}

.app-screen {
    padding: 14px;
}

.topbar,
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar {
    margin-bottom: 16px;
}

.topbar h1,
.section-title h2,
.admin-section h3 {
    margin: 0;
}

.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.topbar-actions,
.payment-actions,
.export-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.primary-button {
    color: white;
    background: var(--brand);
}

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

.secondary-button {
    color: var(--ink);
    background: #e5e7eb;
}

.danger-button {
    color: white;
    background: var(--cancel);
}

.small-button {
    min-height: 44px;
}

.checkout-layout {
    display: grid;
    gap: 14px;
}

.products-area,
.cart-panel,
.admin-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.product-groups {
    display: grid;
    gap: 18px;
    margin-top: 14px;
}

.category-group h3 {
    margin: 0 0 10px;
    color: #164e63;
    font-size: 18px;
}

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

.product-button {
    min-height: 86px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    text-align: left;
    color: white;
    background: #2563eb;
}

.product-button span {
    font-size: 14px;
    font-weight: 700;
    opacity: 0.9;
}

.cart-panel {
    position: sticky;
    top: 12px;
    align-self: start;
}

.cart-panel h2 {
    margin: 0 0 12px;
}

.cart-list {
    min-height: 76px;
    display: grid;
    gap: 8px;
}

.cart-empty {
    color: var(--muted);
    padding: 16px 0;
}

.cart-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eef2f7;
}

.cart-row strong {
    display: block;
}

.cart-row span {
    color: var(--muted);
    font-size: 14px;
}

.quantity-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.quantity-actions button {
    width: 44px;
    min-height: 44px;
    padding: 0;
    background: #e5e7eb;
}

.total-box {
    display: grid;
    place-items: center;
    margin: 14px 0;
    padding: 16px;
    border: 2px solid #0f766e;
    border-radius: 8px;
    background: #ecfeff;
}

.total-box strong {
    font-size: 56px;
    line-height: 1;
}

.paid-button {
    flex: 1 1 130px;
    color: white;
    background: var(--paid);
}

.cancel-button {
    flex: 1 1 130px;
    color: white;
    background: var(--cancel);
}

.free-button {
    flex: 1 1 130px;
    color: white;
    background: var(--free);
}

.free-reason-panel {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 8px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
}

.message {
    min-height: 22px;
    margin: 10px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.error-message {
    color: #dc2626;
}

.success-message {
    color: #15803d;
}

.admin-panel {
    margin-top: 16px;
}

.admin-grid {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.admin-section h3 {
    margin-bottom: 12px;
}

.admin-form {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.import-box {
    display: grid;
    gap: 10px;
    margin: 0 0 14px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.import-box h4 {
    margin: 0;
}

.import-actions {
    display: grid;
    gap: 8px;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
}

.checkbox-line input {
    width: 22px;
    min-height: 22px;
}

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

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

th,
td {
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.action-cell {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 190px;
}

.table-action {
    min-height: 44px;
    padding: 0 12px;
}

.password-cell {
    min-width: 240px;
}

.password-cell input {
    min-height: 44px;
}

.inactive-row {
    color: #6b7280;
    background: #f9fafb;
}

.export-section {
    min-height: 180px;
}

.backup-box {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #e5e7eb;
}

.backup-box h4 {
    margin: 0;
}

.backup-box dl {
    display: grid;
    gap: 8px;
    margin: 0;
}

.backup-box dl div {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px;
}

.backup-box dt {
    color: var(--muted);
    font-weight: 700;
}

.backup-box dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.log-panel {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.log-status-list {
    display: grid;
    gap: 8px;
    margin: 0;
}

.log-status-list div {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px;
}

.log-status-list dt {
    color: var(--muted);
    font-weight: 700;
}

.log-status-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

#logs-table td:last-child {
    max-width: 460px;
    white-space: normal;
    overflow-wrap: anywhere;
}

@media (min-width: 760px) {
    .app-screen {
        padding: 22px;
    }

    .checkout-layout {
        grid-template-columns: minmax(0, 1fr) 360px;
    }

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

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

    .import-actions {
        grid-template-columns: 1fr 1fr auto;
        align-items: center;
    }
}

@media (min-width: 1180px) {
    .product-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

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