:root {
    --bg: #f5f1ee;
    --panel: #ffffff;
    --panel-strong: #fffdfc;
    --text: #241f1d;
    --muted: #766b66;
    --line: #e3dbd7;
    --accent: #5b524d;
    --accent-dark: #3f3835;
    --ink-soft: #1c1816;
    --success: #e7f8ee;
    --error: #fde9e9;
    --shadow: 0 20px 50px rgba(43, 34, 29, 0.08);
    --shadow-soft: 0 10px 24px rgba(43, 34, 29, 0.05);
    --sidebar-bg: #49423e;
    --sidebar-link: #ece7e5;
    --sidebar-link-bg: rgba(255, 255, 255, 0.06);
    --sidebar-link-active: #ffffff;
    --sidebar-link-active-bg: linear-gradient(135deg, #6a625d 0%, #544d49 100%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(114, 101, 95, 0.12), transparent 24%),
        radial-gradient(circle at bottom right, rgba(184, 170, 162, 0.12), transparent 22%),
        linear-gradient(180deg, #fcfbfa 0%, var(--bg) 100%);
    color: var(--text);
    overflow-x: hidden;
    line-height: 1.45;
}

a {
    color: var(--accent-dark);
    text-decoration: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 100%;
    table-layout: fixed;
}

th,
td {
    padding: 0.8rem 0.5rem;
    border-bottom: 1px solid var(--line);
    text-align: center;
    vertical-align: middle;
    word-break: break-word;
}

input,
select,
textarea,
button {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    font: inherit;
    background: var(--panel-strong);
    color: var(--text);
}

button {
    border: 1px solid #4e4642;
    background: linear-gradient(135deg, #625955 0%, #413936 100%);
    cursor: pointer;
    font-weight: 700;
    color: #fffaf7;
    box-shadow: 0 14px 30px rgba(67, 61, 58, 0.16);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.button-link {
    display: inline-block;
    text-align: center;
    padding: 0.85rem 0.95rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #fffefd 0%, #f5efeb 100%);
    box-shadow: var(--shadow-soft);
    color: var(--accent-dark);
}

label span,
h1,
h2,
h3 {
    display: block;
}

.app-shell {
    min-height: 100vh;
    width: 100%;
}

body.authenticated .app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.guest .app-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: clamp(0.75rem, 2vh, 1.5rem);
}

.sidebar {
    width: 100%;
    position: relative;
    inset: auto;
    padding: 0.45rem 0.75rem;
    background: linear-gradient(180deg, #544d49 0%, var(--sidebar-bg) 100%);
    color: #f8f5f3;
    box-shadow: 0 10px 30px rgba(32, 24, 21, 0.12);
    z-index: 1;
}

.sidebar > div,
.sidebar > nav {
    width: 100%;
}

.sidebar {
    position: relative;
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    align-items: center;
    gap: 1rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.nav-brand-text {
    display: inline-block;
    color: #f8f5f3;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    margin-top: 0;
}

.nav-links-main {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
    min-width: 0;
}

.nav-links-end {
    justify-content: flex-end;
    position: relative;
    z-index: 1;
}

.nav-links a {
    color: var(--sidebar-link);
    padding: 0.42rem 0.62rem;
    border-radius: 9px;
    background: var(--sidebar-link-bg);
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: 0.18s ease;
    font-size: 0.82rem;
    white-space: nowrap;
    line-height: 1.1;
}

.nav-logout {
    margin-left: auto;
}

.nav-links a:hover,
.nav-links a:focus-visible {
    color: var(--sidebar-link-active);
    background: var(--sidebar-link-active-bg);
}

.nav-links a.active {
    color: #2d2724;
    background: linear-gradient(135deg, #ffffff 0%, #e9e2de 100%);
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.content {
    padding: 0;
    width: 100%;
    min-width: 0;
}

body.authenticated .content {
    flex: 1;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: calc(100vh - 58px);
}

.content > * {
    min-width: 0;
}

.card,
.login-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(252, 249, 247, 0.97) 100%);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(227, 219, 215, 0.95);
    box-shadow: var(--shadow);
    border-radius: 26px;
}

.topbar {
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.75rem;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    border-radius: 0;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.55rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(227, 219, 215, 0.92);
    box-shadow: var(--shadow-soft);
}

.page-heading {
    font-size: 1.14rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--ink-soft);
    letter-spacing: 0.01em;
}

.sidebar-toggle {
    display: none;
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: none;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-direction: column;
}

.sidebar-toggle span {
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: var(--ink-soft);
    display: block;
}

.sidebar-backdrop {
    display: none;
}

.card {
    padding: 1.2rem 1.35rem;
}

.login-card {
    width: min(100%, 430px);
    margin: 0 auto;
    padding: clamp(1rem, 2.2vh, 2rem);
    background: rgba(95, 88, 84, 0.92);
    border-color: rgba(255, 255, 255, 0.12);
}

.grid {
    display: grid;
    gap: 0.6rem;
    margin: 0;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.grid.one {
    grid-template-columns: minmax(320px, 1fr);
    justify-content: stretch;
    flex: 1;
    min-height: 0;
}

.grid.three {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.grid.four {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.stack {
    display: grid;
    gap: 0.85rem;
}

.card h3 {
    margin: 0 0 0.75rem;
    font-size: 1.14rem;
    line-height: 1.15;
}

form.stack > label,
form.stack > .sale-extras {
    display: grid;
    gap: 0.38rem;
}

label span {
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.login-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: clamp(0.75rem, 1.8vh, 1.5rem);
}

.login-logo {
    width: auto;
    max-width: min(58vw, 230px);
    max-height: min(20vh, 160px);
    height: auto;
    display: block;
}

.login-card label span {
    margin-bottom: 0.3rem;
    font-weight: 700;
    color: #f5f7fb;
}

.login-card .stack {
    gap: clamp(0.75rem, 1.6vh, 1rem);
}

.login-card input,
.login-card button {
    padding: clamp(0.72rem, 1.5vh, 0.85rem) 0.95rem;
}

.login-card input[type="checkbox"] {
    width: auto;
    padding: 0;
    margin: 0;
}

.password-field {
    position: relative;
    display: block;
}

.password-field input {
    padding-right: 3rem;
}

.eye-button {
    width: 2rem;
    min-width: 2rem;
    height: 2rem;
    padding: 0.3rem;
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    right: 0.65rem;
    transform: translateY(-50%);
}

.eye-button svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.eye-button[aria-pressed="true"] {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.field-error {
    display: block;
    margin-top: 0.4rem;
    color: #ffb8b8;
    font-size: 0.85rem;
}

.login-options {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #dbe2ef;
    font-size: 0.92rem;
}

.check-row span {
    margin: 0;
    display: inline;
    font-weight: 400;
}

.stat-card span,
.muted,
.hint {
    color: var(--muted);
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 66px;
}

.stat-card strong,
.amount {
    font-size: 2rem;
    margin-top: 0.4rem;
    color: var(--ink-soft);
}

.stat-card strong {
    margin-top: 0;
    font-size: 1.9rem;
    line-height: 1;
}

.amount {
    margin: 0.35rem 0 0;
    font-size: 1.7rem;
}

@media (min-width: 1100px) {
    body.authenticated .content > section:first-of-type.grid.four {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.75rem;
        padding: 0.8rem 1rem 0;
    }

    body.authenticated .content > section:first-of-type.grid.four .stat-card {
        min-height: 82px;
        padding: 1rem 1.1rem;
    }

    body.authenticated .content > section:first-of-type.grid.four .stat-card span {
        font-size: 0.88rem;
    }

    body.authenticated .content > section:first-of-type.grid.four .stat-card strong {
        font-size: 2rem;
    }

    body.authenticated .content > section:nth-of-type(2).card {
        margin: 0 1rem;
        padding: 1rem 1.1rem;
    }

    body.authenticated .content > section:nth-of-type(2).card form.grid.four {
        grid-template-columns: 1.1fr 1.1fr 0.9fr 0.8fr;
        gap: 0.75rem;
        align-items: end;
    }

    body.authenticated .content > section:nth-of-type(3).grid.three {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.75rem;
        padding: 0 1rem;
    }

    body.authenticated .content > section:nth-of-type(3).grid.three .card {
        min-height: 128px;
        padding: 1rem 1.1rem;
    }

    body.authenticated .content > section:nth-of-type(3).grid.three .amount {
        font-size: 2rem;
    }

    body.authenticated .content > section:nth-of-type(4).card {
        margin: 0 1rem;
        min-height: 0;
        padding: 1rem 1.1rem;
    }

    body.authenticated .content > section:nth-of-type(4).card table {
        table-layout: auto;
    }

    body.authenticated .content > section:nth-of-type(5).grid.two {
        grid-template-columns: 0.95fr 1.05fr;
        gap: 0.75rem;
        padding: 0 1rem;
    }

    body.authenticated .content > section:nth-of-type(6).card {
        margin: 0 1rem 1rem;
        padding: 1rem 1.1rem;
    }
}

.alert {
    padding: 1rem 1.1rem;
    border-radius: 14px;
    margin-bottom: 1rem;
}

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

.alert.error {
    background: var(--error);
    color: #4f2020;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.65rem;
}

.section-head.compact {
    margin-bottom: 0.5rem;
}

.sale-extras .section-head.compact h3 {
    display: block;
    margin: 0;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.45;
    color: var(--ink-soft);
}

.sale-extras .section-head.compact {
    margin: 0 0 0.38rem;
    justify-content: flex-start;
}

.topbar strong,
.card h3,
.card h2,
.card th,
label span {
    color: var(--ink-soft);
}

table thead th {
    font-size: 0.88rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: center;
}

tbody tr:hover {
    background: #f6f2f0;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(93, 86, 82, 0.42);
    box-shadow: 0 0 0 4px rgba(93, 86, 82, 0.1);
    background: #fff;
}

button:hover,
button:focus-visible,
.button-link:hover,
.button-link:focus-visible {
    transform: translateY(-1px);
    filter: brightness(1.02);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.centered-hint {
    margin-top: clamp(0.7rem, 1.5vh, 1rem);
    text-align: center;
}

.phone-field {
    position: relative;
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 0.65rem;
    align-items: center;
}

.customer-search {
    position: relative;
}

.customer-search-list {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 20;
    display: grid;
    gap: 0.2rem;
    padding: 0.3rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 28px rgba(43, 34, 29, 0.12);
    backdrop-filter: blur(10px);
}

.customer-search-item {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    box-shadow: none;
    text-align: left;
}

.customer-search-item:hover,
.customer-search-item:focus-visible {
    background: #f4efec;
}

.customer-lock-row {
    display: inline-flex;
    justify-content: flex-start;
    align-items: center;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.customer-lock-button {
    width: auto;
    min-width: 0;
    padding: 0.24rem 0.55rem;
    font-size: 0.68rem;
    box-shadow: none;
}

.locked-input {
    background: linear-gradient(180deg, #f6f1ee 0%, #efe7e2 100%);
    color: #4d4541;
    cursor: default;
}

.customer-search-name,
.customer-search-phone {
    display: block;
}

.customer-search-name {
    color: var(--ink-soft);
    font-size: 0.8rem;
    font-weight: 700;
}

.customer-search-phone {
    margin-top: 0.12rem;
    color: var(--muted);
    font-size: 0.7rem;
}

.phone-prefix {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.65rem 0.75rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #faf5f2 0%, #f3ece8 100%);
    color: var(--ink-soft);
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.service-boxes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
}

.service-box {
    position: relative;
    display: block;
    cursor: pointer;
}

.service-box input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.service-box-copy {
    display: flex;
    flex-direction: column;
    gap: 0.14rem;
    min-height: 54px;
    justify-content: center;
    padding: 0.6rem 0.7rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #fffefd 0%, #f7f1ed 100%);
    transition: 0.18s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.service-box-copy strong {
    color: var(--ink-soft);
    font-size: 0.92rem;
    line-height: 1.05;
}

.service-box-copy small {
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1;
}

.service-box input:focus-visible + .service-box-copy {
    border-color: rgba(93, 86, 82, 0.42);
    box-shadow: 0 0 0 4px rgba(93, 86, 82, 0.12);
}

.service-box input:checked + .service-box-copy {
    background: linear-gradient(135deg, #5c5551 0%, #47413d 100%);
    border-color: #4d4642;
    box-shadow: 0 12px 24px rgba(67, 61, 58, 0.16);
}

.service-box input:checked + .service-box-copy strong,
.service-box input:checked + .service-box-copy small {
    color: #ffffff;
}

.sale-extras {
    display: grid;
    gap: 0.65rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.product-boxes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
}

.product-box {
    position: relative;
    display: block;
    cursor: pointer;
}

.product-box input[type="checkbox"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.product-box-copy {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.14rem 0.55rem;
    align-items: center;
    min-height: 52px;
    padding: 0.52rem 0.62rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #fffefd 0%, #f7f1ed 100%);
    transition: 0.18s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.product-box-copy strong {
    color: var(--ink-soft);
    font-size: 0.84rem;
    line-height: 1.05;
}

.product-box-copy small {
    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1;
    grid-column: 1;
}

.product-box-qty {
    display: grid;
    grid-template-columns: auto minmax(0, 76px);
    align-items: center;
    gap: 0.35rem;
    margin-top: 0;
    grid-column: 2;
    grid-row: 1 / span 2;
    position: relative;
    z-index: 2;
}

.product-box-qty span {
    margin: 0;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
}

.product-box-qty input {
    padding: 0.45rem 0.55rem;
    min-height: 40px;
    font-size: 0.94rem;
    border-radius: 12px;
    text-align: center;
    font-weight: 700;
    position: relative;
    z-index: 3;
    pointer-events: auto;
}

.product-box-qty input:disabled {
    opacity: 0;
    pointer-events: none;
}

.product-box input:focus-visible + .product-box-copy {
    border-color: rgba(93, 86, 82, 0.42);
    box-shadow: 0 0 0 4px rgba(93, 86, 82, 0.12);
}

.product-box input:checked + .product-box-copy {
    background: linear-gradient(135deg, #5c5551 0%, #47413d 100%);
    border-color: #4d4642;
    box-shadow: 0 12px 24px rgba(67, 61, 58, 0.16);
}

.product-box input:checked + .product-box-copy strong,
.product-box input:checked + .product-box-copy small,
.product-box input:checked + .product-box-copy .product-box-qty span {
    color: #ffffff;
}

.product-box input:checked + .product-box-copy .product-box-qty input {
    background: rgba(255, 255, 255, 0.96);
}

.hint {
    font-size: 0.74rem;
    line-height: 1.35;
}

.grid.one > .card {
    width: 100%;
    margin-inline: 0;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.grid.one > .card form.stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 0.65rem;
    row-gap: 0.75rem;
    align-items: start;
    flex: 1;
    align-content: start;
}

.grid.one > .card form.stack > label:nth-of-type(3),
.grid.one > .card form.stack > .sale-extras,
.grid.one > .card form.stack > label:nth-of-type(5),
.grid.one > .card form.stack > button {
    grid-column: 1 / -1;
}

.grid.two > .card {
    min-height: 100%;
}

.grid.one > .card form.stack > button[type="submit"] {
    margin-top: 0.15rem;
    min-height: 52px;
    font-size: 0.95rem;
}

.grid.one > .card form.stack > input[type="hidden"] {
    display: none;
}

input,
select,
textarea,
button {
    padding: 0.9rem 1rem;
}

@media (min-width: 1100px) and (min-height: 680px) {
    html,
    body,
    body.authenticated .app-shell {
        min-height: 100dvh;
    }

    body.authenticated {
        overflow-y: auto;
    }

    body.authenticated .content {
        min-height: calc(100dvh - 58px);
        overflow: visible;
    }

    .grid.one {
        height: 100%;
        min-height: 100%;
        margin-bottom: 0;
    }

    .grid.one > .card {
        height: 100%;
        min-height: 100%;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        box-shadow: none;
    }
}

@media (max-width: 1200px) {
    .grid.four {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .grid.three {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 960px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    body.authenticated .app-shell {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        display: block;
        width: min(82vw, 280px);
        inset: 0 auto 0 0;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        padding: 1rem;
        overflow-y: auto;
        box-shadow: 14px 0 35px rgba(32, 24, 21, 0.14);
        z-index: 30;
    }

    .nav-brand {
        justify-content: center;
        width: 100%;
    }

    .nav-brand-text {
        font-size: 1.08rem;
        letter-spacing: 0.14em;
        white-space: normal;
        text-align: center;
    }

    .nav-links {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-top: 1.25rem;
    }

    .nav-links-main,
    .nav-links-end {
        display: grid;
        gap: 0.75rem;
    }

    .nav-links a {
        width: 100%;
    }

    .nav-logout {
        justify-self: stretch;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.28);
        border: 0;
        padding: 0;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.22s ease, visibility 0.22s ease;
        z-index: 20;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .content,
    body.authenticated .content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 0.95rem;
        padding-top: 0.85rem;
        justify-content: flex-start;
        min-height: auto;
        height: auto;
    }

    .content > *,
    .grid,
    .stack,
    form,
    label {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .grid.one,
    .grid.two,
    .grid.three,
    .grid.four {
        grid-template-columns: 1fr;
    }

    .service-boxes {
        grid-template-columns: 1fr;
    }

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

    .topbar {
        padding: 0.35rem 0 0.85rem;
        align-items: flex-start;
    }

    .topbar-title {
        width: 100%;
        justify-content: flex-start;
        padding: 0.55rem 0.65rem;
        border-radius: 16px;
    }

    .card,
    .login-card {
        border-radius: 18px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 1rem;
    }

    .section-head {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    th,
    td {
        padding: 0.7rem 0.45rem;
    }

    table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    input,
    select,
    textarea,
    button {
        max-width: 100%;
    }

    .nav-brand-text {
        letter-spacing: 0.08em;
    }

    .login-card {
        padding: 1.5rem;
    }

    .grid.one > .card form.stack {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .content,
    body.authenticated .content {
        padding: 0.7rem;
        padding-top: 0.7rem;
    }

    .card,
    .login-card {
        padding: 0.95rem;
        border-radius: 16px;
    }

    .page-heading {
        font-size: 1.2rem;
    }

    .phone-field {
        grid-template-columns: 1fr;
        gap: 0.45rem;
    }

    .phone-prefix {
        min-height: 44px;
        justify-content: flex-start;
    }

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

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

    .service-box-copy {
        min-height: 50px;
        padding: 0.52rem 0.6rem;
    }

    .service-box-copy strong {
        font-size: 0.84rem;
    }

    .service-box-copy small {
        font-size: 0.72rem;
    }

    .product-box-copy {
        min-height: 0;
        padding: 0.55rem 0.6rem;
    }

    th,
    td {
        padding: 0.6rem 0.4rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 420px) {
    .sidebar {
        width: min(88vw, 280px);
    }

    .service-boxes {
        grid-template-columns: 1fr;
    }

    .product-boxes {
        grid-template-columns: 1fr;
    }

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

    .product-box-copy small,
    .product-box-qty {
        grid-column: auto;
    }

    .product-box-qty {
        grid-row: auto;
        grid-template-columns: auto minmax(0, 64px);
        justify-content: start;
    }

    .nav-brand-text {
        font-size: 0.95rem;
        letter-spacing: 0.06em;
    }

    input,
    select,
    textarea,
    button {
        padding: 0.75rem 0.85rem;
    }
}
