:root {
  --ink: #33262a;
  --blue: #ae2e47;
  --shop: #d8e3f2;
  --paper: #fff;
  --canvas: #f3f0f1;
  --line: #e5dadd;
  --muted: #65768a;
  --danger: #842237;
  --shadow: 0 18px 50px rgba(65, 35, 44, .12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; min-width: 320px; overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.app { height: 100vh; min-height: 0; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 22px; background: var(--paper); border-bottom: 1px solid var(--line); position: relative; z-index: 4;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.brand-mark, .auth-mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: var(--blue); color: #fff; font-weight: 850; letter-spacing: -.04em;
}
.brand h1 { font-size: 16px; margin: 0; line-height: 1.2; }
.brand p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.inline-form { display: inline; margin: 0; }

.btn {
  min-height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px;
  background: #fff; cursor: pointer; font-weight: 700; font-size: 13px; transition: .18s ease;
}
.btn:hover { border-color: #9fb2c6; transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.save { background: #238552; border-color: #238552; color: #fff; min-width: 104px; }
.btn.save:hover { background: #197143; border-color: #197143; }
.btn.save:disabled { background: #86b89d; border-color: #86b89d; }
.btn.ghost-danger { color: var(--danger); }
.btn.small { min-height: 30px; padding: 0 9px; font-size: 11px; border-radius: 8px; }
.icon-btn { width: 40px; padding: 0; font-size: 18px; }
.action-menu { position: relative; }
.action-menu > summary { list-style: none; display: flex; align-items: center; gap: 7px; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu[open] > summary { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(174,46,71,.10); }
.action-menu-panel {
  position: absolute; z-index: 12; right: 0; top: calc(100% + 8px); min-width: 210px; padding: 7px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 16px 38px rgba(65,35,44,.18);
}
.menu-action {
  display: block; width: 100%; min-height: 39px; border: 0; border-radius: 8px; padding: 8px 10px;
  background: transparent; color: var(--ink); text-align: left; font-size: 13px; font-weight: 700; cursor: pointer;
}
.menu-action:hover { background: #f8edf0; color: var(--blue); }

.layout { min-height: 0; display: grid; grid-template-columns: 350px minmax(0, 1fr); }
.sidebar { min-height: 0; overflow: auto; background: #fff; border-right: 1px solid var(--line); padding: 22px; position: relative; z-index: 3; }
.section + .section { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 22px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .09em; }
.badge { font-size: 11px; font-weight: 800; color: var(--blue); background: #f8edf0; padding: 5px 8px; border-radius: 999px; }
.help { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.floor-list { display: grid; gap: 16px; margin-top: 14px; }
.floor-row-group { display: grid; gap: 6px; }
.floor-row { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; }
.floor-svg-row { display: flex; align-items: center; gap: 8px; padding-left: 42px; flex-wrap: wrap; }
.floor-number { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #f8edf0; font-size: 12px; font-weight: 850; }
.floor-input, .input {
  width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; color: var(--ink); outline: none; background: #fff;
}
.floor-input:focus, .input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(174, 46, 71, .1); }
.color-input { height: 44px; padding: 5px; cursor: pointer; }
label.field, div.field { display: grid; gap: 7px; margin-top: 14px; font-size: 12px; font-weight: 800; }
.field.no-top { margin-top: 0; }
.field small { font-weight: 500; color: var(--muted); line-height: 1.4; }
label.check-field { display: flex; align-items: center; gap: 9px; font-weight: 700; cursor: pointer; }
.check-field input { width: 16px; height: 16px; accent-color: var(--blue); }
input[type="range"] { width: 100%; accent-color: var(--blue); }
.range-head { display: flex; justify-content: space-between; gap: 10px; }
.range-value { color: var(--blue); font-variant-numeric: tabular-nums; }

.empty-state { border: 1px dashed #b9c7d4; border-radius: 14px; padding: 18px; background: #f8fafc; }
.empty-state strong { display: block; margin-bottom: 7px; font-size: 14px; }
.editor-fields { display: grid; }
.logo-drop {
  min-height: 104px; border: 1px dashed #aabac9; border-radius: 12px; display: grid; place-items: center;
  padding: 12px; text-align: center; cursor: pointer; background: #f8fafc; transition: .18s ease;
}
.logo-drop:hover { border-color: var(--blue); background: #fbf3f5; }
.logo-drop img { max-width: 100%; max-height: 76px; object-fit: contain; }
.logo-drop span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.row-actions { display: flex; gap: 8px; margin-top: 10px; }
.row-actions .btn { flex: 1; }

.store-list { display: grid; gap: 8px; margin-top: 14px; }
#exportFloorPngBtn { margin-top: 12px; width: 100%; }
.store-list-empty { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.store-group-title { margin: 8px 0 1px; color: var(--muted); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .09em; }
.store-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; }
.store-item.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(174,46,71,.08); }
.store-item-main { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: transparent; padding: 0; text-align: left; cursor: pointer; }
.store-thumb { width: 38px; height: 38px; border-radius: 9px; background: #f8edf0; display: grid; place-items: center; overflow: hidden; flex: 0 0 auto; font-size: 12px; font-weight: 900; }
.store-thumb img { max-width: 86%; max-height: 76%; object-fit: contain; }
.store-copy { min-width: 0; flex: 1; }
.store-copy strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.store-copy small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.store-item-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 9px; }

.workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto 1fr; }
.workspace-bar {
  min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.76); backdrop-filter: blur(12px);
}
.floor-tabs { display: flex; flex-wrap: wrap; gap: 7px; }
.floor-tab { border: 1px solid transparent; background: transparent; border-radius: 999px; padding: 8px 12px; cursor: pointer; font-weight: 750; font-size: 12px; }
.floor-tab:hover { background: #fff; }
.floor-tab.active { background: var(--blue); color: #fff; }
.zoom-controls { display: flex; align-items: center; gap: 6px; }
.zoom-label { min-width: 52px; text-align: center; font-size: 12px; font-weight: 800; }
.canvas-wrap { min-height: 0; overflow: auto; padding: 28px; display: grid; place-items: center; }
.map-card { width: min(1120px, 100%); background: #fff; border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; transform-origin: center; transition: transform .18s ease; }
.map-stage { width: 100%; position: relative; }
.map-stage svg { display: block; width: 100%; height: auto; user-select: none; }
.map-stage .shop-shape { cursor: pointer; transition: filter .15s ease, opacity .15s ease; }
.map-stage .shop-shape:hover { filter: brightness(.94) saturate(1.06); }
.map-stage .shop-shape.is-selected { filter: brightness(.88) saturate(1.18); }
.map-stage .selection-ring { fill: none; stroke: var(--danger); stroke-width: 3; stroke-dasharray: 8 5; pointer-events: none; vector-effect: non-scaling-stroke; }
.map-stage .logo-layer { pointer-events: none; }
.statusbar { padding: 9px 14px; border-top: 1px solid var(--line); background: #fbfcfd; color: var(--muted); font-size: 11px; display: flex; justify-content: space-between; gap: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff;
  border-radius: 10px; padding: 11px 15px; font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; z-index: 30; transition: .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(11, 34, 57, .52); display: grid; place-items: center; padding: 22px; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 44px); overflow: auto; border-radius: 18px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0 0 5px; font-size: 20px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 22px; }
textarea.code { width: 100%; min-height: 112px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #faf7f8; color: #34282c; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
textarea.code-large { min-height: 180px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.user-form { display: grid; grid-template-columns: 1fr 1.25fr 1.25fr .8fr auto; gap: 8px; align-items: center; }
.user-list { display: grid; gap: 8px; margin-top: 20px; }
.user-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.user-row strong { font-size: 13px; }
.user-row small { display: block; margin-top: 3px; color: var(--muted); }
.user-role { border-radius: 999px; background: #f8edf0; padding: 5px 8px; font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .05em; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg,#f3e9ec,#fbf9fa); }
.auth-card { width: min(460px,100%); background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 8px 0 8px; font-size: 26px; letter-spacing: -.03em; }
.auth-card .eyebrow { margin: 20px 0 0; color: var(--blue); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .12em; }
.auth-intro { color: var(--muted); font-size: 14px; line-height: 1.55; }
.auth-form { display: grid; gap: 14px; margin-top: 22px; }
.auth-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 800; }
.auth-form input { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
.auth-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(174,46,71,.1); }
.auth-form small { color: var(--muted); margin-top: -7px; }
.auth-error { margin-top: 16px; border-radius: 10px; padding: 11px 12px; color: #8e2036; background: #fae9ed; font-size: 13px; }
.auth-card details { margin-top: 18px; font-size: 12px; color: var(--muted); }
.auth-card pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #f6f8fa; padding: 10px; border-radius: 8px; }

@media (max-width: 1100px) {
  .user-form { grid-template-columns: 1fr 1fr; }
  .user-form .btn { grid-column: 1 / -1; }
}
@media (max-width: 920px) {
  html, body { height: auto; }
  body { overflow: visible; }
  .app { height: auto; min-height: 100vh; }
  .topbar { align-items: flex-start; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: none; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace { min-height: 650px; }
}
@media (max-width: 640px) {
  .topbar { display: grid; }
  .actions { justify-content: flex-start; }
  .workspace-bar { align-items: flex-start; }
  .canvas-wrap { padding: 12px; }
  .btn { padding-inline: 11px; }
  .action-menu-panel { position: fixed; left: 12px; right: 12px; top: 82px; }
  .user-form { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: 1fr auto; }
  .user-row .btn { grid-column: 1 / -1; }
}

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.media-item { position: relative; display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: left; transition: .18s ease; }
.media-item:hover, .media-item:focus-visible { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(174, 46, 71, .1); outline: none; }
.media-thumb { height: 84px; display: grid; place-items: center; border-radius: 8px; background: #f8f5f6; }
.media-thumb img { max-width: 90%; max-height: 90%; object-fit: contain; }
.media-name { font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-delete { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--danger); font-size: 14px; line-height: 1; cursor: pointer; opacity: 0; transition: .15s ease; }
.media-item:hover .media-delete, .media-delete:focus-visible { opacity: 1; }
@media (hover: none) { .media-delete { opacity: 1; } }

.cred-box { display: grid; gap: 8px; margin-top: 16px; padding: 14px; border: 1px solid #9fd2b5; border-radius: 12px; background: #f1faf4; }
.cred-box .code { min-height: 76px; }
.cred-box .btn { justify-self: start; }
