:root {
    --bg: #f6f3ee;
    --panel: #ffffff;
    --ink: #25211d;
    --muted: #756c62;
    --line: #ddd6cc;
    --accent: #2f6f5e;
    --accent-dark: #245548;
    --danger: #a43d32;
    --soft: #eef4f1;
}

* {
    box-sizing: border-box;
}

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

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

a:hover {
    text-decoration: underline;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 28px;
    background: #fffaf2;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-size: 20px;
    font-weight: 700;
}

.brand img {
    width: 86px;
    height: 34px;
    object-fit: contain;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 64px;
}

.page-head {
    margin-bottom: 18px;
}

.page-head h1 {
    margin: 0 0 6px;
    font-size: 34px;
    line-height: 1.1;
}

.page-head p,
.muted {
    color: var(--muted);
}

.split {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(44, 34, 20, 0.05);
}

.panel + .panel,
section + section {
    margin-top: 22px;
}

.narrow {
    max-width: 460px;
    margin: 56px auto;
}

.form {
    display: grid;
    gap: 14px;
}

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

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 10px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
}

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

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

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

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

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover,
.button:hover {
    text-decoration: none;
    border-color: var(--accent);
}

.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

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

.discount-button {
    border-color: #9a661e;
    background: #f2c36b;
    color: #3b2910;
}

.discount-button:hover {
    border-color: #7d5116;
    background: #e6b24f;
}

.danger {
    color: var(--danger);
}

.link {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
}

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

.order-table-actions {
    margin-top: 12px;
}

.error {
    color: var(--danger);
    font-weight: 700;
}

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

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

th {
    color: var(--muted);
    background: #fbfaf7;
    font-size: 13px;
}

tfoot td {
    font-weight: 700;
    background: var(--soft);
}

.money,
.meta strong,
.blank-items td:nth-child(4),
.blank-items td:nth-child(6),
.blank-items tfoot td {
    white-space: nowrap;
}

.money {
    min-width: 110px;
    word-break: keep-all;
}

.price-nowrap {
    display: inline-block;
    min-width: max-content;
    white-space: nowrap;
    word-break: keep-all;
}

.money-input input {
    min-width: 96px;
}

.order-table input {
    min-width: 82px;
}

.order-table tbody tr.dragging {
    opacity: 0.55;
}

.base-sum-row td {
    background: #f8f0cf;
    font-weight: 700;
    text-transform: uppercase;
}

.dish-name-cell {
    position: relative;
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-right: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f7f3ed;
    color: var(--muted);
    cursor: grab;
    user-select: none;
    vertical-align: middle;
}

.drag-handle:active {
    cursor: grabbing;
}

.time-cell {
    min-width: 96px;
}

.serving-time-input {
    width: 86px;
    min-height: 34px;
    padding: 6px 8px;
    text-align: center;
}

.time-control {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.step-field {
    display: inline-grid;
    grid-template-columns: 30px 68px 30px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.step-field button {
    min-height: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #f7f3ed;
    color: var(--accent);
}

.step-field input {
    min-width: 0;
    width: 68px;
    min-height: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-radius: 0;
    text-align: center;
}

.step-field input::-webkit-outer-spin-button,
.step-field input::-webkit-inner-spin-button,
.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.step-field input,
.quantity-input {
    appearance: textfield;
    -moz-appearance: textfield;
}

.time-separator {
    color: var(--muted);
    font-weight: 700;
}

.quantity-input {
    min-width: 74px;
}

.dish-modal .quantity-input {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
}

.fixed-price {
    vertical-align: middle;
}

.note-cell {
    min-width: 210px;
}

.note-cell input {
    min-width: 200px;
}

.delete-cell {
    width: 44px;
    text-align: center;
}

.trash-button {
    min-width: 34px;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 6px;
    border-color: transparent;
    background: transparent;
    color: var(--danger);
}

.trash-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.trash-button:hover {
    border-color: var(--danger);
    background: #fff3f1;
}

.add-line {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 190px 110px minmax(180px, 1fr) auto;
    gap: 10px;
    margin-top: 16px;
}

.category-add {
    grid-template-columns: minmax(220px, 1fr) 140px auto;
    margin-top: 0;
}

.users-add {
    grid-template-columns: minmax(160px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr) 180px auto;
    margin-top: 0;
}

.order-items-panel {
    overflow-x: auto;
}

.menu-picker h2 {
    margin-top: 0;
}

.menu-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.menu-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 78px;
    padding: 12px;
    border: 1px solid #9f978d;
    border-radius: 6px;
    background: #e3dfd8;
    color: var(--ink);
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.15;
}

.menu-tile:hover {
    border-color: var(--accent);
    background: var(--soft);
}

.category-tile:nth-child(6n + 1) {
    background: #d8efdf;
}

.category-tile:nth-child(6n + 2) {
    background: #f4ebb7;
}

.category-tile:nth-child(6n + 3) {
    background: #d6e7f4;
}

.category-tile:nth-child(6n + 4) {
    background: #ead9f2;
}

.category-tile:nth-child(6n + 5) {
    background: #f0d6c8;
}

.category-tile:nth-child(6n) {
    background: #d7ece8;
}

.dish-tile {
    min-height: 64px;
    background: #f9f8f5;
    font-size: 15px;
}

.menu-panel-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.menu-panel-head h3 {
    margin: 0;
    font-size: 22px;
}

.dish-modal,
.discount-modal,
.required-fields-modal,
.taste-reminder-modal,
.gift-reminder-modal,
.order-reminder-modal,
.save-confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.35);
}

.dish-modal[hidden],
.discount-modal[hidden],
.required-fields-modal[hidden],
.taste-reminder-modal[hidden],
.gift-reminder-modal[hidden],
.order-reminder-modal[hidden],
.save-confirm-modal[hidden] {
    display: none;
}

.dish-modal-card {
    width: min(420px, 100%);
    padding: 20px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.dish-modal-card h3 {
    margin: 0 0 16px;
}

.modal-form {
    display: grid;
    gap: 16px;
}

.modal-form .form-actions,
.dish-modal-card > .form-actions {
    justify-content: flex-end;
}

.discount-amount {
    color: var(--danger);
}

.seating-field {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(260px, 0.9fr);
    gap: 14px;
    align-items: stretch;
}

.seating-actions {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
}

.seating-open-tile {
    min-height: 96px;
    background: #d7ece8;
}

.seating-preview {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 96px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.seating-preview[hidden] {
    display: none;
}

.seating-preview img {
    width: 100%;
    height: 80px;
    object-fit: contain;
    background: #f7f5f0;
    border: 1px solid var(--line);
}

.seating-preview-name {
    color: var(--ink);
    font-weight: 700;
}

.seating-modal {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.35);
}

.seating-modal[hidden] {
    display: none;
}

.seating-modal-card {
    width: min(1120px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow: auto;
    padding: 20px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.seating-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.seating-tile {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfaf7;
    color: var(--ink);
    font-weight: 700;
}

.seating-tile:hover {
    border-color: var(--accent);
    background: var(--soft);
}

.seating-tile img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
}

.dish-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.dish-card {
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.dish-card img,
.photo-placeholder {
    display: grid;
    width: 100%;
    aspect-ratio: 4 / 3;
    place-items: center;
    object-fit: cover;
    background: #e7ded1;
    color: var(--muted);
    font-weight: 700;
}

.dish-card > div {
    padding: 14px;
}

.dish-card h3 {
    margin: 0 0 8px;
}

.dish-card p {
    margin: 0 0 12px;
    color: var(--muted);
}

.meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.tech {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}

.mini-table th,
.mini-table td {
    padding: 6px;
    font-size: 13px;
}

.ingredients-editor {
    display: grid;
    gap: 10px;
}

.ingredients-table input,
.ingredients-table select {
    min-width: 120px;
}

.ingredients-table th:last-child,
.ingredients-table td:last-child {
    width: 90px;
}

.print-page {
    background: #d8d8d8;
}

.print-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 16px;
}

.sheet {
    display: flex;
    flex-direction: column;
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 24px;
    padding: 4mm;
    background: #fff;
    color: #000;
    font-size: 10px;
    line-height: 1.08;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.25);
}

.print-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 0 5px;
}

.print-brand img {
    width: 58px;
    height: 22px;
    object-fit: contain;
}

.sheet h1 {
    margin: 0 0 2px;
    text-align: center;
    font-size: 14px;
    line-height: 1;
}

.doc-title {
    margin: 0 0 3px;
    text-align: center;
    font-size: 8.5px;
    line-height: 1.05;
}

.blank-head-grid {
    display: grid;
    grid-template-columns: 60% 1fr;
    gap: 4px;
    align-items: stretch;
    margin-bottom: 3px;
}

.blank-info td,
.blank-items th,
.blank-items td {
    border: 1px solid #000;
    padding: 1px 3px;
    font-size: 10px;
    line-height: 1.05;
}

.blank-info {
    margin-bottom: 0;
}

.blank-info td:first-child {
    width: 34%;
    font-weight: 700;
}

.blank-seating-box {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    border: 1px solid #000;
    padding: 2px;
}

.blank-seating-box img {
    display: block;
    width: 100%;
    max-height: 132px;
    object-fit: contain;
}

.blank-items {
    table-layout: fixed;
}

.blank-items th:nth-child(1),
.blank-items td:nth-child(1) {
    width: 7%;
}

.blank-items th:nth-child(2),
.blank-items td:nth-child(2) {
    width: 39%;
}

.blank-items th:nth-child(3),
.blank-items td:nth-child(3) {
    width: 13.5%;
}

.blank-items th:nth-child(4),
.blank-items td:nth-child(4),
.blank-items th:nth-child(6),
.blank-items td:nth-child(6) {
    width: 8%;
}

.blank-items th:nth-child(5),
.blank-items td:nth-child(5) {
    width: 5%;
}

.blank-items th:nth-child(7),
.blank-items td:nth-child(7) {
    width: 19.5%;
}

.blank-items th {
    background: #f0f0f0;
    color: #000;
    text-align: center;
}

.blank-items td:nth-child(1),
.blank-items td:nth-child(3),
.blank-items td:nth-child(4),
.blank-items td:nth-child(5),
.blank-items td:nth-child(6) {
    text-align: center;
}

.blank-items td:nth-child(3) {
    font-style: italic;
}

.blank-items td:nth-child(5) {
    font-weight: 700;
}

.category-row td {
    background: #ffd84d;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.blank-items .category-row td {
    background: #ffd84d;
    font-weight: 800;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.category-row td:first-child {
    text-align: center;
}

.category-row td:nth-child(2) {
    text-align: left;
}

.base-sum-row td {
    background: #f8f0cf;
    font-weight: 700;
    font-style: normal;
    text-transform: uppercase;
}

.base-sum-row td:first-child {
    text-align: right;
}

.signatures {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 7px;
    font-size: 9px;
    line-height: 1;
}

.terms-footer {
    margin-top: auto;
}

.terms-footer td {
    border: 1px solid #9a9a9a;
    padding: 1px 3px;
    color: #000;
    font-family: "Times New Roman", Times, serif;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

@media (max-width: 760px) {
    .topbar,
    .split {
        align-items: stretch;
        flex-direction: column;
    }

    .grid-form,
    .add-line {
        grid-template-columns: 1fr;
    }

    .seating-field,
    .seating-actions {
        grid-template-columns: 1fr;
    }

    .panel {
        overflow-x: auto;
    }

    .page-head h1 {
        font-size: 28px;
    }
}

@media (max-width: 430px) {
    .topbar {
        gap: 10px;
        padding: 10px 14px;
    }

    .brand {
        font-size: 17px;
    }

    .brand img {
        width: 68px;
        height: 28px;
    }

    .topbar nav {
        gap: 10px;
        font-size: 13px;
    }

    .shell {
        width: calc(100% - 12px);
        margin: 12px auto 28px;
    }

    .panel {
        padding: 14px;
        border-radius: 6px;
        box-shadow: 0 4px 14px rgba(44, 34, 20, 0.04);
    }

    .narrow {
        max-width: none;
        margin: 14px auto;
    }

    .narrow h1 {
        margin-top: 0;
        font-size: 24px;
        line-height: 1.15;
    }

    .form {
        gap: 10px;
    }

    input,
    select,
    textarea,
    button,
    .button {
        min-height: 38px;
    }

    .grid-form {
        gap: 8px;
    }

    .grid-form label {
        gap: 4px;
        font-size: 12px;
    }

    .grid-form input,
    .grid-form select,
    .grid-form textarea {
        min-height: 36px;
        padding: 7px 8px;
        font-size: 14px;
    }

    .seating-field {
        gap: 8px;
    }

    .seating-open-tile {
        min-height: 58px;
    }

    .dish-modal,
    .discount-modal,
    .required-fields-modal,
    .taste-reminder-modal,
    .gift-reminder-modal,
    .order-reminder-modal,
    .save-confirm-modal {
        padding: 12px;
        place-items: start center;
        padding-top: 72px;
    }

    .dish-modal-card {
        width: min(320px, 100%);
        padding: 14px;
    }

    .dish-modal-card h3 {
        margin-bottom: 10px;
        font-size: 18px;
    }

    .modal-form {
        gap: 10px;
    }

    .discount-modal input {
        min-height: 42px;
        font-size: 24px;
        font-weight: 700;
        text-align: center;
    }

    .discount-modal .muted {
        margin: 0;
        font-size: 12px;
        line-height: 1.25;
    }
}

@media print {
    @page {
        size: A4;
        margin: 4mm;
    }

    .print-actions {
        display: none;
    }

    .print-page {
        background: #fff;
    }

    .sheet {
        width: auto;
        min-height: calc(297mm - 8mm);
        margin: 0;
        padding: 0;
        box-shadow: none;
    }
}
