@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
    --ink: #17212b;
    --muted: #65717c;
    --line: #d9e0e4;
    --paper: #ffffff;
    --wash: #f2f5f3;
    --red: #f74228;
    --blue: #003894;
    --blue-dark: #00265f;
    --yellow: #f2c94c;
    --danger: #b42318;
    --shadow: 0 16px 45px rgba(23, 33, 43, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--wash);
    font-family: 'DM Sans', sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
.toast-message { position: fixed; top: 18px; right: 22px; z-index: 30; max-width: min(420px, calc(100vw - 44px)); padding: 13px 17px; color: #fff; background: #16794a; border-left: 5px solid #8ce0b2; box-shadow: 0 10px 30px rgba(0, 0, 0, .22); font-size: .9rem; font-weight: 700; }
.toast-message.is-error { background: #b42318; border-left-color: #ffb4ac; }
.toast-message[hidden] { display: none; }
.site-header {
    position: sticky;
    top: 8px;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 8px 12px 0;
    padding: 18px clamp(20px, 5vw, 72px);
    color: #fff;
    background: var(--blue-dark);
    border-bottom: 5px solid var(--red);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 38, 95, .2);
}
.brand { display: flex; align-items: center; gap: 18px; }
.brand img { width: 150px; height: auto; max-height: 52px; object-fit: contain; background: #fff; padding: 4px 8px; }
.eyebrow { margin: 0 0 3px; color: var(--red); font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.site-header .eyebrow { color: var(--yellow); }
h1, h2 { margin: 0; font-family: 'Barlow Condensed', sans-serif; font-weight: 600; line-height: 1; }
h1 { font-size: clamp(1.55rem, 3vw, 2.25rem); }
h2 { font-size: 1.8rem; }
.language-switch { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.help-link { display: grid; width: 30px; height: 30px; place-items: center; color: var(--blue-dark); background: #fff; border: 1px solid rgba(255, 255, 255, .85); border-radius: 50%; font-weight: 700; text-decoration: none; }
.help-link:hover, .help-link:focus { color: var(--red); border-color: var(--yellow); box-shadow: 0 0 0 2px rgba(242, 201, 76, .2); }
.language-button { display: grid; width: 42px; height: 30px; padding: 3px; place-items: center; background: #fff; border: 1px solid rgba(255, 255, 255, .85); border-bottom: 2px solid transparent; border-radius: 3px; opacity: .82; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.language-button img { display: block; width: 30px; height: 20px; object-fit: cover; }
.language-button:hover, .language-button:focus, .language-button.is-active { opacity: 1; border-color: var(--yellow); box-shadow: 0 0 0 2px rgba(242, 201, 76, .2); }
.page-shell { width: min(1500px, calc(100% - 40px)); margin: 28px auto 60px; }
.guide { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding: 16px 20px; color: #fff; background: var(--red); box-shadow: var(--shadow); }
.guide p { margin: 5px 0 0; font-size: .9rem; }
.text-button { color: #fff; background: transparent; border: 0; text-decoration: underline; }
.guide.is-collapsed p { display: none; }
.panel { margin-bottom: 20px; padding: 24px; background: var(--paper); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading-actions { align-items: center; }
.required-note { color: var(--muted); font-size: .78rem; }
.form-grid { display: grid; grid-template-columns: 2fr 1.5fr repeat(3, 1fr); gap: 16px; }
.order-notice { margin-top: 20px; padding: 13px 16px; color: #513d00; background: #fff7d6; border-left: 4px solid var(--yellow); font-size: .84rem; }
.order-notice p { margin: 5px 0 0; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: .79rem; font-weight: 700; }
.field input, .compact-input { min-width: 0; padding: 10px 11px; color: var(--ink); background: #fbfcfc; border: 1px solid var(--line); border-radius: 2px; outline: 0; }
.field input:focus, .compact-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 56, 148, .12); }
.field input:user-invalid, .compact-input.is-invalid { border-color: var(--danger); background: #fff8f7; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
.primary-button, .secondary-button { padding: 11px 16px; font-weight: 700; border: 1px solid transparent; border-radius: 2px; }
.primary-button { color: #fff; background: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { color: var(--blue); background: #eaf0f8; border-color: #c9d6e8; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); }
.positions-table { width: 100%; min-width: 1160px; border-collapse: collapse; font-size: .8rem; }
.positions-table th { padding: 11px 8px; color: #fff; background: var(--blue); font-size: .72rem; text-align: left; white-space: nowrap; }
.positions-table td { padding: 7px 5px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.positions-table tbody tr:last-child td { border-bottom: 0; }
.positions-table tbody tr:nth-child(even) { background: #f8fafb; }
.positions-table th:last-child { position: sticky; right: 0; z-index: 3; background: var(--blue); box-shadow: -4px 0 8px rgba(23, 33, 43, .1); }
.positions-table td:last-child { position: sticky; right: 0; z-index: 2; background: var(--paper); box-shadow: -4px 0 8px rgba(23, 33, 43, .08); }
.positions-table tbody tr:nth-child(even) td:last-child { background: #f8fafb; }
.position-number { width: 42px; color: var(--blue); font-family: 'Barlow Condensed', sans-serif; font-size: 1.15rem; font-weight: 700; text-align: center; }
.compact-input { width: 100%; padding: 8px 7px; font-size: .8rem; }
.sketch-control { display: flex; gap: 4px; min-width: 105px; }
.sketch-control .compact-input { min-width: 0; }
.sketch-button { flex: 0 0 28px; padding: 0; color: var(--blue); background: #eaf0f8; border: 0; border-radius: 2px; font-weight: 700; }
.sketch-button:hover { color: #fff; background: var(--blue); }
.print-sketch-image { display: none; }
.print-order-row, .print-page-footer { display: none; }
.print-document { display: none; }
.print-sketch-document { display: none; }
.actions-column { width: 132px; }
.row-actions { display: flex; gap: 4px; white-space: nowrap; }
.icon-button { width: 28px; height: 28px; padding: 0; color: var(--blue); background: #eaf0f8; border: 0; border-radius: 2px; font-weight: 700; }
.icon-button:hover { color: #fff; background: var(--blue); }
.icon-button:disabled { cursor: not-allowed; opacity: .35; }
.delete-button { color: var(--danger); background: #fff0ee; }
.empty-state { display: grid; gap: 5px; padding: 28px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.status-message { min-height: 1.4em; margin: 0; color: var(--blue); font-size: .9rem; font-weight: 600; }
.status-message.is-error { color: var(--danger); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: rgba(23, 33, 43, .66); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(960px, 100%); max-height: min(800px, 90vh); overflow: auto; padding: 24px; background: var(--paper); box-shadow: 0 24px 80px rgba(0, 0, 0, .28); }
.sketch-picker-modal { width: min(1040px, 100%); }
.sketch-zoom-backdrop { z-index: 20; }
.sketch-zoom-modal { width: min(1200px, 94vw); max-height: 94vh; }
.sketch-zoom-image { display: block; width: 100%; height: min(66vh, 680px); object-fit: contain; background: #fff; }
.zoom-info-text { margin: 8px 0 0; padding: 6px 10px; color: var(--ink); background: #f2f5f3; border-left: 3px solid var(--blue); font-size: .84rem; }
.zoom-info-text:empty { display: none; }
.sketch-zoom-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.modal-close { padding: 8px 11px; color: var(--blue); background: #eaf0f8; border: 0; border-radius: 2px; font-weight: 700; }
.sketch-board { display: grid; gap: 0; overflow-x: auto; }
.profile-grid, .sketch-grid { display: grid; grid-template-columns: repeat(8, minmax(100px, 1fr)); gap: 0; min-width: 880px; }
.profile-choice { display: grid; gap: 5px; padding: 7px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-bottom: 0; font-size: .75rem; font-weight: 700; text-align: center; }
.profile-images { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 70px; }
.profile-image-button { position: relative; display: block; width: 90%; padding: 0; background: #fff; border: 0; cursor: zoom-in; }
.profile-image-button img { display: block; width: 100%; object-fit: contain; background: #fff; }
.profile-images.profile-count-1 .profile-image-button img { height: 60px; }
.profile-images.profile-count-2 .profile-image-button img { height: 31px; }
.profile-images.profile-count-3 .profile-image-button img { height: 20px; }
.magnify-icon { position: absolute; right: 2px; bottom: 1px; display: grid; width: 18px; height: 18px; place-items: center; color: var(--blue-dark); background: #fff; border: 1px solid var(--blue-dark); border-radius: 50%; font-size: 11px; line-height: 1; opacity: .96; }
.profile-image-button:hover .magnify-icon, .profile-image-button:focus .magnify-icon { color: var(--red); background: #fff; border-color: var(--red); }
.sketch-choice { position: relative; min-width: 0; padding: 0; background: #f7f9fa; border: 1px solid var(--line); }
.sketch-choice-heading { display: flex; min-height: 26px; align-items: center; justify-content: space-between; gap: 4px; padding: 2px 5px; color: var(--blue); font-size: .68rem; font-weight: 700; }
.sketch-select-button { display: block; width: 100%; padding: 2px 5px 5px; background: transparent; border: 0; }
.sketch-zoom-button { display: grid; width: 23px; height: 23px; flex: 0 0 23px; padding: 0; place-items: center; color: var(--blue-dark); background: #fff; border: 1px solid var(--blue-dark); border-radius: 2px; font-size: 12px; }
.sketch-zoom-button:hover, .sketch-zoom-button:focus { color: var(--red); background: #fff; border-color: var(--red); }
.sketch-label { white-space: nowrap; }
.sketch-choice:hover, .sketch-choice:focus-within { border-color: var(--red); outline: 3px solid rgba(247, 66, 40, .18); }
.sketch-select-button img { display: block; width: 100%; aspect-ratio: 165 / 80; object-fit: contain; background: #fff; }
.modal-hint { margin: 18px 0 0; color: var(--muted); font-size: .84rem; }
.import-modal { width: min(480px, 100%); }
.dropzone { display: grid; gap: 10px; padding: 40px 20px; color: var(--muted); background: #fbfcfc; border: 2px dashed var(--line); border-radius: 4px; text-align: center; }
.dropzone.is-dragover { color: var(--blue); background: #eaf0f8; border-color: var(--blue); }
.dropzone-icon { margin: 0; font-size: 2rem; color: var(--blue); }
.dropzone-or { margin: 0; font-size: .78rem; }
.dropzone .primary-button { justify-self: center; }
.profile-zoom-modal { width: min(560px, 100%); padding: 24px; background: var(--paper); box-shadow: 0 24px 80px rgba(0, 0, 0, .28); }
.profile-zoom-image { display: block; width: 100%; height: min(55vh, 360px); object-fit: contain; background: #fff; }
@media (max-width: 1100px) {
    .page-shell { width: min(100% - 28px, 1500px); }
    .panel { padding: 20px; }
    .section-heading-actions { align-items: stretch; flex-direction: column; }
    .toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .toolbar button { width: 100%; }
    .table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
    .modal { max-width: 100%; }
}
@media (max-width: 900px) {
    .site-header { align-items: flex-start; flex-direction: column; }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .profile-grid, .sketch-grid { grid-template-columns: repeat(8, minmax(100px, 1fr)); }
    .section-heading, .section-heading-actions, .form-footer { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
    .page-shell { width: min(100% - 24px, 1500px); margin-top: 16px; }
    .site-header { padding: 16px 12px; }
    .brand { align-items: flex-start; flex-direction: column; gap: 10px; }
    .panel { padding: 17px 12px; }
    .form-grid { grid-template-columns: 1fr; }
    .guide { align-items: flex-start; flex-direction: column; }
    .toolbar { grid-template-columns: 1fr; }
}
