:root {
    --brand: lch(71% 29% 258deg);
    --brand-light: lch(85% 20% 258deg);
    --brand-fallback: #6a7aff;
    --ink: #1f2940;
    --muted: #667085;
    --line: #d8e0f0;
    --panel: rgba(255, 255, 255, 0.94);
    --panel-strong: #ffffff;
    --surface: #eef3ff;
    --danger: #cb3a4d;
    --danger-soft: #fff1f2;
    --success: #147a63;
    --success-soft: #ebfff8;
    --shadow: 0 22px 50px rgba(36, 59, 107, 0.12);
    font-size: 17px;
}

* {
    box-sizing: border-box;
}

html {
    background:
        radial-gradient(circle at top left, rgba(175, 208, 255, 0.8), transparent 28%),
        radial-gradient(circle at top right, rgba(255, 236, 200, 0.78), transparent 24%),
        linear-gradient(180deg, #f5f8ff 0%, #eef3ff 48%, #f8fbff 100%);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Segoe UI", "Apple SD Gothic Neo", sans-serif;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.page-shell {
    max-width: 1920px;
    margin: 0 auto;
    padding: 14px 18px 36px;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 12px;
    align-items: start;
}

.stack {
    display: grid;
    gap: 12px;
}

.panel {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.46);
    border-radius: 28px;
    padding: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.panel--order {
    min-height: 100%;
}

.section-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.section-head--compact {
    margin-bottom: 10px;
}

.section-kicker {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.section-head h2 {
    margin: 0;
    font-size: 1.35rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header--order {
    align-items: start;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.brand-link__logo {
    width: 130px;
    height: auto;
    flex: none;
}

.brand-link h1 {
    margin: 0;
    font-size: 1.9rem;
    line-height: 1.1;
}

.brand-link__desc {
    margin: 8px 0 0;
    max-width: 520px;
    font-size: 0.9rem;
    line-height: 1.55;
    color: #55627d;
}

.top-actions {
    display: grid;
    justify-items: end;
    gap: 10px;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(106, 122, 255, 0.12);
    color: var(--brand);
    font-size: 0.86rem;
    font-weight: 700;
}

.muted {
    color: var(--muted);
    line-height: 1.65;
}

.editor-toolbar,
.backup-actions,
.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.editor-toolbar {
    margin-top: 16px;
}

.display-settings {
    margin-top: 16px;
}

.editor-card {
    margin-top: 14px;
    padding: 14px;
    border-radius: 22px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.editor-head,
.editor-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 128px 48px;
    gap: 10px;
    align-items: center;
}

.editor-head {
    padding: 0 2px 10px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.editor-head span:nth-child(2) {
    padding-left: 0;
}

.editor-head__empty {
    display: block;
}

.editor-row {
    cursor: default;
}

.editor-row.dragging {
    opacity: 0.4;
    background: var(--surface);
    border-style: dashed;
}

.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 48px;
    cursor: grab;
    color: var(--muted);
    font-size: 1.2rem;
    user-select: none;
}

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

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

.editor-row input,
.field input {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 14px;
    padding: 13px 14px;
}

.editor-row input:focus,
.field input:focus {
    outline: 2px solid rgba(106, 122, 255, 0.2);
    border-color: var(--brand);
}

.editor-empty {
    padding: 20px 14px;
    border: 1px dashed var(--line);
    border-radius: 18px;
    color: var(--muted);
    text-align: center;
    background: linear-gradient(180deg, #fafcff, #f4f7ff);
}

.divider {
    margin: 22px 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.status {
    min-height: 1.5em;
    margin-top: 14px;
    color: var(--success);
    font-size: 0.93rem;
}

.button {
    border: 0;
    border-radius: 15px;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button--primary {
    background: linear-gradient(135deg, var(--brand), #8694ff);
    color: #fff;
    box-shadow: 0 12px 24px rgba(106, 122, 255, 0.24);
}

.button--ghost {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
}

.button--danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #f4bdc5;
}

.button--neutral {
    background: #f7f8fc;
    color: var(--ink);
    border: 1px solid var(--line);
}

.button--small {
    padding: 9px 12px;
    font-size: 0.88rem;
}

.history-item .button--small {
    padding: 7px 10px;
    font-size: 0.78rem;
    white-space: nowrap;
}

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

.field {
    display: grid;
    gap: 8px;
    font-size: 0.94rem;
    font-weight: 700;
}

.field--compact {
    max-width: 220px;
}

.field select,
.field input {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 14px;
    padding: 13px 14px;
}

.empty-callout {
    margin-top: 16px;
    padding: 18px;
    border-radius: 18px;
    background: linear-gradient(135deg, #f8fbff, #edf3ff);
    color: #4d5d79;
    border: 1px dashed var(--line);
}

.empty-callout p {
    margin: 0 0 12px;
}

.menu-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(251px, 1fr));
    gap: 8px;
}

.menu-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 6px;
}

.add-btn,
.minus-btn,
.icon-btn {
    border: 0;
    cursor: pointer;
}

.add-btn {
    min-height: 80px;
    padding: 12px 12px;
    text-align: left;
    border-radius: 12px;
    background: linear-gradient(135deg, #eaf7f9, #e7f2f3);
    border: 1px solid #bfe3e6;
    box-shadow: none;
}

.add-btn--active {
    background: linear-gradient(135deg, var(--brand), #8996ff);
    color: #fff;
}

.add-btn--active .menu-price,
.add-btn--active .qty {
    color: rgba(255, 255, 255, 0.86);
}

.menu-name {
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.32;
}

.menu-price,
.qty {
    margin-top: 4px;
    color: #4d7480;
    font-size: 0.84rem;
}

.minus-btn,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #ffe4e5;
    color: var(--danger);
    border: 1px solid #fac9cf;
    min-height: 100%;
    font-size: 1.3rem;
}

.icon-btn {
    min-height: auto;
    width: 48px;
    height: 48px;
    font-size: 1.15rem;
}

.summary-table {
    width: 100%;
    margin-top: 14px;
    border-collapse: collapse;
}

.summary-table th,
.summary-table td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.summary-table th:last-child,
.summary-table td:last-child {
    text-align: right;
}

#emptyState {
    padding-top: 10px;
}

.total-box {
    margin-top: 16px;
    padding: 16px 18px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--success-soft), #f4fff7);
    border: 1px solid #b9ebd7;
    text-align: right;
    font-size: 1.18rem;
    font-weight: 800;
}

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

.panel-actions--dual {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-item {
    padding: 16px;
    border-radius: 20px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.history-item__head,
.history-item__actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.history-item__head {
    justify-content: space-between;
    margin-bottom: 10px;
}

.history-item__meta,
.history-item__items {
    margin: 6px 0 0;
    color: #49556f;
    line-height: 1.55;
}

.history-item__total {
    margin-top: 10px;
    font-weight: 800;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal[hidden] {
    display: none;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 31, 54, 0.42);
    backdrop-filter: blur(4px);
}

.modal__dialog {
    position: relative;
    z-index: 1;
    width: min(860px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 22px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 28px 70px rgba(24, 39, 75, 0.28);
}

.modal__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
    margin-bottom: 12px;
}

.icon-btn--neutral {
    background: #f5f7fd;
    color: var(--ink);
    border-color: var(--line);
}

.icon-btn--small {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
}

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

@media (max-width: 760px) {
    .page-shell {
        padding: 16px 12px 32px;
    }

    .panel {
        padding: 18px;
        border-radius: 22px;
    }

    .meta-grid,
    .panel-actions--dual,
    .menu-grid {
        grid-template-columns: 1fr;
    }

    .panel-header,
    .brand-link {
        display: grid;
    }

    .top-actions {
        justify-items: stretch;
    }

    .editor-head,
    .editor-row {
        grid-template-columns: 28px minmax(0, 1fr) 90px 40px;
        gap: 6px;
    }

    .drag-handle {
        width: 28px;
        height: 38px;
        font-size: 1rem;
    }

    .editor-row .icon-btn {
        width: 100%;
        height: 38px;
    }

    .modal {
        padding: 10px;
    }

    .modal__dialog {
        max-height: calc(100vh - 20px);
        padding: 18px;
        border-radius: 22px;
    }
}
