@font-face {
  font-family: "Bounded";
  src: url("assets/fonts/Bounded-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f7f6f1;
  --ink: #111111;
  --muted: #746f64;
  --line: #e2ded3;
  --panel: rgba(255, 255, 255, 0.88);
  --blue: #111111;
  --blue-soft: #fff7cc;
  --yellow: #f6c400;
  --ok: #111111;
  --warn: #f6c400;
  --danger: #d94a3d;
  --metal: #ebe7dc;
  --shadow: rgba(18, 18, 18, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: var(--app-height, 100vh);
  min-height: var(--app-height, 100vh);
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 78px;
  padding: 10px clamp(16px, 2.2vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 246, 241, 0.9);
  backdrop-filter: blur(18px);
  z-index: 3;
}

.app-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.app-logo {
  width: clamp(46px, 5vw, 64px);
  height: clamp(46px, 5vw, 64px);
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 16px rgba(17, 17, 17, 0.08));
}

.app-lockup h1 {
  margin: 0;
  color: var(--ink);
  font-family: "Bounded", Inter, sans-serif;
  font-size: clamp(24px, 2vw, 34px);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.08;
  white-space: nowrap;
}

.topbar-controls {
  display: grid;
  grid-template-columns: auto minmax(340px, 430px);
  align-items: center;
  gap: 12px;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(126px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 10px 24px rgba(17, 17, 17, 0.06);
}

.view-button {
  height: 40px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.view-button.is-active {
  color: var(--ink);
  background: var(--yellow);
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.14),
    0 8px 16px rgba(246, 196, 0, 0.24);
}

.machine-switcher {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 10px;
  min-width: min(100%, 430px);
  padding: 8px 10px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 10px 24px rgba(17, 17, 17, 0.06);
}

.machine-switcher label {
  gap: 4px;
  padding: 0;
}

.machine-switcher select {
  height: 32px;
  border: 0;
  background: transparent;
  padding: 0 28px 0 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 950;
  line-height: 1;
}

.machine-switcher strong {
  display: grid;
  place-items: center;
  height: 40px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--ink);
  background: var(--yellow);
  font-size: 13px;
  font-weight: 950;
  white-space: nowrap;
}

.segment {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--segment-count, 3), 74px);
  gap: 0;
  padding: 4px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 10px 24px rgba(17, 17, 17, 0.06);
  overflow: hidden;
}

.segment::before {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / var(--segment-count, 3));
  border-radius: 7px;
  background: var(--yellow);
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.14),
    0 8px 16px rgba(246, 196, 0, 0.28);
  content: "";
  transform: translateX(calc(var(--segment-index, 1) * 100%));
  transition: transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.segment-button {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  height: 40px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.segment-button.is-active {
  color: var(--ink);
  background: transparent;
  box-shadow: none;
}

.machine-workspace {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  grid-template-rows: auto auto auto auto;
  align-content: start;
  gap: clamp(10px, 1.4vw, 18px);
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: clamp(8px, 1.2vw, 16px) clamp(16px, 2.2vw, 34px) 10px;
}

.machine-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

.machine-frame {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: min(100%, 820px);
  aspect-ratio: 1.25;
}

.machine-head-render {
  width: 100%;
  height: 100%;
}

.machine-head-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 24px 34px rgba(22, 27, 29, 0.18));
}

.svg-main-body,
.svg-top-panel,
.svg-needle-cover-base,
.svg-logo-plate {
  fill: url("#body");
  stroke: rgba(17, 17, 17, 0.18);
  stroke-width: 2;
}

.svg-side-bracket {
  fill: #e8e6dd;
  stroke: rgba(17, 17, 17, 0.16);
  stroke-width: 2;
}

.svg-rail,
.svg-bottom-rail {
  fill: url("#metal");
  stroke: rgba(17, 17, 17, 0.28);
  stroke-width: 2;
}

.svg-rail.lower {
  fill: #d8d8d2;
}

.svg-screw circle {
  fill: #d8d5ca;
  stroke: rgba(17, 17, 17, 0.32);
  stroke-width: 2;
}

.svg-screw path {
  stroke: rgba(17, 17, 17, 0.55);
  stroke-width: 2;
  stroke-linecap: round;
}

.svg-hit {
  fill: transparent;
  cursor: pointer;
}

.svg-channel,
.svg-marker,
.svg-marker circle,
.svg-marker text {
  cursor: pointer;
}

.svg-marker text {
  user-select: none;
}

.svg-thread {
  stroke: var(--thread);
  stroke-width: 1.9;
  opacity: 0.88;
  pointer-events: none;
}

.svg-channel.is-selected .svg-thread,
.svg-channel.is-selected .svg-needle-line,
.svg-channel.is-selected .svg-thread-tail {
  stroke: var(--yellow);
  stroke-width: 4;
  opacity: 1;
}

.svg-knob,
.svg-disc {
  fill: #f8f7f2;
  stroke: rgba(17, 17, 17, 0.22);
  stroke-width: 2;
}

.svg-knob-inner {
  fill: #bdb9ae;
  stroke: rgba(17, 17, 17, 0.28);
  stroke-width: 1.5;
}

.svg-clamp rect {
  fill: #c9c8c1;
  stroke: rgba(17, 17, 17, 0.36);
  stroke-width: 1.5;
}

.svg-clamp circle {
  fill: #424242;
}

.svg-cover {
  fill: #fefdf9;
  stroke: rgba(17, 17, 17, 0.18);
  stroke-width: 1.8;
}

.svg-needle-line,
.svg-needle-bottom line,
.svg-needle-bottom path {
  fill: none;
  stroke: rgba(17, 17, 17, 0.45);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.svg-needle-bottom rect {
  fill: #d9d8d1;
  stroke: rgba(17, 17, 17, 0.35);
  stroke-width: 1.4;
}

.svg-needle-bottom .svg-thread-tail {
  stroke: var(--thread);
  stroke-width: 1.35;
  opacity: 0.82;
}

.svg-needle-eye {
  fill: rgba(17, 17, 17, 0.55);
  stroke: none;
}

.svg-marker text {
  fill: #ffffff;
  font-size: 15px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: middle;
}

.svg-marker circle {
  fill: var(--ink);
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 3;
}

.svg-channel.is-warn .svg-marker circle {
  fill: var(--yellow);
  stroke: rgba(17, 17, 17, 0.18);
}

.svg-channel.is-warn .svg-marker text {
  fill: var(--ink);
}

.svg-channel.is-danger .svg-marker circle {
  fill: var(--danger);
  stroke: rgba(17, 17, 17, 0.16);
}

.svg-brand-logo {
  opacity: 0.8;
  pointer-events: none;
}

.machine-tension-visual {
  position: absolute;
  left: 15.8%;
  right: 18.4%;
  top: 11.3%;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(var(--needle-count), minmax(12px, 1fr));
  height: 29%;
  padding: 6px 7px 8px;
  border: 1px solid rgba(17, 17, 17, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(246, 244, 236, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    0 8px 18px rgba(17, 17, 17, 0.08);
  pointer-events: none;
}

.tension-slot {
  position: relative;
  min-width: 0;
  height: 100%;
}

.tension-knob,
.tension-disc {
  position: absolute;
  left: 50%;
  border: 1px solid rgba(17, 17, 17, 0.16);
  border-radius: 50%;
  background:
    radial-gradient(circle at 44% 38%, #ffffff 0 18%, #e8e4da 19% 42%, #ffffff 43% 58%, #d2cec3 59% 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 2px 4px rgba(17, 17, 17, 0.12);
  transform: translateX(-50%);
}

.tension-knob {
  top: 2%;
  width: min(92%, 30px);
  aspect-ratio: 1;
}

.tension-disc {
  top: 58%;
  width: min(72%, 23px);
  aspect-ratio: 1;
}

.tension-thread {
  position: absolute;
  left: 50%;
  top: 5%;
  bottom: -18%;
  width: 1px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.3);
  transform: translateX(-50%);
}

.tension-slot.is-selected .tension-thread {
  width: 2px;
  background: var(--yellow);
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.18);
}

.tension-slot.is-warn .tension-knob,
.tension-slot.is-warn .tension-disc {
  border-color: rgba(246, 196, 0, 0.62);
}

.tension-slot.is-danger .tension-knob,
.tension-slot.is-danger .tension-disc {
  border-color: rgba(217, 74, 61, 0.62);
}

.machine-head-needles {
  position: absolute;
  left: 28.2%;
  right: 28.4%;
  top: 34.7%;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(var(--needle-count), minmax(10px, 1fr));
  align-items: end;
  height: 17.3%;
  padding: 4px 5px 6px;
  border: 1px solid rgba(17, 17, 17, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(246, 244, 236, 0.88));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 6px 16px rgba(17, 17, 17, 0.08);
  pointer-events: none;
}

.machine-head-slot {
  position: relative;
  height: 100%;
  min-width: 0;
}

.head-cover {
  position: absolute;
  left: 50%;
  bottom: 16%;
  width: min(86%, 22px);
  height: 70%;
  border: 1px solid rgba(17, 17, 17, 0.16);
  border-radius: 4px 4px 7px 7px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.95), rgba(231, 228, 219, 0.92)),
    #ffffff;
  box-shadow:
    inset 1px 0 0 rgba(255, 255, 255, 0.75),
    inset -1px 0 0 rgba(17, 17, 17, 0.08);
  transform: translateX(-50%);
}

.head-thread {
  position: absolute;
  left: 50%;
  top: 2px;
  bottom: 8%;
  width: 1px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.28);
  transform: translateX(-50%);
}

.machine-head-slot.is-selected .head-thread {
  width: 2px;
  background: var(--yellow);
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.18);
}

.machine-head-slot.is-warn .head-cover {
  border-color: rgba(246, 196, 0, 0.55);
}

.machine-head-slot.is-danger .head-cover {
  border-color: rgba(217, 74, 61, 0.62);
}

.machine-since {
  position: absolute;
  left: 52.8%;
  top: 67.4%;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 17%;
  height: 5.5%;
  padding: 0 10px;
  border-radius: 4px;
  color: #0a63ad;
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.75),
    0 1px 3px rgba(17, 17, 17, 0.05);
  font-size: clamp(6px, 1.05vw, 9px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.machine-plate-scale {
  position: absolute;
  left: 13.9%;
  right: 18.3%;
  top: 71.2%;
  z-index: 7;
  display: grid;
  grid-template-columns: repeat(var(--needle-count), minmax(13px, 1fr));
  height: 8.2%;
  padding: 1px 4px 3px;
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(249, 248, 243, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    0 0 0 1px rgba(255, 255, 255, 0.62);
  pointer-events: none;
}

.plate-channel {
  position: relative;
  min-width: 0;
}

.plate-thread {
  position: absolute;
  left: 50%;
  top: -28%;
  bottom: 35%;
  width: 1px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.38);
  transform: translateX(-50%);
}

.plate-marker {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: grid;
  place-items: center;
  width: min(88%, 24px);
  aspect-ratio: 1.12;
  color: #0a63ad;
  font-size: clamp(6px, 1.15vw, 9px);
  font-weight: 950;
  line-height: 1;
  transform: translateX(-50%);
}

.plate-marker::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 2px solid #0a63ad;
  background: rgba(255, 255, 255, 0.95);
  clip-path: polygon(50% 100%, 4% 12%, 96% 12%);
  content: "";
}

.plate-channel.is-selected .plate-thread {
  width: 2px;
  background: var(--yellow);
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.18);
}

.plate-channel.is-warn .plate-marker {
  color: #735900;
}

.plate-channel.is-warn .plate-marker::before {
  border-color: var(--yellow);
}

.plate-channel.is-danger .plate-marker {
  color: var(--danger);
}

.plate-channel.is-danger .plate-marker::before {
  border-color: var(--danger);
}

.machine-needle-visual {
  position: absolute;
  left: 15.8%;
  right: 18.4%;
  bottom: 2.5%;
  display: grid;
  grid-template-columns: repeat(var(--needle-count), minmax(14px, 1fr));
  height: 16%;
  z-index: 6;
  padding: 5px 2px 4px;
  border: 1px solid rgba(17, 17, 17, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 250, 0.78);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 6px 12px rgba(17, 17, 17, 0.08);
  backdrop-filter: blur(1.5px);
  pointer-events: none;
}

.machine-visual-needle {
  position: relative;
  min-width: 0;
}

.visual-thread {
  position: absolute;
  left: 50%;
  top: 3px;
  bottom: 16px;
  width: 1px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.42);
  transform: translateX(-50%);
}

.visual-tip {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 4px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(#f7f7f2, #505050 58%, #141414);
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.2);
  transform: translateX(-50%);
}

.machine-visual-needle.is-selected .visual-thread {
  width: 2px;
  background: var(--yellow);
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.2);
}

.machine-visual-needle.is-warn .visual-tip {
  background: linear-gradient(#fff6c5, var(--yellow) 58%, #6d5600);
}

.machine-visual-needle.is-danger .visual-tip {
  background: linear-gradient(#ffe2df, var(--danger) 58%, #7b1710);
}

.machine-shadow {
  position: absolute;
  z-index: 1;
  width: min(58%, 720px);
  height: 22px;
  bottom: 2%;
  border-radius: 999px;
  background: radial-gradient(ellipse at center, rgba(40, 45, 48, 0.16), rgba(40, 45, 48, 0));
  filter: blur(5px);
}

.machine-hotspots {
  position: absolute;
  left: 15.8%;
  right: 18.4%;
  bottom: 5.4%;
  display: grid;
  grid-template-columns: repeat(var(--needle-count), minmax(16px, 1fr));
  height: 35%;
  z-index: 8;
  pointer-events: auto;
}

.machine-needle-button {
  position: relative;
  min-width: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
}

.machine-needle-button::before {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0);
  content: "";
  transform: translateX(-50%);
}

.machine-needle-button span {
  position: absolute;
  left: 50%;
  bottom: -3px;
  display: grid;
  place-items: center;
  width: var(--hotspot-size, 22px);
  height: var(--hotspot-size, 22px);
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  color: #ffffff;
  background: var(--blue);
  box-shadow: 0 4px 10px rgba(17, 17, 17, 0.18);
  font-size: calc(var(--hotspot-size, 22px) * 0.47);
  font-weight: 900;
  opacity: 0.78;
  transform: translateX(-50%);
}

.machine-needle-button.is-selected::before {
  background: rgba(246, 196, 0, 0.78);
}

.machine-needle-button.is-selected span {
  color: var(--ink);
  border-color: var(--ink);
  background: var(--yellow);
  opacity: 1;
}

.machine-needle-button.is-warn span {
  background: var(--warn);
}

.machine-needle-button.is-danger span {
  background: var(--danger);
}

.service-panel {
  grid-row: 3;
  grid-column: 2;
  align-self: start;
  display: grid;
  gap: 12px;
  width: 100%;
}

.service-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
}

.attention-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.attention-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.attention-list {
  display: grid;
  gap: 8px;
}

.attention-item,
.attention-empty {
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
}

.attention-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(17, 17, 17, 0.08);
}

.attention-item strong,
.attention-item small {
  display: block;
}

.attention-item strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attention-item small {
  margin-top: 1px;
  font-size: 10px;
  font-weight: 850;
}

.attention-item > span:last-child {
  font-size: 11px;
  font-weight: 950;
  white-space: nowrap;
}

.attention-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 24px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--ink);
  font-size: 9px;
  font-weight: 950;
  text-transform: uppercase;
}

.attention-item.is-warn {
  border-color: rgba(199, 131, 22, 0.5);
  background: rgba(255, 251, 237, 0.88);
}

.attention-item.is-warn .attention-badge {
  color: var(--ink);
  background: var(--yellow);
}

.attention-item.is-danger {
  border-color: rgba(198, 60, 53, 0.58);
  background: rgba(255, 248, 246, 0.92);
}

.attention-item.is-danger .attention-badge {
  background: var(--danger);
}

.attention-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.service-item,
.design-panel,
.needle-editor,
.needle-card,
.history-card,
.history-stat,
.attention-panel,
.backup-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    0 14px 34px rgba(17, 17, 17, 0.07);
}

.service-name,
.console-head,
.needle-meta,
.needle-count,
.needle-size,
.eyebrow,
label span,
.editor-counter small,
.needle-hint,
.backup-note,
.attention-item small {
  color: var(--muted);
}

.service-list {
  display: grid;
  gap: 10px;
}

.service-item {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.service-item.is-warn {
  border-color: rgba(199, 131, 22, 0.55);
}

.service-item.is-danger {
  border-color: rgba(198, 60, 53, 0.62);
  background: rgba(255, 248, 246, 0.92);
}

.service-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.service-name {
  display: block;
  font-size: 13px;
  font-weight: 800;
}

.service-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.service-value {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.bar,
.editor-progress,
.needle-progress {
  overflow: hidden;
  border-radius: 999px;
  background: var(--metal);
}

.bar {
  height: 7px;
}

.bar > span,
.editor-progress > span,
.needle-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ok);
}

.bar > span.is-warn,
.editor-progress > span.is-warn,
.needle-progress span.is-warn {
  background: var(--warn);
}

.bar > span.is-danger,
.editor-progress > span.is-danger,
.needle-progress span.is-danger {
  background: var(--danger);
}

.needle-editor {
  grid-column: 1;
  grid-row: 3;
  align-self: start;
  padding: 14px;
}

.design-panel {
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  padding: 14px;
}

.design-form {
  display: grid;
  gap: 12px;
}

.design-panel.is-collapsed {
  padding: 12px 14px;
}

.design-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.design-head strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  line-height: 1.1;
}

.design-total {
  text-align: right;
  white-space: nowrap;
}

.design-head-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 10px;
}

.design-total span {
  display: block;
  font-size: 24px;
  font-weight: 950;
  line-height: 1;
}

.design-total small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.design-name-field {
  max-width: 560px;
}

.design-needle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
}

.design-needle-field {
  gap: 5px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.design-needle-field.is-warn {
  border-color: rgba(199, 131, 22, 0.5);
  background: rgba(255, 251, 237, 0.88);
}

.design-needle-field.is-danger {
  border-color: rgba(198, 60, 53, 0.58);
  background: rgba(255, 248, 246, 0.92);
}

.design-needle-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.design-needle-field b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--ink);
  font-size: 11px;
  font-weight: 950;
}

.design-needle-field.is-warn b {
  color: var(--ink);
  background: var(--yellow);
}

.design-needle-field.is-danger b {
  background: var(--danger);
}

.design-needle-field small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.design-needle-field input {
  height: 34px;
  padding: 0 8px;
  font-size: 13px;
}

.design-actions {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px);
  justify-content: end;
  gap: 8px;
}

.editor-form {
  display: grid;
  gap: 12px;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-head strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  line-height: 1.1;
}

.needle-hint {
  display: block;
  max-width: 560px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.25;
}

.editor-status,
.needle-status {
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-weight: 950;
}

.editor-status {
  margin-top: 7px;
  min-height: 24px;
  padding: 0 10px;
  font-size: 11px;
}

.needle-status {
  justify-self: start;
  min-height: 18px;
  max-width: 100%;
  padding: 0 7px;
  font-size: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-status.is-ok,
.needle-status.is-ok {
  color: #ffffff;
  background: var(--ink);
}

.editor-status.is-warn,
.needle-status.is-warn {
  color: var(--ink);
  background: var(--yellow);
}

.editor-status.is-danger,
.needle-status.is-danger {
  color: #ffffff;
  background: var(--danger);
}

.eyebrow,
label span {
  display: block;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.editor-counter {
  text-align: right;
  white-space: nowrap;
}

.editor-counter span {
  display: block;
  font-size: 24px;
  font-weight: 950;
  line-height: 1;
}

.editor-counter.is-warn span {
  color: var(--warn);
}

.editor-counter.is-danger span {
  color: var(--danger);
}

.editor-fields {
  display: grid;
  grid-template-columns: 1.15fr 1.1fr 0.8fr 0.8fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

select,
input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.86);
  padding: 0 11px;
  font-size: 14px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

select:focus,
input:focus {
  border-color: rgba(246, 196, 0, 0.95);
  box-shadow:
    0 0 0 3px rgba(246, 196, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  outline: none;
}

input {
  cursor: text;
}

.editor-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.editor-progress {
  height: 8px;
}

.save-button {
  min-width: 0;
  height: 42px;
  border: 0;
  border-radius: 7px;
  color: #ffffff;
  background: var(--ink);
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(17, 17, 17, 0.16);
}

.service-button,
.replace-button {
  height: 36px;
  border: 0;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 900;
}

.service-button {
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 8px 16px rgba(246, 196, 0, 0.2);
}

.replace-button {
  min-width: 0;
  height: 42px;
  color: #ffffff;
  background: var(--danger);
  box-shadow: 0 10px 18px rgba(217, 74, 61, 0.16);
}

.save-button,
.replace-button {
  height: 42px;
  font-size: 14px;
  font-weight: 900;
}

.editor-buttons {
  display: grid;
  grid-auto-columns: minmax(156px, 1fr);
  grid-auto-flow: column;
  gap: 8px;
}

.editor-buttons button {
  width: 100%;
  padding: 0 16px;
}

.history-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: clamp(14px, 2.2vw, 28px) clamp(16px, 3vw, 38px);
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-toolbar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.panel-toolbar strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(20px, 3vw, 32px);
  line-height: 1;
}

.secondary-button {
  min-width: 0;
  height: 42px;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  padding: 0 16px;
  font-size: 14px;
  font-weight: 950;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    0 10px 18px rgba(17, 17, 17, 0.08);
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.history-stat {
  display: grid;
  gap: 6px;
  padding: 16px;
}

.history-stat span,
.history-card-head,
.history-event small,
.history-event time,
.history-stat small,
.history-needle small {
  color: var(--muted);
}

.history-stat span,
.history-card-head {
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.history-stat strong {
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.history-stat small {
  font-size: 12px;
  font-weight: 850;
}

.history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr);
  gap: 14px;
  min-height: 0;
}

.history-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  padding: 14px;
}

.needle-history-grid,
.event-history {
  min-height: 0;
  overflow: auto;
}

.needle-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(154px, 1fr));
  gap: 8px;
  align-content: start;
}

.history-needle,
.history-event,
.history-empty {
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.history-needle {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.history-needle > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-needle strong {
  font-size: 17px;
}

.history-needle small {
  font-size: 11px;
  font-weight: 800;
}

.event-history {
  display: grid;
  gap: 8px;
  align-content: start;
}

.history-event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: center;
  padding: 10px;
}

.history-event strong,
.history-event small {
  display: block;
}

.history-event strong {
  font-size: 14px;
}

.history-event small,
.history-event time {
  font-size: 11px;
  font-weight: 800;
}

.history-event > span:last-of-type {
  font-size: 13px;
  font-weight: 950;
  white-space: nowrap;
}

.history-event time {
  grid-column: 2 / 4;
}

.history-badge {
  display: grid;
  place-items: center;
  min-width: 58px;
  height: 28px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--yellow);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.history-event.is-danger .history-badge {
  color: #ffffff;
  background: var(--danger);
}

.history-event.is-service .history-badge {
  color: #ffffff;
  background: var(--ink);
}

.history-event.is-design .history-badge {
  color: var(--ink);
  background: var(--yellow);
}

.history-empty {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.machines-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: clamp(14px, 2.2vw, 28px) clamp(16px, 3vw, 38px);
}

.machines-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.machines-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.machines-head strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1;
}

.machines-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 14px;
  min-height: 0;
}

.machines-card,
.machine-form,
.backup-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    0 14px 34px rgba(17, 17, 17, 0.07);
}

.machines-card {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.machine-form {
  grid-column: 2;
  grid-row: 1;
}

.backup-card {
  grid-column: 2;
  grid-row: 2;
}

.backup-note {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.backup-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.backup-actions .save-button,
.backup-actions .secondary-button {
  width: 100%;
}

.machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.machine-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  text-align: left;
}

.machine-card.is-active {
  border-color: rgba(246, 196, 0, 0.92);
  background: #fffbed;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 12px 28px rgba(246, 196, 0, 0.14);
}

.machine-card-top,
.machine-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.machine-card-top {
  align-items: flex-start;
}

.machine-card-top strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.12;
  text-overflow: ellipsis;
}

.machine-card-top span {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--yellow);
  font-size: 11px;
  font-weight: 950;
}

.machine-card-metric {
  display: grid;
  gap: 3px;
}

.machine-card-metric small,
.machine-card-foot {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.machine-card-metric b {
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.machine-card-foot {
  flex-wrap: wrap;
}

.machine-card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.machine-open-button,
.machine-delete-button {
  height: 38px;
  border: 0;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 950;
}

.machine-open-button {
  color: #ffffff;
  background: var(--ink);
}

.machine-card.is-active .machine-open-button {
  color: var(--ink);
  background: var(--yellow);
}

.machine-delete-button {
  min-width: 92px;
  color: #ffffff;
  background: var(--danger);
}

.machine-delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.34;
}

.needle-console {
  position: relative;
  grid-column: 1 / -1;
  grid-row: 4;
  z-index: 4;
  display: grid;
  gap: 8px;
  padding: 8px clamp(16px, 3vw, 38px) 10px;
  border-top: 1px solid var(--line);
  background: rgba(247, 246, 241, 0.94);
  backdrop-filter: blur(18px);
}

.console-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.needle-strip {
  display: grid;
  grid-template-columns: repeat(var(--needle-count), minmax(58px, 1fr));
  gap: 8px;
  min-height: 78px;
}

.needle-card {
  display: grid;
  grid-template-rows: auto auto auto auto auto auto;
  gap: 3px;
  min-width: 0;
  padding: 6px;
}

.needle-card.is-selected {
  border-color: rgba(246, 196, 0, 0.92);
  background: #fffbed;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 12px 28px rgba(246, 196, 0, 0.14);
}

.needle-card.is-warn {
  border-color: rgba(199, 131, 22, 0.55);
}

.needle-card.is-danger {
  border-color: rgba(198, 60, 53, 0.62);
}

.needle-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.needle-number {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--blue);
  font-size: 11px;
  font-weight: 900;
}

.needle-card.is-selected .needle-number {
  color: var(--ink);
  background: var(--yellow);
}

.needle-size {
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.needle-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.needle-meta,
.needle-count {
  overflow: hidden;
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.needle-count {
  align-self: end;
}

.needle-progress {
  align-self: end;
  height: 3px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 150px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid rgba(198, 60, 53, 0.28);
  border-radius: 8px;
  color: #ffffff;
  background: var(--danger);
  box-shadow: 0 20px 45px var(--shadow);
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 1121px) and (orientation: landscape) {
  .machine-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(270px, 320px);
    grid-template-rows: auto auto auto auto;
  }

  .machine-stage {
    min-height: 620px;
  }

  .machine-frame {
    width: min(100%, 760px);
  }

  .needle-editor {
    position: relative;
    z-index: 5;
    padding: 12px;
  }

  .design-panel {
    padding: 12px;
  }

  .design-form {
    gap: 10px;
  }

  .editor-form {
    gap: 10px;
  }

  .editor-head strong {
    font-size: 16px;
  }

  .needle-hint {
    max-width: 430px;
  }

  .service-panel {
    align-self: start;
  }

  .needle-console {
    padding-top: 6px;
  }

  .needle-strip {
    min-height: 82px;
  }
}

@media (max-width: 1120px) {
  .machine-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
  }

  .service-panel {
    grid-row: 5;
    grid-column: 1;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .service-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .machine-frame {
    width: min(100%, calc(var(--app-height, 100vh) - 450px));
  }
}

@media (max-width: 820px) {
  .app-shell {
    height: auto;
    min-height: var(--app-height, 100vh);
    overflow: visible;
  }

  .topbar {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  .app-lockup {
    align-items: center;
  }

  .app-lockup h1 {
    font-size: 24px;
    white-space: normal;
  }

  .topbar-controls,
  .segment,
  .view-tabs,
  .machine-switcher {
    width: 100%;
  }

  .topbar-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .segment {
    grid-template-columns: repeat(var(--segment-count, 3), 1fr);
  }

  .machine-switcher {
    grid-template-columns: 1fr auto;
  }

  .machine-workspace {
    padding-top: 14px;
  }

  .machine-frame,
  .machine-head-render {
    width: 100%;
    max-height: none;
  }

  .needle-editor {
    padding: 12px;
  }

  .design-panel {
    padding: 12px;
  }

  .editor-head {
    align-items: flex-start;
  }

  .editor-fields {
    grid-template-columns: 1fr 1fr;
  }

  .design-actions {
    grid-template-columns: 1fr 1fr;
  }

  .history-summary,
  .history-grid,
  .machines-layout {
    grid-template-columns: 1fr;
  }

  .machines-card,
  .machine-form,
  .backup-card {
    grid-column: 1;
    grid-row: auto;
  }

  .panel-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .history-panel,
  .machines-panel {
    overflow: visible;
  }

  .service-panel,
  .service-list {
    grid-template-columns: 1fr;
  }

  .needle-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toast {
    right: 16px;
    bottom: 18px;
  }
}

@media (max-width: 480px) {
  .app-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .app-logo {
    width: 54px;
    height: 54px;
  }

  .app-lockup h1 {
    font-size: 22px;
  }

  .view-tabs {
    grid-template-columns: 1fr;
  }

  .machine-switcher {
    grid-template-columns: 1fr;
  }

  .editor-fields,
  .design-actions,
  .editor-actions {
    grid-template-columns: 1fr;
  }

  .editor-buttons {
    grid-auto-flow: row;
    grid-auto-rows: 42px;
    grid-template-columns: 1fr;
  }

  .editor-buttons button {
    width: 100%;
  }

  .needle-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
