/* CC Vision Stock additions on top of the Ray&Co POS stylesheet (style.css). */
.side-brand { color: #fff; text-decoration: none; padding: 6px 10px 10px; }
.side-brand .brand-name { display: block; font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.side-brand small { font-size: 12px; }
.side-brand .brand-cc { color: var(--gold); }
.login-card .brand-name { display: block; text-align: center; font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.login-card form label { margin-top: 12px; }
.login-card form button { width: 100%; margin-top: 18px; padding: 11px; font-size: 15px; }
#user-badge .who a { color: var(--nav-label); font-size: 11.5px; }
.badge.editor { background: var(--purple-bg); color: var(--purple); }
.badge.viewer { background: var(--surface-3); color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; align-items: end; }
.form-grid .actions { display: flex; gap: 8px; }
.role-help { margin: 12px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.toolbar-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar-row input[type="search"] { max-width: 320px; }
.toolbar-row select { max-width: 200px; }
tr.inactive td { color: var(--muted); }
dialog.drawer form label { margin-top: 14px; }
dialog.drawer .drawer-f { display: flex; gap: 8px; margin-top: 22px; }

/* stock list */
.stock-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stock-filters input[type="search"] { flex: 1 1 280px; min-width: 240px; }
.stock-filters select { flex: 0 1 180px; width: auto; }
.stock-filters .check { margin: 0; display: flex; align-items: center; white-space: nowrap; color: var(--ink-2); font-size: 14px; }
.filter-note { margin: 8px 0 0; min-height: 1em; }
.stock-summary { display: flex; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.stock-summary .stat { flex: 1 1 160px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.stock-summary .stat span { display: block; font-size: 12px; color: var(--muted); }
.stock-summary .stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stock-summary .stat.warn { background: var(--warn-soft); border-color: #F0D9A8; }
.stock-summary .stat.warn b { color: var(--warn); }
.stock-table td { vertical-align: top; }
.stock-table .zero { color: #B4BCC8; }
.stock-table th.scope, .stock-table td.scope { background: var(--accent-soft); }
.stock-table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 2px solid var(--line-strong); }
.stock-table tr.clickable { cursor: pointer; }
.stock-table tbody tr.clickable:hover td { background: var(--surface-2); }
.stock-table tbody tr.clickable:hover td.scope { background: #E2EFC4; }
.stock-table .empty-row { text-align: center; color: var(--muted); padding: 28px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 14px; }
/* style.css pulls tables to the card edges with a negative margin, which the scrolling
   .table-wrap then clips. Pull the wrapper out instead and keep the table inside it. */
.card .table-wrap { margin: 0 -20px; }
.card .table-wrap > table { margin: 0; width: 100%; }
.card .table-wrap > table th:first-child, .card .table-wrap > table td:first-child { padding-left: 20px; }
.card .table-wrap > table th:last-child, .card .table-wrap > table td:last-child { padding-right: 20px; }

/* product page */
.back-link { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; font-size: 13px; }
.back-link:hover { color: var(--accent); }
.product-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.product-top .card { margin-bottom: 16px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.product-photo { max-width: 200px; max-height: 160px; border-radius: 8px; border: 1px solid var(--line); }
.stock-summary.compact { margin: 0 0 12px; }
.stock-summary.compact .stat { padding: 8px 12px; flex: 1 1 80px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 4px 2px 12px; font-size: 13px; font-weight: 600; }
.chip button { padding: 2px 8px; }
td.nowrap { white-space: nowrap; }
.plus { color: var(--good); font-weight: 600; }
.minus { color: var(--bad); font-weight: 600; }
.mv { display: inline-block; border-radius: 6px; padding: 1px 8px; font-size: 12.5px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.mv.receive, .mv.adjust_in { background: var(--good-soft); color: var(--good); }
.mv.transfer { background: var(--accent-soft); color: var(--accent); }
.mv.return { background: var(--purple-bg); color: var(--purple); }
.mv.stock_out, .mv.adjust_out { background: var(--warn-soft); color: var(--warn); }

/* SPH × CYL grid */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--surface); color: var(--ink-2); border: 0; border-radius: 0; padding: 6px 12px; font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.active { background: var(--brand); color: var(--brand-ink); }
.legend { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-left: auto; }
.legend .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line-strong); display: inline-block; margin-left: 8px; }
.legend .sw.out { background: var(--bad-soft); border-color: #F0B9B4; }
.legend .sw.low { background: var(--warn-soft); border-color: #F0D9A8; }
.legend .sw.none { background: repeating-linear-gradient(45deg, var(--surface-3), var(--surface-3) 3px, var(--surface) 3px, var(--surface) 6px); }
.grid-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.power-grid { border-collapse: separate; border-spacing: 0; width: auto; font-size: 13px; }
.power-grid th, .power-grid td { padding: 5px 8px; min-width: 52px; text-align: right; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.power-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: center; }
.power-grid th.sph { position: sticky; left: 0; z-index: 1; background: var(--surface-2); font-weight: 600; color: var(--ink-2); }
.power-grid th.corner { position: sticky; left: 0; top: 0; z-index: 3; font-size: 11px; color: var(--muted); }
.power-grid tfoot th, .power-grid tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 600; }
.power-grid tfoot th.sph { z-index: 3; }
.power-grid td[data-variant] { cursor: pointer; }
.power-grid td[data-variant]:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.power-grid td.low { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.power-grid td.out { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.power-grid td.none { background: repeating-linear-gradient(45deg, var(--surface-3), var(--surface-3) 3px, var(--surface) 3px, var(--surface) 6px); }
.power-grid .sum { background: var(--surface-2); font-weight: 600; color: var(--ink-2); }
a.row-link { color: inherit; text-decoration: none; display: block; }
a.row-link:hover .t-name { color: var(--accent); text-decoration: underline; }

/* movement form */
.tabs-row { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs-row button { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong); font-weight: 500; }
.tabs-row button:hover { background: var(--surface-2); }
.tabs-row button.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.form-grid .wide { grid-column: 1 / -1; }
.lookup { position: relative; }
.lookup-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); max-height: 360px; overflow: auto; }
.lookup-item { display: flex; gap: 12px; align-items: baseline; width: 100%; text-align: left; background: transparent; color: var(--ink); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 9px 12px; font-weight: 400; }
.lookup-item:hover, .lookup-item:focus { background: var(--accent-soft); }
.lookup-item small { margin-left: auto; color: var(--muted); white-space: nowrap; }
.lookup-empty { padding: 12px; color: var(--muted); }
.lines-table input.qty { width: 110px; text-align: right; margin: 0; }
.lines-table tr.short td { background: var(--bad-soft); }
.lines-table tfoot td { font-weight: 600; background: var(--surface-2); }
.error-text { color: var(--bad); }
.form-actions { display: flex; gap: 10px; margin-bottom: 30px; }
dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(1100px, 96vw); max-height: 92vh; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(22, 24, 21, .25); }
dialog.modal.small { width: min(480px, 96vw); }
dialog.modal::backdrop { background: rgba(22, 24, 21, .35); }
dialog.modal[open] { display: flex; flex-direction: column; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin: 0; font-size: 17px; }
.modal-b { padding: 16px 20px; overflow: auto; }
.modal-f { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); }
.modal-f .muted { margin-right: auto; }
.input-grid td { padding: 2px 3px; min-width: 64px; position: relative; }
.input-grid td input { width: 100%; margin: 0; padding: 4px 6px; text-align: right; border-radius: 4px; font-size: 13px; }
.input-grid td .have { display: block; font-size: 10.5px; line-height: 1.2; color: var(--muted); text-align: right; padding: 1px 2px 0; }
.input-grid td input::placeholder { color: #C9D0DA; }
.input-grid td.out input { border-color: var(--bad); background: var(--bad-soft); }
dialog.drawer.wide { width: min(760px, 100vw); }

/* dashboard */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.card h2 .more { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--accent); text-decoration: none; }
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--accent); }
#kpis .stat { flex-basis: 120px; }

/* import / export */
.stock-summary .stat.bad { background: var(--bad-soft); border-color: #F0B9B4; }
.stock-summary .stat.bad b { color: var(--bad); }
.stock-summary .stat small { display: block; }
.error-card { border-color: #F0B9B4; }
.success-card { background: var(--good-soft); border-color: #BFE3CD; margin: 12px 0 0; padding: 12px 16px; }

/* best / slow sellers */
.warn-note { background: var(--warn-soft); color: var(--warn); margin: 12px 0 0; }
#f-days button { padding: 7px 14px; }

/* stock form: browse by brand / category */
.lookup-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lookup-row .lookup { flex: 1 1 320px; }
.lookup-row select { flex: 0 1 200px; width: auto; }
.lookup-row .check { margin: 0; display: flex; align-items: center; white-space: nowrap; color: var(--ink-2); font-size: 14px; }
.browse { border: 1px solid var(--line-strong); border-radius: 8px; margin: 0 0 16px; background: var(--surface); }
.browse-h { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: 8px 8px 0 0; font-size: 13.5px; }
.browse-list { max-height: 360px; overflow: auto; }
.browse-list table { width: 100%; }
.browse-list th { position: sticky; top: 0; z-index: 1; }
.browse-list td, .browse-list th { padding: 6px 12px; }
.browse-list tr.picked td { background: var(--good-soft); }
#ui-table tr.short td { background: var(--bad-soft); }

/* ---------- Work orders (ใบงาน) ---------- */
.step-tabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; margin-bottom: 16px; }
.step-tab { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 12px; font-weight: 500; }
.step-tab b { font-size: 22px; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.step-tab small { font-size: 11.5px; color: var(--muted); }
.step-tab small .late { color: var(--bad); font-weight: 600; }
.step-tab.mine { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.step-tab.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.step-tab.active b, .step-tab.active small, .step-tab.active small .late { color: var(--brand-ink); }
.step { display: inline-block; border-radius: 6px; padding: 1px 8px; font-size: 12.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.step.delivered { background: var(--good-soft); color: var(--good); }
.step.cancelled { background: var(--surface-3); color: var(--muted); }
.hold { display: inline-block; border-radius: 6px; padding: 1px 8px; font-size: 12.5px; font-weight: 600; background: var(--warn-soft); color: var(--warn); white-space: nowrap; }
.age { font-variant-numeric: tabular-nums; white-space: nowrap; }
.age.late { color: var(--bad); font-weight: 600; }
.wo-progress { display: flex; gap: 4px; margin: 4px 0 18px; flex-wrap: wrap; }
.wo-progress span { flex: 1 1 90px; text-align: center; font-size: 12px; padding: 6px 4px; border-radius: 6px; background: var(--surface-3); color: var(--muted); }
.wo-progress span.past { background: var(--good-soft); color: var(--good); }
.wo-progress span.now { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.wo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wo-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 16px; align-items: start; }
.wo-grid .card { margin-bottom: 16px; }
.alert-card { border: 1px solid #F0B9B4; background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.alert-card.warn { border-color: #F0D9A8; background: var(--warn-soft); color: var(--warn); }
.alert-card ul { margin: 6px 0 0; padding-left: 18px; }
.rx-grid { border-collapse: collapse; width: 100%; }
.rx-grid th, .rx-grid td { border: 1px solid var(--line); padding: 4px 6px; text-align: center; font-variant-numeric: tabular-nums; }
.rx-grid th { background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.rx-grid input { width: 100%; min-width: 64px; text-align: right; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); position: relative; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.timeline li.fail::before, .timeline li.cancel::before { background: var(--bad); }
.timeline li.hold::before { background: var(--warn); }
.timeline li.done::before { background: var(--good); }
.timeline .when { color: var(--muted); font-size: 12px; }
.file-thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.file-thumbs a { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; width: 120px; text-decoration: none; color: var(--ink-2); font-size: 12px; }
.file-thumbs img { display: block; width: 120px; height: 90px; object-fit: cover; background: var(--surface-3); }
.file-thumbs span { display: block; padding: 4px 6px; }
.dept-checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.dept-checks label { margin: 0; font-weight: 400; display: flex; align-items: center; gap: 6px; }
fieldset.wo-section { border: 0; padding: 0; margin: 0; }
