:root {
  --ink: #171b16;
  --muted: #697064;
  --paper: #f3f0e7;
  --panel: #fffdf7;
  --line: #d9d4c7;
  --green: #1d5a3b;
  --lime: #b9d96b;
  --amber: #d99136;
  --red: #ad453b;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(28, 35, 24, 0.09);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100dvh;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 80% 0, #e4ebd5 0, transparent 34rem), var(--paper);
}
button,
input,
select {
  font: inherit;
}
button {
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: white;
  padding: 0.78rem 1.15rem;
  font-weight: 720;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 44px;
}
button:hover {
  filter: brightness(1.07);
}
button:disabled {
  cursor: not-allowed;
  filter: none;
  opacity: 0.45;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(185, 217, 107, 0.75);
  outline-offset: 2px;
}
.secondary {
  background: transparent;
  color: var(--green);
  border: 1px solid #9ba894;
}
.quiet {
  background: transparent;
  color: var(--muted);
}
.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1rem, 4vw, 3.5rem);
  border-bottom: 1px solid rgba(93, 103, 84, 0.2);
  position: sticky;
  top: 0;
  background: rgba(243, 240, 231, 0.88);
  backdrop-filter: blur(18px);
  z-index: 10;
}
.brand {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
  font-weight: 800;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--green);
  color: var(--lime);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}
.identity {
  color: var(--muted);
  font-size: 0.88rem;
}
main {
  width: min(1320px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 4rem) 0 5rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login {
  max-width: 620px;
  margin: 5vh auto;
  padding: clamp(1.5rem, 5vw, 4rem);
}
h1 {
  font-size: clamp(2.5rem, 7vw, 5.5rem);
  line-height: 0.92;
  letter-spacing: -0.065em;
  margin: 0.45rem 0 1.5rem;
  max-width: 10ch;
}
h2 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  letter-spacing: -0.05em;
  margin: 0.2rem 0;
}
h3 {
  font-size: 1.2rem;
  margin: 2.2rem 0 0.8rem;
}
.lead {
  font-size: 1.12rem;
  color: var(--muted);
  max-width: 42ch;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 850;
  margin: 0;
}
.stack {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
}
.stack.small {
  margin-top: 1rem;
  gap: 0.65rem;
}
label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 11px;
  padding: 0.8rem;
  color: var(--ink);
  min-height: 46px;
}
.message {
  min-height: 1.5rem;
  color: var(--red);
}
.tabs {
  display: flex;
  gap: 0.35rem;
  overflow: auto;
  padding: 0.3rem;
  margin-bottom: 2.5rem;
}
.tab {
  white-space: nowrap;
}
.tab.active {
  background: var(--ink);
}
.view {
  animation: fade 0.24s ease;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.actions,
.toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.toolbar {
  padding: 1rem;
  background: rgba(255, 253, 247, 0.65);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 1rem;
}
.toolbar label {
  min-width: 220px;
}
.state-grid,
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.8rem;
}
.state-card,
.camera-card,
.event {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 1.15rem;
}
.state-card.alert {
  border-color: #dba45e;
  background: #fff8eb;
}
.metric {
  font-size: 2.2rem;
  font-weight: 820;
  line-height: 1;
}
.tableware-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.8rem 0;
}
.tableware-metrics div {
  display: grid;
  gap: 0.25rem;
  padding: 0.65rem;
  border-radius: 10px;
  background: #ece9df;
}
.tableware-metrics strong {
  font-size: 1.8rem;
  line-height: 1;
}
.tableware-metrics span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
}
.meta {
  color: var(--muted);
  font-size: 0.82rem;
}
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.3rem 0.58rem;
  background: #e3e8dd;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}
.badge.offline,
.badge.suspended,
.badge.revoked {
  background: #f2d9d5;
  color: var(--red);
}
.event-list {
  display: grid;
  gap: 0.6rem;
}
.event {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}
.camera-card .actions {
  margin-top: 1rem;
}
.camera-action-hint {
  margin: 0.1rem 0 0;
  line-height: 1.4;
}
.camera-card h3 {
  margin: 0.7rem 0;
}
.camera-preview {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #ddd7ca;
  border-radius: 10px;
  margin: 0.8rem 0;
}
.camera-preview-placeholder {
  min-height: 132px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.7rem;
  margin: 0.8rem 0;
  padding: 1rem;
  border: 1px dashed #b8b2a5;
  border-radius: 10px;
  background: #ece9df;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}
.preview-session-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  margin: 0.8rem 0;
  padding: 0.75rem;
  border: 1px solid #b9c7ae;
  border-radius: 10px;
  background: #eef4e8;
}
.preview-session-status[hidden] {
  display: none;
}
.preview-session-status > div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--green);
  font-size: 0.78rem;
}
.preview-session-status progress {
  width: 100%;
  height: 7px;
  grid-column: 1;
  accent-color: var(--green);
}
.preview-session-status button {
  grid-column: 2;
  grid-row: 1 / span 2;
}
dialog {
  border: 0;
  border-radius: 20px;
  padding: 2rem;
  max-width: min(520px, calc(100% - 2rem));
  box-shadow: 0 30px 100px rgba(12, 18, 10, 0.38);
}
.mini {
  min-width: 44px;
  padding: 0.55rem 0.75rem;
}
.danger {
  background: #8f3e36;
}
.table-manager {
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.mask-manager {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.mask-manager-head,
.mask-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.mask-actions button {
  flex: 1;
}
.mask-count {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #f0dedb;
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 850;
}
.table-manager-head,
.table-order {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}
.table-order {
  margin-top: 0.5rem;
}
.table-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.table-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  text-align: left;
  border-radius: 9px;
  background: #ece9df;
  color: var(--ink);
  padding: 0.55rem 0.7rem;
}
.table-item.active {
  background: var(--green);
  color: white;
}
.table-item small {
  opacity: 0.75;
}
dialog::backdrop {
  background: #172017aa;
  backdrop-filter: blur(8px);
}
.dialog-close {
  float: right;
  background: transparent;
  color: var(--ink);
  font-size: 1.5rem;
  padding: 0.2rem;
}
.pair-qr {
  display: block;
  width: min(100%, 360px);
  margin: 1rem auto;
}
.claim {
  font-family: ui-monospace, monospace;
  word-break: break-all;
  background: #f0eee6;
  padding: 0.8rem;
  border-radius: 10px;
}
.calibration-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
}
.compact {
  padding: 1.1rem;
}
.compact label + label {
  margin-top: 1rem;
}
.calibration-camera-status {
  margin: 0.55rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: 9px;
  background: #f4e7cf;
  color: #74501d;
  line-height: 1.4;
}
.hint {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}
.version-list {
  margin: 1rem 0 0;
}
.version-list div {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 0.6rem 0;
}
.version-list dt {
  color: var(--muted);
}
.version-list dd {
  font-weight: 800;
}
.editor-shell {
  min-width: 0;
  background: #1b201a;
  border-radius: var(--radius);
  padding: 0.7rem;
  box-shadow: var(--shadow);
}
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0 0.65rem;
  color: #f5f3eb;
  overflow-x: auto;
  scrollbar-width: thin;
}
.editor-tool-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}
.editor-tool-group + .editor-tool-group {
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}
.editor-tool-group-end {
  margin-left: auto;
}
.tool-button {
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 9px;
  background: #30362e;
  color: #f8f6ef;
  white-space: nowrap;
}
.tool-button[aria-pressed="true"] {
  background: var(--lime);
  border-color: var(--lime);
  color: #172017;
}
.icon-button {
  width: 44px;
  padding-inline: 0;
  font-size: 1.35rem;
}
#zoom-value {
  min-width: 4.2rem;
  color: #e1e5db;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.76rem;
  text-align: center;
}
#coordinate-value {
  min-width: 13.5rem;
  padding-inline: 0.35rem;
  color: #cfd5c7;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.72rem;
  text-align: right;
  white-space: nowrap;
}
.editor-viewport {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.editor {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  border-radius: 12px;
  background: #2b3029;
  touch-action: none;
}
.editor-stage {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  will-change: transform;
}
.editor-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.editor-stage svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.editor.pan-active,
.editor.pan-active .editor-stage {
  cursor: grab;
}
.editor.panning,
.editor.panning .editor-stage {
  cursor: grabbing;
}
.editor polygon {
  fill: rgba(185, 217, 107, 0.18);
  stroke: var(--lime);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
}
.editor #roi-polygon {
  pointer-events: none;
}
.editor .privacy-mask {
  fill: url(#privacy-hatch);
  stroke: #dd776d;
  stroke-width: 3;
  stroke-dasharray: 7 5;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}
.editor .privacy-mask.selected {
  fill: rgba(173, 69, 59, 0.42);
  stroke: #ffd3ce;
  stroke-width: 4;
}
.roi-handle {
  fill: #fff;
  stroke: var(--green);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  cursor: grab;
}
.handle-hit {
  fill: transparent;
  stroke: none;
  pointer-events: all;
  cursor: grab;
}
.handle-visual {
  pointer-events: none;
}
.mask-handle {
  fill: #fff8f5;
  stroke: var(--red);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  cursor: grab;
}
.editor #focus-handle {
  fill: #44db7d;
  stroke: #0c4c28;
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  cursor: grab;
  pointer-events: none;
}
.editor #focus-hit {
  cursor: grab;
}
.editor #editor-empty {
  position: absolute;
  inset: auto 1rem 1rem;
  background: #151913d9;
  color: #fff;
  padding: 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  pointer-events: none;
}
.editor-help {
  margin: 0.6rem 0 0;
  color: #b8c0b2;
  font-size: 0.75rem;
  line-height: 1.4;
}
.editor-shell:fullscreen,
.editor-shell.is-fullscreen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding:
    max(0.65rem, env(safe-area-inset-top))
    max(0.65rem, env(safe-area-inset-right))
    max(0.65rem, env(safe-area-inset-bottom))
    max(0.65rem, env(safe-area-inset-left));
  border-radius: 0;
  background: #141813;
}
.editor-shell.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.editor-shell:fullscreen .editor-viewport,
.editor-shell.is-fullscreen .editor-viewport {
  flex: 1;
  min-height: 0;
}
.editor-shell:fullscreen .editor,
.editor-shell.is-fullscreen .editor {
  flex: 0 0 auto;
  max-width: 100%;
  max-height: 100%;
}
body.editor-fullscreen-open {
  overflow: hidden;
}
#toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  background: var(--ink);
  color: white;
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  transform: translateY(180%);
  transition: 0.25s;
  max-width: min(420px, calc(100% - 2rem));
}
#toast.show {
  transform: translateY(0);
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}
@media (max-width: 760px) {
  .topbar {
    height: 62px;
  }
  .identity {
    display: none;
  }
  main {
    width: min(100% - 1rem, 1320px);
    padding-top: 1rem;
  }
  .login {
    margin: 1rem auto;
  }
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .calibration-layout {
    grid-template-columns: 1fr;
  }
  .editor-shell {
    order: -1;
  }
  .editor-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
    overflow-x: visible;
    padding-bottom: 0.55rem;
  }
  .editor-tool-group + .editor-tool-group {
    padding-left: 0;
    border-left: 0;
  }
  .editor-tool-group-end {
    margin-left: auto;
  }
  #coordinate-value {
    display: none;
  }
  .editor-help {
    margin-bottom: 0.1rem;
  }
  .actions {
    width: 100%;
  }
  .actions button {
    flex: 1;
  }
  .toolbar > * {
    flex: 1;
  }
  .event {
    align-items: flex-start;
    flex-direction: column;
  }
  .tabs {
    position: sticky;
    top: 66px;
    background: var(--paper);
    z-index: 8;
    padding: 0.4rem 0;
  }
}
@media (max-width: 430px) {
  .editor-tool-group {
    gap: 0.25rem;
  }
  .editor-tool-group + .editor-tool-group {
    padding-left: 0.3rem;
  }
  .tool-button {
    padding-inline: 0.62rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
