/* ProdFlow BusinessWay — design system */

/* ---------- Tokens ---------- */
:root {
    color-scheme: light;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    --bg: #f3f5f9;
    --bg-board: #eef1f6;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --surface-3: #edf1f7;
    --border: #e2e7ef;
    --border-strong: #cfd7e3;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --faint: #94a3b8;

    --primary: #1e6fd9;
    --primary-hover: #185fbd;
    --primary-soft: #e8f1fd;
    --primary-text: #1558b0;
    --on-primary: #ffffff;

    --red: #e5484d;
    --red-soft: #fdecec;
    --orange: #f2a20c;
    --orange-soft: #fff4dc;
    --green: #1f9d55;
    --green-soft: #e4f6ec;
    --grey: #cdd5e0;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .06);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
    --overlay: rgba(15, 23, 42, .45);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --topbar-h: 64px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1018;
    --bg-board: #0b1018;
    --surface: #131a26;
    --surface-2: #182130;
    --surface-3: #1f2a3c;
    --border: #243044;
    --border-strong: #33415a;
    --text: #e8edf6;
    --text-2: #c3cddd;
    --muted: #8d9ab0;
    --faint: #64728a;

    --primary: #4b93f0;
    --primary-hover: #66a4f4;
    --primary-soft: rgba(75, 147, 240, .14);
    --primary-text: #7fb3f6;
    --on-primary: #06101f;

    --red: #f2555a;
    --red-soft: rgba(242, 85, 90, .14);
    --orange: #f5b13a;
    --orange-soft: rgba(245, 177, 58, .14);
    --green: #3cc47a;
    --green-soft: rgba(60, 196, 122, .14);
    --grey: #344157;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
    --overlay: rgba(2, 6, 14, .66);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
[hidden], .hidden { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
body.has-layer { overflow: hidden; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--primary-text); text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-soft); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

.muted { color: var(--muted); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 14px; border-radius: 10px;
    font-weight: 600; font-size: 13.5px; white-space: nowrap;
    border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, opacity .15s;
    user-select: none;
}
.btn i { font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(1.06); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
.btn-danger-ghost { color: var(--red); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-soft); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid currentColor; border-color: var(--on-primary) transparent var(--on-primary) transparent;
    animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--muted) transparent var(--muted) transparent; }

.icon-btn {
    width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center;
    color: var(--text-2); border: 1px solid var(--border); background: var(--surface); transition: .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn.plain { border-color: transparent; background: transparent; }
.icon-btn.plain:hover { background: var(--surface-3); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Badges & chips ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
    border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
    background: var(--surface-3); color: var(--text-2);
}
.badge i { font-size: 10px; }
.badge-urgent { background: var(--red-soft); color: var(--red); }
.badge-note { background: var(--orange-soft); color: #b8770a; }
:root[data-theme="dark"] .badge-note { color: var(--orange); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-success { background: var(--green-soft); color: var(--green); }

.chip {
    display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px;
    border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text-2); font-weight: 600; font-size: 13px; transition: .15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip[aria-pressed="true"] { background: var(--red-soft); border-color: transparent; color: var(--red); }
.chip .count { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.chip[aria-pressed="true"] .count { background: var(--red); color: #fff; }

.kbd { font-size: 11px; font-weight: 600; color: var(--faint); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; line-height: 18px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field, .field-row + .field, .field + .field-row, .field-row + .field-row { margin-top: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row > .field + .field { margin-top: 0; }
.label { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.label .optional { font-weight: 500; color: var(--faint); }
.hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
    width: 100%; height: 40px; padding: 0 12px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.select {
    appearance: none; padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 13px; pointer-events: none; }
.input-icon > .input { padding-left: 36px; }
.input-icon > .kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }

.stepper { display: flex; align-items: stretch; height: 40px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { width: 40px; color: var(--text-2); }
.stepper button:hover { background: var(--surface-3); }
.stepper input { flex: 1; min-width: 0; border: 0; text-align: center; font-weight: 600; background: transparent; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper input:focus { outline: none; }
.stepper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.switch-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
}
.switch-row strong { display: block; font-size: 13.5px; }
.switch-row span { font-size: 12px; color: var(--muted); }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--grey); transition: .2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.switch input:checked + .track { background: var(--red); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); }
.segmented button { height: 28px; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Status ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grey); flex: none; }
.s-red { --s: var(--red); --s-soft: var(--red-soft); }
.s-orange { --s: var(--orange); --s-soft: var(--orange-soft); }
.s-green { --s: var(--green); --s-soft: var(--green-soft); }
.s-grey { --s: var(--grey); --s-soft: var(--surface-3); }
.dot.s-red, .dot.s-orange, .dot.s-green { background: var(--s); }

.status-seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.status-seg button {
    height: 30px; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
    border: 1px solid var(--border); background: var(--surface); transition: .15s;
}
.status-seg button .dot { background: var(--s); }
.status-seg button:hover { border-color: var(--border-strong); color: var(--text); }
.status-seg button[aria-pressed="true"] { background: var(--s-soft); border-color: var(--s); color: var(--text); }

/* ---------- App shell ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
    display: flex; align-items: center; gap: 16px; padding: 0 20px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; flex: none; color: var(--text); }
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, #3b8cf0, #1558b0); color: #fff; font-size: 16px;
    box-shadow: 0 4px 12px rgba(30, 111, 217, .35);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.topbar-search { flex: 1; max-width: 460px; margin-left: 8px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar .divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.sync { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sync .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.sync.is-error .dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

/* ---------- Board ---------- */
.board-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--bg-board); }
.board-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px 0; flex-wrap: wrap; }
.board-summary { font-size: 13px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.board-summary b { color: var(--text); font-weight: 700; }
.step-tabs { display: none; }

.board {
    flex: 1; min-height: 0; display: flex; gap: 12px; padding: 14px 16px 16px;
    overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity;
}
.column {
    flex: 1 0 268px; max-width: 400px; display: flex; flex-direction: column; min-height: 0;
    background: color-mix(in srgb, var(--surface-3) 55%, transparent);
    border: 1px solid var(--border); border-radius: 16px; scroll-snap-align: start;
}
:root[data-theme="dark"] .column { background: #0f1520; }
.column-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px; }
.column-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); font-size: 13px; flex: none; }
.column-title { font-weight: 700; font-size: 13.5px; }
.column-step { font-size: 11.5px; color: var(--faint); font-weight: 500; }
.column-count { margin-left: auto; min-width: 26px; height: 22px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.column-body { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.column-empty { margin: 6px 2px; padding: 22px 12px; border: 1.5px dashed var(--border); border-radius: 12px; text-align: center; color: var(--faint); font-size: 12.5px; }
.column-empty i { display: block; font-size: 18px; margin-bottom: 6px; opacity: .7; }

/* ---------- Order card ---------- */
.card {
    position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 12px; box-shadow: var(--shadow-sm); cursor: pointer; text-align: left;
    transition: box-shadow .18s, border-color .18s, transform .18s;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.card.is-urgent { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); }
.card.is-urgent::before { content: ''; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--red); }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 11.5px; color: var(--faint); }
.card-id { font-weight: 600; font-variant-numeric: tabular-nums; }
.card-time { margin-left: auto; }
.card-main { display: flex; gap: 10px; align-items: center; }
.thumb { width: 46px; height: 46px; flex: none; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); object-fit: contain; padding: 3px; }
.card-title { font-weight: 650; font-size: 13.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-sub b { color: var(--text); font-weight: 650; }
.card-client { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2); min-width: 0; }
.avatar { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; background: var(--av, #64748b); }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.card-tags .opt { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.mockups { display: flex; gap: 6px; margin-top: 10px; }
.mockups button { position: relative; width: 52px; height: 52px; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); flex: none; }
.mockups img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.mockups button:hover img { transform: scale(1.06); }
.mockups .more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 23, 42, .58); color: #fff; font-weight: 700; font-size: 13px; }
.progress { display: flex; gap: 3px; margin-top: 12px; }
.progress span { flex: 1; height: 5px; border-radius: 3px; background: var(--grey); position: relative; }
.progress span.s-red, .progress span.s-orange, .progress span.s-green { background: var(--s); }
.progress span.is-current { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 1px; }
.progress-label { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.card-actions { display: flex; gap: 6px; margin-top: 12px; }
.card-actions .btn { flex: 1; }
.card-actions .btn-prev { flex: 0 0 38px; padding: 0; }

/* skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Layers: drawer / dialog ---------- */
.layer { position: fixed; inset: 0; z-index: 60; display: flex; }
.layer[hidden] { display: none !important; }
.layer-backdrop { position: absolute; inset: 0; background: var(--overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .18s ease; }
.panel {
    position: relative; display: flex; flex-direction: column; background: var(--surface);
    box-shadow: var(--shadow-lg); max-height: 100%; min-height: 0;
}
.layer-drawer { justify-content: flex-end; }
.layer-drawer .panel { width: min(600px, 100%); height: 100%; border-left: 1px solid var(--border); animation: slide-in .24s cubic-bezier(.2, .8, .2, 1); }
.layer-dialog { align-items: center; justify-content: center; padding: 20px; }
.layer-dialog .panel { width: min(440px, 100%); border-radius: var(--radius-lg); border: 1px solid var(--border); animation: pop .2s cubic-bezier(.2, .8, .2, 1); max-height: calc(100vh - 40px); }
.panel-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.panel-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.panel-head .icon-btn { margin-left: auto; flex: none; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.panel-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.panel-foot .spacer { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

.form-section + .form-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.form-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.form-section-title .badge { text-transform: none; letter-spacing: 0; }

/* ---------- Product picker ---------- */
.product-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.product-tile {
    position: relative; display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; text-align: left;
    border: 1.5px solid var(--border); background: var(--surface); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.product-tile:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.product-tile .ph { position: relative; display: block; width: 100%; aspect-ratio: 1; background: var(--surface-2); }
.product-tile img { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); object-fit: contain; }
.product-tile .meta { flex: 1; display: block; padding: 7px 9px 9px; border-top: 1px solid var(--border); }
.product-tile .name { font-size: 12px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-tile .ref { font-size: 11px; color: var(--faint); margin-top: 2px; }
.product-tile .check { position: absolute; top: 7px; right: 7px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-size: 11px; opacity: 0; transform: scale(.6); transition: .15s; }
.product-tile[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.product-tile[aria-checked="true"] .check { opacity: 1; transform: none; }
.picker-empty { grid-column: 1 / -1; padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.options-box { display: grid; gap: 12px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.hint-inline { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 11.5px; }
.product-tile .tile-count { position: absolute; top: 7px; left: 7px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; background: var(--text); color: var(--bg); font-size: 11px; font-weight: 700; }
.product-tile .tile-count[hidden] { display: none; }

/* ---------- Products of an order ---------- */
.item-lines { display: grid; gap: 10px; }
.item-lines:not(:empty) + .empty-inline { display: none; }
.item-line { display: grid; gap: 12px; padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.item-line.is-new { animation: pop .25s ease; }
.item-line-head { display: flex; align-items: center; gap: 10px; }
.item-line-name { flex: 1; min-width: 0; }
.item-line-head .stepper { width: 124px; flex: none; }
.item-line-head > .icon-btn { flex: none; }
.add-product { margin-top: 12px; }
.empty-inline[hidden] { display: none; }
.item-details { display: grid; gap: 10px; }
.item-detail { display: grid; gap: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.item-detail-head { display: flex; align-items: center; gap: 10px; }
.item-detail-head > div { flex: 1; }
.item-qty { font-size: 13px; padding: 4px 10px; }
.cell-sub { display: block; font-size: 11px; color: var(--faint); margin-top: 1px; }

/* Card with several products */
.card-items { display: grid; gap: 7px; }
.card-item { display: flex; align-items: center; gap: 9px; min-width: 0; }
.card-item .thumb { width: 32px; height: 32px; border-radius: 8px; padding: 2px; }
.card-item-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; }
.card-item-qty { flex: none; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.card-more { font-size: 12px; color: var(--muted); padding-left: 41px; }
.card-items > .card-sub { margin-top: 1px; padding-top: 7px; border-top: 1px dashed var(--border); }

/* Auto-finish countdown (last step) */
.auto-finish { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 6px 9px; border-radius: 8px; font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.auto-finish.is-soon { color: #b8770a; background: var(--orange-soft); border-color: transparent; }
:root[data-theme="dark"] .auto-finish.is-soon { color: var(--orange); }

/* ---------- Image picker ---------- */
.image-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.image-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.image-item > button.view { position: absolute; inset: 0; }
.image-item img { width: 100%; height: 100%; object-fit: cover; }
.image-item .remove {
    position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center; font-size: 11px; color: #fff; background: rgba(15, 23, 42, .72); z-index: 1;
}
.image-item .remove:hover { background: var(--red); }
.image-item .tag { position: absolute; left: 5px; bottom: 5px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--primary); color: var(--on-primary); }
.dropzone {
    aspect-ratio: 1; border-radius: 10px; border: 1.5px dashed var(--border-strong); background: var(--surface);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; text-align: center;
    color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 8px; transition: .15s;
}
.dropzone i { font-size: 18px; color: var(--primary); }
.dropzone:hover, .image-picker.is-dragover .dropzone { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.image-picker.is-dragover { outline: 2px dashed var(--primary); outline-offset: 4px; border-radius: 12px; }
.image-picker-hint { margin-top: 8px; }

/* ---------- Order detail ---------- */
.detail-hero { display: flex; gap: 14px; align-items: center; }
.detail-hero .thumb { width: 68px; height: 68px; border-radius: 14px; padding: 5px; }
.detail-hero h2 { font-size: 18px; line-height: 1.25; }
.detail-hero .card-sub { font-size: 13px; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 18px; }
.stat { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.stat span { display: block; font-size: 11.5px; color: var(--muted); }
.stat b { display: block; font-size: 13.5px; font-weight: 650; margin-top: 1px; }
.stat .stat-client { display: flex; align-items: center; gap: 7px; margin-top: 3px; font-size: 13.5px; font-weight: 650; min-width: 0; }
.stat .stat-client .avatar { width: 20px; height: 20px; font-size: 9px; }
.section { margin-top: 22px; }
.section-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section-title .count { color: var(--faint); font-weight: 600; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--orange-soft); color: var(--text); font-size: 13px; white-space: pre-wrap; }
.callout i { color: var(--orange); margin-top: 2px; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.kv dt, .kv dd { padding: 9px 12px; font-size: 13px; border-top: 1px solid var(--border); }
.kv dt { color: var(--muted); background: var(--surface-2); }
.kv dd { font-weight: 600; word-break: break-word; }
.kv dt:nth-of-type(1), .kv dd:nth-of-type(1) { border-top: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery button { aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.gallery button:hover img { transform: scale(1.05); }
.empty-inline { padding: 14px; border-radius: 12px; border: 1.5px dashed var(--border); color: var(--faint); font-size: 12.5px; text-align: center; }

.steps { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.step { display: flex; align-items: center; gap: 12px; padding: 10px 12px; flex-wrap: wrap; }
.step + .step { border-top: 1px solid var(--border); }
.step.is-current { background: var(--primary-soft); }
.step-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: 12px; flex: none; }
.step.is-current .step-icon { background: var(--primary); color: var(--on-primary); }
.step-name { font-weight: 600; font-size: 13px; }
.step-name small { display: block; font-weight: 500; color: var(--primary-text); font-size: 11px; }
.step .status-seg { margin-left: auto; }

.table-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 9px 12px; white-space: nowrap; }
.table td { padding: 9px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .low { color: var(--red); font-weight: 700; }
.table .ok { color: var(--green); font-weight: 700; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }

/* ---------- PDF thumbnails ---------- */
.pdf-thumb {
    position: absolute; inset: 0; display: grid; place-items: center;
    background: var(--surface-2); color: var(--red); font-size: 22px;
}
.pdf-thumb:not(.is-ready) i { animation: pulse-soft 1.2s ease-in-out infinite; }
.pdf-thumb.is-error i { animation: none; opacity: .8; }
.pdf-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; background: #fff; }
.mockups .pdf-thumb { font-size: 18px; }
.file-tag {
    position: absolute; left: 4px; top: 4px; z-index: 1; pointer-events: none;
    font-size: 9px; font-weight: 800; letter-spacing: .03em; line-height: 1;
    padding: 3px 5px; border-radius: 5px; background: var(--red); color: #fff;
}
.gallery button { position: relative; }
@keyframes pulse-soft { 50% { opacity: .35; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
    pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 380px;
    padding: 12px 14px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg);
    font-size: 13px; font-weight: 500; animation: toast-in .25s cubic-bezier(.2, .8, .2, 1); white-space: pre-line;
}
.toast i { margin-top: 2px; }
.toast.success i { color: var(--green); }
.toast.error i { color: var(--red); }
.toast.is-leaving { animation: toast-out .2s forwards; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(10px); opacity: 0; } }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(4, 8, 16, .94); display: flex; align-items: center; justify-content: center; animation: fade .15s; touch-action: pan-y; }
.lightbox[hidden] { display: none !important; }
.lightbox img { max-width: calc(100vw - 140px); max-height: calc(100vh - 110px); object-fit: contain; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); user-select: none; }
.lightbox .lb-btn { position: absolute; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.1); font-size: 16px; transition: .15s; }
.lightbox .lb-btn:hover { background: rgba(255,255,255,.2); }
.lightbox .lb-close { top: 16px; right: 16px; }
.lightbox .lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-bar { position: absolute; left: 0; right: 0; bottom: 18px; display: flex; justify-content: center; gap: 12px; align-items: center; color: rgba(255,255,255,.8); font-size: 13px; }
.lightbox .lb-bar a { color: #fff; display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.1); }
.lightbox .lb-pdf {
    width: min(920px, calc(100vw - 140px)); height: calc(100vh - 110px); overflow-y: auto; overscroll-behavior: contain;
    display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 14px;
    border-radius: 10px; background: #3a3f47;
}
.lightbox .lb-pdf[hidden] { display: none; }
.lightbox .lb-page { width: 100%; flex: none; background: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.lightbox .lb-page canvas { display: block; width: 100%; height: auto; }
.lightbox .lb-status { margin: auto; color: rgba(255,255,255,.8); font-size: 14px; display: flex; gap: 10px; align-items: center; }

/* ---------- Confirm & login ---------- */
.confirm-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 18px; margin-bottom: 14px; }
.confirm-icon.danger { background: var(--red-soft); color: var(--red); }
.confirm-icon.success { background: var(--green-soft); color: var(--green); }
.confirm-title { font-size: 17px; font-weight: 700; }
.confirm-text { color: var(--muted); margin-top: 6px; font-size: 13.5px; }
.form-error { color: var(--red); font-size: 12.5px; font-weight: 500; margin-top: 8px; }

.fab { display: none; }

/* ---------- Admin dashboard ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 750; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin-top: 3px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-sm); display: flex; gap: 14px; align-items: center; }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 17px; flex: none; background: var(--s-soft, var(--primary-soft)); color: var(--s, var(--primary)); }
.kpi-value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-sm); min-width: 0; }
.box + .box { margin-top: 18px; }
.grid-2 .box + .box { margin-top: 0; }
.box-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.box-head h2 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.box-head h2 i { color: var(--primary); font-size: 14px; }
.box-head .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.box-body { padding: 16px 18px; }
.chart-wrap { position: relative; height: 290px; }
.range-custom { display: flex; gap: 8px; align-items: center; }
.range-custom .input { height: 32px; width: 140px; font-size: 12.5px; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; }
.bar-row .thumb { width: 34px; height: 34px; border-radius: 8px; padding: 2px; }
.bar-row .name { font-size: 12.5px; font-weight: 600; }
.bar-track { height: 6px; border-radius: 3px; background: var(--surface-3); margin-top: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--primary); }
.bar-row .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.prod-cell { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.prod-cell .thumb { width: 34px; height: 34px; border-radius: 8px; padding: 2px; }
.table-foot { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--border); }
.table-history { min-width: 680px; }

.admin-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.admin-product { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); transition: .15s; text-align: left; }
.admin-product:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.admin-product .thumb { width: 56px; height: 56px; border-radius: 11px; }
.admin-product .name { font-weight: 650; font-size: 13.5px; line-height: 1.25; }
.admin-product .meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }

.builder { display: flex; flex-direction: column; gap: 8px; }
.builder-row { display: grid; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.builder-row.prop { grid-template-columns: 1fr 120px 32px; }
.builder-row.prop .full { grid-column: 1 / -1; }
.builder-row.comp { grid-template-columns: 1fr 90px 90px 32px; }
.builder-row .input, .builder-row .select { height: 36px; font-size: 13px; }
.builder-head { display: grid; gap: 8px; padding: 0 10px; font-size: 11px; font-weight: 600; color: var(--faint); }
.builder-head.comp { grid-template-columns: 1fr 90px 90px 32px; }
.image-field { display: flex; gap: 14px; align-items: center; }
.image-field .preview { width: 88px; height: 88px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); padding: 6px; object-fit: contain; flex: none; }
.image-field .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }

.process-list { display: flex; flex-direction: column; gap: 8px; }
.process-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.process-row .num { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--muted); flex: none; }
.process-row .name { font-weight: 600; flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.process-row .actions { display: flex; gap: 4px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.icon-grid button { height: 46px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 16px; }
.icon-grid button:hover { border-color: var(--border-strong); }
.icon-grid button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.notice { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--primary-soft); color: var(--text-2); font-size: 12.5px; margin-bottom: 12px; }
.notice i { color: var(--primary); margin-top: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .topbar .sync { display: none; }
}

@media (max-width: 760px) {
    :root { --topbar-h: 58px; }
    body { font-size: 14.5px; }
    .topbar { padding: 0 12px; gap: 8px; }
    .brand-sub, .hide-sm { display: none !important; }
    .topbar-search { display: none; }
    .board-toolbar { padding: 10px 12px 0; gap: 8px 10px; }
    .board-toolbar .chip { height: 34px; }
    .board-summary { gap: 10px; font-size: 12.5px; }
    .board-toolbar .topbar-search-mobile { display: block; flex: 1 1 100%; }
    .step-tabs {
        display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px 0; scrollbar-width: none;
    }
    .step-tabs::-webkit-scrollbar { display: none; }
    .step-tabs button {
        flex: none; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
        background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text-2); display: inline-flex; gap: 7px; align-items: center;
    }
    .step-tabs button span { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); }
    .step-tabs button[aria-current="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
    .step-tabs button[aria-current="true"] span { background: rgba(255,255,255,.2); color: inherit; }
    .board { padding: 10px 12px 90px; gap: 10px; scroll-snap-type: x mandatory; }
    .column { flex: 0 0 calc(100vw - 24px); max-width: none; scroll-snap-stop: always; }
    .card-actions .btn { height: 40px; }
    .fab {
        display: grid; place-items: center; position: fixed; right: 16px; bottom: 18px; z-index: 40;
        width: 56px; height: 56px; border-radius: 18px; background: var(--primary); color: var(--on-primary);
        font-size: 20px; box-shadow: 0 10px 24px rgba(30, 111, 217, .4);
    }
    .layer-drawer .panel { width: 100%; border-left: 0; animation: sheet-in .26s cubic-bezier(.2, .8, .2, 1); }
    .layer-dialog { padding: 0; align-items: flex-end; }
    .layer-dialog .panel { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; animation: sheet-in .24s cubic-bezier(.2, .8, .2, 1); }
    .panel-head, .panel-body { padding-left: 16px; padding-right: 16px; }
    .panel-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
    .panel-foot .btn { flex: 1; }
    .panel-foot .btn.btn-square { flex: 0 0 44px; padding: 0; }
    .table .status-seg { flex-wrap: nowrap; }
    .table .status-seg button { padding: 0 9px; }
    .table .status-seg .lbl { display: none; }
    .panel-foot .spacer { display: none; }
    .field-row { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
    .step .status-seg { margin-left: 42px; }
    .product-picker { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .toasts { left: 12px; right: 12px; bottom: 84px; align-items: stretch; }
    .toast { max-width: none; min-width: 0; }
    .lightbox img { max-width: 100vw; max-height: calc(100vh - 140px); border-radius: 0; }
    .lightbox .lb-pdf { width: 100vw; height: calc(100vh - 150px); border-radius: 0; padding: 8px; gap: 8px; margin-top: -20px; }
    .lightbox .lb-prev, .lightbox .lb-next { top: auto; bottom: 10px; transform: none; width: 40px; height: 40px; }
    .lightbox .lb-bar { bottom: 16px; }
    .page { padding: 16px 12px 40px; }
    .page-head h1 { font-size: 20px; }
    .kpis { gap: 10px; }
    .kpi { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
    .kpi-icon { width: 36px; height: 36px; font-size: 14px; }
    .kpi-value { font-size: 22px; }
    .box-head, .box-body { padding-left: 14px; padding-right: 14px; }
    .box-head .tools { margin-left: 0; width: 100%; }
    .chart-wrap { height: 230px; }
    .builder-row.comp, .builder-head.comp { grid-template-columns: 1fr 70px 70px 32px; }
    .table .hide-sm-col { display: none; }
}
@media (min-width: 761px) { .topbar-search-mobile { display: none; } }
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
