:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1f2933;
    background: #f5f7f9;
    font-size: 18px;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button, .button-link { cursor: pointer; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .8rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid #d8dee4;
}
.topbar h1 { margin: 0; font-size: 1.45rem; }
.branch-line { display: flex; gap: .45rem; flex-wrap: wrap; font-size: .92rem; margin-top: .2rem; }
.topbar-logo { width: min(17vw, 170px); height: 58px; margin-left: auto; object-fit: contain; object-position: right center; }
.muted { color: #68737d; }

.order-shell { max-width: 1180px; margin: 0 auto; padding: 1rem 1rem 6rem; }
.list-head, .order-row {
    display: grid;
    grid-template-columns: 8.5rem 64px minmax(0, 1fr) 7.5rem;
    gap: 1rem;
    align-items: center;
}
.list-head { padding: .45rem 1rem; color: #68737d; font-size: .82rem; font-weight: 700; }
.order-list { overflow: hidden; border: 1px solid #d8dee4; border-radius: 12px; background: #fff; }
.order-row { min-height: 76px; padding: .8rem 1rem; border-bottom: 1px solid #e5e9ed; transition: background-color .12s ease; }
.order-row:last-child { border-bottom: 0; }
.order-row.selected { background: #f0f7f2; }
.article-id { font-variant-numeric: tabular-nums; font-weight: 750; letter-spacing: .02em; }
.description { display: flex; align-items: center; gap: .65rem; min-width: 0; line-height: 1.28; }
.image-button {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    color: #3d5f7a;
    padding: .45rem;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
}
.image-button svg { width: 22px; height: 22px; fill: currentColor; }
.image-button:hover, .image-button:focus-visible { background: #eef3f6; }
.quantity { text-align: right; }
.quantity input {
    width: 100%;
    min-height: 52px;
    border: 2px solid #aab5bf;
    border-radius: 10px;
    padding: .35rem .55rem;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    background: #fff;
}
.quantity input:focus { outline: 3px solid rgba(46, 111, 166, .2); border-color: #2e6fa6; }
.limit { display: block; color: #a12a2a; margin-top: .25rem; }

.submit-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9;
    min-height: 76px;
    padding: .65rem max(1rem, env(safe-area-inset-right)) calc(.65rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    background: rgba(255,255,255,.97);
    border-top: 1px solid #d8dee4;
    box-shadow: 0 -6px 20px rgba(28, 39, 49, .08);
}

.primary, .secondary, .button-link {
    min-height: 48px;
    border-radius: 10px;
    padding: .65rem 1rem;
    border: 1px solid transparent;
    font-weight: 750;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.primary { background: #245f91; color: white; }
.primary:hover, .primary:focus-visible { background: #194f7c; }
.secondary { background: #fff; border-color: #b8c1c9; color: #27333d; }
.wide { width: 100%; margin-top: .5rem; }

.alert { background: #fff2f0; border: 1px solid #e8b7b0; color: #7d251c; padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; }

.login-shell, .success-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.login-card, .success-card { width: min(100%, 440px); background: #fff; border: 1px solid #d8dee4; border-radius: 16px; padding: 1.5rem; box-shadow: 0 12px 36px rgba(28,39,49,.08); }
.login-card h1, .success-card h1 { margin-top: 0; }
.login-card label { display: block; margin: 1rem 0 .35rem; font-weight: 700; }
.login-card input { width: 100%; min-height: 54px; border: 2px solid #aab5bf; border-radius: 10px; padding: .5rem .7rem; }
.success-card { text-align: center; }
.success-mark { margin: 0 auto 1rem; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: #e7f4ea; font-size: 2.4rem; font-weight: 800; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 30, .62); }
.modal-card { position: relative; z-index: 1; width: min(92vw, 620px); max-height: 90vh; overflow: auto; background: #fff; border-radius: 16px; padding: 1.25rem; box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.modal-card h2 { margin: 0 2.5rem 1rem 0; font-size: 1.15rem; }
.modal-close { position: absolute; right: .75rem; top: .6rem; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #eef1f4; font-size: 1.8rem; }
.image-viewer { position: relative; display: grid; place-items: center; min-height: min(58vh, 520px); }
.image-modal-card img { display: block; max-width: 100%; max-height: 68vh; margin: 0 auto; object-fit: contain; }
.image-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 52px;
    height: 64px;
    border: 0;
    border-radius: 12px;
    background: rgba(255,255,255,.9);
    box-shadow: 0 2px 12px rgba(0,0,0,.16);
    color: #27333d;
    font-size: 2.5rem;
    line-height: 1;
}
.image-nav-prev { left: .4rem; }
.image-nav-next { right: .4rem; }
.image-nav:hover, .image-nav:focus-visible { background: #fff; }
.image-counter { margin-top: .65rem; text-align: center; color: #68737d; font-variant-numeric: tabular-nums; }
.modal-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.25rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 700px) {
    :root { font-size: 17px; }
    .topbar { align-items: flex-start; }
    .topbar-logo { width: 92px; height: 44px; }
    .list-head { display: none; }
    .order-list { border-radius: 0; border-left: 0; border-right: 0; }
    .order-shell { padding-left: 0; padding-right: 0; }
    .order-row { grid-template-columns: minmax(0, 5rem) 44px minmax(0, 1fr) 3.5rem; gap: .55rem; padding: .75rem .7rem; }
    .submit-bar { justify-content: space-between; }
}

.draft-status { margin-right: auto; color: #68737d; font-size: .86rem; }
.draft-status[data-state="saving"] { color: #3d5f7a; }
.draft-status[data-state="saved"] { color: #2d6a3f; }
.draft-status[data-state="error"] { color: #a12a2a; font-weight: 700; }

@media (max-width: 700px) {
    .draft-status { display: none; }
}

.description-text {
    min-width: 0;
}
.info-button {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    color: #5b6975;
    padding: .45rem;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
}
.info-button svg { width: 21px; height: 21px; fill: currentColor; }
.info-button:hover, .info-button:focus-visible { background: #eef3f6; color: #2f526d; }
.info-text {
    white-space: pre-wrap;
    line-height: 1.5;
}
.session-modal { z-index: 80; }
.session-modal-card { width: min(92vw, 520px); }
.session-expired .quantity input:disabled {
    background: #eef1f4;
    color: #68737d;
    border-color: #c5cdd4;
}
button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.image-button.article-thumbnail {
    position: relative;
    align-self: stretch;
    width: 100%;
    height: auto;
    min-height: 52px;
    padding: 0;
    overflow: hidden;
}
.article-thumbnail img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media (max-width: 700px) {
    .article-id, .description-text { overflow-wrap: anywhere; }
    .description { flex-wrap: wrap; gap: .35rem; }
}

.submit-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.selected-summary { white-space: nowrap; }
.history-modal-card, .cart-modal-card, .note-modal-card { width: min(94vw, 760px); }
.history-content, .cart-content { display: grid; gap: .85rem; }
.history-order { border: 1px solid #d8dee4; border-radius: 10px; overflow: hidden; }
.history-order-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .7rem .85rem;
    background: #f5f7f9;
}
.history-order-head span { color: #68737d; text-align: right; }
.summary-list { list-style: none; margin: 0; padding: 0; }
.summary-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    padding: .7rem .85rem;
    border-bottom: 1px solid #e5e9ed;
}
.summary-list li:last-child { border-bottom: 0; }
.summary-list strong { min-width: 4rem; text-align: right; font-variant-numeric: tabular-nums; }
.empty-message { margin: 0; padding: .8rem; color: #68737d; }
.note-label { display: block; margin-bottom: .4rem; font-weight: 700; }
.note-textarea {
    width: 100%;
    min-height: 9rem;
    resize: vertical;
    border: 2px solid #aab5bf;
    border-radius: 10px;
    padding: .65rem .75rem;
    font: inherit;
}
.note-textarea:focus { outline: 3px solid rgba(46, 111, 166, .2); border-color: #2e6fa6; }
.note-persistence-hint { margin: .65rem 0 0; font-size: .86rem; }
[data-open-note][data-has-content="true"]::after { content: " •"; color: #2d6a3f; }
.topbar-menu { position: relative; flex: 0 0 auto; }
.menu-trigger {
    width: 48px;
    height: 48px;
    padding: .65rem;
    display: grid;
    place-items: center;
    border: 1px solid #b8c1c9;
    border-radius: 10px;
    background: #fff;
    color: #27333d;
}
.menu-trigger:hover, .menu-trigger:focus-visible, .menu-trigger[aria-expanded="true"] { background: #eef3f6; }
.menu-trigger svg { width: 26px; height: 26px; fill: currentColor; }
.menu-panel {
    position: absolute;
    top: calc(100% + .45rem);
    right: 0;
    z-index: 20;
    min-width: 12rem;
    padding: .35rem;
    border: 1px solid #d8dee4;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(28,39,49,.18);
}
.menu-panel form { margin: 0; }
.menu-item {
    width: 100%;
    min-height: 48px;
    padding: .65rem .8rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #27333d;
    text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: #eef3f6; }

@media (max-width: 700px) {
    .order-shell { padding-bottom: 12rem; }
    .submit-bar { flex-wrap: wrap; gap: .5rem; }
    .submit-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .5rem;
    }
    .selected-summary { align-self: center; text-align: center; }
    .submit-actions .primary { grid-column: 1 / -1; }
    .history-order-head { display: grid; gap: .25rem; }
    .history-order-head span { text-align: left; }
}
