:root {
    --color-ink: #1a2420;
    --color-ink-soft: #4a5a52;
    --color-surface: #f3efe6;
    --color-surface-raised: #fffdf8;
    --color-border: #d9d0c0;
    --color-brand: #1f3d32;
    --color-brand-bright: #2f5c4a;
    --color-accent: #c45c26;
    --color-accent-soft: #f3d5c2;
    --color-success: #2f6b4f;
    --shadow-soft: 0 10px 30px rgba(26, 36, 32, 0.08);
    --radius: 16px;
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(
            circle at top left,
            rgba(47, 92, 74, 0.12),
            transparent 40%
        ),
        linear-gradient(
            160deg,
            #ebe4d6 0%,
            var(--color-surface) 45%,
            #e7efe9 100%
        );
    color: var(--color-ink);
    font-family: var(--font-body);
}

body {
    min-height: 100dvh;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.app-shell {
    max-width: 920px;
    margin: 0 auto;
    padding: 1rem 1rem 2.5rem;
}

.top-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.brand-mark {
    margin: 0;
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    color: var(--color-brand-bright);
}

.top-bar h1 {
    margin: 0.15rem 0 0;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    font-weight: 700;
}

.top-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-row {
    margin-bottom: 1rem;
}

.search-row input,
.order-form input[type="text"],
.order-form input[type="number"],
.order-form input[type="url"],
.settings-form input {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    font: inherit;
    background: var(--color-surface-raised);
    color: var(--color-ink);
}

.primary-button,
.ghost-button,
.icon-button {
    border: 0;
    cursor: pointer;
    font: inherit;
}

.primary-button {
    background: var(--color-brand);
    color: #f7f3ea;
    border-radius: 999px;
    padding: 0.7rem 1.1rem;
    font-weight: 700;
}

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

.ghost-button {
    background: transparent;
    color: var(--color-ink-soft);
    border-radius: 999px;
    padding: 0.7rem 1rem;
}

.icon-button {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    background: rgba(255, 253, 248, 0.8);
    border: 1px solid var(--color-border);
}

.view[hidden] {
    display: none !important;
}

.product-list,
.order-groups {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.product-card,
.order-group-card {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    width: 100%;
    text-align: left;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-raised);
    box-shadow: var(--shadow-soft);
    padding: 0.65rem;
    cursor: pointer;
    font: inherit;
    color: inherit;
    animation: rise-in 280ms ease both;
}

.product-card img,
.dialog-product img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 12px;
    background: #ddd4c4;
    flex-shrink: 0;
}

.product-card-body {
    flex: 1;
    min-width: 0;
}

.product-card-body h2,
.order-group-card h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
}

.product-meta {
    margin: 0.25rem 0 0;
    color: var(--color-ink-soft);
    font-size: 0.9rem;
}

.product-price {
    font-weight: 700;
    white-space: nowrap;
    color: var(--color-brand);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-size: 0.8rem;
    font-weight: 700;
}

.empty-state {
    margin: 2rem 0;
    padding: 1.5rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    text-align: center;
    color: var(--color-ink-soft);
    background: rgba(255, 253, 248, 0.55);
}

.order-dialog,
.settings-dialog,
.detail-dialog {
    border: 0;
    border-radius: 20px;
    padding: 0;
    width: min(520px, calc(100vw - 1.5rem));
    background: var(--color-surface-raised);
    box-shadow: var(--shadow-soft);
}

.order-dialog::backdrop,
.settings-dialog::backdrop,
.detail-dialog::backdrop {
    background: rgba(20, 28, 24, 0.45);
}

.order-form,
.settings-form,
.detail-panel {
    padding: 1.1rem 1.2rem 1.25rem;
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.dialog-header h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.35rem;
}

.dialog-product {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    margin-bottom: 1rem;
}

.dialog-name {
    margin: 0;
    font-weight: 700;
}

.dialog-meta {
    margin: 0.25rem 0 0;
    color: var(--color-ink-soft);
}

.price-fieldset {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 0.75rem;
    margin: 0 0 1rem;
}

.price-fieldset legend {
    padding: 0 0.35rem;
    font-size: 0.85rem;
    color: var(--color-ink-soft);
}

.price-option {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    padding: 0.45rem 0.2rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.75rem;
}

.form-grid label,
.settings-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--color-ink-soft);
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.1rem;
}

.form-error {
    margin: 0.75rem 0 0;
    color: #9b2c2c;
}

.hint {
    margin: 0 0 1rem;
    color: var(--color-ink-soft);
    font-size: 0.92rem;
}

.detail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-height: 55vh;
    overflow: auto;
}

.detail-list li {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 0.75rem;
    background: #faf7f0;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    background: var(--color-brand);
    color: #f7f3ea;
    padding: 0.75rem 1.1rem;
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
    z-index: 40;
}

.pending-badge {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: var(--color-accent);
    font-weight: 600;
}

.config-actions {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin: 1rem 0;
}

.config-actions .primary-button,
.config-actions .ghost-button {
    width: 100%;
    text-align: center;
}

.settings-dialog {
    width: min(560px, calc(100vw - 1.5rem));
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    .product-card img {
        width: 64px;
        height: 64px;
    }
}
