:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --border: #e2e4ea;
  --text: #1f2330;
  --text-muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.navbar .brand { font-weight: 700; font-size: 18px; color: var(--text); }

.navbar .nav-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }

.badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--primary);
  font-weight: 600;
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: white;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #eef0f5; color: var(--text); }
.btn.secondary:hover { background: #e1e4ec; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-input, input[type=text], input[type=email], input[type=password], input[type=file], select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }

.grid-stores {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.store-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: box-shadow .15s ease;
}
.store-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.store-card h3 { margin: 0 0 4px; font-size: 16px; }
.store-card .code { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.store-card .meta { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.store-card .footer-row { display: flex; justify-content: space-between; align-items: center; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
.login-card {
  background: white;
  border-radius: 14px;
  padding: 36px;
  width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p.subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 16px; }
.hint-box { margin-top: 18px; padding: 12px; background: #f5f6fa; border-radius: 8px; font-size: 12px; color: var(--text-muted); line-height: 1.6; }

.store-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.store-header h1 { margin: 0 0 4px; font-size: 22px; }
.store-header .meta { color: var(--text-muted); font-size: 13px; }

.layout-wrap {
  position: relative;
  width: 100%;
  min-height: 480px;
  background: #eef0f5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: default;
}
.layout-wrap.placing { cursor: crosshair; }
.layout-wrap.placing-zone { cursor: crosshair; }
.layout-wrap img.bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  display: none;
  background-image:
    linear-gradient(to right, rgba(79,70,229,.22) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(79,70,229,.22) 1px, transparent 1px);
  background-position: -1px -1px;
}
.grid-overlay.visible { display: block; }
.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 40px;
  pointer-events: none;
}

.gondola-marker {
  position: absolute;
  min-width: 22px;
  min-height: 22px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  overflow: hidden;
  padding: 2px;
  transform: translate(-50%, -50%);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  border: 2px solid white;
  user-select: none;
  z-index: 5;
}

.zone-box {
  position: absolute;
  border: 2px solid;
  border-radius: 4px;
  cursor: move;
  z-index: 2;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  user-select: none;
  overflow: hidden;
}
.zone-box.color-blue   { background: rgba(59,130,246,.16); border-color: #3b82f6; color: #1d4ed8; }
.zone-box.color-green  { background: rgba(34,197,94,.16);  border-color: #22c55e; color: #15803d; }
.zone-box.color-yellow { background: rgba(234,179,8,.20);  border-color: #eab308; color: #92660a; }
.zone-box.color-gray   { background: rgba(107,114,128,.16);border-color: #6b7280; color: #374151; }
.zone-box.color-purple { background: rgba(168,85,247,.16); border-color: #a855f7; color: #7e22ce; }

.zone-resize-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: white;
  border: 2px solid var(--primary);
  border-radius: 50%;
  cursor: nwse-resize;
  z-index: 3;
}

.zone-draw-preview {
  position: absolute;
  border: 2px dashed var(--primary);
  background: rgba(79,70,229,.12);
  z-index: 4;
  pointer-events: none;
  border-radius: 4px;
}
.gondola-marker.no-planogram { background: #9ca3af; }
.gondola-marker:hover { outline: 2px solid rgba(79,70,229,.4); }

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 26, .45);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}
.panel {
  width: 420px;
  max-width: 92vw;
  height: 100%;
  background: white;
  padding: 24px;
  overflow-y: auto;
  box-shadow: -8px 0 24px rgba(0,0,0,.15);
}
.panel h2 { margin-top: 0; font-size: 18px; }
.panel-close { float: right; cursor: pointer; font-size: 22px; color: var(--text-muted); background: none; border: none; line-height: 1; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,17,26,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.modal {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 380px;
  max-width: 92vw;
}
.modal h2 { margin-top: 0; font-size: 17px; }

.plano-active-img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  max-height: 260px;
  object-fit: contain;
  background: #fafafa;
}

.version-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.version-item img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.version-item .v-info { flex: 1; font-size: 12px; color: var(--text-muted); }
.version-item .v-info strong { color: var(--text); font-size: 13px; }
.active-tag {
  font-size: 10px;
  font-weight: 700;
  background: #dcfce7;
  color: var(--success);
  padding: 2px 8px;
  border-radius: 999px;
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.checkbox-row input { width: auto; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
