:root {
  /* Mako Garment blue, with a soft gradient on brand surfaces */
  --brand: #2f45c6; --brand-2: #4a6cf0; --brand-deep: #1f2f96; --brand-soft: #eef1fe; --brand-line: #c7d0fa;
  --grad: linear-gradient(135deg, #1f2f96 0%, #2f45c6 45%, #4a6cf0 100%);
  --bg: #f4f6fb; --card: #fff; --ink: #141a2e; --muted: #64708a; --line: #e2e6ef;
  --green: #16a34a; --green-d: #15803d; --red: #dc2626; --red-soft: #fee2e2;
  --amber: #b45309; --amber-soft: #fef3c7; --blue: #2563eb; --blue-soft: #dbeafe;
  /* chart + timeline (reference palette & fixed status colours) */
  --c-work: #0ca30c; --c-break: #fab219; --c-stop: #a3a29b; --c-idle: #d03b3b;
  --grid: #e1e0d9; --axis: #c3c2b7; --tick: #898781;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
h2 .i { color: var(--brand); }
h3 { font-size: 16px; margin-top: 14px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hint { font-size: 13px; color: var(--amber); background: var(--amber-soft); padding: 8px 10px; border-radius: 10px; margin: 8px 0 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row.gap { justify-content: flex-start; flex-wrap: wrap; margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.neg { color: var(--red); }
.pos { color: var(--green-d); }

/* Icons */
.i { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -0.2em; }

/* Layout */
header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--grad); color: #fff; box-shadow: 0 2px 12px rgba(31, 47, 150, .25); }
header.top h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .back { color: #fff; display: flex; padding: 4px; margin-left: -6px; }
header.top .back .i { width: 26px; height: 26px; }
.mark { width: 32px; height: 32px; border-radius: 9px; border: 1px solid rgba(255,255,255,.4); flex: none; display: block; }
header.top .who { font-size: 14px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
header.top .who button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 9px; padding: 7px 9px; cursor: pointer; display: flex; }
@media (max-width: 400px) { .who-name { display: none; } }
main { max-width: 820px; margin: 0 auto; padding: 16px 16px 104px; }
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px 10px; color: var(--muted); text-decoration: none; font-size: 11.5px; }
nav.tabs a .i { width: 22px; height: 22px; }
nav.tabs a.on { color: var(--brand); font-weight: 650; }
#netbar { position: sticky; top: 0; z-index: 10; padding: 8px 16px; font-size: 14px; font-weight: 600; text-align: center; display: flex; gap: 8px; justify-content: center; align-items: center; }
#netbar.off { background: var(--red); color: #fff; }
#netbar.saving { background: var(--amber-soft); color: var(--amber); }
#netbar[hidden] { display: none; }

/* Cards */
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; color: inherit; text-decoration: none; box-shadow: 0 1px 2px rgba(20, 26, 46, .04); }
.card.express { border: 2px solid var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.card.held { border-left: 5px solid var(--amber); }
.card.owner { border-color: var(--brand-line); background: linear-gradient(180deg, #fbfcff, #fff); }
a.card { transition: transform .12s, box-shadow .12s; }
a.card:hover { box-shadow: 0 4px 14px rgba(20, 26, 46, .08); }
a.card:active { transform: scale(.995); }
.inv { font-weight: 750; font-size: 17px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inv.big { font-size: 22px; }
.meta { font-size: 14px; color: var(--muted); margin-top: 8px; }
.notes { background: var(--bg); padding: 8px 10px; border-radius: 10px; white-space: pre-wrap; }
.overdue { color: var(--red); font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); vertical-align: middle; }
.badge.red { background: var(--red); color: #fff; }
.chip { display: inline-block; font-size: 13px; padding: 2px 8px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); margin: 2px 2px 2px 0; }
.sizes-line { margin: 10px 0 8px; }
.status { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.st-new { background: #eceef3; color: #4b5563; }
.st-sew { background: var(--blue-soft); color: #1e40af; }
.st-ready { background: #dcfce7; color: #166534; }
.st-run { background: var(--green); color: #fff; }
.st-break, .st-hold { background: var(--amber-soft); color: var(--amber); }
.st-done { background: #e5e7eb; color: #374151; }
.st-partial { background: #ffedd5; color: #9a3412; }
.qty-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 14px; }
.qty-foot .done { color: var(--green-d); display: flex; align-items: center; gap: 5px; }
.qty-foot .left { color: var(--muted); }
.qty-foot.big { font-size: 16px; }
.short { margin-top: 8px; padding: 7px 10px; border-radius: 10px; background: #fff1f0; color: #b42318; font-size: 13.5px; font-weight: 600; display: flex; gap: 6px; align-items: flex-start; border: 1px solid #fecdca; }
.short .i { margin-top: 1px; }
.short.hold { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }

.progress { height: 8px; background: #e9ecf3; border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; background: linear-gradient(90deg, #16a34a, #22c55e); border-radius: 99px; transition: width .4s; }
.progress.big { height: 14px; margin: 6px 0; }
.ready { margin: 14px 0 6px; padding: 12px; background: #f0fdf4; border-radius: 12px; }
.ready .pct { font-size: 22px; color: var(--green-d); }

/* Forms */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 10px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; font-weight: 400; border: 1px solid #cfd5e2; border-radius: 10px; background: #fff; color: var(--ink); }
input[hidden] { display: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
textarea { min-height: 70px; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 12px; border-radius: 10px; background: var(--bg); }
label.check input { width: 22px; height: 22px; margin: 0; flex: none; }
.express-check { background: var(--red-soft) !important; color: #991b1b; }
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.size-grid.wide { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.size-grid label { margin: 0; }
.upload { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px; border: 2px dashed var(--brand-line); border-radius: 12px; background: var(--brand-soft); color: var(--brand); cursor: pointer; text-align: center; }
.upload .i { width: 24px; height: 24px; }
.upload input { display: none; }
#invStatus { margin-top: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; font-size: 13px; white-space: nowrap; }
.toggle input { width: 18px; height: 18px; margin: 0; }

/* Order item lines */
.line { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: #fbfcfe; }
.line.bad { border: 2px solid var(--red); background: var(--red-soft); }
.line-main { display: grid; grid-template-columns: 1.4fr .8fr .7fr .8fr auto; gap: 8px; align-items: end; }
.line-main label, .line-more label { margin: 0; font-size: 12.5px; }
.line-more { margin-top: 8px; display: grid; gap: 8px; }
.fabrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fab-row { display: flex; align-items: center; gap: 8px; }
.fab-row input:not([type=checkbox]) { margin: 0; flex: 1; min-width: 0; }
.short-why { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
form.no-sizes .size-only { display: none; }
form.no-sizes .line-main { grid-template-columns: 1.6fr .7fr .8fr auto; }
form.no-sewing .sew-only { display: none; }
@media (max-width: 560px) {
  .line-main { grid-template-columns: 1fr 1fr; }
  .line-main label:first-child { grid-column: 1 / -1; }
  .line-main .btn { grid-column: 2; justify-self: end; }
  form.no-sizes .line-main { grid-template-columns: 1fr 1fr; }
  .fabrics, .short-why { grid-template-columns: 1fr; }
}
.chips-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pchip { margin: 0; }
.pchip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pchip span { display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 500; cursor: pointer; }
.pchip input:checked + span { background: var(--grad); color: #fff; border-color: transparent; }
.pchip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 10px 16px; font: inherit; font-weight: 600; border-radius: 12px; border: 1px solid #cfd5e2; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(47, 69, 198, .3); }
.btn.big { width: 100%; min-height: 54px; font-size: 17px; margin-top: 6px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #f3b4b4; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.icon { min-width: 46px; padding: 8px 10px; }
.btn.start { width: 100%; min-height: 60px; font-size: 18px; background: linear-gradient(135deg, #15803d, #22c55e); border-color: transparent; color: #fff; box-shadow: 0 3px 10px rgba(22, 163, 74, .3); }
.btn.start:disabled { background: #9ca3af; box-shadow: none; }
.btn.tea { background: #fff7ed; border-color: #fdba74; color: #9a3412; }
.btn.lunch { background: #fefce8; border-color: #fde047; color: #854d0e; }
.btn.stopb { background: #f3f4f6; color: #374151; }
.btn.finish { background: #1f2937; border-color: #1f2937; color: #fff; }
button.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

/* Orders list */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input { flex: 1 1 200px; margin: 0; }
.filters { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.filters button.on { background: var(--grad); color: #fff; border-color: transparent; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Tables */
.tbl { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tfoot td { font-weight: 700; border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-cell b { font-size: 15px; }
.size-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px; }
.fabric { display: inline-block; font-size: 12px; margin: 4px 4px 0 0; padding: 1px 6px; border-radius: 6px; }
.fabric.ok { background: #dcfce7; color: #166534; }
.fabric.no { background: #fee2e2; color: #b42318; font-weight: 600; }
.place { margin-bottom: 4px; }
.short-line { color: #b42318; font-weight: 600; display: flex; gap: 5px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #c4c9d2; margin-right: 6px; }
.dot.d-out { background: var(--blue); }
.dot.d-back { background: var(--green); }

/* Sewing */
.sew { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.sew.done { border-left-color: var(--green); background: #fafafa; }
.sew .row.gap { margin-top: 8px; }

/* Embroidery */
.job { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 14px; background: #fcfcfe; }
.job.state-running { border-color: #86efac; box-shadow: 0 0 0 3px #f0fdf4; }
.job h3 { margin: 0; font-size: 18px; }
.pstages { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
@media (max-width: 480px) { .pstages { grid-template-columns: 1fr; } }
.pstage { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.photos { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 2px; }
.thumb { flex: none; width: 84px; height: 84px; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 0; position: relative; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: inherit; color: inherit; margin: 0; }
.thumb .i { width: 26px; height: 26px; margin-bottom: 14px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb span { position: absolute; bottom: 0; left: 0; right: 0; font-size: 11px; background: rgba(0,0,0,.55); color: #fff; padding: 2px; text-align: center; font-weight: 500; }
.thumb.add { border: 2px dashed var(--brand-line); color: var(--brand); background: var(--brand-soft); }
.thumb.add span { background: var(--brand); }
.live { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-radius: 12px; margin-bottom: 10px; font-weight: 600; }
.live-l { display: flex; align-items: center; gap: 8px; }
.live b { font-size: 24px; font-variant-numeric: tabular-nums; }
.live.run { background: #dcfce7; color: #166534; }
.live.brk { background: var(--amber-soft); color: var(--amber); }
.live.fin { background: #e5e7eb; color: #1f2937; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--green); animation: pulse 1.2s infinite; flex: none; }
@keyframes pulse { 50% { opacity: .25; } }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 6px; }
.stats div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.stats span { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.stats b { font-variant-numeric: tabular-nums; }
.pieces { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.counter { display: flex; align-items: center; gap: 6px; }
.counter b { min-width: 72px; text-align: center; font-size: 18px; }
.add-pos { display: flex; gap: 8px; align-items: center; }
.add-pos select { margin: 0; flex: 1; }
details.log { margin-top: 10px; font-size: 14px; }
details.log summary { cursor: pointer; color: var(--brand); font-weight: 600; }
details.log ul { list-style: none; padding: 0; margin: 8px 0 0; }
details.log li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
details.log time { font-variant-numeric: tabular-nums; color: var(--muted); margin-right: 6px; }
pre { white-space: pre-wrap; font-size: 12px; background: var(--bg); padding: 10px; border-radius: 10px; max-height: 260px; overflow: auto; }

/* Money */
dl.money { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0 0 12px; }
dl.money dt { color: var(--muted); }
dl.money dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
dl.money .tot { font-weight: 800; font-size: 18px; color: var(--ink); border-top: 1px solid var(--line); padding-top: 8px; }
dl.money dd.tot.neg { color: var(--red); }
dl.money dd.tot.pos { color: var(--green-d); }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.tile span { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.tile b { display: block; font-size: 21px; margin-top: 4px; }
.tile.hero { grid-column: 1 / -1; background: var(--grad); color: #fff; border: 0; box-shadow: 0 6px 20px rgba(47, 69, 198, .28); }
.tile.hero span { color: rgba(255,255,255,.85); }
.tile.hero b { font-size: 32px; }
.tile.hero b.neg { color: #fecaca; }
.tile.alert b { color: var(--red); }
.sect-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 22px 0 10px; }
.sect-title h2 { margin: 0; }
.range { padding: 12px 14px; }
.range-in { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.range-in label { margin: 0; flex: 1 1 140px; }
.range .filters { margin: 0; }
.cost-form { display: grid; grid-template-columns: 1fr 1.4fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 10px; }
.cost-form label { margin: 0; }
@media (max-width: 560px) { .cost-form { grid-template-columns: 1fr 1fr; } .cost-form label:nth-child(2) { grid-column: 1 / -1; grid-row: 1; } }

/* Charts */
.chart { width: 100%; min-height: 230px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: #52514e; margin: 0 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.plot { position: relative; }
.plot svg { display: block; overflow: visible; }
.plot .grid { stroke: var(--grid); stroke-width: 1; }
.plot .axis { stroke: var(--axis); stroke-width: 1; }
.plot .tick { fill: var(--tick); font-size: 11px; font-variant-numeric: tabular-nums; }
.plot .cross { stroke: #898781; stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.plot .dot { pointer-events: none; }
.plot .bar { transform-box: fill-box; transform-origin: bottom; animation: grow .6s cubic-bezier(.2, .8, .2, 1) both; }
.plot .line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .9s .2s ease-out forwards; }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .plot .bar, .plot .line { animation: none; stroke-dashoffset: 0; } }
.tip { position: absolute; top: 0; z-index: 2; pointer-events: none; background: #fff; border: 1px solid rgba(11,11,11,.1); box-shadow: 0 6px 18px rgba(0,0,0,.12); border-radius: 10px; padding: 8px 10px; font-size: 13px; min-width: 150px; color: #0b0b0b; }
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 6px; color: #52514e; }
.tip div span { margin-left: auto; color: #0b0b0b; font-weight: 600; font-variant-numeric: tabular-nums; }
.tip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Day timeline */
.timeline { overflow-x: auto; padding-bottom: 4px; }
.tl-row { display: grid; grid-template-columns: 150px 1fr; gap: 8px; align-items: center; min-width: 620px; margin-bottom: 6px; }
.tl-label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-track { position: relative; height: 22px; background: #f3f4f7; border-radius: 6px; }
.tl-head .tl-track { background: none; height: 34px; }
.tl-row.combined .tl-track { height: 30px; }
.seg { position: absolute; top: 0; bottom: 0; border-right: 2px solid #fff; }
.seg:first-child { border-radius: 6px 0 0 6px; }
.k-work { background: var(--c-work); }
.k-break { background: var(--c-break); }
.k-tea, .k-lunch { background: var(--c-break); }
.k-stop { background: var(--c-stop); }
.k-idle { background: repeating-linear-gradient(45deg, #f6c7c7 0 6px, #fbe3e3 6px 12px); box-shadow: inset 0 0 0 1px #e8a3a3; }
.legend i.k-idle { box-shadow: inset 0 0 0 1px #d03b3b; }
.shift-band { position: absolute; top: 0; height: 14px; border-left: 2px solid var(--brand); padding-left: 4px; font-size: 11px; font-weight: 700; color: var(--brand); white-space: nowrap; overflow: hidden; }
.hr { position: absolute; bottom: 0; transform: translateX(-50%); font-size: 11px; color: var(--tick); font-variant-numeric: tabular-nums; }
.bar-split { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 10px 0 8px; background: #f3f4f7; gap: 2px; }
.gaps { list-style: none; padding: 0; margin: 10px 0 0; font-size: 14px; }
.gaps li { padding: 6px 0; border-top: 1px dashed var(--line); display: flex; align-items: center; gap: 8px; }
.k-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.print-title { display: none; }

/* Settings */
.srow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.srow.type { grid-template-columns: 1fr 1.5fr .8fr auto auto auto; }
.srow.shift { grid-template-columns: 1.3fr 1fr 1fr auto; }
.srow.cost { grid-template-columns: 1.4fr 1fr 1fr auto; }
.srow input, .srow select { margin: 0; }
.phone-link { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0; }
.phone-link #qr { padding: 10px; background: #fff; border-radius: 12px; }
.phone-link .addr { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; user-select: all; }
@media (max-width: 560px) {
  .srow.type { grid-template-columns: 1fr 1fr auto; }
  .srow.type [data-f=keywords] { grid-column: 1 / -1; grid-row: 2; }
  .srow.type [data-f=unitCost] { grid-column: 1; grid-row: 3; }
  .srow.shift, .srow.cost { grid-template-columns: 1fr 1fr auto; }
  .srow.shift [data-f=name], .srow.cost [data-f=name] { grid-column: 1 / -1; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* Login */
.login { max-width: 420px; margin: 0 auto; padding: 40px 20px; min-height: 100vh; }
.brand { display: flex; align-items: center; gap: 14px; justify-content: center; margin-bottom: 22px; }
.brand-mark { width: 60px; height: 60px; border-radius: 16px; display: block; box-shadow: 0 8px 22px rgba(2, 84, 165, .35); }
.brand-name { font-size: 24px; font-weight: 800; letter-spacing: -.01em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: 13px; color: var(--muted); }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 18px; text-align: center; box-shadow: 0 10px 30px rgba(20, 26, 46, .06); }
.big-icon .i { width: 44px; height: 44px; color: var(--muted); }
.user-pick { display: grid; gap: 8px; margin: 14px 0; text-align: left; }
.pick { display: flex; align-items: center; gap: 10px; margin: 0; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.pick input { width: 20px; height: 20px; margin: 0; flex: none; }
.pick .i { color: var(--brand); }
.pick:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.login input[name=pin] { text-align: center; font-size: 22px; letter-spacing: .3em; padding-right: 48px; padding-left: 48px; }
/* A text box drawn as dots, so Chrome doesn't offer saved passwords for a PIN. */
.login input.pin.masked { -webkit-text-security: disc; text-security: disc; }
.pin-wrap { position: relative; }
.pin-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); margin-top: 2px; background: none; border: 0; padding: 8px; color: var(--muted); cursor: pointer; }
.pin-eye .i { width: 22px; height: 22px; }
.login-err { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff1f0; border: 1px solid #fecdca; color: #b42318; font-weight: 600; font-size: 15px; }
.login-err[hidden] { display: none; }

/* Modal + toast */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(15,18,30,.5); display: flex; align-items: flex-end; justify-content: center; }
#modal[hidden] { display: none; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet img.full { width: 100%; border-radius: 10px; }
@media (min-width: 640px) { #modal { align-items: center; } .sheet { border-radius: 18px; } }
#toast { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 30; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--red); }

/* Alignment helpers */
.grid2.align-end { align-items: end; }
label.btn { margin: 0; font-size: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; margin-top: 10px; }
.btn-row .btn { flex: 0 1 auto; }
.filters .count { font-size: 12px; opacity: .75; }

/* Uploads on the order form */
.uploads { margin-bottom: 4px; }
.uploads .upload { flex-direction: column; gap: 2px; margin: 0; padding: 14px 10px; font-weight: 700; }
.uploads .upload small { font-weight: 400; font-size: 12px; color: var(--muted); }
#wsStatus { margin-top: 4px; }

/* Sewing split on a new order */
.sew-split { background: #f5f8ff; border: 1px dashed var(--brand-line); border-radius: 10px; padding: 8px; }
.splits { display: grid; gap: 6px; margin: 6px 0; }
.split { display: grid; grid-template-columns: 1fr 90px auto; gap: 6px; }
.split input { margin: 0; }
.short-why { grid-template-columns: 1.2fr 1fr .9fr; }
@media (max-width: 560px) { .short-why { grid-template-columns: 1fr; } }

/* Settings: product costs */
.cost-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.cost-grid label { margin: 0; }

/* Embroidery runs */
.pos-sum { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0; align-items: center; }
.pos-sum span { display: inline-flex; align-items: center; gap: 4px; }
.runs { list-style: none; padding: 0; margin: 6px 0 10px; }
.runs li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.run-txt { flex: 1; min-width: 0; }
.minis { display: flex; gap: 4px; }
.mini { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; cursor: pointer; background: #fff; }
.mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ok-dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff; flex: none; }
.ok-dot .i { width: 14px; height: 14px; stroke-width: 3; }
.ok-dot.live { background: var(--amber); }
.thumb .ok-dot { position: absolute; top: 4px; right: 4px; font-style: normal; }
.done-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; color: #fff; background: var(--green); border-radius: 999px; padding: 1px 8px 1px 6px; margin-left: 4px; }
.done-chip .i { width: 12px; height: 12px; stroke-width: 3; }
.pstage.has { border-color: #86efac; background: #f6fef9; }
.run-live { border: 1px solid var(--brand-line); background: #fbfcff; border-radius: 12px; padding: 10px; margin-top: 8px; }
.run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 4px; }
.new-run { display: grid; grid-template-columns: 1fr 100px auto; gap: 8px; align-items: end; margin-top: 8px; padding: 10px; border: 1px dashed var(--brand-line); border-radius: 12px; }
.new-run label { margin: 0; }
.task .new-run, .new-run:not(:has(select)) { grid-template-columns: 100px auto; }
.job.state-finished { border-color: #86efac; }
.job h3 { display: flex; align-items: center; gap: 6px; }
.pchip.task span { border-style: dashed; }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.sheet-row:first-of-type { border-top: 0; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.big { font-size: 14px; padding: 5px 10px; }
.tile small { display: block; margin-top: 2px; }
.tl-row.machine .tl-label { color: var(--brand); font-weight: 600; display: flex; align-items: center; gap: 4px; }

/* Progress strip: received → embroidered → completed → remaining */
.pstrip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.pstrip div { position: relative; overflow: hidden; background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.pstrip span { display: block; font-size: 12px; color: var(--muted); }
.pstrip b { font-size: 20px; position: relative; }
.pstrip i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--brand-2); border-radius: 0 4px 4px 0; }
.pstrip .ok i { background: var(--green); }
.pstrip .rem b { color: var(--amber); }
@media (max-width: 420px) { .pstrip { grid-template-columns: repeat(2, 1fr); } }
.progress-tbl td, .progress-tbl th { white-space: nowrap; }
.backlog { list-style: none; padding: 0; margin: 6px 0 0; font-size: 13px; }
.backlog li { display: flex; gap: 6px; align-items: center; padding: 2px 0; color: #166534; }
.recv { margin-bottom: 10px; }
.src-pick { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; padding: 10px; border-radius: 10px; background: var(--amber-soft); margin-bottom: 8px; }
.src-pick label { margin: 0; color: var(--amber); display: flex; flex-direction: column; gap: 2px; }
.new-run.with-src { grid-template-columns: 1.3fr 1fr 90px auto; }
@media (max-width: 560px) { .new-run, .new-run.with-src { grid-template-columns: 1fr 1fr; } .new-run .btn { grid-column: 1 / -1; } }

/* Floating "New order" button (Orders and Archive pages) */
.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 6; display: flex; align-items: center; gap: 6px; padding: 14px 18px; border-radius: 999px; background: var(--grad); color: #fff; font-weight: 700; text-decoration: none; box-shadow: 0 6px 18px rgba(31, 47, 150, .4); }
.fab .i { width: 22px; height: 22px; }
main { padding-bottom: 150px; }

/* Order cards: working days first, two-colour embroidery bar, who added it */
.due-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin-bottom: 8px; }
.due-chip span { font-weight: 500; opacity: .8; }
.due-chip.soon { background: var(--amber-soft); color: var(--amber); }
.due-chip.late { background: var(--red); color: #fff; }
.ebar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 2px; margin-top: 10px; background: #fff; }
.ebar-done { background: linear-gradient(90deg, #15803d, #22c55e); transition: width .4s; }
.ebar-left { background: #fdba74; }
.ebar > div:first-child { border-radius: 99px 0 0 99px; }
.ebar > div:last-child { border-radius: 0 99px 99px 0; }
.ebar-legend { display: flex; gap: 14px; margin-top: 5px; flex-wrap: wrap; }
.ebar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ebar-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ebar-legend .k-done { background: #16a34a; }
.ebar-legend .k-left { background: #fdba74; }
.added-by { margin-top: 8px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* Daily target */
.card.target { border: 0; background: linear-gradient(135deg, #f0f4ff, #fff); box-shadow: 0 0 0 1px var(--brand-line); }
.card.target.empty { font-size: 14px; display: flex; gap: 8px; align-items: center; }
.target-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--brand); }
.target-row { padding: 6px 0; }
.target-row + .target-row { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 10px; }
.target-row b { font-size: 22px; }
.target-row b small { font-size: 14px; color: var(--muted); font-weight: 500; }
.tbar { height: 14px; border-radius: 99px; background: #e9ecf3; overflow: hidden; margin: 6px 0 4px; }
.tbar div { height: 100%; border-radius: 99px; background: var(--grad); transition: width .5s; }
.target-row.hit .tbar div { background: linear-gradient(90deg, #15803d, #22c55e); }
.target-row.hit .small { color: var(--green-d); font-weight: 700; }

/* Ads budget */
.ads-form { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 10px; }
.ads-form label { margin: 0; }
@media (max-width: 640px) { .ads-form { grid-template-columns: 1fr 1fr; } .ads-form .btn { grid-column: 1 / -1; } }
.srow.cost .cost-when { margin: 0; font-size: 12px; font-weight: 500; color: var(--muted); }
tr.muted td { opacity: .6; }

/* Stock / reorder list */
.card.stock.must { border: 2px solid var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.card.stock.done { opacity: .75; }
.card.must h3 { color: #b42318; display: flex; align-items: center; gap: 6px; }
.stock-name { font-size: 17px; }
.must-title { color: #b42318; }
.count-pill { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px; }
.count-pill.red { background: var(--red); color: #fff; }
.short-list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.short-list li { padding: 7px 0; border-top: 1px dashed #fecdca; }
.short-list li:first-child { border-top: 0; }
.thumb.sm { width: 64px; height: 64px; }
.thumb.sm .i { margin-bottom: 12px; }
.btn.tick { background: linear-gradient(135deg, #15803d, #22c55e); color: #fff; border-color: transparent; }
.stock-archive { margin-top: 18px; }
.stock-archive summary { font-size: 16px; display: flex; align-items: center; gap: 6px; }
.stock-archive .card { margin-top: 10px; }

/* Settings: Save stays reachable on a long page, and its result shows right above it */
.save-bar { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 4; background: linear-gradient(180deg, rgba(244,246,251,0), var(--bg) 30%); padding: 14px 0 6px; margin-top: 4px; }
.save-bar .btn.big { margin-top: 0; }
.save-status { margin: 0 0 8px; font-size: 14px; font-weight: 600; min-height: 0; }
.save-status:empty { display: none; }
.save-status.ok { padding: 8px 12px; border-radius: 10px; background: #dcfce7; color: #166534; }
.save-status.err { padding: 8px 12px; border-radius: 10px; background: #fff1f0; border: 1px solid #fecdca; color: #b42318; }
.pin-field { letter-spacing: .2em; font-size: 18px; }
.pin-field::placeholder { letter-spacing: normal; font-size: 15px; }

/* Accounts & roles */
.srow.user { grid-template-columns: 1.3fr 1fr 1.2fr auto; }
@media (max-width: 560px) { .srow.user { grid-template-columns: 1fr 1fr auto; } .srow.user [data-f=role] { grid-column: 1 / -1; grid-row: 2; } }
.perm-tbl td, .perm-tbl th { vertical-align: middle; }
.perm-tbl input { width: 20px; height: 20px; margin: 0 auto; display: block; }
.perm-tbl .i { color: var(--green); }
th.center, td.center { text-align: center; }
.who-name small { display: block; font-size: 11px; opacity: .8; line-height: 1; }
.pick small { font-weight: 400; }

/* Print (reports → paper or PDF) */
@media print {
  header.top, nav.tabs, #netbar, .filters, .range, .btn, #toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { break-inside: avoid; box-shadow: none; }
  .print-title { display: block; }
  .tile.hero { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
  .tile.hero span { color: var(--muted); }
  .timeline { overflow: visible; }
  .k-work, .k-break, .k-stop, .k-idle, .k-tea, .k-lunch, .bar-split div { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Passwords */
.pw-weak { color: var(--amber); background: var(--amber-soft); padding: 6px 10px; border-radius: 8px; margin: 8px 0 0; }
.srow .pw-weak { grid-column: 1 / -1; margin: 0; font-size: 12px; }
.public-link { margin-top: 12px; }
.public-link .addr { word-break: break-all; }
.login input[name=pin]::placeholder { letter-spacing: normal; font-size: 17px; }
